25 if (InquiryData->DeviceType == 0)
44 switch (InquiryData->DeviceType)
99 if (InquiryData->DeviceType == 0)
118 switch (InquiryData->DeviceType)
125 return "GenSequential";
160 return "UsbstorOther";
203 static WCHAR DeviceText[] =
L"USB Mass Storage Device";
212 DPRINT(
"USBSTOR_PdoHandleQueryDeviceText DeviceTextDescription\n");
223 Irp->IoStatus.Information = 0;
240 DPRINT(
"USBSTOR_PdoHandleQueryDeviceText DeviceTextLocationInformation\n");
251 Irp->IoStatus.Information = 0;
292 ASSERT(DeviceExtension->InquiryData);
337 Irp->IoStatus.Information = 0;
375 ASSERT(ResultBufferLength);
376 ASSERT(ResultBufferLength > ResultBufferOffset);
378 DPRINT(
"ResultBufferOffset %lu ResultBufferLength %lu Buffer %s Length %lu\n", ResultBufferOffset, ResultBufferLength,
Buffer,
strlen(
Buffer));
385 DeviceString.
MaximumLength = (ResultBufferLength - ResultBufferOffset) *
sizeof(
WCHAR);
401 ResultBufferLength -= (DeviceString.
Length +
sizeof(
WCHAR)) /
sizeof(
WCHAR);
402 ResultBufferOffset += (DeviceString.
Length +
sizeof(
WCHAR)) /
sizeof(
WCHAR);
407 *NewResultBufferOffset = ResultBufferOffset;
421 CHAR Id1[50], Id2[50], Id3[50], Id4[50], Id5[50], Id6[50];
422 ULONG Id1Length, Id2Length, Id3Length, Id4Length, Id5Length,Id6Length;
439 ASSERT(FDODeviceExtension->DeviceDescriptor);
466 Id1Length =
strlen(Id1) + 1;
467 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId1 %s\n", Id1);
479 Id2Length =
strlen(Id2) + 1;
480 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId2 %s\n", Id2);
491 Id3Length =
strlen(Id3) + 1;
492 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId3 %s\n", Id3);
505 Id4Length =
strlen(Id4) + 1;
506 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId4 %s\n", Id4);
516 Id5Length =
strlen(Id5) + 1;
517 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId5 %s\n", Id5);
526 Id6Length =
strlen(Id6) + 1;
527 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId6 %s\n", Id6);
532 TotalLength = Id1Length + Id2Length + Id3Length + Id4Length + Id5Length + Id6Length + 1;
543 Irp->IoStatus.Information = 0;
601 ASSERT(FDODeviceExtension->DeviceDescriptor);
628 Irp->IoStatus.Information = 0;
672 if (FDODeviceExtension->SerialNumber)
677 swprintf(
Buffer,
L"%s&%c", FDODeviceExtension->SerialNumber->bString, PDODeviceExtension->LUN);
684 swprintf(
Buffer,
L"%04lu&%c", FDODeviceExtension->InstanceCount, PDODeviceExtension->LUN);
701 Irp->IoStatus.Information = 0;
731 DPRINT(
"USBSTOR_PdoHandleDeviceRelations\n");
746 return Irp->IoStatus.Status;
753 if (!DeviceRelations)
764 DeviceRelations->
Count = 1;
855 Irp->IoStatus.Information = 0;
860 DPRINT(
"IRP_MN_REMOVE_DEVICE\n");
862 if(*DeviceExtension->PDODeviceObject !=
NULL)
867 *DeviceExtension->PDODeviceObject =
NULL;
903 Caps->UniqueID =
FALSE;
904 Caps->Removable =
TRUE;
915 if (DeviceExtension->Claimed)
921 DPRINT1(
"[USBSTOR] Request %x fails because device is still claimed\n", IoStack->
MinorFunction);
1058 if (!
Irp->MdlAddress)
1077 Request->DataTransferLength = DataTransferLength;
1141 DPRINT1(
"[USBSTOR] Failed to build irp\n");
1154 ASSERT(PDODeviceExtension->LowerDeviceObject);
1171 *OutData =
Request->DataBuffer;
1323 PDODeviceExtension->PDODeviceObject = &FDODeviceExtension->ChildPDO[LUN];
1324 PDODeviceExtension->Self = PDO;
1325 PDODeviceExtension->LUN = LUN;
1335 PDO->
Flags &= ~DO_DEVICE_INITIALIZING;
1340 FDODeviceExtension->ChildPDO[LUN] = PDO;
1364 DPRINT1(
"[USBSTOR] Status %x IsFloppy %x MediumTypeCode %x\n",
Status, PDODeviceExtension->IsFloppy, PDODeviceExtension->MediumTypeCode);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
ACPI_SIZE strlen(const char *String)
#define FILE_DEVICE_SECURE_OPEN
#define STATUS_NOT_SUPPORTED
#define NT_SUCCESS(StatCode)
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
#define SRB_FUNCTION_EXECUTE_SCSI
#define SRB_FLAGS_DATA_IN
BOOLEAN USBSTOR_IsFloppy(IN PUCHAR Buffer, IN ULONG BufferLength, OUT PUCHAR MediumTypeCode)
NTSTATUS NTAPI USBSTOR_SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
PKMT_RESULTBUFFER ResultBuffer
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
#define ExFreePoolWithTag(_P, _T)
#define FILE_DEVICE_MASS_STORAGE
#define sprintf(buf, format,...)
#define FILE_AUTOGENERATED_DEVICE_NAME
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IRP_MN_SURPRISE_REMOVAL
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
#define IoCompleteRequest
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SCSIOP_READ_FORMATTED_CAPACITY
#define STATUS_MORE_PROCESSING_REQUIRED
static ULONG CopyField(IN PUCHAR Name, IN PCHAR Buffer, IN ULONG MaxLength, IN CHAR DefaultCharacter, IN BOOLEAN Trim)
PDEVICE_OBJECT Objects[1]
struct _IO_STACK_LOCATION::@3974::@4001 DeviceCapabilities
PDEVICE_OBJECT DeviceObject
struct _IO_STACK_LOCATION::@3974::@4005 QueryId
struct _IO_STACK_LOCATION::@3974::@4006 QueryDeviceText
struct _IO_STACK_LOCATION::@3974::@3999 QueryDeviceRelations
union _IO_STACK_LOCATION::@1575 Parameters
struct _IO_STACK_LOCATION::@3974::@4013 Others
COMMON_DEVICE_EXTENSION Common
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
NTSTATUS USBSTOR_PdoHandleQueryInstanceId(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
static LPCSTR USBSTOR_GetGenericType(IN PINQUIRYDATA InquiryData)
NTSTATUS USBSTOR_CreatePDO(IN PDEVICE_OBJECT DeviceObject, IN UCHAR LUN)
NTSTATUS USBSTOR_PdoHandleQueryCompatibleId(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
NTSTATUS USBSTOR_PdoHandleQueryDeviceId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS USBSTOR_PdoHandleQueryHardwareId(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
NTSTATUS USBSTOR_PdoHandlePnp(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
VOID USBSTOR_ConvertToUnicodeString(IN CHAR *Buffer, IN ULONG ResultBufferLength, IN ULONG ResultBufferOffset, OUT LPWSTR ResultBuffer, OUT PULONG NewResultBufferOffset)
NTSTATUS USBSTOR_PdoHandleDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
static LPCSTR USBSTOR_GetDeviceType(IN PINQUIRYDATA InquiryData)
NTSTATUS USBSTOR_PdoHandleQueryDeviceText(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS USBSTOR_SendIrp(IN PDEVICE_OBJECT PDODeviceObject, IN ULONG DataTransferLength, IN UCHAR OpCode, OUT PVOID *OutData)
NTSTATUS USBSTOR_SendInquiryIrp(IN PDEVICE_OBJECT PDODeviceObject)
NTSTATUS USBSTOR_AllocateIrp(IN PDEVICE_OBJECT DeviceObject, IN ULONG DataTransferLength, IN UCHAR OpCode, IN PKEVENT Event, OUT PSCSI_REQUEST_BLOCK *OutRequest, OUT PIRP *OutIrp)
NTSTATUS USBSTOR_SendFormatCapacityIrp(IN PDEVICE_OBJECT PDODeviceObject)
NTSTATUS NTAPI USBSTOR_CompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Ctx)
struct UFI_INQUIRY_RESPONSE * PUFI_INQUIRY_RESPONSE
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFQUEUE _Out_ WDFREQUEST * OutRequest
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define IRP_MN_QUERY_REMOVE_DEVICE
#define ObReferenceObject