From 4c40190620110abe882501f893deda6d98a4026f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 9 May 2006 18:40:46 +0200 Subject: [PATCH] user: Separate the 16 and 32-bit versions of WINPROC_GetProc. --- dlls/user/class.c | 33 ++++++++++++++++------- dlls/user/win.c | 4 +-- dlls/user/winproc.c | 64 ++++++++++++++++++++------------------------- dlls/user/winproc.h | 3 ++- dlls/user/wnd16.c | 2 +- 5 files changed, 58 insertions(+), 48 deletions(-) diff --git a/dlls/user/class.c b/dlls/user/class.c index 0e9d4ffac4..c851066926 100644 --- a/dlls/user/class.c +++ b/dlls/user/class.c @@ -149,7 +149,20 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG newval ) * * Get the class winproc for a given proc type */ -static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type ) +static WNDPROC16 CLASS_GetProc16( CLASS *classPtr ) +{ + WNDPROC proc = classPtr->winprocA; + if (!proc) proc = classPtr->winprocW; + return WINPROC_GetProc16( proc ); +} + + +/*********************************************************************** + * CLASS_GetProc + * + * Get the class winproc for a given proc type + */ +static WNDPROC CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type ) { WNDPROC proc = classPtr->winprocA; @@ -170,10 +183,9 @@ static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type ) * Set the class winproc for a given proc type. * Returns the previous window proc. */ -static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type ) +static void CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type ) { WNDPROC *proc = &classPtr->winprocA; - WNDPROC16 ret; if (classPtr->winprocW) { @@ -182,7 +194,6 @@ static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE */ if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW; } - ret = WINPROC_GetProc( *proc, type ); *proc = WINPROC_AllocProc( newproc, type ); /* now clear the one that we didn't set */ if (classPtr->winprocA && classPtr->winprocW) @@ -192,7 +203,6 @@ static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE else classPtr->winprocA = 0; } - return ret; } @@ -730,7 +740,7 @@ LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset ) case GCLP_WNDPROC: if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; if (class == CLASS_OTHER_PROCESS) break; - ret = (LONG)CLASS_GetProc( class, WIN_PROC_16 ); + ret = (LONG)CLASS_GetProc16( class ); release_class_ptr( class ); return ret; case GCLP_MENUNAME: @@ -942,7 +952,8 @@ LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval ) { case GCLP_WNDPROC: if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; - retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 ); + retval = (LONG)CLASS_GetProc16( class ); + CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 ); release_class_ptr( class ); return retval; case GCLP_MENUNAME: @@ -982,7 +993,8 @@ DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval ) retval = 0; /* Old value is now meaningless anyway */ break; case GCLP_WNDPROC: - retval = (DWORD)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W ); + retval = (DWORD)CLASS_GetProc( class, WIN_PROC_32W ); + CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W ); break; case GCLP_HBRBACKGROUND: retval = (DWORD)class->hbrBackground; @@ -1048,7 +1060,10 @@ DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval ) if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; if (offset == GCLP_WNDPROC) - retval = (DWORD)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A ); + { + retval = (DWORD)CLASS_GetProc( class, WIN_PROC_32A ); + CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A ); + } else /* GCL_MENUNAME */ { CLASS_SetMenuNameA( class, (LPCSTR)newval ); diff --git a/dlls/user/win.c b/dlls/user/win.c index 2cacdb883a..df0ffd8a59 100644 --- a/dlls/user/win.c +++ b/dlls/user/win.c @@ -2165,7 +2165,7 @@ LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset ) } } retvalue = GetWindowLongA( WIN_Handle32(hwnd), offset ); - if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc( (WNDPROC)retvalue, WIN_PROC_16 ); + if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue ); return retvalue; } @@ -2215,7 +2215,7 @@ LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval ) { WNDPROC new_proc = WINPROC_AllocProc( (WNDPROC)newval, WIN_PROC_16 ); WNDPROC old_proc = (WNDPROC)SetWindowLongA( WIN_Handle32(hwnd), offset, (LONG_PTR)new_proc ); - return (LONG)WINPROC_GetProc( (WNDPROC)old_proc, WIN_PROC_16 ); + return (LONG)WINPROC_GetProc16( (WNDPROC)old_proc ); } else return SetWindowLongA( WIN_Handle32(hwnd), offset, newval ); } diff --git a/dlls/user/winproc.c b/dlls/user/winproc.c index 51f0ab815b..571a23f975 100644 --- a/dlls/user/winproc.c +++ b/dlls/user/winproc.c @@ -528,35 +528,44 @@ static WINDOWPROC *WINPROC_GetPtr( WNDPROC handle ) } +/********************************************************************** + * WINPROC_GetProc16 + * + * Get a window procedure pointer that can be passed to the Windows program. + */ +WNDPROC16 WINPROC_GetProc16( WNDPROC proc ) +{ + WINDOWPROC *ptr = (WINDOWPROC *)proc; + + if (!proc) return 0; + + if (ptr->type == WIN_PROC_16) + return ptr->thunk.t_from32.proc; + else + return (WNDPROC16)MAKESEGPTR( get_winproc_selector(), + (char *)&ptr->thunk - (char *)winproc_array ); +} + + /********************************************************************** * WINPROC_GetProc * * Get a window procedure pointer that can be passed to the Windows program. */ -WNDPROC16 WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type ) +WNDPROC WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type ) { WINDOWPROC *ptr = (WINDOWPROC *)proc; if (!proc) return NULL; - if (type == WIN_PROC_16) /* We want a 16:16 address */ - { - if (ptr->type == WIN_PROC_16) - return ptr->thunk.t_from32.proc; - else - return (WNDPROC16)MAKESEGPTR( get_winproc_selector(), - (char *)&ptr->thunk - (char *)winproc_array ); - } - else /* We want a 32-bit address */ - { - if (ptr->type == WIN_PROC_16) - return (WNDPROC16)&ptr->thunk; - else if (type != ptr->type) - /* Have to return the jmp address if types don't match */ - return (WNDPROC16)&ptr->jmp; - else - /* Some Win16 programs want to get back the proc they set */ - return (WNDPROC16)ptr->thunk.t_from16.proc; - } + + if (ptr->type == WIN_PROC_16) + return (WNDPROC)&ptr->thunk; + else if (type != ptr->type) + /* Have to return the jmp address if types don't match */ + return (WNDPROC)&ptr->jmp; + else + /* Some Win16 programs want to get back the proc they set */ + return (WNDPROC)ptr->thunk.t_from16.proc; } @@ -3205,11 +3214,6 @@ LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg, if (!(proc = WINPROC_GetPtr( (WNDPROC)func ))) return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam ); -#if testing - func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_16 ); - return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam ); -#endif - switch(proc->type) { case WIN_PROC_16: @@ -3267,11 +3271,6 @@ LRESULT WINAPI CallWindowProcA( if (!(proc = WINPROC_GetPtr( func ))) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); -#if testing - func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_32A ); - return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); -#endif - switch(proc->type) { case WIN_PROC_16: @@ -3308,11 +3307,6 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, if (!(proc = WINPROC_GetPtr( (WNDPROC)func ))) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); -#if testing - func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_32W ); - return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); -#endif - switch(proc->type) { case WIN_PROC_16: diff --git a/dlls/user/winproc.h b/dlls/user/winproc.h index f1fbe8e638..f0204aede7 100644 --- a/dlls/user/winproc.h +++ b/dlls/user/winproc.h @@ -52,7 +52,8 @@ typedef struct struct tagWINDOWPROC; -extern WNDPROC16 WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type ); +extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc ); +extern WNDPROC WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type ); extern WNDPROC WINPROC_AllocProc( WNDPROC func, WINDOWPROCTYPE type ); extern WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc ); diff --git a/dlls/user/wnd16.c b/dlls/user/wnd16.c index 20a0902270..b923c83292 100644 --- a/dlls/user/wnd16.c +++ b/dlls/user/wnd16.c @@ -1358,7 +1358,7 @@ BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 * if (ret) { WNDPROC proc = WINPROC_AllocProc( wc32.lpfnWndProc, WIN_PROC_32A ); - wc->lpfnWndProc = WINPROC_GetProc( proc, WIN_PROC_16 ); + wc->lpfnWndProc = WINPROC_GetProc16( proc ); wc->style = wc32.style; wc->cbClsExtra = wc32.cbClsExtra; wc->cbWndExtra = wc32.cbWndExtra; -- 2.32.0.93.g670b81a890