Commit 6b3da8a4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move message spy implementation from user32.

parent 65fe0f65
......@@ -39,7 +39,6 @@ C_SRCS = \
rawinput.c \
resource.c \
scroll.c \
spy.c \
static.c \
sysparams.c \
text.c \
......
......@@ -33,6 +33,7 @@
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(graphics);
WINE_DECLARE_DEBUG_CHANNEL(message);
HMODULE user32_module = 0;
......@@ -355,3 +356,23 @@ BOOL WINAPI ShutdownBlockReasonDestroy(HWND hwnd)
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
}
const char *SPY_GetMsgName( UINT msg, HWND hwnd )
{
return (const char *)NtUserCallHwndParam( hwnd, msg, NtUserSpyGetMsgName );
}
const char *SPY_GetVKeyName( WPARAM wparam )
{
return (const char *)NtUserCallOneParam( wparam, NtUserSpyGetVKeyName );
}
void SPY_EnterMessage( INT flag, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
if (TRACE_ON(message)) NtUserMessageCall( hwnd, msg, wparam, lparam, 0, FNID_SPYENTER, flag );
}
void SPY_ExitMessage( INT flag, HWND hwnd, UINT msg, LRESULT lreturn, WPARAM wparam, LPARAM lparam )
{
if (TRACE_ON(message)) NtUserMessageCall( hwnd, msg, wparam, lparam, lreturn, FNID_SPYEXIT, flag );
}
......@@ -143,13 +143,6 @@ BOOL WINAPI User32CallWindowsHook( const struct win_hook_params *params, ULONG s
/* message spy definitions */
#define SPY_DISPATCHMESSAGE 0x0100
#define SPY_SENDMESSAGE 0x0101
#define SPY_DEFWNDPROC 0x0102
#define SPY_RESULT_OK 0x0001
#define SPY_RESULT_DEFWND 0x0002
extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ) DECLSPEC_HIDDEN;
extern const char *SPY_GetVKeyName(WPARAM wParam) DECLSPEC_HIDDEN;
extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
......
......@@ -43,6 +43,7 @@ C_SRCS = \
pen.c \
printdrv.c \
region.c \
spy.c \
syscall.c \
sysparams.c \
vertical.c \
......
......@@ -1186,6 +1186,7 @@ static struct unix_funcs unix_funcs =
NtUserGetUpdatedClipboardFormats,
NtUserIsClipboardFormatAvailable,
NtUserMapVirtualKeyEx,
NtUserMessageCall,
NtUserMoveWindow,
NtUserRedrawWindow,
NtUserRegisterClassExWOW,
......
......@@ -273,6 +273,12 @@ BOOL WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam
return send_window_message( hwnd, msg, wparam, lparam, (LRESULT *)result_info, ansi );
case FNID_SENDNOTIFYMESSAGE:
return send_notify_message( hwnd, msg, wparam, lparam, ansi );
case FNID_SPYENTER:
spy_enter_message( ansi, hwnd, msg, wparam, lparam );
return 0;
case FNID_SPYEXIT:
spy_exit_message( ansi, hwnd, msg, result_info, wparam, lparam );
return 0;
default:
FIXME( "%p %x %lx %lx %lx %x %x\n", hwnd, msg, wparam, lparam, result_info, type, ansi );
}
......
......@@ -218,6 +218,21 @@ typedef struct tagWINDOWPROC
#define WINSWITCH_CLASS_ATOM MAKEINTATOM(32771) /* WinSwitch */
#define ICONTITLE_CLASS_ATOM MAKEINTATOM(32772) /* IconTitle */
/* message spy definitions */
#define SPY_DISPATCHMESSAGE 0x0100
#define SPY_SENDMESSAGE 0x0101
#define SPY_DEFWNDPROC 0x0102
#define SPY_RESULT_OK 0x0001
#define SPY_RESULT_DEFWND 0x0002
extern const char *debugstr_msg_name( UINT msg, HWND hwnd ) DECLSPEC_HIDDEN;
extern const char *debugstr_vkey_name( WPARAM wParam ) DECLSPEC_HIDDEN;
extern void spy_enter_message( INT flag, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
extern void spy_exit_message( INT flag, HWND hwnd, UINT msg,
LRESULT lreturn, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
/* class.c */
WNDPROC alloc_winproc( WNDPROC func, BOOL ansi ) DECLSPEC_HIDDEN;
WINDOWPROC *get_winproc_ptr( WNDPROC handle ) DECLSPEC_HIDDEN;
......
......@@ -19,20 +19,16 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winreg.h"
#include "win.h"
#include "user_private.h"
#include "wine/debug.h"
#if 0
#pragma makedep unix
#endif
#include "win32u_private.h"
#include "ntuser_private.h"
#include "commctrl.h"
#include "commdlg.h"
#include "richedit.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(message);
......@@ -2023,7 +2019,7 @@ typedef struct
WPARAM wParam; /* message parameter */
LPARAM lParam; /* message parameter */
INT data_len; /* length of data to dump */
char msg_name[60]; /* message name (see SPY_GetMsgName) */
char msg_name[60]; /* message name (see debugstr_msg_name) */
WCHAR wnd_class[60]; /* window class name (full) */
WCHAR wnd_name[16]; /* window name for message */
} SPY_INSTANCE;
......@@ -2104,13 +2100,16 @@ static const USER_MSG *SPY_Bsearch_Msg( const USER_MSG *msgs, UINT count, UINT c
*/
static void SPY_GetClassName( SPY_INSTANCE *sp_e )
{
static const WCHAR property_sheet_infoW[] =
{'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0};
/* special code to detect a property sheet dialog */
if ((GetClassLongW(sp_e->msg_hwnd, GCW_ATOM) == WC_DIALOG) &&
(GetPropW(sp_e->msg_hwnd, L"PropertySheetInfo"))) {
if ((get_class_long( sp_e->msg_hwnd, GCW_ATOM, FALSE ) == WC_DIALOG) &&
(NtUserGetProp( sp_e->msg_hwnd, property_sheet_infoW ))) {
lstrcpyW(sp_e->wnd_class, WC_PROPSHEETW);
}
else {
GetClassNameW(sp_e->msg_hwnd, sp_e->wnd_class, ARRAY_SIZE(sp_e->wnd_class));
UNICODE_STRING str = { .Buffer = sp_e->wnd_class, .MaximumLength = sizeof(sp_e->wnd_class) };
NtUserGetClassName( sp_e->msg_hwnd, FALSE, &str );
}
}
......@@ -2131,10 +2130,16 @@ static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e )
if (sp_e->msgnum >= 0xc000)
{
if (GlobalGetAtomNameA( sp_e->msgnum, sp_e->msg_name+1, sizeof(sp_e->msg_name)-2 ))
char buf[sizeof(ATOM_BASIC_INFORMATION) + MAX_ATOM_LEN * sizeof(WCHAR)];
ATOM_BASIC_INFORMATION *abi = (ATOM_BASIC_INFORMATION *)buf;
if (!NtQueryInformationAtom( sp_e->msgnum, AtomBasicInformation, abi, sizeof(buf), NULL ))
{
sp_e->msg_name[0] = '\"';
strcat( sp_e->msg_name, "\"" );
unsigned int j = 0;
sp_e->msg_name[j++] = '\"';
j += ntdll_wcstoumbs( abi->Name, abi->NameLength / sizeof(WCHAR),
sp_e->msg_name + j, sizeof(sp_e->msg_name) - 3, FALSE );
sp_e->msg_name[j++] = '\"';
sp_e->msg_name[j] = 0;
return;
}
}
......@@ -2199,13 +2204,13 @@ static void SPY_GetWndName( SPY_INSTANCE *sp_e )
}
/***********************************************************************
* SPY_GetMsgName
* debugstr_msg_name
*
* **** External function ****
*
* Get message name
*/
const char *SPY_GetMsgName( UINT msg, HWND hWnd )
const char *debugstr_msg_name( UINT msg, HWND hWnd )
{
SPY_INSTANCE ext_sp_e;
DWORD save_error = GetLastError();
......@@ -2221,9 +2226,9 @@ const char *SPY_GetMsgName( UINT msg, HWND hWnd )
}
/***********************************************************************
* SPY_GetVKeyName
* debugstr_vkey_name
*/
const char *SPY_GetVKeyName(WPARAM wParam)
const char *debugstr_vkey_name(WPARAM wParam)
{
const char *vk_key_name;
......@@ -2431,7 +2436,7 @@ static void SPY_DumpStructure(const SPY_INSTANCE *sp_e, BOOL enter)
if (!enter) break;
unicode = IsWindowUnicode(sp_e->msg_hwnd);
unicode = is_window_unicode( sp_e->msg_hwnd );
cs = (CREATESTRUCTA *)sp_e->lParam;
TRACE("%s %s ex=%08x style=%08x %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n",
unicode ? debugstr_w((LPCWSTR)cs->lpszName) : debugstr_a(cs->lpszName),
......@@ -2488,6 +2493,7 @@ static void SPY_DumpStructure(const SPY_INSTANCE *sp_e, BOOL enter)
const SPY_NOTIFY *p;
WCHAR from_class[60];
DWORD save_error;
UNICODE_STRING str = { .Buffer = from_class, .MaximumLength = sizeof(from_class) };
p = SPY_Bsearch_Notify( pnmh->code );
if (p) {
......@@ -2499,7 +2505,7 @@ static void SPY_DumpStructure(const SPY_INSTANCE *sp_e, BOOL enter)
if (pnmh->code == NM_CUSTOMDRAW) {
/* save and restore error code over the next call */
save_error = GetLastError();
GetClassNameW(pnmh->hwndFrom, from_class, ARRAY_SIZE(from_class));
NtUserGetClassName( pnmh->hwndFrom, FALSE, &str );
SetLastError(save_error);
if (wcscmp(TOOLBARCLASSNAMEW, from_class) == 0)
dumplen = sizeof(NMTBCUSTOMDRAW)-sizeof(NMHDR);
......@@ -2530,61 +2536,64 @@ static void SPY_DumpStructure(const SPY_INSTANCE *sp_e, BOOL enter)
*/
static BOOL spy_init(void)
{
int i;
char buffer[1024];
HKEY hkey;
char *exclude;
if (!TRACE_ON(message)) return FALSE;
if (spy_exclude) return TRUE;
exclude = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, SPY_MAX_MSGNUM + 2 );
exclude = calloc( 1, SPY_MAX_MSGNUM + 2 );
/* @@ Wine registry key: HKCU\Software\Wine\Debug */
if(!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Debug", &hkey))
if ((hkey = reg_open_hkcu_key( "Software\\Wine\\Debug" )))
{
DWORD type, count = sizeof(buffer);
char buffer[2048];
KEY_VALUE_PARTIAL_INFORMATION *info = (void *)buffer;
unsigned int i, size;
buffer[0] = 0;
if (!RegQueryValueExA(hkey, "SpyInclude", 0, &type, (LPBYTE) buffer, &count) &&
strcmp( buffer, "INCLUDEALL" ))
if ((size = query_reg_ascii_value( hkey, "SpyInclude", info, sizeof(buffer) )))
{
const WCHAR *data = (const WCHAR *)info->Data;
for (i = 0; i < size / sizeof(WCHAR); i++) buffer[i] = data[i];
buffer[i] = 0;
TRACE("Include=%s\n", buffer );
for (i = 0; i <= SPY_MAX_MSGNUM; i++)
exclude[i] = (MessageTypeNames[i] && !strstr(buffer,MessageTypeNames[i]));
if (strcmp( buffer, "INCLUDEALL" ))
{
for (i = 0; i <= SPY_MAX_MSGNUM; i++)
exclude[i] = MessageTypeNames[i] && !strstr(buffer,MessageTypeNames[i]);
}
}
count = sizeof(buffer);
buffer[0] = 0;
if (!RegQueryValueExA(hkey, "SpyExclude", 0, &type, (LPBYTE) buffer, &count))
if ((size = query_reg_ascii_value( hkey, "SpyExclude", info, sizeof(buffer) )))
{
const WCHAR *data = (const WCHAR *)info->Data;
for (i = 0; i < size / sizeof(WCHAR); i++) buffer[i] = data[i];
buffer[i] = 0;
TRACE("Exclude=%s\n", buffer );
if (!strcmp( buffer, "EXCLUDEALL" ))
for (i = 0; i <= SPY_MAX_MSGNUM; i++) exclude[i] = TRUE;
else
for (i = 0; i <= SPY_MAX_MSGNUM; i++)
exclude[i] = (MessageTypeNames[i] && strstr(buffer,MessageTypeNames[i]));
exclude[i] = MessageTypeNames[i] && strstr(buffer,MessageTypeNames[i]);
}
count = sizeof(buffer);
if(!RegQueryValueExA(hkey, "SpyExcludeDWP", 0, &type, (LPBYTE) buffer, &count))
exclude[SPY_MAX_MSGNUM + 1] = atoi(buffer);
if (query_reg_ascii_value( hkey, "SpyExcludeDWP", info, sizeof(buffer) ))
exclude[SPY_MAX_MSGNUM + 1] = wcstol( (const WCHAR *)info->Data, NULL, 0 );
RegCloseKey(hkey);
NtClose( hkey );
}
if (InterlockedCompareExchangePointer( (void **)&spy_exclude, exclude, NULL ))
HeapFree( GetProcessHeap(), 0, exclude );
free( exclude );
return TRUE;
}
/***********************************************************************
* SPY_EnterMessage
* spy_enter_message
*/
void SPY_EnterMessage( INT iFlag, HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam )
void spy_enter_message( INT iFlag, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
SPY_INSTANCE sp_e;
int indent;
......@@ -2600,7 +2609,7 @@ void SPY_EnterMessage( INT iFlag, HWND hWnd, UINT msg,
SPY_GetMsgStuff(&sp_e);
indent = get_indent_level();
/* each SPY_SENDMESSAGE must be complemented by call to SPY_ExitMessage */
/* each SPY_SENDMESSAGE must be complemented by call to spy_exit_message */
switch(iFlag)
{
case SPY_DISPATCHMESSAGE:
......@@ -2612,7 +2621,7 @@ void SPY_EnterMessage( INT iFlag, HWND hWnd, UINT msg,
case SPY_SENDMESSAGE:
{
char taskName[20];
DWORD tid = GetWindowThreadProcessId( hWnd, NULL );
DWORD tid = get_window_thread( hWnd, NULL );
if (tid == GetCurrentThreadId()) strcpy( taskName, "self" );
else sprintf( taskName, "tid %04x", GetCurrentThreadId() );
......@@ -2636,9 +2645,9 @@ void SPY_EnterMessage( INT iFlag, HWND hWnd, UINT msg,
/***********************************************************************
* SPY_ExitMessage
* spy_exit_message
*/
void SPY_ExitMessage( INT iFlag, HWND hWnd, UINT msg, LRESULT lReturn,
void spy_exit_message( INT iFlag, HWND hWnd, UINT msg, LRESULT lReturn,
WPARAM wParam, LPARAM lParam )
{
SPY_INSTANCE sp_e;
......
......@@ -4709,6 +4709,8 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code )
}
case NtUserSetCallbacks:
return (UINT_PTR)InterlockedExchangePointer( (void **)&user_callbacks, (void *)arg );
case NtUserSpyGetVKeyName:
return (UINT_PTR)debugstr_vkey_name( arg );
default:
FIXME( "invalid code %u\n", code );
return 0;
......
......@@ -1079,7 +1079,7 @@
@ stdcall NtUserMapVirtualKeyEx(long long long)
@ stub NtUserMarkWindowForRawMouse
@ stub NtUserMenuItemFromPoint
@ stub NtUserMessageCall
@ stdcall NtUserMessageCall(long long long long long long long)
@ stub NtUserMinInitialize
@ stub NtUserMinMaximize
@ stub NtUserModifyUserStartupInfoFlags
......
......@@ -233,6 +233,8 @@ struct unix_funcs
BOOL (WINAPI *pNtUserGetUpdatedClipboardFormats)( UINT *formats, UINT size, UINT *out_size );
BOOL (WINAPI *pNtUserIsClipboardFormatAvailable)( UINT format );
UINT (WINAPI *pNtUserMapVirtualKeyEx)( UINT code, UINT type, HKL layout );
BOOL (WINAPI *pNtUserMessageCall)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
ULONG_PTR result_info, DWORD type, BOOL ansi );
BOOL (WINAPI *pNtUserMoveWindow)( HWND hwnd, INT x, INT y, INT cx, INT cy, BOOL repaint );
BOOL (WINAPI *pNtUserRedrawWindow)( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags );
ATOM (WINAPI *pNtUserRegisterClassExWOW)( const WNDCLASSEXW *wc, UNICODE_STRING *name,
......@@ -379,6 +381,7 @@ extern HWND is_current_process_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL is_desktop_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL is_iconic( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL is_window_unicode( HWND hwnd ) DECLSPEC_HIDDEN;
extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN;
extern BOOL get_window_rect( HWND hwnd, RECT *rect, UINT dpi ) DECLSPEC_HIDDEN;
enum coords_relative;
......
......@@ -781,7 +781,7 @@ static BOOL is_window_drawable( HWND hwnd, BOOL icon )
}
/* see IsWindowUnicode */
static BOOL is_window_unicode( HWND hwnd )
BOOL is_window_unicode( HWND hwnd )
{
WND *win;
BOOL ret = FALSE;
......@@ -5033,6 +5033,8 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code )
STYLESTRUCT *style = (void *)param;
return set_window_style( hwnd, style->styleNew, style->styleOld );
}
case NtUserSpyGetMsgName:
return (UINT_PTR)debugstr_msg_name( param, hwnd );
default:
FIXME( "invalid code %u\n", code );
return 0;
......
......@@ -939,6 +939,13 @@ UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout )
return unix_funcs->pNtUserMapVirtualKeyEx( code, type, layout );
}
BOOL WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
ULONG_PTR result_info, DWORD type, BOOL ansi )
{
if (!unix_funcs) return 0;
return unix_funcs->pNtUserMessageCall( hwnd, msg, wparam, lparam, result_info, type, ansi );
}
BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
{
if (!unix_funcs) return FALSE;
......
......@@ -121,6 +121,7 @@ enum
NtUserIncrementKeyStateCounter,
NtUserLock,
NtUserSetCallbacks,
NtUserSpyGetVKeyName,
};
/* NtUserCallTwoParam codes, not compatible with Windows */
......@@ -182,6 +183,7 @@ enum
/* temporary exports */
NtUserIsWindowDrawable,
NtUserSetWindowStyle,
NtUserSpyGetMsgName,
};
/* NtUserMessageCall codes */
......@@ -189,6 +191,9 @@ enum
{
FNID_SENDMESSAGE = 0x02b1,
FNID_SENDNOTIFYMESSAGE = 0x02b7,
/* Wine-specific exports */
FNID_SPYENTER = 0x0300,
FNID_SPYEXIT = 0x0301,
};
/* color index used to retrieve system 55aa brush */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment