[NTDLL_APITEST] Allow the test to load on Windows XP. ROSTESTS-293
[reactos.git] / modules / rostests / apitests / ntdll / NtLoadUnloadKey.c
index bc4f4b9..f9bb9c2 100644 (file)
@@ -25,6 +25,7 @@
 
 #endif
 
+static NTSTATUS (NTAPI *pNtUnloadKey2)(POBJECT_ATTRIBUTES, ULONG);
 
 static BOOLEAN
 RetrieveCurrentModuleNTDirectory(
@@ -381,8 +382,12 @@ DisconnectRegistry(
                                OBJ_CASE_INSENSITIVE,
                                RootKey,
                                NULL);
-    // return NtUnloadKey(&ObjectAttributes);
-    return NtUnloadKey2(&ObjectAttributes, Flags);
+    if (!pNtUnloadKey2)
+    {
+        win_skip("NtUnloadKey2 unavailable, using NtUnloadKey. Flags %lu\n", Flags);
+        return NtUnloadKey(&ObjectAttributes);
+    }
+    return pNtUnloadKey2(&ObjectAttributes, Flags);
 }
 
 
@@ -409,6 +414,8 @@ START_TEST(NtLoadUnloadKey)
     BOOLEAN PrivilegeSet[2] = {FALSE, FALSE};
     WCHAR PathBuffer[MAX_PATH];
 
+    pNtUnloadKey2 = (PVOID)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "NtUnloadKey2");
+
     /* Retrieve our current directory */
     RetrieveCurrentModuleNTDirectory(&NtTestPath);