Skip to content

Instantly share code, notes, and snippets.

@KunYi
Created September 23, 2018 09:21
Show Gist options
  • Save KunYi/3b3fb75a3db2ffde1913a112c1344cd9 to your computer and use it in GitHub Desktop.
Save KunYi/3b3fb75a3db2ffde1913a112c1344cd9 to your computer and use it in GitHub Desktop.
#include <wmiguid.h>
NTSTATUS status;
GUID smbiosGUID = SMBIOS_DATA_GUID; // defined in wmiguid.h
PVOID wmiObject = NULL;
PWNODE_ALL_DATA dataBuffer;
//
// Get a WMI block handle to the SMBIOS_DATA_GUID
//
status = IoWMIOpenBlock( (GUID *) &smbiosGUID, WMIGUID_QUERY,
&wmiObject );
if (!NT_SUCCESS(status)) {
return status;
}
//
// Determine how much space is required for the data
//
status = IoWMIQueryAllData( wmiObject, &bufferSize, NULL );
if (status != STATUS_BUFFER_TOO_SMALL) {
ObDereferenceObject( wmiObject );
return status;
}
//
// Allocate the necessary storage. This space must come out of NP-pool
//
dataBuffer = ExAllocatePoolWithTag(NonPagedPool, bufferSize, TAG_SMBIOS);
if (dataBuffer == NULL) {
ObDereferenceObject( wmiObject );
return STATUS_INSUFFICIENT_RESOURCES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment