diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 522ff386db4..59901331518 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -52,7 +52,6 @@ WINE_DECLARE_DEBUG_CHANNEL(key); #define WM_NCMOUSELAST (WM_NCMOUSEFIRST+(WM_MOUSELAST-WM_MOUSEFIRST)) #define MAX_PACK_COUNT 4 -#define MAX_SENDMSG_RECURSION 64 #define SYS_TIMER_RATE 55 /* min. timer rate in ms (actually 54.925)*/ @@ -1613,14 +1612,10 @@ static BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL unicode, BOOL same_thread, enum wm_char_mapping mapping ) { - struct user_thread_info *thread_info = get_user_thread_info(); LRESULT result = 0; CWPSTRUCT cwp; CWPRETSTRUCT cwpret; - if (thread_info->recursion_count > MAX_SENDMSG_RECURSION) return 0; - thread_info->recursion_count++; - if (msg & 0x80000000) { result = handle_internal_message( hwnd, msg, wparam, lparam ); @@ -1646,7 +1641,6 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar cwpret.hwnd = hwnd; HOOK_CallHooks( WH_CALLWNDPROCRET, HC_ACTION, same_thread, (LPARAM)&cwpret, unicode ); done: - thread_info->recursion_count--; return result; } diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index 6de86e878b0..ac5ec416903 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -53,6 +53,7 @@ typedef struct tagWINDOWPROC #define WINPROC_HANDLE (~0UL >> 16) #define MAX_WINPROCS 8192 #define BUILTIN_WINPROCS 9 /* first BUILTIN_WINPROCS entries are reserved for builtin procs */ +#define MAX_WINPROC_RECURSION 64 WNDPROC EDIT_winproc_handle = 0; @@ -2177,6 +2178,7 @@ LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) { + struct user_thread_info *thread_info = get_user_thread_info(); WND *wndPtr; WINDOWPROC *proc; @@ -2192,6 +2194,9 @@ BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, if (!proc) return TRUE; + if (thread_info->recursion_count > MAX_WINPROC_RECURSION) return FALSE; + thread_info->recursion_count++; + if (unicode) { if (proc->procW) @@ -2210,6 +2215,7 @@ BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, else WINPROC_CallProc32ATo16( call_window_proc16, hwnd, msg, wParam, lParam, result, proc->proc16 ); } + thread_info->recursion_count--; return TRUE; }