Created
September 23, 2018 09:21
-
-
Save KunYi/3b3fb75a3db2ffde1913a112c1344cd9 to your computer and use it in GitHub Desktop.
smbios in kernel mode from "https://www.winvistatips.com/threads/smbios-info-from-kernel-mode.178848/"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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