disharm0niz Posted August 18, 2022 Posted August 18, 2022 (edited) Hi everyone. I started kernel mode programming just a few days ago and am having some problems. I am trying to get disk drives serial numbers from kernel mode. Here is my code so far: NTSTATUS Status; GUID PhysicalMedia; PVOID wmiObject = NULL; PVOID DataBlockObject = NULL; ULONG BufferSize; PhysicalMedia.Data1 = 0xBF253431; PhysicalMedia.Data2 = 0x1E4D; PhysicalMedia.Data3 = 0x4F57; PhysicalMedia.Data4[0] = 0x00; PhysicalMedia.Data4[1] = 0xE7; PhysicalMedia.Data4[2] = 0x64; PhysicalMedia.Data4[3] = 0xB2; PhysicalMedia.Data4[4] = 0xCA; PhysicalMedia.Data4[5] = 0xCC; PhysicalMedia.Data4[6] = 0x80; PhysicalMedia.Data4[7] = 0x1E; 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")); } Of course it is not working and returns the message ‘The GUID passed was not recognized as valid by a WMI data provider.’. I used this post idea but it seems I can't access the block. How can I access the data block correctly? I would appreciate it if someone could help me. Edit #1: I noticed I overwrite array number 0. I fixed it but still getting same error. Edit#2: I converted UUID from string to GUID using windows function. But still it says the guid is invalid in my driver. Here is the added code. GUID Guid; UNICODE_STRING Ustring; RtlInitUnicodeString(&Ustring, L"bf253431-1e4d-4F57-00e7-64b2cacc801e"); NTSTATUS RStatus; RStatus = RtlGUIDFromString(&Ustring, &Guid); if (RStatus == STATUS_SUCCESS) { KdPrint(("RtlGUIDFromString succeeded \n")); } else { KdPrint(("The string UUID is invalid. \n")); } Edited August 18, 2022 by disharm0niz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now