IoGetDevicePropertyData() with DEVPKEY_Device_InstanceId returns STATUS_OBJECT_NAME_NOT_FOUND in Windows 7 - solution?

Hello,
I'm calling IoGetDevicePropertyData with DEVPKEY_Device_InstanceId in a minifilter on Windows 7 Sp1 x64 and get STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034), although it works on newer windows.
Is this key unsupported for IoGetDevicePropertyData on w7? what's the correct workaround to get device instance id in kernel on win7?

Thank you so much.

It's not supported on the ancient win7. From the docs:
Version : Windows Vista and later versions of Windows Header : Devpkey.h (include Devpkey.h)

On Windows 7 SP1 x64, when I go to Device Manager → Disk drives → Details, I don’t see Device Instance ID listed at all (while on Windows 10+ it’s available).

So my questions are:

  1. Is there any other way on Windows 7 to obtain the Device Instance ID (either in Device Manager or programmatically in kernel mode)?

  2. If not directly available, is it valid/safe to reconstruct the Device Instance ID from the Hardware IDs (like USBSTOR\DiskVendorCoProductCode_____2.00, etc.) combined with the USB serial number?

Thanks!

There’s a note about that in the docs: DEVPKEY_Device_InstanceId - Windows drivers | Microsoft Learn

1 Like

CM and SetupDi functions are usermode. If you have usermode helper service, OK. In kernel… Hmm. you can call IoGetDeviceProperty(DevicePropertyHardwareID) then open the registry key under HKLM\System\CCS\Enum + the matching hardware ID and enumerate instances. Find one where the value for “Driver” matches the string returned by IoGetDeviceProperty(DevicePropertyDriverKeyName,…)