ohmu
·
2026-10-15
1#pragma once
2
3#include <windef.h>
4#include <wmistr.h>
5#include <assert.h>
6
7/**
8 * The WmiOpenBlock function opens the WMI data block object for the specified WMI class.
9 *
10 * \param Guid Specifies the GUID for WMI class.
11 * \param DesiredAccess Specifies the desired access rights to the data block object.
12 * \param DataBlockHandle Pointer to a memory location where the routine returns a handle to the data block object.
13 * \return ULONG Successful or errant status.
14 */
15NTSYSAPI ULONG NTAPI
16WmiOpenBlock(
17 _In_ LPCGUID Guid,
18 _In_ ACCESS_MASK DesiredAccess,
19 _Out_ PHANDLE DataBlockHandle);
20
21/**
22 * The WmiQueryAllDataW function returns all WMI data blocks that implement a given WMI class (Unicode).
23 *
24 * \param DataBlockHandle Handle to a WMI data block object.
25 * \param BufferLength Pointer to a memory location that specifies the size of the buffer.
26 * \param Buffer Pointer to the buffer where the routine returns the WMI data.
27 * \return ULONG Successful or errant status.
28 */
29NTSYSAPI ULONG NTAPI
30WmiQueryAllDataW(
31 _In_ HANDLE DataBlockHandle,
32 _Inout_ PULONG BufferLength,
33 _Out_writes_bytes_opt_(*BufferLength) PVOID Buffer);
34
35/**
36 * The WmiCloseBlock function closes a WMI data block object.
37 *
38 * \param DataBlockHandle Handle to the data block object to be closed.
39 * \return ULONG Successful or errant status.
40 */
41NTSYSAPI ULONG NTAPI
42WmiCloseBlock(
43 _In_ HANDLE DataBlockHandle);
44
45static inline void ffCloseWmiBlock(HANDLE* hBlock) {
46 assert(hBlock);
47 if (*hBlock) {
48 WmiCloseBlock(*hBlock);
49 }
50}
51
52// MOF: https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/km/wmicore.mof