Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Unable to get disk drives serial numbers from kernel mode

Featured Replies

Posted

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 by disharm0niz

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.