STORAGE_DEVICE_DESCRIPTOR (Structures)
Last changed: Polymaker-24.226.223.60

.
Summary
Used in conjunction with the IOCTL_STORAGE_QUERY_PROPERTY control code to retrieve the storage device descriptor data for a device.

C# Definition:

[StructLayout(LayoutKind.Sequential)]
struct STORAGE_DEVICE_DESCRIPTOR
{
    public uint Version;
    public uint Size;
    public byte DeviceType;
    public byte DeviceTypeModifier;
    [MarshalAs(UnmanagedType.U1)]
    public bool RemovableMedia;
    [MarshalAs(UnmanagedType.U1)]
    public bool CommandQueueing;
    public uint VendorIdOffset;
    public uint ProductIdOffset;
    public uint ProductRevisionOffset;
    public uint SerialNumberOffset;
    public STORAGE_BUS_TYPE BusType;
    public uint RawPropertiesLength;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x16)]
    public byte[] RawDeviceProperties;
}

VB Definition:

Structure STORAGE_DEVICE_DESCRIPTOR
   Public TODO
End Structure

User-Defined Field Types:

STORAGE_BUS_TYPE

Sample Code:

//To get the values of VendorIdOffset, ProductIdOffset, ProductRevisionOffset
//IntPtr resultPtr is obtained from Kernel32.DeviceIoControl with IOCTL_STORAGE_QUERY_PROPERTY control code

var deviceInfo = (STORAGE_DEVICE_DESCRIPTOR)Marshal.PtrToStructure(resultPtr, typeof(STORAGE_DEVICE_DESCRIPTOR));
string vendorId, productId, firmwareRev, serialNumber;
if(deviceInfo.VendorIdOffset != 0)
    vendorId = Marshal.PtrToStringAnsi(new IntPtr((long)resultPtr + deviceInfo.VendorIdOffset));
if(deviceInfo.ProductIdOffset != 0)
    productId = Marshal.PtrToStringAnsi(new IntPtr((long)resultPtr + deviceInfo.ProductIdOffset));
if(deviceInfo.ProductRevisionOffset != 0)
    firmwareRev = Marshal.PtrToStringAnsi(new IntPtr((long)resultPtr + deviceInfo.ProductRevisionOffset));
if(deviceInfo.SerialNumberOffset != 0)
    serialNumber = Marshal.PtrToStringAnsi(new IntPtr((long)resultPtr + deviceInfo.SerialNumberOffset));

Documentation