Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Need a little help to retrieve Hard Disk Serial numbers in kernel mode

disharm0nizdisharm0niz Member Posts: 1

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.

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 12 September 2022 Live, Online
Internals & Software Drivers 23 October 2022 Live, Online
Kernel Debugging 14 November 2022 Live, Online
Developing Minifilters 5 December 2022 Live, Online