Sebastian Lackner : kernel32/tests: Add tests for calling VirtualProtect with NULL as last argument.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 4 07:58:53 CDT 2015
Module: wine
Branch: master
Commit: 152b575eed7566cba9575891dad9c07706a3f353
URL: http://source.winehq.org/git/wine.git/?a=commit;h=152b575eed7566cba9575891dad9c07706a3f353
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Sat May 2 18:37:26 2015 +0200
kernel32/tests: Add tests for calling VirtualProtect with NULL as last argument.
---
dlls/kernel32/tests/virtual.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 75e91d5..2dea156 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -47,6 +47,7 @@ static struct _TEB * (WINAPI *pNtCurrentTeb)(void);
static PVOID (WINAPI *pRtlAddVectoredExceptionHandler)(ULONG, PVECTORED_EXCEPTION_HANDLER);
static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID);
static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL);
+static NTSTATUS (WINAPI *pNtProtectVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG *);
/* ############################### */
@@ -2478,6 +2479,9 @@ static void test_VirtualProtect(void)
DWORD ret, old_prot, rw_prot, exec_prot, i, j;
MEMORY_BASIC_INFORMATION info;
SYSTEM_INFO si;
+ void *addr;
+ SIZE_T size;
+ NTSTATUS status;
GetSystemInfo(&si);
trace("system page size %#x\n", si.dwPageSize);
@@ -2486,6 +2490,31 @@ static void test_VirtualProtect(void)
base = VirtualAlloc(0, si.dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
ok(base != NULL, "VirtualAlloc failed %d\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ ret = VirtualProtect(base, si.dwPageSize, PAGE_READONLY, NULL);
+ todo_wine
+ ok(!ret, "VirtualProtect should fail\n");
+ todo_wine
+ ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %d\n", GetLastError());
+ old_prot = 0xdeadbeef;
+ ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
+ ok(ret, "VirtualProtect failed %d\n", GetLastError());
+ todo_wine
+ ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
+
+ addr = base;
+ size = si.dwPageSize;
+ status = pNtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, PAGE_READONLY, NULL);
+ todo_wine
+ ok(status == STATUS_ACCESS_VIOLATION, "NtProtectVirtualMemory should fail, got %08x\n", status);
+ addr = base;
+ size = si.dwPageSize;
+ old_prot = 0xdeadbeef;
+ status = pNtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, PAGE_NOACCESS, &old_prot);
+ ok(status == STATUS_SUCCESS, "NtProtectVirtualMemory should succeed, got %08x\n", status);
+ todo_wine
+ ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
+
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
{
SetLastError(0xdeadbeef);
@@ -3477,6 +3506,7 @@ START_TEST(virtual)
pNtCurrentTeb = (void *)GetProcAddress( hntdll, "NtCurrentTeb" );
pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlAddVectoredExceptionHandler" );
pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlRemoveVectoredExceptionHandler" );
+ pNtProtectVirtualMemory = (void *)GetProcAddress( hntdll, "NtProtectVirtualMemory" );
test_shared_memory(FALSE);
test_shared_memory_ro(FALSE, FILE_MAP_READ|FILE_MAP_WRITE);
More information about the wine-cvs
mailing list