Is there any example for IoWMIQuerySingleInstance ?

IoWMIOpenBlock function

Remarks

Use the IoWMIQueryXxx and IoWMISetXxx routines to read and write WMI class properties. …

Accroding the above, I want to get the SerialNumber of Win32_BaseBoard in my driver. But the second param of IoWMIQuerySingleInstance named “InstanceName”, I don’t understand what is this even if I read its doc. How get I get the “InstanceName” ?

Or is there any examples of usage IoWMI* to get the SerialNumber of Win32_BaseBoard ?

I don’t believe that you can query any arbitrary WMI instance from a kernel driver. You can only query WMI instances that are provided by the kernel provider.

You can determine who is the provider for a class with this bit of powershell:

(Get-CimClass Win32_BaseBoard).CimClassQualifiers['provider']

The kernel provider is named WMIProv. In the case of Win32_BaseBoard, it’s provided by CIMWin32. (In general, any class named Win32_Xxx is unlikely to be provided by a kernel provider. Actually, any class is unlikely to be provided by a kernel provider… most come from one of the win32 usermode providers.)

This WMI class gets its data from SMBios. You might have to parse that from your driver, or find a way to have a usermode helper do the WMI query and feed the data to your driver.

@“Jeffrey_Tippet_[MSFT]” said:

This WMI class gets its data from SMBios. You might have to parse that from your driver, or find a way to have a usermode helper do the WMI query and feed the data to your driver.

I have see the SMBios, there are a few versions, which version do I need to write code for? How can I be compatible with most machines without reading error offset or blue screen?

Ideally… have a usermode agent query WMI and push the results into your driver. I’m not aware of a high-level API to query SMBios from a kernel driver. (There might be one – I don’t know a ton about the area.)

If you can’t have a usermode agent, and you don’t find any high-level kernel APIs to parse the table for you, hten you’re probably stuck writing parsing code yourself.
AuxKlibGetSystemFirmwareTable(‘RSMB’) gives you the raw table to parse.

@“Jeffrey_Tippet_[MSFT]” said:
Ideally… have a usermode agent query WMI and push the results into your driver. I’m not aware of a high-level API to query SMBios from a kernel driver. (There might be one – I don’t know a ton about the area.)

If you can’t have a usermode agent, and you don’t find any high-level kernel APIs to parse the table for you, hten you’re probably stuck writing parsing code yourself.
AuxKlibGetSystemFirmwareTable(‘RSMB’) gives you the raw table to parse.

As far as I know, the raw table data struct define by SMBios spec. So I’m not sure I can write this part correct, compatible with most machines without BSOD.

If you want to retrieve the SMBIOS table, you can definitely retrieve it from kernel mode. There’s an AuxKlib Function that you can use for this. Though I’ve used the function to retrieve sundry ACPI tables (including just recently), I have never retrieved the SMBIOS table and know nothing about it.

Peter

@“Peter_Viscarola_(OSR)” said:
If you want to retrieve the SMBIOS table, you can definitely retrieve it from kernel mode. There’s an AuxKlib Function that you can use for this. Though I’ve used the function to retrieve sundry ACPI tables (including just recently), I have never retrieved the SMBIOS table and know nothing about it.

Peter

Thank you, I will try it.