query wmi with IoWMIOpenBlock

We have this IoWMIOpenBlock but how to get the UUID from e.g. “Win32_InfraredDevice” or “Win32_NetworkLoginProfile”.
I know the header “wmidata.h” but this file has not all GUID of the available classes from “cimv2”.

Thanks in advance

Does someone use this IoWMIOpenBlock functions? It seems to me that the most of them are not supported now.

IoWMIOpenBlock is still supported. But WMI in general is not under active development, so you’ll probably find there are not many experts, and the documentation might be a bit stale.

Furthermore, IoWMIOpenBlock can only query kernel providers. It’s not supported (or really a desirable architecture) for a kernel client to query a usermode provider. Since most WMI classes are implemented by a usermode provider, this means that your kernel driver cannot query most classes, including the two you mention.

How can you determine whether a WMI class is implemented by a kernel or usermode provider? Query the class definition via PowerShell:

(Get-CimClass -Namespace root\cimv2 -Class Win32_NetworkLoginProfile).CimClassQualifiers['provider'].Value

A provider value of CIMWin32 means it’s implemented by some sort of usermode COM server. A value of WMIProv means it’s implemented internally by WMI, which includes kernel providers. (To see an example of a kernel-provided WMI class, you can query root\wmi\MSNdis_RSSEnabled.)

To answer your specific question: you can always obtain the UUID for a class by querying WMI:

(Get-CimClass -Namespace root\cimv2 -Class Win32_NetworkLoginProfile).CimClassQualifiers['UUID']

In this case, the UUID is part of the contract for the class, so it’s safe to lift the UUID from a running system and hardcode the UUID into your code. (Microsoft won’t “change” the UUID unless the class takes a breaking change that makes it fundamentally semantically incompatible with the old class.)

Thank you jeffrey.
I looked at the file wmidata.h winsdk in the “km” folder:
There is for example this guid:

// MSSmBios_SysidUUID - SYSID_UUID
#define MSSmBios_SysidUUIDGuid
{ 0x8f680852,0xa584,0x11d1, { 0xbf,0x38,0x00,0xa0,0xc9,0x06,0x29,0x10 } }

It seems for me that this is especially done for KM. If I try this guid and others with your get-cimclass, I get always the output “Not found”

That class is in a different namespace:

get-cimclass -Namespace root\wmi MSSmBios_SysidUUID

It does appear that this one has a kernel provider, so there’s some chance you can query it from a kernel client. Although, you probably have to query for MSSmBios_SysidUUIDList; the MSSmBios_SysidUUID is just a helper class.