Hi everyone, I am new to kernel programming. I am trying to retrieve the hard disk serial number using WMI with the below code.
NTSTATUS Status;
GUID PhysicalMedia;
PVOID wmiObject = NULL;
GUID Guid;
UNICODE_STRING Ustring;
RtlInitUnicodeString(&Ustring, L"{BF253431-1E4D-4F57-00E7-64B2CACC801E}"); //UUID of PhysicalDisk
NTSTATUS RStatus;
RStatus = RtlGUIDFromString(&Ustring, &Guid);
if (RStatus == STATUS_SUCCESS)
{
KdPrint(("RtlGUIDFromString succeeded \n"));
PhysicalMedia = Guid;
Status = IoWMIOpenBlock((GUID*)&PhysicalMedia, WMIGUID_QUERY, &wmiObject);
if (Status == STATUS_SUCCESS)
{
KdPrint(("IoWMIOpenBlock succeeded \n"));
}
else
{
KdPrint(("IoWMIOpenBlock failed (0x%08X)\n", Status));
if (Status == STATUS_WMI_GUID_NOT_FOUND)
KdPrint(("The GUID passed was not recognized as valid by a WMI data provider. \n"));
if (Status == STATUS_BUFFER_TOO_SMALL)
KdPrint(("The buffer passed by the caller in the OutBuffer parameter is too small. The routine returns the required buffer size in the memory location pointed to by the InOutBufferSize parameter. \n"));
}
}
else
{
KdPrint(("The string UUID is invalid. \n"));
}
But I get the error “The GUID passed was not recognized as valid by a WMI data provider”. I would really appreciate if someone could help me.