mirror of
https://github.com/reactos/reactos.git
synced 2024-10-03 07:53:49 +00:00
[NTDLL_APITEST] Allow the test to load on Windows XP. ROSTESTS-293
This commit is contained in:
parent
d73a72c21d
commit
6fe9441d32
|
@ -15,6 +15,7 @@ enum ServiceCommands
|
||||||
RegisterShimCacheWithoutHandle = 129,
|
RegisterShimCacheWithoutHandle = 129,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static NTSTATUS (NTAPI *pNtApphelpCacheControl)(APPHELPCACHESERVICECLASS, PAPPHELP_CACHE_SERVICE_LOOKUP);
|
||||||
|
|
||||||
NTSTATUS CallCacheControl(UNICODE_STRING* PathName, BOOLEAN WithMapping, APPHELPCACHESERVICECLASS Service)
|
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;
|
CacheEntry.ImageHandle = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
Status = NtApphelpCacheControl(Service, &CacheEntry);
|
Status = pNtApphelpCacheControl(Service, &CacheEntry);
|
||||||
if (CacheEntry.ImageHandle != INVALID_HANDLE_VALUE)
|
if (CacheEntry.ImageHandle != INVALID_HANDLE_VALUE)
|
||||||
NtClose(CacheEntry.ImageHandle);
|
NtClose(CacheEntry.ImageHandle);
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -64,31 +65,31 @@ void CheckValidation(UNICODE_STRING* PathName)
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Validate the handling of a NULL pointer */
|
/* Validate the handling of a NULL pointer */
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceRemove, NULL);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceRemove, NULL);
|
||||||
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, NULL);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, NULL);
|
||||||
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
||||||
|
|
||||||
/* Validate the handling of a NULL pointer inside the struct */
|
/* Validate the handling of a NULL pointer inside the struct */
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceRemove, &CacheEntry);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceRemove, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
||||||
|
|
||||||
/* Just call the dump function */
|
/* Just call the dump function */
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceDump, NULL);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceDump, NULL);
|
||||||
ok_ntstatus(Status, STATUS_SUCCESS);
|
ok_ntstatus(Status, STATUS_SUCCESS);
|
||||||
|
|
||||||
/* Validate the handling of an invalid handle inside the struct */
|
/* Validate the handling of an invalid handle inside the struct */
|
||||||
CacheEntry.ImageName = *PathName;
|
CacheEntry.ImageName = *PathName;
|
||||||
CacheEntry.ImageHandle = (HANDLE)2;
|
CacheEntry.ImageHandle = (HANDLE)2;
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
||||||
|
|
||||||
/* Validate the handling of an invalid service number */
|
/* Validate the handling of an invalid service number */
|
||||||
Status = NtApphelpCacheControl(999, NULL);
|
Status = pNtApphelpCacheControl(999, NULL);
|
||||||
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
||||||
Status = NtApphelpCacheControl(999, &CacheEntry);
|
Status = pNtApphelpCacheControl(999, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle)
|
||||||
let's test invalid handle behavior */
|
let's test invalid handle behavior */
|
||||||
CacheEntry.ImageName = ntPath;
|
CacheEntry.ImageName = ntPath;
|
||||||
CacheEntry.ImageHandle = 0;
|
CacheEntry.ImageHandle = 0;
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
||||||
|
|
||||||
/* re-add it for the next test */
|
/* re-add it for the next test */
|
||||||
|
@ -162,7 +163,7 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle)
|
||||||
Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup);
|
Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup);
|
||||||
ok_ntstatus(Status, STATUS_SUCCESS);
|
ok_ntstatus(Status, STATUS_SUCCESS);
|
||||||
CacheEntry.ImageHandle = (HANDLE)1;
|
CacheEntry.ImageHandle = (HANDLE)1;
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
||||||
|
|
||||||
/* and again */
|
/* and again */
|
||||||
|
@ -170,7 +171,7 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle)
|
||||||
Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup);
|
Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup);
|
||||||
ok_ntstatus(Status, STATUS_SUCCESS);
|
ok_ntstatus(Status, STATUS_SUCCESS);
|
||||||
CacheEntry.ImageHandle = (HANDLE)0x80000000;
|
CacheEntry.ImageHandle = (HANDLE)0x80000000;
|
||||||
Status = NtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry);
|
||||||
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
ok_ntstatus(Status, STATUS_NOT_FOUND);
|
||||||
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ntPath.Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, ntPath.Buffer);
|
||||||
|
@ -343,6 +344,14 @@ START_TEST(NtApphelpCacheControl)
|
||||||
win_skip("RegisterServiceCtrlHandlerExA not available, skipping tests\n");
|
win_skip("RegisterServiceCtrlHandlerExA not available, skipping tests\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pNtApphelpCacheControl = (void*)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtApphelpCacheControl");
|
||||||
|
if (!pNtApphelpCacheControl)
|
||||||
|
{
|
||||||
|
win_skip("NtApphelpCacheControl not available, skipping tests\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
argc = winetest_get_mainargs(&argv);
|
argc = winetest_get_mainargs(&argv);
|
||||||
if(argc < 3)
|
if(argc < 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static NTSTATUS (NTAPI *pNtUnloadKey2)(POBJECT_ATTRIBUTES, ULONG);
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
RetrieveCurrentModuleNTDirectory(
|
RetrieveCurrentModuleNTDirectory(
|
||||||
|
@ -381,8 +382,12 @@ DisconnectRegistry(
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
RootKey,
|
RootKey,
|
||||||
NULL);
|
NULL);
|
||||||
// return NtUnloadKey(&ObjectAttributes);
|
if (!pNtUnloadKey2)
|
||||||
return NtUnloadKey2(&ObjectAttributes, Flags);
|
{
|
||||||
|
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};
|
BOOLEAN PrivilegeSet[2] = {FALSE, FALSE};
|
||||||
WCHAR PathBuffer[MAX_PATH];
|
WCHAR PathBuffer[MAX_PATH];
|
||||||
|
|
||||||
|
pNtUnloadKey2 = (PVOID)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "NtUnloadKey2");
|
||||||
|
|
||||||
/* Retrieve our current directory */
|
/* Retrieve our current directory */
|
||||||
RetrieveCurrentModuleNTDirectory(&NtTestPath);
|
RetrieveCurrentModuleNTDirectory(&NtTestPath);
|
||||||
|
|
||||||
|
|
|
@ -7,25 +7,35 @@
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
|
static NTSTATUS (NTAPI *pRtlCopyMappedMemory)(PVOID, const VOID *, SIZE_T);
|
||||||
|
|
||||||
START_TEST(RtlCopyMappedMemory)
|
START_TEST(RtlCopyMappedMemory)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
UCHAR Buffer1[32];
|
UCHAR Buffer1[32];
|
||||||
UCHAR Buffer2[32];
|
UCHAR Buffer2[32];
|
||||||
|
|
||||||
StartSeh() RtlCopyMappedMemory(NULL, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION);
|
pRtlCopyMappedMemory = (PVOID)GetProcAddress(GetModuleHandleW(L"ntdll.dll"),
|
||||||
StartSeh() RtlCopyMappedMemory(Buffer1, NULL, 1); EndSeh(STATUS_ACCESS_VIOLATION);
|
"RtlCopyMappedMemory");
|
||||||
StartSeh() RtlCopyMappedMemory(NULL, Buffer1, 1); EndSeh(STATUS_ACCESS_VIOLATION);
|
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()
|
StartSeh()
|
||||||
Status = RtlCopyMappedMemory(NULL, NULL, 0);
|
Status = pRtlCopyMappedMemory(NULL, NULL, 0);
|
||||||
EndSeh(STATUS_SUCCESS);
|
EndSeh(STATUS_SUCCESS);
|
||||||
ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
|
ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
|
||||||
|
|
||||||
RtlFillMemory(Buffer1, sizeof(Buffer1), 0x11);
|
RtlFillMemory(Buffer1, sizeof(Buffer1), 0x11);
|
||||||
RtlFillMemory(Buffer2, sizeof(Buffer2), 0x22);
|
RtlFillMemory(Buffer2, sizeof(Buffer2), 0x22);
|
||||||
StartSeh()
|
StartSeh()
|
||||||
Status = RtlCopyMappedMemory(Buffer1, Buffer2, sizeof(Buffer1));
|
Status = pRtlCopyMappedMemory(Buffer1, Buffer2, sizeof(Buffer1));
|
||||||
EndSeh(STATUS_SUCCESS);
|
EndSeh(STATUS_SUCCESS);
|
||||||
ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
|
ok(Status == STATUS_SUCCESS, "RtlCopyMappedMemory returned %lx\n", Status);
|
||||||
ok(RtlCompareMemory(Buffer1, Buffer2, sizeof(Buffer1)) == sizeof(Buffer1), "Data not copied\n");
|
ok(RtlCompareMemory(Buffer1, Buffer2, sizeof(Buffer1)) == sizeof(Buffer1), "Data not copied\n");
|
||||||
|
|
Loading…
Reference in a new issue