Author: jimtabor Date: Tue Dec 1 06:35:05 2009 New Revision: 44340
URL: http://svn.reactos.org/svn/reactos?rev=44340&view=rev Log: - [Win32k] Make DispatchMessage call direct to WinProc callback. Add more thread death checks.
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Tue Dec 1 06:35:05 2009 @@ -335,6 +335,9 @@ LARGE_INTEGER TickCount; LONG Time; LRESULT retval; + PMSGMEMORY MsgMemoryEntry; + INT lParamBufferSize; + LPARAM lParamPacked; PWINDOW_OBJECT Window = NULL;
if (pMsg->hwnd) @@ -376,9 +379,37 @@ } } // Need a window! - if (!Window) return 0; - - retval = co_IntPostOrSendMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam); + if ( !Window || !Window->Wnd ) return 0; + + /* See if this message type is present in the table */ + MsgMemoryEntry = FindMsgMemory(pMsg->message); + if ( !MsgMemoryEntry ) + { + lParamBufferSize = -1; + } + else + { + lParamBufferSize = MsgMemorySize(MsgMemoryEntry, pMsg->wParam, pMsg->lParam); + } + + if (! NT_SUCCESS(PackParam(&lParamPacked, pMsg->message, pMsg->wParam, pMsg->lParam))) + { + DPRINT1("Failed to pack message parameters\n"); + return 0; + } + + retval = co_IntCallWindowProc( Window->Wnd->lpfnWndProc, + !Window->Wnd->Unicode, + pMsg->hwnd, + pMsg->message, + pMsg->wParam, + lParamPacked, + lParamBufferSize); + + if (! NT_SUCCESS(UnpackParam(lParamPacked, pMsg->message, pMsg->wParam, pMsg->lParam))) + { + DPRINT1("Failed to unpack message parameters\n"); + }
if (pMsg->message == WM_PAINT) { @@ -1324,7 +1355,7 @@ if( Status == STATUS_SUCCESS ) { pThread = (PTHREADINFO)peThread->Tcb.Win32Thread; - if( !pThread || !pThread->MessageQueue || (pThread->TIF_flags & TIF_INCLEANUP)) + if( !pThread || !pThread->MessageQueue || (pThread->TIF_flags & TIF_INCLEANUP)) { ObDereferenceObject( peThread ); return FALSE; @@ -1370,7 +1401,6 @@ wParam, lParam);
- pti = PsGetCurrentThreadWin32Thread(); if (Wnd == HWND_BROADCAST) { HWND *List; @@ -1392,11 +1422,19 @@ PWINDOW_OBJECT Window;
Window = UserGetWindowObject(Wnd); - if (NULL == Window) + if ( !Window || !Window->Wnd ) { return FALSE; } - if(Window->Status & WINDOWSTATUS_DESTROYING) + + pti = Window->Wnd->head.pti; + if ( pti->TIF_flags & TIF_INCLEANUP ) + { + DPRINT1("Attempted to post message to window 0x%x when the thread is in cleanup!\n", Wnd); + return FALSE; + } + + if ( Window->Status & WINDOWSTATUS_DESTROYING ) { DPRINT1("Attempted to post message to window 0x%x that is being destroyed!\n", Wnd); /* FIXME - last error code? */ @@ -1760,6 +1798,9 @@
Info.Ansi = !Window->Wnd->Unicode; Info.Proc = Window->Wnd->lpfnWndProc; + + // Make the call from here if CALLWNDPROC or CALLWNDPROCRET are hooked + // or just do it in User32!
IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, &Result); }