https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6fe9441d32f532c39446b…
commit 6fe9441d32f532c39446b6ca7a2c9e11849676e0
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Thu Nov 30 01:44:40 2017 +0100
[NTDLL_APITEST] Allow the test to load on Windows XP. ROSTESTS-293
---
.../apitests/ntdll/NtApphelpCacheControl.c | 33 ++++++++++++++--------
modules/rostests/apitests/ntdll/NtLoadUnloadKey.c | 11 ++++++--
.../rostests/apitests/ntdll/RtlCopyMappedMemory.c | 24 +++++++++++-----
3 files changed, 47 insertions(+), 21 deletions(-)
diff --git a/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c
b/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c
index ea9cb2920c..d0ffde0880 100644
--- a/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c
+++ b/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c
@@ -15,6 +15,7 @@ enum ServiceCommands
RegisterShimCacheWithoutHandle = 129,
};
+static NTSTATUS (NTAPI *pNtApphelpCacheControl)(APPHELPCACHESERVICECLASS,
PAPPHELP_CACHE_SERVICE_LOOKUP);
NTSTATUS CallCacheControl(UNICODE_STRING* PathName, BOOLEAN WithMapping,
APPHELPCACHESERVICECLASS Service)
{
@@ -38,7 +39,7 @@ NTSTATUS CallCacheControl(UNICODE_STRING* PathName, BOOLEAN WithMapping,
APPHELP
{
CacheEntry.ImageHandle = INVALID_HANDLE_VALUE;
}
- Status = NtApphelpCacheControl(Service, &CacheEntry);
+ Status = pNtApphelpCacheControl(Service, &CacheEntry);
if (CacheEntry.ImageHandle != INVALID_HANDLE_VALUE)
NtClose(CacheEntry.ImageHandle);
return Status;
@@ -64,31 +65,31 @@ void CheckValidation(UNICODE_STRING* PathName)
NTSTATUS Status;
/* Validate the handling of a NULL pointer */
- Status = NtApphelpCacheControl(ApphelpCacheServiceRemove, NULL);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceRemove, NULL);
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
- Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, NULL);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, NULL);
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
/* Validate the handling of a NULL pointer inside the struct */
- Status = NtApphelpCacheControl(ApphelpCacheServiceRemove, &CacheEntry);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceRemove, &CacheEntry);
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
- Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
/* Just call the dump function */
- Status = NtApphelpCacheControl(ApphelpCacheServiceDump, NULL);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceDump, NULL);
ok_ntstatus(Status, STATUS_SUCCESS);
/* Validate the handling of an invalid handle inside the struct */
CacheEntry.ImageName = *PathName;
CacheEntry.ImageHandle = (HANDLE)2;
- Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
ok_ntstatus(Status, STATUS_NOT_FOUND);
/* Validate the handling of an invalid service number */
- Status = NtApphelpCacheControl(999, NULL);
+ Status = pNtApphelpCacheControl(999, NULL);
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
- Status = NtApphelpCacheControl(999, &CacheEntry);
+ Status = pNtApphelpCacheControl(999, &CacheEntry);
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
}
@@ -154,7 +155,7 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle)
let's test invalid handle behavior */
CacheEntry.ImageName = ntPath;
CacheEntry.ImageHandle = 0;
- Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
ok_ntstatus(Status, STATUS_NOT_FOUND);
/* re-add it for the next test */
@@ -162,7 +163,7 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle)
Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup);
ok_ntstatus(Status, STATUS_SUCCESS);
CacheEntry.ImageHandle = (HANDLE)1;
- Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
ok_ntstatus(Status, STATUS_NOT_FOUND);
/* and again */
@@ -170,7 +171,7 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle)
Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup);
ok_ntstatus(Status, STATUS_SUCCESS);
CacheEntry.ImageHandle = (HANDLE)0x80000000;
- Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
+ Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
ok_ntstatus(Status, STATUS_NOT_FOUND);
RtlFreeHeap(RtlGetProcessHeap(), 0, ntPath.Buffer);
@@ -343,6 +344,14 @@ START_TEST(NtApphelpCacheControl)
win_skip("RegisterServiceCtrlHandlerExA not available, skipping
tests\n");
return;
}
+
+ pNtApphelpCacheControl =
(void*)GetProcAddress(GetModuleHandleA("ntdll.dll"),
"NtApphelpCacheControl");
+ if (!pNtApphelpCacheControl)
+ {
+ win_skip("NtApphelpCacheControl not available, skipping tests\n");
+ return;
+ }
+
argc = winetest_get_mainargs(&argv);
if(argc < 3)
{
diff --git a/modules/rostests/apitests/ntdll/NtLoadUnloadKey.c
b/modules/rostests/apitests/ntdll/NtLoadUnloadKey.c
index bc4f4b967a..f9bb9c2937 100644
--- a/modules/rostests/apitests/ntdll/NtLoadUnloadKey.c
+++ b/modules/rostests/apitests/ntdll/NtLoadUnloadKey.c
@@ -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);
diff --git a/modules/rostests/apitests/ntdll/RtlCopyMappedMemory.c
b/modules/rostests/apitests/ntdll/RtlCopyMappedMemory.c
index d6c3149096..b7150dfc5c 100644
--- a/modules/rostests/apitests/ntdll/RtlCopyMappedMemory.c
+++ b/modules/rostests/apitests/ntdll/RtlCopyMappedMemory.c
@@ -7,25 +7,35 @@
#include "precomp.h"
+static NTSTATUS (NTAPI *pRtlCopyMappedMemory)(PVOID, const VOID *, SIZE_T);
+
START_TEST(RtlCopyMappedMemory)
{
NTSTATUS Status;
UCHAR Buffer1[32];
UCHAR Buffer2[32];
-
- StartSeh() RtlCopyMappedMemory(NULL, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION);
- StartSeh() RtlCopyMappedMemory(Buffer1, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION);
- StartSeh() RtlCopyMappedMemory(NULL, Buffer1, 1); EndSeh(STATUS_ACCESS_VIOLATION);
-
+
+ pRtlCopyMappedMemory =
(PVOID)GetProcAddress(GetModuleHandleW(L"ntdll.dll"),
+ "RtlCopyMappedMemory");
+ if (!pRtlCopyMappedMemory)
+ {
+ win_skip("RtlCopyMappedMemory (NT >= 5.2 API) not available\n");
+ return;
+ }
+
+ StartSeh() pRtlCopyMappedMemory(NULL, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION);
+ StartSeh() pRtlCopyMappedMemory(Buffer1, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION);
+ StartSeh() pRtlCopyMappedMemory(NULL, Buffer1, 1); EndSeh(STATUS_ACCESS_VIOLATION);
+
StartSeh()
- Status = RtlCopyMappedMemory(NULL, NULL, 0);
+ Status = pRtlCopyMappedMemory(NULL, NULL, 0);
EndSeh(STATUS_SUCCESS);
ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n",
Status);
RtlFillMemory(Buffer1, sizeof(Buffer1), 0x11);
RtlFillMemory(Buffer2, sizeof(Buffer2), 0x22);
StartSeh()
- Status = RtlCopyMappedMemory(Buffer1, Buffer2, sizeof(Buffer1));
+ Status = pRtlCopyMappedMemory(Buffer1, Buffer2, sizeof(Buffer1));
EndSeh(STATUS_SUCCESS);
ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n",
Status);
ok(RtlCompareMemory(Buffer1, Buffer2, sizeof(Buffer1)) == sizeof(Buffer1), "Data
not copied\n");