Skip to content

Commit

Permalink
DiskIO (Windows): detect serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Dec 17, 2023
1 parent b692b75 commit 9339a0f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/detection/diskio/diskio_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,29 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
device->bytesWritten = (uint64_t) diskPerformance.BytesWritten.QuadPart;
device->writeCount = (uint64_t) diskPerformance.WriteCount;

DEVICE_SEEK_PENALTY_DESCRIPTOR dspd = {};
DWORD retSize = 0;

char sddBuffer[4096];
if(DeviceIoControl(
hDevice,
IOCTL_STORAGE_QUERY_PROPERTY,
&(STORAGE_PROPERTY_QUERY) {
.PropertyId = StorageDeviceProperty,
.QueryType = PropertyStandardQuery,
},
sizeof(STORAGE_PROPERTY_QUERY),
&sddBuffer,
sizeof(sddBuffer),
&retSize,
NULL
) && retSize > 0)
{
STORAGE_DEVICE_DESCRIPTOR* sdd = (STORAGE_DEVICE_DESCRIPTOR*) sddBuffer;
if (sdd->SerialNumberOffset != 0)
ffStrbufSetS(&device->serial, (const char*) sddBuffer + sdd->SerialNumberOffset);
}

DEVICE_SEEK_PENALTY_DESCRIPTOR dspd = {};
if(DeviceIoControl(
hDevice,
IOCTL_STORAGE_QUERY_PROPERTY,
Expand Down

0 comments on commit 9339a0f

Please sign in to comment.