ReactOS 0.4.15-dev-7991-ge77da17
WndProc.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for mismatch with function prototype in window procedure callback.
5 * PROGRAMMERS:
6 */
7
8#include "precomp.h"
9
10/* Used wine Redraw test for proof in principle. */
11
12#define WMPAINT_COUNT_THRESHOLD 10
13
14/* Global variables to trigger exit from loop */
16
17/*
18 * Force stack corruption when calling from assumed window procedure callback.
19 * Adding (6 and) more will force exception faults and terminate the test program.
20 * The test is with five and this is safe for windows.
21 *
22 * But,,,, ReactOS compiled with GCC can handle this,,,,,,
23 */
25 HWND hwnd,
26 UINT msg,
29{
30 switch (msg)
31 {
32 case WM_PAINT:
33 break;
35 trace("Doing WM_PAINT %d/%d\n", WMPAINT_count, WMPAINT_COUNT_THRESHOLD);
36
38 {
39 PAINTSTRUCT ps;
40
41 trace("Calling *Paint()\n");
42 BeginPaint(hwnd, &ps);
43 EndPaint(hwnd, &ps);
44 return 1;
45 }
46
47 // This will force one stack corruption "ret" fault with normal window
48 // procedure callback.
49#ifdef __MINGW32__
50 trace("Executing __MINGW32__ stack corruption code\n");
51 asm ("movl $0, %eax\n\t"
52 "leave\n\t"
53 "ret");
54#elif defined(_M_IX86)
55//#ifdef _MSC_VER
56 trace("Executing MSVC x86 stack corruption code\n");
57 __asm
58 {
59 mov eax, 0
60 leave
61 ret
62 }
63#else
64 ok(FALSE, "FIXME: stack corruption code is unimplemented\n");
65#endif
66
67 break;
68 default:
69 trace("Doing empty default: msg = %u\n", msg);
70 }
71
72 trace("Calling DefWindowProc()\n");
74}
75
76static void test_wndproc(void)
77{
78 WNDCLASSA cls;
79 ATOM clsAtom;
81
82 cls.style = CS_DBLCLKS;
84 cls.cbClsExtra = 0;
85 cls.cbWndExtra = 0;
87 cls.hIcon = NULL;
90 cls.lpszMenuName = NULL;
91 cls.lpszClassName = "RedrawWindowClass";
92
93 clsAtom = RegisterClassA(&cls);
94 ok(clsAtom != 0, "RegisterClassA() failed: LastError = %lu\n", GetLastError());
95
96 if (clsAtom == 0)
97 {
98 skip("No Class atom\n");
99 return;
100 }
101
103 CW_USEDEFAULT, 0, 100, 100, NULL, NULL, NULL, NULL);
104
105 ok(hwndMain != NULL, "CreateWindowA() failed: LastError = %lu\n", GetLastError());
106
107 ok(WMPAINT_count == 0,
108 "Multiple unexpected WM_PAINT calls = %d\n", WMPAINT_count);
109
110 if (hwndMain == NULL)
111 {
112 skip("No Window\n");
114 "UnregisterClassA() failed: LastError = %lu\n", GetLastError());
115 return;
116 }
117
119 ok(WMPAINT_count == 0,
120 "Multiple unexpected WM_PAINT calls = %d\n", WMPAINT_count);
121
123 ok(WMPAINT_count == 1 || broken(WMPAINT_count == 0), /* sometimes on win9x */
124 "Multiple unexpected WM_PAINT calls = %d\n", WMPAINT_count);
125
128 "RedrawWindow (RDW_UPDATENOW) never completed (%d/%d)\n",
130
132 "DestroyWindow() failed: LastError = %lu\n", GetLastError());
133
135 "UnregisterClassA() failed: LastError = %lu\n", GetLastError());
136}
137
138static void test_get_wndproc(void)
139{
141 SetLastError(0xfeedf00d);
143 ok (ret == 0, "Should return NULL\n");
144 ok (GetLastError() == ERROR_ACCESS_DENIED, "Wrong return error!\n");
145 SetLastError(0xfeedf00d);
147 ok (ret == 0, "Should return NULL\n");
148 ok (GetLastError() == ERROR_ACCESS_DENIED, "Wrong return error!\n");
149 SetLastError(0xfeedf00d);
151 ok (ret == 0, "Should return NULL\n");
152 ok (GetLastError() == ERROR_ACCESS_DENIED, "Wrong return error!\n");
153 SetLastError(0xfeedf00d);
155 ok (ret == 0, "Should return NULL\n");
156 ok (GetLastError() == ERROR_ACCESS_DENIED, "Wrong return error!\n");
157}
158
160{
161#ifdef __RUNTIME_CHECKS__
162 skip("This test breaks MSVC runtime checks!\n");
163 return;
164#endif /* __RUNTIME_CHECKS__ */
165
167 test_wndproc();
168}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
static int WMPAINT_count
Definition: WndProc.c:15
static void test_wndproc(void)
Definition: WndProc.c:76
static int redrawComplete
Definition: WndProc.c:15
static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: WndProc.c:24
#define WMPAINT_COUNT_THRESHOLD
Definition: WndProc.c:12
static void test_get_wndproc(void)
Definition: WndProc.c:138
#define broken(x)
Definition: _sntprintf.h:21
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
#define leave
Definition: btrfs_drv.h:138
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define DefWindowProc
Definition: ros2win.h:31
HWND hwndMain
Definition: solitaire.cpp:13
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:614
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
#define GWLP_WNDPROC
Definition: treelist.c:66
int ret
HWND WINAPI GetShellWindow(VOID)
Definition: desktop.c:651
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define WM_PAINT
Definition: winuser.h:1620
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define GetWindowLongPtrW
Definition: winuser.h:4829
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define IDC_ARROW
Definition: winuser.h:687
#define RDW_UPDATENOW
Definition: winuser.h:1220
#define GetWindowLongPtrA
Definition: winuser.h:4828
#define CS_DBLCLKS
Definition: winuser.h:651
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define RDW_ALLCHILDREN
Definition: winuser.h:1221
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:775
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI DestroyWindow(_In_ HWND)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2121