Jump to content
Tuts 4 You

Unable to get disk drives serial numbers from kernel mode


Recommended Posts

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"));
		KdPrint(("IoWMIOpenBlock failed (0x%08X)\n",Status));
			KdPrint(("The GUID passed was not recognized as valid by a WMI data provider. \n"));
			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;
	RtlInitUnicodeString(&Ustring, L"bf253431-1e4d-4F57-00e7-64b2cacc801e");
	RStatus = RtlGUIDFromString(&Ustring, &Guid);
	if (RStatus == STATUS_SUCCESS)
		KdPrint(("RtlGUIDFromString succeeded \n"));
		KdPrint(("The string UUID is invalid. \n"));


Edited by disharm0niz
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...