23 switch (InquiryData->DeviceType)
48 switch (InquiryData->DeviceType)
54 return "GenSequential";
64 return "UsbstorOther";
131 CHAR LocalBuffer[26];
140 InquiryData = (
PINQUIRYDATA)&DeviceExtension->InquiryData;
147 DPRINT(
"USBSTOR_PdoHandleQueryDeviceText\n");
150 LocalBuffer[
Offset++] =
' ';
152 LocalBuffer[
Offset++] =
'\0';
161 Irp->IoStatus.Information = 0;
172 Irp->IoStatus.Information = 0;
173 return Irp->IoStatus.Status;
193 InquiryData = (
PINQUIRYDATA)&DeviceExtension->InquiryData;
215 Irp->IoStatus.Information = 0;
243 ASSERT(ResultBufferLength);
244 ASSERT(ResultBufferLength > ResultBufferOffset);
246 DPRINT(
"ResultBufferOffset %lu ResultBufferLength %lu Buffer %s Length %lu\n", ResultBufferOffset, ResultBufferLength,
Buffer,
strlen(
Buffer));
251 DeviceString.
MaximumLength = (ResultBufferLength - ResultBufferOffset) *
sizeof(
WCHAR);
260 ResultBufferLength -= (DeviceString.
Length +
sizeof(
WCHAR)) /
sizeof(
WCHAR);
261 ResultBufferOffset += (DeviceString.
Length +
sizeof(
WCHAR)) /
sizeof(
WCHAR);
263 *NewResultBufferOffset = ResultBufferOffset;
275 CHAR Id1[50], Id2[50], Id3[50], Id4[50], Id5[50], Id6[50], Id7[50];
276 ULONG Id1Length, Id2Length, Id3Length, Id4Length, Id5Length, Id6Length, Id7Length;
282 ASSERT(FDODeviceExtension->DeviceDescriptor);
283 InquiryData = (
PINQUIRYDATA)&PDODeviceExtension->InquiryData;
299 Id1Length =
strlen(Id1) + 1;
300 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId1 %s\n", Id1);
310 Id2Length =
strlen(Id2) + 1;
311 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId2 %s\n", Id2);
320 Id3Length =
strlen(Id3) + 1;
321 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId3 %s\n", Id3);
332 Id4Length =
strlen(Id4) + 1;
333 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId4 %s\n", Id4);
343 Id5Length =
strlen(Id5) + 1;
344 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId5 %s\n", Id5);
352 Id6Length =
strlen(Id6) + 1;
353 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId6 %s\n", Id6);
360 Id7Length =
strlen(Id7) + 1;
361 DPRINT(
"USBSTOR_PdoHandleQueryHardwareId HardwareId7 %s\n", Id7);
364 TotalLength = Id1Length + Id2Length + Id3Length + Id4Length + Id5Length + Id6Length + Id7Length + 1;
369 Irp->IoStatus.Information = 0;
407 ASSERT(FDODeviceExtension->DeviceDescriptor);
418 Irp->IoStatus.Information = 0;
446 FDODeviceExtension = PDODeviceExtension->LowerDeviceObject->DeviceExtension;
448 Descriptor = FDODeviceExtension->SerialNumber;
460 CharCount = (
sizeof(
"99999999") - 1) +
469 Irp->IoStatus.Information = 0;
479 PDODeviceExtension->LUN);
486 FDODeviceExtension->InstanceCount,
487 PDODeviceExtension->LUN);
507 DPRINT(
"USBSTOR_PdoHandleDeviceRelations\n");
515 return Irp->IoStatus.Status;
519 if (!DeviceRelations)
525 DeviceRelations->
Count = 1;
585 Irp->IoStatus.Information = 0;
590 DPRINT(
"IRP_MN_REMOVE_DEVICE\n");
592 if(*DeviceExtension->PDODeviceObject !=
NULL)
594 *DeviceExtension->PDODeviceObject =
NULL;
626 Caps->UniqueID =
FALSE;
627 Caps->Removable =
TRUE;
635 if (DeviceExtension->Claimed)
638 DPRINT1(
"[USBSTOR] Request %x fails because device is still claimed\n", IoStack->
MinorFunction);
723 *OutDataTransferLength,
845 DPRINT(
"DeviceType %x\n", InquiryData->DeviceType);
846 DPRINT(
"DeviceTypeModifier %x\n", InquiryData->DeviceTypeModifier);
847 DPRINT(
"RemovableMedia %x\n", InquiryData->RemovableMedia);
848 DPRINT(
"Version %x\n", InquiryData->Versions);
849 DPRINT(
"Format %x\n", InquiryData->ResponseDataFormat);
850 DPRINT(
"Length %x\n", InquiryData->AdditionalLength);
851 DPRINT(
"Reserved %p\n", InquiryData->Reserved);
852 DPRINT(
"VendorId %c%c%c%c%c%c%c%c\n", InquiryData->VendorId[0], InquiryData->VendorId[1], InquiryData->VendorId[2], InquiryData->VendorId[3], InquiryData->VendorId[4], InquiryData->VendorId[5], InquiryData->VendorId[6], InquiryData->VendorId[7]);
853 DPRINT(
"ProductId %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", InquiryData->ProductId[0], InquiryData->ProductId[1], InquiryData->ProductId[2], InquiryData->ProductId[3],
854 InquiryData->ProductId[4], InquiryData->ProductId[5], InquiryData->ProductId[6], InquiryData->ProductId[7],
855 InquiryData->ProductId[8], InquiryData->ProductId[9], InquiryData->ProductId[10], InquiryData->ProductId[11],
856 InquiryData->ProductId[12], InquiryData->ProductId[13], InquiryData->ProductId[14], InquiryData->ProductId[15]);
858 DPRINT(
"Revision %c%c%c%c\n", InquiryData->ProductRevisionLevel[0], InquiryData->ProductRevisionLevel[1], InquiryData->ProductRevisionLevel[2], InquiryData->ProductRevisionLevel[3]);
888 InquiryData = (
PINQUIRYDATA)&PDODeviceExtension->InquiryData;
894 PDODeviceExtension->PDODeviceObject = &FDODeviceExtension->ChildPDO[LUN];
895 PDODeviceExtension->Self = PDO;
896 PDODeviceExtension->LUN = LUN;
901 PDO->
Flags &= ~DO_DEVICE_INITIALIZING;
904 FDODeviceExtension->ChildPDO[LUN] = PDO;
#define ExAllocatePoolUninitialized
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
ACPI_SIZE strlen(const char *String)
_In_ PSCSI_REQUEST_BLOCK Srb
struct _INQUIRYDATA * PINQUIRYDATA
#define CDB6GENERIC_LENGTH
#define WRITE_ONCE_READ_MULTIPLE_DEVICE
#define DIRECT_ACCESS_DEVICE
#define READ_ONLY_DIRECT_ACCESS_DEVICE
#define SEQUENTIAL_ACCESS_DEVICE
#define SENSE_BUFFER_SIZE
#define INQUIRYDATABUFFERSIZE
#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
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_FUNCTION_EXECUTE_SCSI
#define SRB_STATUS_DATA_OVERRUN
#define SRB_FLAGS_DATA_IN
#define SRB_STATUS(Status)
#define SRB_FLAGS_NO_QUEUE_FREEZE
#define SRB_STATUS_SUCCESS
#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
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
PKMT_RESULTBUFFER ResultBuffer
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)
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
#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]
UCHAR ProductRevisionLevel[4]
struct _IO_STACK_LOCATION::@3983::@4005 Scsi
struct _IO_STACK_LOCATION::@3983::@4014 QueryId
struct _IO_STACK_LOCATION::@3983::@4008 QueryDeviceRelations
struct _IO_STACK_LOCATION::@3983::@4010 DeviceCapabilities
struct _IO_STACK_LOCATION::@3983::@4015 QueryDeviceText
union _IO_STACK_LOCATION::@1584 Parameters
COMMON_DEVICE_EXTENSION Common
UCHAR SenseInfoBufferLength
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
struct _CDB::_CDB6GENERIC CDB6GENERIC
struct _CDB::_CDB6INQUIRY CDB6INQUIRY
struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR
NTSTATUS USBSTOR_PdoHandleQueryInstanceId(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
static NTSTATUS USBSTOR_FillInquiryData(IN PDEVICE_OBJECT PDODeviceObject)
static NTSTATUS USBSTOR_SendInternalCdb(IN PDEVICE_OBJECT PdoDevice, IN PCDB Cdb, IN UCHAR CdbLength, IN ULONG TimeOutValue, OUT PVOID OutDataBuffer, OUT PULONG OutDataTransferLength)
static ULONG CopyFieldTruncate(IN PUCHAR Name, IN PCHAR Buffer, IN ULONG MaxLength)
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 NTAPI USBSTOR_SyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Ctx)
NTSTATUS USBSTOR_PdoHandleQueryDeviceText(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#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
@ DeviceTextLocationInformation
#define IRP_MN_QUERY_REMOVE_DEVICE
#define ObReferenceObject