IOCTL_STORAGE_PROPERTY_QUERY

Thanks.
I also find some thing :
1)use drive letter, use createfile
2)use IOCTL_STORAGE_PROPERTY_QUERY, query some property of the
storage device
3)if device's Bustype is BusTypeUsb, it's based on usb device
4)vid & pid is obvious in out data

 

 

IOCTL_STORAGE_QUERY_PROPERTY Control Code

已有 78 次阅读  2011-04-26 16:30
  1. Returns the properties of a storage device or adapter. The request indicates the kind of information to retrieve, such as the inquiry data for a device or the capabilities and limitations of an adapter. IOCTL_STORAGE_QUERY_PROPERTY can also be used to determine whether the port driver supports a particular property or which fields in the property descriptor can be modified with a subsequent change-property request.
  2. BOOL WINAPI DeviceIoControl(
  3. __in (HANDLE) hDevice, // handle to a partition
  4. __in (DWORD) IOCTL_STORAGE_QUERY_PROPERTY, // dwIoControlCode
  5. __in (LPVOID) lpInBuffer, // input buffer - STORAGE_PROPERTY_QUERY structure
  6. __in (DWORD) nInBufferSize, // size of input buffer
  7. __out_opt (LPVOID) lpOutBuffer, // output buffer - see Remarks
  8. __in (DWORD) nOutBufferSize, // size of output buffer
  9. __out_opt (LPDWORD) lpBytesReturned, // number of bytes returned
  10. __inout_opt (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure
  11. Parameters
  12. hDevice
  13. A handle to the disk device from which partition information is retrieved. To retrieve a device handle, call the CreateFile function.
  14. dwIoControlCode
  15. The control code for the operation. Use IOCTL_STORAGE_QUERY_PROPERTY for this operation.
  16. lpInBuffer
  17. A pointer to a buffer that contains a STORAGE_PROPERTY_QUERY data structure that specifies the details about the query. Device properties must be retrieved only from a device; attempting to retrieve device properties from an adapter will cause an error.
  18. nInBufferSize
  19. The size of the input buffer, in bytes. It must be large enough to contain a STORAGE_PROPERTY_QUERY data structure.
  20. lpOutBuffer
  21. An optional pointer to a buffer that receives a structure that starts with the same fields as a STORAGE_DESCRIPTOR_HEADER data structure. For more information on the specific structures returned see the Remarks section.
  22. nOutBufferSize
  23. The size of the output buffer, in bytes. It can be zero to determine whether a property exists without retrieving its data. To do that, set this parameter to zero (0) and the QueryType member of the STORAGE_PROPERTY_QUERY input structure to PropertyExistsQuery (1). If the call to DeviceIoControl returns a nonzero value then the property exists.
  24. lpBytesReturned
  25. A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
  26. If the output buffer is too small, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.
  27. If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
  28. If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.
  29. lpOverlapped
  30. A pointer to an OVERLAPPED structure.
  31. If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.
  32. If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.
  33. For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation is complete. Otherwise, the function does not return until the operation is complete or an error occurs.
  34. Return Value
  35. If the operation completes successfully, DeviceIoControl returns a nonzero value.
  36. If the operation fails or is pending, DeviceIoControl returns zero. To get extended error information, call GetLastError.
  37. Remarks
  38. The optional output buffer returned through the lpOutBuffer parameter can be one of several structures depending on the value of the PropertyId member of the STORAGE_PROPERTY_QUERY structure pointed to by the lpInBuffer parameter. These values are enumerated by the STORAGE_PROPERTY_ID enumeration. If the QueryType member of the STORAGE_PROPERTY_QUERY is set to PropertyExistsQuery then no structure is returned.
  39. PropertyId value lpOutBuffer structure
  40. StorageDeviceProperty (0) STORAGE_DEVICE_DESCRIPTOR
  41. StorageAdapterProperty (1) STORAGE_ADAPTER_DESCRIPTOR
  42. StorageDeviceIdProperty (2) STORAGE_DEVICE_ID_DESCRIPTOR
  43. StorageDeviceUniqueIdProperty (3) STORAGE_DEVICE_UNIQUE_IDENTIFIER
  44. StorageDeviceWriteCacheProperty (4) STORAGE_WRITE_CACHE_PROPERTY
  45. StorageMiniportProperty (5) STORAGE_MINIPORT_DESCRIPTOR
  46. StorageAccessAlignmentProperty (6) STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR
  47. StorageDeviceSeekPenaltyProperty (7) DEVICE_SEEK_PENALTY_DESCRIPTOR
  48. StorageDeviceTrimProperty (8) DEVICE_TRIM_DESCRIPTOR
  49. Requirements
  50. Minimum supported client
  51. Windows 2000 Professional
  52. Minimum supported server
  53. Windows 2000 Server
  54. Header
  55. WinIoCtl.h


  1. STORAGE_PROPERTY_QUERY Structure
  2. Indicates the properties of a storage device or adapter to retrieve as the input buffer passed to the IOCTL_STORAGE_QUERY_PROPERTY control code.
  3. Syntax
  4. typedef struct _STORAGE_PROPERTY_QUERY {
  5. STORAGE_PROPERTY_ID PropertyId;
  6. STORAGE_QUERY_TYPE QueryType;
  7. BYTE AdditionalParameters[1];
  8. } STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
  9. Members
  10. PropertyId
  11. Indicates whether the caller is requesting a device descriptor, an adapter descriptor, a write cache property, a device unique ID (DUID), or the device identifiers provided in the device's SCSI vital product data (VPD) page. For a list of the property IDs that can be assigned to this member, see STORAGE_PROPERTY_ID.
  12. Value Meaning
  13. StorageDeviceProperty
  14. 0
  15. Indicates that the caller is querying for the device descriptor.
  16. StorageAdapterProperty
  17. 1
  18. Indicates that the caller is querying for the adapter descriptor.
  19. StorageDeviceIdProperty
  20. 2
  21. Indicates that the caller is querying for the device identifiers provided with the SCSI vital product data pages.
  22. StorageDeviceUniqueIdProperty
  23. 3
  24. Indicates that the caller is querying for the unique device identifiers.
  25. StorageDeviceWriteCacheProperty
  26. 4
  27. Indicates that the caller is querying for the write cache property.
  28. StorageMiniportProperty
  29. 5
  30. Indicates that the caller is querying for the miniport driver descriptor.
  31. StorageAccessAlignmentProperty
  32. 6
  33. Indicates that the caller is querying for the access alignment descriptor.
  34. StorageDeviceSeekPenaltyProperty
  35. 7
  36. Indicates that the caller is querying for the seek penalty descriptor.
  37. StorageDeviceTrimProperty
  38. 8
  39. Indicates that the caller is querying for the trim descriptor.
  40. QueryType
  41. Contains flags indicating the type of query to be performed as enumerated by the STORAGE_QUERY_TYPE enumeration.
  42. Value Meaning
  43. PropertyStandardQuery
  44. 0
  45. Instructs the port driver to report a device descriptor, an adapter descriptor or a unique hardware device ID (DUID).
  46. PropertyExistsQuery
  47. 1
  48. Instructs the port driver to report whether the descriptor is supported.
  49. AdditionalParameters
  50. Contains an array of bytes that can be used to retrieve additional parameters for specific queries.
  51. Remarks
  52. The optional output buffer returned through the lpOutBuffer parameter of the IOCTL_STORAGE_QUERY_PROPERTY control code can be one of several structures depending on the value of the PropertyId member. If the QueryType member is set to PropertyExistsQuery, then no structure is returned.
  53. PropertyId value lpOutBuffer structure
  54. StorageDeviceProperty (0) STORAGE_DEVICE_DESCRIPTOR
  55. StorageAdapterProperty (1) STORAGE_ADAPTER_DESCRIPTOR
  56. StorageDeviceIdProperty (2) STORAGE_DEVICE_ID_DESCRIPTOR
  57. StorageDeviceUniqueIdProperty (3) STORAGE_DEVICE_UNIQUE_IDENTIFIER
  58. StorageDeviceWriteCacheProperty (4) STORAGE_WRITE_CACHE_PROPERTY
  59. StorageMiniportProperty (5) STORAGE_MINIPORT_DESCRIPTOR
  60. StorageAccessAlignmentProperty (6) STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR
  61. StorageDeviceSeekPenaltyProperty (7) DEVICE_SEEK_PENALTY_DESCRIPTOR
  62. StorageDeviceTrimProperty (8) DEVICE_TRIM_DESCRIPTOR
  63. Requirements
  64. Minimum supported client
  65. Windows 2000 Professional
  66. Minimum supported server
  67. Windows 2000 Server
  68. Header
  69. WinIoCtl.h


  1. STORAGE_DEVICE_DESCRIPTOR Structure
  2. Used in conjunction with the IOCTL_STORAGE_QUERY_PROPERTY control code to retrieve the storage device descriptor data for a device.
  3. Syntax
  4. typedef struct _STORAGE_DEVICE_DESCRIPTOR {
  5. DWORD Version;
  6. DWORD Size;
  7. BYTE DeviceType;
  8. BYTE DeviceTypeModifier;
  9. BOOLEAN RemovableMedia;
  10. BOOLEAN CommandQueueing;
  11. DWORD VendorIdOffset;
  12. DWORD ProductIdOffset;
  13. DWORD ProductRevisionOffset;
  14. DWORD SerialNumberOffset;
  15. STORAGE_BUS_TYPE BusType;
  16. DWORD RawPropertiesLength;
  17. BYTE RawDeviceProperties[1];
  18. } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
  19. Members
  20. Version
  21. Contains the size of this structure, in bytes. The value of this member will change as members are added to the structure.
  22. Size
  23. Specifies the total size of the descriptor, in bytes, which may include vendor ID, product ID, product revision, device serial number strings and bus-specific data which are appended to the structure.
  24. DeviceType
  25. Specifies the device type as defined by the Small Computer Systems Interface (SCSI) specification.
  26. DeviceTypeModifier
  27. Specifies the device type modifier, if any, as defined by the SCSI specification. If no device type modifier exists, this member is zero.
  28. RemovableMedia
  29. Indicates when TRUE that the device's media (if any) is removable. If the device has no media, this member should be ignored. When FALSE the device's media is not removable.
  30. CommandQueueing
  31. Indicates when TRUE that the device supports multiple outstanding commands (SCSI tagged queuing or equivalent). When FALSE, the device does not support SCSI-tagged queuing or the equivalent.
  32. VendorIdOffset
  33. Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's vendor ID. If the device has no vendor ID, this member is zero.
  34. ProductIdOffset
  35. Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's product ID. If the device has no product ID, this member is zero.
  36. ProductRevisionOffset
  37. Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's product revision string. If the device has no product revision string, this member is zero.
  38. SerialNumberOffset
  39. Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's serial number. If the device has no serial number, this member is 0xffffffff.
  40. BusType
  41. Specifies an enumerator value of type STORAGE_BUS_TYPE that indicates the type of bus to which the device is connected. This should be used to interpret the raw device properties at the end of this structure (if any).
  42. RawPropertiesLength
  43. Indicates the number of bytes of bus-specific data that have been appended to this descriptor.
  44. RawDeviceProperties
  45. Contains an array of length one that serves as a place holder for the first byte of the bus specific property data.
  46. Remarks
  47. An application can determine the required buffer size by issuing a IOCTL_STORAGE_QUERY_PROPERTY control code passing a STORAGE_DESCRIPTOR_HEADER structure for the output buffer, and then using the returned Size member of the STORAGE_DESCRIPTOR_HEADER structure to allocate a buffer of the proper size.
  48. Requirements
  49. Minimum supported client
  50. Windows 2000 Professional
  51. Minimum supported server
  52. Windows 2000 Server
  53. Header
  54. WinIoCtl.h



  1. STORAGE_BUS_TYPE Enumeration
  2. Provides a symbolic means of representing storage bus types.
  3. Syntax
  4. typedef enum _STORAGE_BUS_TYPE {
  5. BusTypeUnknown = 0x00,
  6. BusTypeScsi = 0x1,
  7. BusTypeAtapi = 0x2,
  8. BusTypeAta = 0x3,
  9. BusType1394 = 0x4,
  10. BusTypeSsa = 0x5,
  11. BusTypeFibre = 0x6,
  12. BusTypeUsb = 0x7,
  13. BusTypeRAID = 0x8,
  14. BusTypeiScsi = 0x9,
  15. BusTypeSas = 0xA,
  16. BusTypeSata = 0xB,
  17. BusTypeSd = 0xC,
  18. BusTypeMmc = 0xD,
  19. BusTypeVirtual = 0xE,
  20. BusTypeFileBackedVirtual = 0xF,
  21. BusTypeMax = 0x10,
  22. BusTypeMaxReserved = 0x7F
  23. } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
  24. Constants
  25. BusTypeUnknown
  26. Indicates an unknown bus type.
  27. BusTypeScsi
  28. Indicates a SCSI bus type.
  29. BusTypeAtapi
  30. Indicates an ATAPI bus type.
  31. BusTypeAta
  32. Indicates an ATA bus type.
  33. BusType1394
  34. Indicates an IEEE 1394 bus type.
  35. BusTypeSsa
  36. Indicates an SSA bus type.
  37. BusTypeFibre
  38. Indicates a fiber channel bus type.
  39. BusTypeUsb
  40. Indicates a USB bus type.
  41. BusTypeRAID
  42. Indicates a RAID bus type.
  43. BusTypeiScsi
  44. Indicates an iSCSI bus type.
  45. Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  46. BusTypeSas
  47. Indicates a serial-attached SCSI (SAS) bus type.
  48. Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  49. BusTypeSata
  50. Indicates a SATA bus type.
  51. Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  52. BusTypeSd
  53. Indicates a secure digital (SD) bus type.
  54. Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  55. BusTypeMmc
  56. Indicates a multimedia card (MMC) bus type.
  57. Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  58. BusTypeVirtual
  59. Indicates a virtual bus type.
  60. Windows Vista, Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  61. BusTypeFileBackedVirtual
  62. Indicates a file-backed virtual bus type.
  63. Windows Vista, Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
  64. BusTypeMax
  65. Indicates the maximum value for this value.
  66. BusTypeMaxReserved
  67. The maximum value of the storage bus type range.
  68. Requirements
  69. Minimum supported client
  70. Windows 2000 Professional
  71. Minimum supported server
  72. Windows 2000 Server
  73. Header
  74. WinIoCtl.h




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值