msdn:
SerialNumberOffset
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 zero.
这个成员指向的是以0结尾的ascii字符串。所以直接(BYTE*)(Descriptor+(*Descriptor).SerialNumberOffset)就是这个字符串了。然后自己挨个字符找零就能知道长度了。
不过最好先看一下SerialNumberOffset的值是不是0。
PSTORAGE_DEVICE_DESCRIPTOR Descriptor;
PUCHAR p;
char ProductIdOffset[128];
char VendorIdOffset[128];
char SerialNumberOffset[128];
int index=0;
int i;
Descriptor = (PSTORAGE_DEVICE_DESCRIPTOR)Buffer;
p = (PUCHAR) Buffer;