mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Add message's spy into user32.dll. In order to enable, just uncomment #define YDEBUG in spy.c file and optionally set the messages you want to include / exclude in the registry (HKCU\ReactOS\Debug).
When it's turned off (YDEBUG is not defined), it doesn't provide any slow-down to the system. DefWindowProc() functions are slightly refactored to have one exit point instead of numerous returns in a switch-case statement. FIXME: maybe DPRINTs will be changed to DbgPrint because it's pointless to display path to the spy.c file everytime. svn path=/trunk/; revision=23330
This commit is contained in:
parent
3d97c16cd1
commit
b9673c3ca0
11 changed files with 2767 additions and 29 deletions
|
@ -84,6 +84,11 @@ HKCU,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP",
|
|||
HKCU,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP","SPMajorVersion",0x00010001,0x00000001
|
||||
HKCU,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP","SPMinorVersion",0x00010001,0x00000000
|
||||
|
||||
; DEBUG: Windows Messages SPY configuration
|
||||
HKCU,"SOFTWARE\ReactOS\Debug","SpyInclude",0x00020000,"INCLUDEALL"
|
||||
;HKCU,"SOFTWARE\ReactOS\Debug","SpyExclude",0x00020000,""
|
||||
;HKCU,"SOFTWARE\ReactOS\Debug","SpyExcludeDWP",0x00020000,""
|
||||
|
||||
; GUI Setup
|
||||
|
||||
HKCU, "Control Panel\Desktop\WindowMetrics","CaptionFont",0x00000001,f5,ff,ff,ff,00,00,00,\
|
||||
|
|
|
@ -1867,8 +1867,8 @@ static LRESULT ComboWndProc_common( HWND hwnd, UINT message,
|
|||
{
|
||||
LPHEADCOMBO lphc = (LPHEADCOMBO)GetWindowLongPtrW( hwnd, 0 );
|
||||
|
||||
//TRACE("[%p]: msg %s wp %08x lp %08lx\n",
|
||||
// hwnd, SPY_GetMsgName(message, hwnd), wParam, lParam );
|
||||
TRACE("[%p]: msg %s wp %08x lp %08lx\n",
|
||||
hwnd, SPY_GetMsgName(message, hwnd), wParam, lParam );
|
||||
|
||||
if( lphc || message == WM_NCCREATE )
|
||||
switch(message)
|
||||
|
|
|
@ -445,7 +445,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
|
|||
EDITSTATE *es = (EDITSTATE *)GetWindowLongPtrW( hwnd, 0 );
|
||||
LRESULT result = 0;
|
||||
|
||||
//TRACE("hwnd=%p msg=%x (%s) wparam=%x lparam=%lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam);
|
||||
TRACE("hwnd=%p msg=%x (%s) wparam=%x lparam=%lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam);
|
||||
|
||||
if (!es && msg != WM_NCCREATE)
|
||||
return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
|
||||
|
@ -1108,7 +1108,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
|
|||
|
||||
if (es) EDIT_UnlockBuffer(es, FALSE);
|
||||
|
||||
//TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
|
||||
TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -2634,8 +2634,8 @@ static LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg,
|
|||
}
|
||||
if (descr->style & LBS_COMBOBOX) lphc = descr->lphc;
|
||||
|
||||
//TRACE("[%p]: msg %s wp %08x lp %08lx\n",
|
||||
// hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam );
|
||||
TRACE("[%p]: msg %s wp %08x lp %08lx\n",
|
||||
hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam );
|
||||
switch(msg)
|
||||
{
|
||||
#ifndef __REACTOS__
|
||||
|
|
|
@ -137,5 +137,22 @@ BOOL STDCALL GdiDllInitialize(HANDLE, DWORD, LPVOID);
|
|||
void InitStockObjects(void);
|
||||
VOID DeleteFrameBrushes(VOID);
|
||||
|
||||
/* message spy definitions */
|
||||
#define SPY_DISPATCHMESSAGE 0x0101
|
||||
#define SPY_SENDMESSAGE 0x0103
|
||||
#define SPY_DEFWNDPROC 0x0105
|
||||
|
||||
#define SPY_RESULT_OK 0x0001
|
||||
#define SPY_RESULT_INVALIDHWND 0x0003
|
||||
#define SPY_RESULT_DEFWND 0x0005
|
||||
|
||||
extern const char *SPY_GetMsgName(UINT msg, HWND hWnd);
|
||||
extern const char *SPY_GetVKeyName(WPARAM wParam);
|
||||
extern void SPY_EnterMessage(INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
extern void SPY_ExitMessage(INT iFlag, HWND hwnd, UINT msg,
|
||||
LRESULT lReturn, WPARAM wParam, LPARAM lParam);
|
||||
extern int SPY_Init(void);
|
||||
|
||||
|
||||
#endif
|
||||
/* EOF */
|
||||
|
|
|
@ -101,6 +101,10 @@ DllMain(
|
|||
Cleanup();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize message spying */
|
||||
if (!SPY_Init()) return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<file>paint.c</file>
|
||||
<file>prop.c</file>
|
||||
<file>rect.c</file>
|
||||
<file>spy.c</file>
|
||||
<file>text.c</file>
|
||||
<file>window.c</file>
|
||||
<file>winpos.c</file>
|
||||
|
|
|
@ -1538,6 +1538,9 @@ DefWindowProcA(HWND hWnd,
|
|||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
LRESULT Result = 0;
|
||||
|
||||
SPY_EnterMessage(SPY_DEFWNDPROC, hWnd, Msg, wParam, lParam);
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
|
@ -1558,12 +1561,14 @@ DefWindowProcA(HWND hWnd,
|
|||
else
|
||||
NtUserDefSetText(hWnd, NULL);
|
||||
|
||||
return (1);
|
||||
Result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_GETTEXTLENGTH:
|
||||
{
|
||||
return (LRESULT)NtUserInternalGetWindowText(hWnd, NULL, 0);
|
||||
Result = (LRESULT)NtUserInternalGetWindowText(hWnd, NULL, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_GETTEXT:
|
||||
|
@ -1574,7 +1579,10 @@ DefWindowProcA(HWND hWnd,
|
|||
|
||||
Buffer = HeapAlloc(GetProcessHeap(), 0, wParam * sizeof(WCHAR));
|
||||
if (!Buffer)
|
||||
return FALSE;
|
||||
{
|
||||
Result = 0;
|
||||
break;
|
||||
}
|
||||
Length = NtUserInternalGetWindowText(hWnd, Buffer, wParam);
|
||||
if (Length > 0 && wParam > 0 &&
|
||||
!WideCharToMultiByte(CP_ACP, 0, Buffer, -1,
|
||||
|
@ -1585,7 +1593,8 @@ DefWindowProcA(HWND hWnd,
|
|||
|
||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||
|
||||
return (LRESULT)Length;
|
||||
Result = (LRESULT)Length;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SETTEXT:
|
||||
|
@ -1607,11 +1616,12 @@ DefWindowProcA(HWND hWnd,
|
|||
{
|
||||
DefWndNCPaint(hWnd, (HRGN)1, -1);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
Result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
FIXME: Implement these.
|
||||
/* FIXME: Implement these. */
|
||||
case WM_IME_CHAR:
|
||||
case WM_IME_KEYDOWN:
|
||||
case WM_IME_KEYUP:
|
||||
|
@ -1620,10 +1630,14 @@ DefWindowProcA(HWND hWnd,
|
|||
case WM_IME_ENDCOMPOSITION:
|
||||
case WM_IME_SELECT:
|
||||
case WM_IME_SETCONTEXT:
|
||||
*/
|
||||
DPRINT1("FIXME: WM_IME_* conversion isn't implemented yet!");
|
||||
/* fall through */
|
||||
default:
|
||||
Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, FALSE);
|
||||
}
|
||||
|
||||
return User32DefWindowProc(hWnd, Msg, wParam, lParam, FALSE);
|
||||
SPY_ExitMessage(SPY_RESULT_DEFWND, hWnd, Msg, Result, wParam, lParam);
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1633,6 +1647,9 @@ DefWindowProcW(HWND hWnd,
|
|||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
LRESULT Result = 0;
|
||||
|
||||
SPY_EnterMessage(SPY_DEFWNDPROC, hWnd, Msg, wParam, lParam);
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
|
@ -1646,17 +1663,20 @@ DefWindowProcW(HWND hWnd,
|
|||
RtlInitUnicodeString(&UnicodeString, (LPWSTR)cs->lpszName);
|
||||
|
||||
NtUserDefSetText( hWnd, (cs->lpszName ? &UnicodeString : NULL));
|
||||
return (1);
|
||||
Result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_GETTEXTLENGTH:
|
||||
{
|
||||
return (LRESULT)NtUserInternalGetWindowText(hWnd, NULL, 0);
|
||||
Result = (LRESULT)NtUserInternalGetWindowText(hWnd, NULL, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_GETTEXT:
|
||||
{
|
||||
return (LRESULT)NtUserInternalGetWindowText(hWnd, (PWSTR)lParam, wParam);
|
||||
Result = (LRESULT)NtUserInternalGetWindowText(hWnd, (PWSTR)lParam, wParam);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SETTEXT:
|
||||
|
@ -1672,22 +1692,30 @@ DefWindowProcW(HWND hWnd,
|
|||
{
|
||||
DefWndNCPaint(hWnd, (HRGN)1, -1);
|
||||
}
|
||||
return (1);
|
||||
Result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_IME_CHAR:
|
||||
{
|
||||
SendMessageW(hWnd, WM_CHAR, wParam, lParam);
|
||||
return (0);
|
||||
Result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_IME_SETCONTEXT:
|
||||
{
|
||||
/* FIXME */
|
||||
return (0);
|
||||
DPRINT1("FIXME: WM_IME_SETCONTEXT is not implemented!");
|
||||
Result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return User32DefWindowProc(hWnd, Msg, wParam, lParam, TRUE);
|
||||
default:
|
||||
Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, TRUE);
|
||||
}
|
||||
SPY_ExitMessage(SPY_RESULT_DEFWND, hWnd, Msg, Result, wParam, lParam);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1050,7 +1050,7 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
|
|||
{
|
||||
MDICLIENTINFO *ci = NULL;
|
||||
|
||||
// TRACE("%p %04x (%s) %08x %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
TRACE("%p %04x (%s) %08x %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
|
||||
if (WM_NCCREATE != message && NULL == (ci = get_client_info(hwnd)))
|
||||
{
|
||||
|
@ -1368,7 +1368,7 @@ LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient,
|
|||
{
|
||||
MDICLIENTINFO *ci = get_client_info( hwndMDIClient );
|
||||
|
||||
// TRACE("%p %p %04x (%s) %08x %08lx\n", hwnd, hwndMDIClient, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
TRACE("%p %p %04x (%s) %08x %08lx\n", hwnd, hwndMDIClient, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
|
||||
if (ci)
|
||||
{
|
||||
|
@ -1466,7 +1466,7 @@ LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message,
|
|||
HWND client = GetParent(hwnd);
|
||||
MDICLIENTINFO *ci = get_client_info( client );
|
||||
|
||||
// TRACE("%p %04x (%s) %08x %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
TRACE("%p %04x (%s) %08x %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
#ifndef __REACTOS__
|
||||
hwnd = WIN_GetFullHandle( hwnd );
|
||||
#endif
|
||||
|
@ -1509,7 +1509,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
|
|||
HWND client = GetParent(hwnd);
|
||||
MDICLIENTINFO *ci = get_client_info( client );
|
||||
|
||||
// TRACE("%p %04x (%s) %08x %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
TRACE("%p %04x (%s) %08x %08lx\n", hwnd, message, SPY_GetMsgName(message, hwnd), wParam, lParam);
|
||||
#ifndef __REACTOS__
|
||||
hwnd = WIN_GetFullHandle( hwnd );
|
||||
#endif
|
||||
|
|
|
@ -1297,8 +1297,12 @@ DispatchMessageA(CONST MSG *lpmsg)
|
|||
if (! Info.HandledByKernel)
|
||||
{
|
||||
/* We need to send the message ourselves */
|
||||
SPY_EnterMessage(SPY_DISPATCHMESSAGE, Info.Msg.hwnd, Info.Msg.message,
|
||||
Info.Msg.wParam, Info.Msg.lParam);
|
||||
Result = IntCallWindowProcA(Info.Ansi, Info.Proc, Info.Msg.hwnd,
|
||||
Info.Msg.message, Info.Msg.wParam, Info.Msg.lParam);
|
||||
SPY_ExitMessage(SPY_RESULT_OK, Info.Msg.hwnd, Info.Msg.message, Result,
|
||||
Info.Msg.wParam, Info.Msg.lParam);
|
||||
}
|
||||
MsgConversionCleanup(lpmsg, TRUE, TRUE, &Result);
|
||||
|
||||
|
@ -1321,8 +1325,12 @@ DispatchMessageW(CONST MSG *lpmsg)
|
|||
if (! Info.HandledByKernel)
|
||||
{
|
||||
/* We need to send the message ourselves */
|
||||
SPY_EnterMessage(SPY_DISPATCHMESSAGE, Info.Msg.hwnd, Info.Msg.message,
|
||||
Info.Msg.wParam, Info.Msg.lParam);
|
||||
Result = IntCallWindowProcW(Info.Ansi, Info.Proc, Info.Msg.hwnd,
|
||||
Info.Msg.message, Info.Msg.wParam, Info.Msg.lParam);
|
||||
SPY_ExitMessage(SPY_RESULT_OK, Info.Msg.hwnd, Info.Msg.message, Result,
|
||||
Info.Msg.wParam, Info.Msg.lParam);
|
||||
}
|
||||
MsgConversionCleanup(lpmsg, FALSE, TRUE, &Result);
|
||||
|
||||
|
@ -1791,12 +1799,15 @@ SendMessageTimeoutA(
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam);
|
||||
|
||||
Info.Ansi = TRUE;
|
||||
Result = NtUserSendMessageTimeout(UcMsg.hwnd, UcMsg.message,
|
||||
UcMsg.wParam, UcMsg.lParam,
|
||||
fuFlags, uTimeout, (ULONG_PTR*)lpdwResult, &Info);
|
||||
if(!Result)
|
||||
{
|
||||
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
|
||||
return FALSE;
|
||||
}
|
||||
if (! Info.HandledByKernel)
|
||||
|
@ -1818,7 +1829,8 @@ SendMessageTimeoutA(
|
|||
UcMsg.message, UcMsg.wParam, UcMsg.lParam);
|
||||
if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result))
|
||||
{
|
||||
return FALSE;
|
||||
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if(lpdwResult)
|
||||
|
@ -1830,10 +1842,12 @@ SendMessageTimeoutA(
|
|||
/* Message sent by kernel. Convert back to Ansi */
|
||||
if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result))
|
||||
{
|
||||
return FALSE;
|
||||
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -1855,6 +1869,8 @@ SendMessageTimeoutW(
|
|||
NTUSERSENDMESSAGEINFO Info;
|
||||
LRESULT Result;
|
||||
|
||||
SPY_EnterMessage(SPY_SENDMESSAGE, hWnd, Msg, wParam, lParam);
|
||||
|
||||
Info.Ansi = FALSE;
|
||||
Result = NtUserSendMessageTimeout(hWnd, Msg, wParam, lParam, fuFlags, uTimeout,
|
||||
lpdwResult, &Info);
|
||||
|
@ -1864,9 +1880,12 @@ SendMessageTimeoutW(
|
|||
Result = IntCallWindowProcW(Info.Ansi, Info.Proc, hWnd, Msg, wParam, lParam);
|
||||
if(lpdwResult)
|
||||
*lpdwResult = Result;
|
||||
|
||||
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
|
2664
reactos/dll/win32/user32/windows/spy.c
Normal file
2664
reactos/dll/win32/user32/windows/spy.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue