[NTDLL_APITEST] Allow the test to load on Windows XP. ROSTESTS-293
[reactos.git] / modules / rostests / apitests / ntdll / NtLoadUnloadKey.c
index b8339af..f9bb9c2 100644 (file)
@@ -5,18 +5,7 @@
  * PROGRAMMERS:     Hermes Belusca-Maito (hermes.belusca@sfr.fr)
  */
 
-#include <stdio.h>
-
-#include <apitest.h>
-#include <strsafe.h>
-
-#define WIN32_NO_STATUS
-#include <ndk/rtlfuncs.h>
-#include <ndk/cmfuncs.h>
-#include <ndk/cmtypes.h>
-#include <ndk/iofuncs.h>
-#include <ndk/obfuncs.h>
-#include <ndk/setypes.h>
+#include "precomp.h"
 
 /* See xdk/cmtypes.h */
 #define REG_CREATED_NEW_KEY     1
@@ -36,6 +25,7 @@
 
 #endif
 
+static NTSTATUS (NTAPI *pNtUnloadKey2)(POBJECT_ATTRIBUTES, ULONG);
 
 static BOOLEAN
 RetrieveCurrentModuleNTDirectory(
@@ -392,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);
 }
 
 
@@ -420,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);