user32: Avoid compiler specific code in the DefWindowProc test

Dmitry Timoshkov dmitry at codeweavers.com
Mon Mar 19 10:56:49 CDT 2007


"Mikolaj Zalewski" <mikolaj at zalewski.pl> wrote:

> > The test doesn't pass here under XP:
> 
>  I've also tested it under (a fully patched) XP. However it might be a 
> differance in compilers - in your output the pointers to 
> DefWindowProc[AW] looks like pointing to the EXE image. What compiler 
> did you use? I've used Visual C++ 7.1 and get pointer pointing to 
> user32

Thanks for the hint. Indeed that's a compiler specific thing, in my case
VC 6.0 apparently creates import thunks in the PE import section of a PE
module itself.

The following patch fixes the failure for me.

Changelog:
    user32: Avoid compiler specific code in the DefWindowProc test.

--- a/dlls/user32/tests/class.c
+++ b/dlls/user32/tests/class.c
@@ -558,10 +558,14 @@ static void test_instances(void)
 
 static void test_defwndproc()
 {
-    char classA[] = "deftest";
-    WCHAR classW[] = {'d','e','f','t','e','s','t',0};
+    static const char classA[] = "deftest";
+    static const WCHAR classW[] = {'d','e','f','t','e','s','t',0};
+    WNDPROC pDefWindowProcA, pDefWindowProcW;
     int i;
 
+    pDefWindowProcA = (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcA");
+    pDefWindowProcW = (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcW");
+
     for (i = 0; i < 4; i++)
     {
         WNDCLASSEXA cls;  /* the memory layout of WNDCLASSEXA and WNDCLASSEXW is the same */
@@ -572,9 +576,9 @@ static void test_defwndproc()
         cls.hInstance = GetModuleHandle(NULL);
         cls.hbrBackground = GetStockObject (WHITE_BRUSH);
         if (i & 1)
-            cls.lpfnWndProc = DefWindowProcA;
+            cls.lpfnWndProc = pDefWindowProcA;
         else
-            cls.lpfnWndProc = DefWindowProcW;
+            cls.lpfnWndProc = pDefWindowProcW;
 
         if (i & 2)
         {
@@ -583,7 +587,7 @@ static void test_defwndproc()
         }
         else
         {
-            cls.lpszClassName = (LPSTR)classW;
+            cls.lpszClassName = (LPCSTR)classW;
             atom = RegisterClassExW((WNDCLASSEXW *)&cls);
         }
         ok(atom != 0, "Couldn't register class, i=%d, %d\n", i, GetLastError());
@@ -592,32 +596,32 @@ static void test_defwndproc()
         ok(hwnd != NULL, "Couldn't create window i=%d\n", i);
         if ((i & 1) && (i & 2))
         {
-            ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
-                (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), DefWindowProcA);
-            ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
-                (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), DefWindowProcA);
+            ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
+                (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), pDefWindowProcA);
+            ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
+                (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), pDefWindowProcA);
         }
         else
         todo_wine {
-            ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
-                (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), DefWindowProcA);
-            ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
-                (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), DefWindowProcA);
+            ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
+                (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), pDefWindowProcA);
+            ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
+                (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), pDefWindowProcA);
         }
 
         if (!(i & 1) && !(i & 2))
         {
-            ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
-                (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), DefWindowProcW);
-            ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
-                (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), DefWindowProcW);
+            ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
+                (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), pDefWindowProcW);
+            ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
+                (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), pDefWindowProcW);
         }
         else
         todo_wine {
-            ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
-                (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), DefWindowProcW);
-            ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
-                (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), DefWindowProcW);
+            ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
+                (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), pDefWindowProcW);
+            ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
+                (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), pDefWindowProcW);
         }
 
         DestroyWindow(hwnd);





More information about the wine-patches mailing list