https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a6b61b855c49e5ce8a450…
commit a6b61b855c49e5ce8a4503fa29b5ddbbbe55fe32
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Oct 7 12:09:27 2017 +0200
[KERNEL32_APITEST]: Add few tests for IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
---
.../rostests/apitests/kernel32/DeviceIoControl.c | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/modules/rostests/apitests/kernel32/DeviceIoControl.c
b/modules/rostests/apitests/kernel32/DeviceIoControl.c
index a7edb8678a..ed1c6f7fa3 100644
--- a/modules/rostests/apitests/kernel32/DeviceIoControl.c
+++ b/modules/rostests/apitests/kernel32/DeviceIoControl.c
@@ -9,6 +9,7 @@
#include <strsafe.h>
#include <winioctl.h>
#include <mountmgr.h>
+#include <mountdev.h>
WCHAR Letter;
HANDLE Device;
@@ -110,6 +111,42 @@ QueryDeviceName(VOID)
HeapFree(GetProcessHeap(), 0, AllocatedMDN);
}
+static
+VOID
+QueryUniqueId(VOID)
+{
+ UINT Ret;
+ DWORD Size, Error;
+ MOUNTDEV_UNIQUE_ID MUI, *AllocatedMUI;
+
+ Ret = DeviceIoControl(Device, IOCTL_MOUNTDEV_QUERY_UNIQUE_ID, NULL, 0, &MUI,
sizeof(MUI) - 1, &Size, NULL);
+ ok(Ret == 0, "DeviceIoControl succeed\n");
+ Error = GetLastError();
+ ok(Error == ERROR_INVALID_PARAMETER, "Expecting ERROR_INVALID_PARAMETER, got
%ld\n", Error);
+ ok(Size == 48 /* ?! */, "Invalid output size: %ld\n", Size);
+
+ Ret = DeviceIoControl(Device, IOCTL_MOUNTDEV_QUERY_UNIQUE_ID, NULL, 0, &MUI,
sizeof(MUI), &Size, NULL);
+ ok(Ret == 0, "DeviceIoControl succeed\n");
+ Error = GetLastError();
+ ok(Error == ERROR_MORE_DATA, "Expecting ERROR_MORE_DATA, got %ld\n",
Error);
+ ok(Size == sizeof(MOUNTDEV_UNIQUE_ID), "Invalid output size: %ld\n",
Size);
+
+ AllocatedMUI = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MOUNTDEV_UNIQUE_ID,
UniqueId) + MUI.UniqueIdLength + sizeof(UNICODE_NULL));
+ if (AllocatedMUI == NULL)
+ {
+ skip("Memory allocation failure\n");
+ return;
+ }
+
+ Size = 0;
+ Ret = DeviceIoControl(Device, IOCTL_MOUNTDEV_QUERY_UNIQUE_ID, NULL, 0, AllocatedMUI,
FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + MUI.UniqueIdLength, &Size, NULL);
+ ok(Ret != 0, "DeviceIoControl failed: %ld\n", GetLastError());
+ ok(Size == FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + MUI.UniqueIdLength,
"Invalid output size: %ld\n", Size);
+ ok(AllocatedMUI->UniqueIdLength == MUI.UniqueIdLength, "Mismatching sizes: %d
%d\n", AllocatedMUI->UniqueIdLength, MUI.UniqueIdLength);
+
+ HeapFree(GetProcessHeap(), 0, AllocatedMUI);
+}
+
START_TEST(DeviceIoControl)
{
UINT Ret;
@@ -137,6 +174,7 @@ START_TEST(DeviceIoControl)
GetDiskGeometry();
QueryDeviceName();
+ QueryUniqueId();
CloseHandle(Device);
}