Author: tfaber Date: Sat Sep 28 09:24:47 2013 New Revision: 60405
URL: http://svn.reactos.org/svn/reactos?rev=60405&view=rev Log: [NTDLL_APITEST] - Do not use Zw functions from user mode
Added: trunk/rostests/apitests/ntdll/NtContinue.c - copied, changed from r60399, trunk/rostests/apitests/ntdll/ZwContinue.c trunk/rostests/apitests/ntdll/i386/NtContinue.S - copied unchanged from r60399, trunk/rostests/apitests/ntdll/i386/ZwContinue.S Removed: trunk/rostests/apitests/ntdll/ZwContinue.c trunk/rostests/apitests/ntdll/i386/ZwContinue.S Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/RtlGetLengthWithoutTrailingPathSeperators.c trunk/rostests/apitests/ntdll/testlist.c
Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists.... ============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Sat Sep 28 09:24:47 2013 @@ -2,6 +2,7 @@ list(APPEND SOURCE LdrEnumResources.c NtAllocateVirtualMemory.c + NtContinue.c NtCreateThread.c NtFreeVirtualMemory.c NtMapViewOfSection.c @@ -21,11 +22,10 @@ RtlInitializeBitMap.c SystemInfo.c Timer.c - ZwContinue.c testlist.c)
if(ARCH STREQUAL "i386") - add_asm_files(ntdll_apitest_asm i386/ZwContinue.S) + add_asm_files(ntdll_apitest_asm i386/NtContinue.S) endif()
add_executable(ntdll_apitest ${SOURCE} ${ntdll_apitest_asm})
Copied: trunk/rostests/apitests/ntdll/NtContinue.c (from r60399, trunk/rostests/apitests/ntdll/ZwContinue.c) URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtContinue.... ============================================================================== --- trunk/rostests/apitests/ntdll/ZwContinue.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/NtContinue.c [iso-8859-1] Sat Sep 28 09:24:47 2013 @@ -1,22 +1,22 @@ /* * PROJECT: ReactOS api tests * LICENSE: GPL - See COPYING in the top level directory - * PURPOSE: Test for ZwContinue - * PROGRAMMER: + * PURPOSE: Test for NtContinue + * PROGRAMMER: */
#include <apitest.h> +#include <ndk/kefuncs.h>
#include <setjmp.h> #include <time.h>
#ifdef _M_IX86 -#define ZWC_SEGMENT_BITS (0xFFFF) -#define ZWC_EFLAGS_BITS (0x3C0CD5) +#define NTC_SEGMENT_BITS (0xFFFF) +#define NTC_EFLAGS_BITS (0x3C0CD5) #endif
void continuePoint(void); -LONG NTAPI ZwContinue(IN CONTEXT *, IN BOOLEAN);
static jmp_buf jmpbuf; static CONTEXT continueContext; @@ -66,24 +66,24 @@ "ContextFlags=0x%lx\n", pContext->ContextFlags);
/* Random data segments */ - ok((pContext->SegGs & ZWC_SEGMENT_BITS) == - (continueContext.SegGs & ZWC_SEGMENT_BITS), + ok((pContext->SegGs & NTC_SEGMENT_BITS) == + (continueContext.SegGs & NTC_SEGMENT_BITS), "SegGs=0x%lx / 0x%lx\n", pContext->SegGs, continueContext.SegGs);
- ok((pContext->SegFs & ZWC_SEGMENT_BITS) == - (continueContext.SegFs & ZWC_SEGMENT_BITS), + ok((pContext->SegFs & NTC_SEGMENT_BITS) == + (continueContext.SegFs & NTC_SEGMENT_BITS), "SegFs=0x%lx / 0x%lx\n", pContext->SegFs, continueContext.SegFs);
- ok((pContext->SegEs & ZWC_SEGMENT_BITS) == - (continueContext.SegEs & ZWC_SEGMENT_BITS), + ok((pContext->SegEs & NTC_SEGMENT_BITS) == + (continueContext.SegEs & NTC_SEGMENT_BITS), "SegEs=0x%lx / 0x%lx\n", pContext->SegEs, continueContext.SegEs);
- ok((pContext->SegDs & ZWC_SEGMENT_BITS) == - (continueContext.SegDs & ZWC_SEGMENT_BITS), + ok((pContext->SegDs & NTC_SEGMENT_BITS) == + (continueContext.SegDs & NTC_SEGMENT_BITS), "SegDs=0x%lx / 0x%lx\n", pContext->SegDs, continueContext.SegDs);
/* Integer registers */ - ok(pContext->Edi == continueContext.Edi, + ok(pContext->Edi == continueContext.Edi, "Edi: 0x%lx != 0x%lx\n", pContext->Edi, continueContext.Edi); ok(pContext->Esi == continueContext.Esi, "Esi: 0x%lx != 0x%lx\n", pContext->Esi, continueContext.Esi); @@ -104,16 +104,16 @@ ok(pContext->Esp == continueContext.Esp, "Esp: 0x%lx != 0x%lx\n", pContext->Esp, continueContext.Esp);
- ok((pContext->SegCs & ZWC_SEGMENT_BITS) == - (continueContext.SegCs & ZWC_SEGMENT_BITS), + ok((pContext->SegCs & NTC_SEGMENT_BITS) == + (continueContext.SegCs & NTC_SEGMENT_BITS), "SegCs: 0x%lx != 0x%lx\n", pContext->SegCs, continueContext.SegCs);
- ok((pContext->EFlags & ZWC_EFLAGS_BITS) == - (continueContext.EFlags & ZWC_EFLAGS_BITS), + ok((pContext->EFlags & NTC_EFLAGS_BITS) == + (continueContext.EFlags & NTC_EFLAGS_BITS), "EFlags: 0x%lx != 0x%lx\n", pContext->EFlags, continueContext.EFlags);
- ok((pContext->SegSs & ZWC_SEGMENT_BITS) == - (continueContext.SegSs & ZWC_SEGMENT_BITS), + ok((pContext->SegSs & NTC_SEGMENT_BITS) == + (continueContext.SegSs & NTC_SEGMENT_BITS), "SegSs: 0x%lx != 0x%lx\n", pContext->SegSs, continueContext.SegSs); #endif
@@ -121,7 +121,7 @@ longjmp(jmpbuf, 1); }
-void Test_ZwContinue() +START_TEST(NtContinue) { initrand();
@@ -158,16 +158,10 @@ /* Can't do a lot about segments */ #endif
- ZwContinue(&continueContext, FALSE); + NtContinue(&continueContext, FALSE); ok(0, "should never get here\n"); }
/* Second time */ return; } - -START_TEST(ZwContinue) -{ - Test_ZwContinue(); -} -
Modified: trunk/rostests/apitests/ntdll/RtlGetLengthWithoutTrailingPathSeperators.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetLengt... ============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetLengthWithoutTrailingPathSeperators.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlGetLengthWithoutTrailingPathSeperators.c [iso-8859-1] Sat Sep 28 09:24:47 2013 @@ -104,19 +104,19 @@ &str, pentry->input);
len = 0xDEADBEEF; - + StartSeh() res = RtlGetLengthWithoutTrailingPathSeperators(0, &str, &len); EndSeh(STATUS_SUCCESS); - - ok(res == pentry->expected_result, + + ok(res == pentry->expected_result, "Unexpected result 0x%08x (expected 0x%08x) in [%d:%d]\n", res, pentry->expected_result, i, pentry->line); ok(len == pentry->expected_output, - "Unexpected length %d (expected %d) in [%d:%d]\n", + "Unexpected length %d (expected %d) in [%d:%d]\n", len, pentry->expected_output, - i, pentry->line); + i, pentry->line); }
// Invalid parameters @@ -127,10 +127,10 @@ res = RtlGetLengthWithoutTrailingPathSeperators(0, NULL, &len); EndSeh(STATUS_SUCCESS);
- ok(res == STATUS_INVALID_PARAMETER, + ok(res == STATUS_INVALID_PARAMETER, "Unexpected result 0x%08x (expected STATUS_INVALID_PARAMETER)\n", res); - ok(len == 0, + ok(len == 0, "Unexpected length %08x (expected 0)\n", len);
@@ -138,7 +138,7 @@ res = RtlGetLengthWithoutTrailingPathSeperators(0, &str, NULL); EndSeh(STATUS_SUCCESS);
- ok(res == STATUS_INVALID_PARAMETER, + ok(res == STATUS_INVALID_PARAMETER, "Unexpected result 0x%08x (expected STATUS_INVALID_PARAMETER)\n", res);
@@ -146,7 +146,7 @@ res = RtlGetLengthWithoutTrailingPathSeperators(0, NULL, NULL); EndSeh(STATUS_SUCCESS);
- ok(res == STATUS_INVALID_PARAMETER, + ok(res == STATUS_INVALID_PARAMETER, "Unexpected result 0x%08x (expected STATUS_INVALID_PARAMETER)\n", res);
@@ -158,11 +158,11 @@ res = RtlGetLengthWithoutTrailingPathSeperators(1<<i, &str, &len); EndSeh(STATUS_SUCCESS);
- ok(res == STATUS_INVALID_PARAMETER, + ok(res == STATUS_INVALID_PARAMETER, "Unexpected result 0x%08x (expected STATUS_INVALID_PARAMETER)\n", res);
- ok(len == 0, + ok(len == 0, "Unexpected length %08x (expected 0)\n", len); } @@ -173,11 +173,11 @@ res = RtlGetLengthWithoutTrailingPathSeperators(0xFFFFFFFF, &str, &len); EndSeh(STATUS_SUCCESS);
- ok(res == STATUS_INVALID_PARAMETER, + ok(res == STATUS_INVALID_PARAMETER, "Unexpected result 0x%08x (expected STATUS_INVALID_PARAMETER)\n", res); - - ok(len == 0, + + ok(len == 0, "Unexpected length %08x (expected 0)\n", len); }
Removed: trunk/rostests/apitests/ntdll/ZwContinue.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/ZwContinue.... ============================================================================== --- trunk/rostests/apitests/ntdll/ZwContinue.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/ZwContinue.c (removed) @@ -1,173 +0,0 @@ -/* - * PROJECT: ReactOS api tests - * LICENSE: GPL - See COPYING in the top level directory - * PURPOSE: Test for ZwContinue - * PROGRAMMER: - */ - -#include <apitest.h> - -#include <setjmp.h> -#include <time.h> - -#ifdef _M_IX86 -#define ZWC_SEGMENT_BITS (0xFFFF) -#define ZWC_EFLAGS_BITS (0x3C0CD5) -#endif - -void continuePoint(void); -LONG NTAPI ZwContinue(IN CONTEXT *, IN BOOLEAN); - -static jmp_buf jmpbuf; -static CONTEXT continueContext; -static unsigned int nRandBytes; - -static int initrand(void) -{ - unsigned int nRandMax; - unsigned int nRandMaxBits; - time_t tLoc; - - nRandMax = RAND_MAX; - for(nRandMaxBits = 0; nRandMax != 0; nRandMax >>= 1, ++ nRandMaxBits); - nRandBytes = nRandMaxBits / CHAR_BIT; - //assert(nRandBytes != 0); - srand((unsigned)(time(&tLoc) & UINT_MAX)); - return 1; -} - -static void randbytes(void * p, size_t n) -{ - unsigned char * b; - size_t i; - int r = rand(); - - b = (unsigned char *)p; - for(i = 0; i < n; ++ i) - { - if(i % nRandBytes == 0) - r = rand(); - b[i] = (unsigned char)(r & UCHAR_MAX); - r >>= CHAR_BIT; - } -} - -static ULONG randULONG(void) -{ - ULONG n; - randbytes(&n, sizeof(n)); - return n; -} - -void check(CONTEXT * pContext) -{ -#ifdef _M_IX86 - ok(pContext->ContextFlags == CONTEXT_FULL, - "ContextFlags=0x%lx\n", pContext->ContextFlags); - - /* Random data segments */ - ok((pContext->SegGs & ZWC_SEGMENT_BITS) == - (continueContext.SegGs & ZWC_SEGMENT_BITS), - "SegGs=0x%lx / 0x%lx\n", pContext->SegGs, continueContext.SegGs); - - ok((pContext->SegFs & ZWC_SEGMENT_BITS) == - (continueContext.SegFs & ZWC_SEGMENT_BITS), - "SegFs=0x%lx / 0x%lx\n", pContext->SegFs, continueContext.SegFs); - - ok((pContext->SegEs & ZWC_SEGMENT_BITS) == - (continueContext.SegEs & ZWC_SEGMENT_BITS), - "SegEs=0x%lx / 0x%lx\n", pContext->SegEs, continueContext.SegEs); - - ok((pContext->SegDs & ZWC_SEGMENT_BITS) == - (continueContext.SegDs & ZWC_SEGMENT_BITS), - "SegDs=0x%lx / 0x%lx\n", pContext->SegDs, continueContext.SegDs); - - /* Integer registers */ - ok(pContext->Edi == continueContext.Edi, - "Edi: 0x%lx != 0x%lx\n", pContext->Edi, continueContext.Edi); - ok(pContext->Esi == continueContext.Esi, - "Esi: 0x%lx != 0x%lx\n", pContext->Esi, continueContext.Esi); - ok(pContext->Ebx == continueContext.Ebx, - "Ebx: 0x%lx != 0x%lx\n", pContext->Ebx, continueContext.Ebx); - ok(pContext->Edx == continueContext.Edx, - "Edx: 0x%lx != 0x%lx\n", pContext->Edx, continueContext.Edx); - ok(pContext->Ecx == continueContext.Ecx, - "Ecx: 0x%lx != 0x%lx\n", pContext->Ecx, continueContext.Ecx); - ok(pContext->Eax == continueContext.Eax, - "Eax: 0x%lx != 0x%lx\n", pContext->Eax, continueContext.Eax); - - /* Control registers and segments */ - ok(pContext->Ebp == continueContext.Ebp, - "Ebp: 0x%lx != 0x%lx\n", pContext->Ebp, continueContext.Ebp); - ok(pContext->Eip == continueContext.Eip, - "Eip: 0x%lx != 0x%lx\n", pContext->Eip, continueContext.Eip); - ok(pContext->Esp == continueContext.Esp, - "Esp: 0x%lx != 0x%lx\n", pContext->Esp, continueContext.Esp); - - ok((pContext->SegCs & ZWC_SEGMENT_BITS) == - (continueContext.SegCs & ZWC_SEGMENT_BITS), - "SegCs: 0x%lx != 0x%lx\n", pContext->SegCs, continueContext.SegCs); - - ok((pContext->EFlags & ZWC_EFLAGS_BITS) == - (continueContext.EFlags & ZWC_EFLAGS_BITS), - "EFlags: 0x%lx != 0x%lx\n", pContext->EFlags, continueContext.EFlags); - - ok((pContext->SegSs & ZWC_SEGMENT_BITS) == - (continueContext.SegSs & ZWC_SEGMENT_BITS), - "SegSs: 0x%lx != 0x%lx\n", pContext->SegSs, continueContext.SegSs); -#endif - - /* Return where we came from */ - longjmp(jmpbuf, 1); -} - -void Test_ZwContinue() -{ - initrand(); - - /* First time */ - if(setjmp(jmpbuf) == 0) - { - CONTEXT bogus; - - continueContext.ContextFlags = CONTEXT_FULL; - GetThreadContext(GetCurrentThread(), &continueContext); - -#ifdef _M_IX86 - continueContext.ContextFlags = CONTEXT_FULL; - - /* Fill the integer registers with random values */ - continueContext.Edi = randULONG(); - continueContext.Esi = randULONG(); - continueContext.Ebx = randULONG(); - continueContext.Edx = randULONG(); - continueContext.Ecx = randULONG(); - continueContext.Eax = randULONG(); - continueContext.Ebp = randULONG(); - - /* Randomize all the allowed flags (determined experimentally with WinDbg) */ - continueContext.EFlags = randULONG() & 0x3C0CD5; - - /* Randomize the stack pointer as much as possible */ - continueContext.Esp = (ULONG)(((ULONG_PTR)&bogus) & 0xFFFFFFFF) + - sizeof(bogus) - (randULONG() & 0xF) * 4; - - /* continuePoint() is implemented in assembler */ - continueContext.Eip = (ULONG)((ULONG_PTR)continuePoint & 0xFFFFFFF); - - /* Can't do a lot about segments */ -#endif - - ZwContinue(&continueContext, FALSE); - ok(0, "should never get here\n"); - } - - /* Second time */ - return; -} - -START_TEST(ZwContinue) -{ - Test_ZwContinue(); -} -
Removed: trunk/rostests/apitests/ntdll/i386/ZwContinue.S URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/i386/ZwCont... ============================================================================== --- trunk/rostests/apitests/ntdll/i386/ZwContinue.S [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/i386/ZwContinue.S (removed) @@ -1,54 +0,0 @@ - -#include <asm.inc> -#include <ks386.inc> - - -// cpu 486 -.code - -EXTERN _check:PROC - -PUBLIC _continuePoint -_continuePoint: - push ss - push 0 - pushfd - push cs - push offset _continuePoint - push ebp - - push eax - push ecx - push edx - push ebx - push esi - push edi - - push ds - push es - push fs - push gs - - // TODO: floating point state - sub esp, 112 - - // Debug registers - sub esp, 24 - - push HEX(00010007) - - // Fill the Esp field - lea eax, [esp + HEX(0CC)] - lea ecx, [esp + HEX(0C4)] - mov [ecx], eax - - // Call the function that will compare the current context with the expected one - cld - push esp - call _check - - // check() must not return - int 3 - -// EOF -END
Modified: trunk/rostests/apitests/ntdll/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c?... ============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Sat Sep 28 09:24:47 2013 @@ -5,6 +5,7 @@
extern void func_LdrEnumResources(void); extern void func_NtAllocateVirtualMemory(void); +extern void func_NtContinue(void); extern void func_NtCreateThread(void); extern void func_NtFreeVirtualMemory(void); extern void func_NtMapViewOfSection(void); @@ -24,12 +25,12 @@ extern void func_RtlGetLongestNtPathLength(void); extern void func_RtlInitializeBitMap(void); extern void func_TimerResolution(void); -extern void func_ZwContinue(void);
const struct test winetest_testlist[] = { { "LdrEnumResources", func_LdrEnumResources }, { "NtAllocateVirtualMemory", func_NtAllocateVirtualMemory }, + { "NtContinue", func_NtContinue }, { "NtCreateThread", func_NtCreateThread }, { "NtFreeVirtualMemory", func_NtFreeVirtualMemory }, { "NtMapViewOfSection", func_NtMapViewOfSection }, @@ -49,7 +50,6 @@ { "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength }, { "RtlInitializeBitMap", func_RtlInitializeBitMap }, { "TimerResolution", func_TimerResolution }, - { "ZwContinue", func_ZwContinue },
{ 0, 0 } };