kernel32/tests: Load tests on Win9x again (VirtualAllocEx+VirtualFreeEx)

Detlef Riekenberg wine.dev at web.de
Sun Nov 19 09:05:47 CST 2006


On Mi, 2006-11-08 at 14:12 -0600, Alexandre Julliard wrote:

> Author: Dmitry Timoshkov <dmitry at codeweavers.com>
> Date:   Wed Nov  8 23:45:33 2006 +0800
> 
> kernel32: Add basic OpenProcess test.


Changelog:
kernel32/tests: Load tests on Win9x again (VirtualAllocEx+VirtualFreeEx)


-- 
 
By by ... Detlef

-------------- next part --------------
>From 7b63bf71bc9c48e1b7a04fac738b0545bf918e6c Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev at web.de>
Date: Sun, 19 Nov 2006 15:53:48 +0100
Subject: [PATCH] kernel32/tests: Load tests on Win9x again (VirtualAllocEx+VirtualFreeEx)
---
 dlls/kernel32/tests/process.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 89657cc..d40ea26 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -31,6 +31,10 @@ #include "winuser.h"
 #include "wincon.h"
 #include "winnls.h"
 
+static HINSTANCE hkernel32;
+static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
+static LPVOID (WINAPI *pVirtualFreeEx)(HANDLE, LPVOID, SIZE_T, DWORD);
+
 static char     base[MAX_PATH];
 static char     selfname[MAX_PATH];
 static char     resfile[MAX_PATH];
@@ -147,12 +151,17 @@ #endif
  * generates basic information like:
  *      base:           absolute path to curr dir
  *      selfname:       the way to reinvoke ourselves
+ * function-pointers, which are not implemented in all windows versions
  */
 static int     init(void)
 {
     myARGC = winetest_get_mainargs( &myARGV );
     if (!GetCurrentDirectoryA(sizeof(base), base)) return 0;
     strcpy(selfname, myARGV[0]);
+
+    hkernel32 = GetModuleHandleA("kernel32");
+    pVirtualAllocEx = (void *) GetProcAddress(hkernel32, "VirtualAllocEx");
+    pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
     return 1;
 }
 
@@ -1273,12 +1282,15 @@ static void test_OpenProcess(void)
     MEMORY_BASIC_INFORMATION info;
     SIZE_T dummy, read_bytes;
 
+    /* Not implemented in all windows versions */
+    if ((!pVirtualAllocEx) || (!pVirtualFreeEx)) return;
+
     /* without PROCESS_VM_OPERATION */
     hproc = OpenProcess(PROCESS_ALL_ACCESS & ~PROCESS_VM_OPERATION, FALSE, GetCurrentProcessId());
     ok(hproc != NULL, "OpenProcess error %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
-    addr1 = VirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
+    addr1 = pVirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
 todo_wine {
     ok(!addr1, "VirtualAllocEx should fail\n");
     ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
@@ -1295,12 +1307,12 @@ todo_wine {
     hproc = OpenProcess(PROCESS_VM_OPERATION, FALSE, GetCurrentProcessId());
     ok(hproc != NULL, "OpenProcess error %d\n", GetLastError());
 
-    addr1 = VirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
+    addr1 = pVirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
 todo_wine {
     ok(addr1 != NULL, "VirtualAllocEx error %d\n", GetLastError());
 }
     if (addr1 == NULL) /* FIXME: remove once Wine is fixed */
-        addr1 = VirtualAllocEx(GetCurrentProcess(), 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
+        addr1 = pVirtualAllocEx(GetCurrentProcess(), 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
 
     /* without PROCESS_QUERY_INFORMATION */
     SetLastError(0xdeadbeef);
@@ -1337,7 +1349,7 @@ todo_wine {
 
     SetLastError(0xdeadbeef);
 todo_wine {
-    ok(!VirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
+    ok(!pVirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
        "VirtualFreeEx without PROCESS_VM_OPERATION rights should fail\n");
     ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
 }
-- 
1.4.1



More information about the wine-patches mailing list