Commit 9ec81d16 authored by Alexandre Julliard's avatar Alexandre Julliard

Got rid of dynamic thunk allocation in mouse/keyboard event procs and

window hooks.
parent de51f615
...@@ -7,16 +7,11 @@ ...@@ -7,16 +7,11 @@
#include <string.h> #include <string.h>
#include "debugtools.h"
#include "callback.h"
#include "builtin16.h"
#include "windef.h" #include "windef.h"
#include "wingdi.h" #include "winbase.h"
#include "winuser.h" #include "winuser.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
DEFAULT_DEBUG_CHANNEL(event);
#include "pshpack1.h" #include "pshpack1.h"
typedef struct _MOUSEINFO typedef struct _MOUSEINFO
{ {
...@@ -32,11 +27,7 @@ typedef struct _MOUSEINFO ...@@ -32,11 +27,7 @@ typedef struct _MOUSEINFO
} MOUSEINFO, *LPMOUSEINFO; } MOUSEINFO, *LPMOUSEINFO;
#include "poppack.h" #include "poppack.h"
/**********************************************************************/ static FARPROC16 DefMouseEventProc;
typedef VOID CALLBACK (*LPMOUSE_EVENT_PROC)(DWORD,DWORD,DWORD,DWORD,DWORD);
static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
/*********************************************************************** /***********************************************************************
* Inquire (MOUSE.1) * Inquire (MOUSE.1)
...@@ -56,34 +47,12 @@ WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo) ...@@ -56,34 +47,12 @@ WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
return sizeof(MOUSEINFO); return sizeof(MOUSEINFO);
} }
/**********************************************************************/
static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
DWORD dwFlags, DWORD dx, DWORD dy,
DWORD cButtons, DWORD dwExtraInfo )
{
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
context.SegCs = SELECTOROF( proc );
context.Eip = OFFSETOF( proc );
context.Eax = (WORD)dwFlags;
context.Ebx = (WORD)dx;
context.Ecx = (WORD)dy;
context.Edx = (WORD)cButtons;
context.Esi = LOWORD( dwExtraInfo );
context.Edi = HIWORD( dwExtraInfo );
wine_call_to_16_regs_short( &context, 0 );
}
/*********************************************************************** /***********************************************************************
* Enable (MOUSE.2) * Enable (MOUSE.2)
*/ */
VOID WINAPI MOUSE_Enable( FARPROC16 proc ) VOID WINAPI MOUSE_Enable( FARPROC16 proc )
{ {
THUNK_Free( (FARPROC)DefMouseEventProc ); DefMouseEventProc = proc;
DefMouseEventProc = (LPMOUSE_EVENT_PROC)THUNK_Alloc( proc, (RELAY)MOUSE_CallMouseEventProc );
} }
/*********************************************************************** /***********************************************************************
...@@ -91,6 +60,5 @@ VOID WINAPI MOUSE_Enable( FARPROC16 proc ) ...@@ -91,6 +60,5 @@ VOID WINAPI MOUSE_Enable( FARPROC16 proc )
*/ */
VOID WINAPI MOUSE_Disable(VOID) VOID WINAPI MOUSE_Disable(VOID)
{ {
THUNK_Free( (FARPROC)DefMouseEventProc );
DefMouseEventProc = 0; DefMouseEventProc = 0;
} }
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "winuser.h" #include "winuser.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "callback.h"
#include "hook.h" #include "hook.h"
#include "win.h" #include "win.h"
#include "queue.h" #include "queue.h"
...@@ -43,7 +42,6 @@ typedef struct ...@@ -43,7 +42,6 @@ typedef struct
HQUEUE16 ownerQueue; /* 08 Owner queue (0 for system hook) */ HQUEUE16 ownerQueue; /* 08 Owner queue (0 for system hook) */
HMODULE16 ownerModule; /* 0a Owner module */ HMODULE16 ownerModule; /* 0a Owner module */
WORD flags; /* 0c flags */ WORD flags; /* 0c flags */
HOOKPROC thunk; /* 0e Hook procedure (CallTo16 thunk) */
} HOOKDATA; } HOOKDATA;
#include "poppack.h" #include "poppack.h"
...@@ -894,20 +892,6 @@ static HHOOK HOOK_SetHook( INT16 id, LPVOID proc, INT type, ...@@ -894,20 +892,6 @@ static HHOOK HOOK_SetHook( INT16 id, LPVOID proc, INT type,
data->ownerModule = hModule; data->ownerModule = hModule;
data->flags = type; data->flags = type;
/* Create CallTo16 thunk for 16-bit hooks */
if ( (data->flags & HOOK_MAPTYPE) == HOOK_WIN16 )
data->thunk = (HOOKPROC)THUNK_Alloc( (FARPROC16)data->proc,
(RELAY)HOOK_CallTo16_long_wwl );
else
data->thunk = data->proc;
if ( !data->thunk && data->proc )
{
USER_HEAP_FREE( handle );
return 0;
}
/* Insert it in the correct linked list */ /* Insert it in the correct linked list */
if (hQueue) if (hQueue)
...@@ -969,9 +953,6 @@ static BOOL HOOK_RemoveHook( HANDLE16 hook ) ...@@ -969,9 +953,6 @@ static BOOL HOOK_RemoveHook( HANDLE16 hook )
if (!*prevHook) return FALSE; if (!*prevHook) return FALSE;
*prevHook = data->next; *prevHook = data->next;
if ( (data->flags & HOOK_MAPTYPE) == HOOK_WIN16 )
THUNK_Free( (FARPROC)data->thunk );
USER_HEAP_FREE( hook ); USER_HEAP_FREE( hook );
return TRUE; return TRUE;
} }
...@@ -1031,16 +1012,18 @@ static LRESULT HOOK_CallHook( HANDLE16 hook, INT fromtype, INT code, ...@@ -1031,16 +1012,18 @@ static LRESULT HOOK_CallHook( HANDLE16 hook, INT fromtype, INT code,
/* Suspend window structure locks before calling user code */ /* Suspend window structure locks before calling user code */
iWndsLocks = WIN_SuspendWndsLock(); iWndsLocks = WIN_SuspendWndsLock();
ret = data->thunk(code, wParam, lParam); if ((data->flags & HOOK_MAPTYPE) == HOOK_WIN16)
{
/* Grrr. While the hook procedure is supposed to have an LRESULT return ret = HOOK_CallTo16_long_wwl( data->proc, code, wParam, lParam );
value even in Win16, it seems that for those hook types where the /* Grrr. While the hook procedure is supposed to have an LRESULT return
return value is interpreted as BOOL, Windows doesn't actually check value even in Win16, it seems that for those hook types where the
the HIWORD ... Some buggy Win16 programs, notably WINFILE, rely on return value is interpreted as BOOL, Windows doesn't actually check
that, because they neglect to clear DX ... */ the HIWORD ... Some buggy Win16 programs, notably WINFILE, rely on
if ( (data->flags & HOOK_MAPTYPE) == HOOK_WIN16 that, because they neglect to clear DX ... */
&& data->id != WH_JOURNALPLAYBACK ) if (data->id != WH_JOURNALPLAYBACK) ret = LOWORD( ret );
ret = LOWORD( ret ); }
else
ret = data->proc(code, wParam, lParam);
WIN_RestoreWndsLock(iWndsLocks); WIN_RestoreWndsLock(iWndsLocks);
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "win.h" #include "win.h"
#include "user.h" #include "user.h"
#include "message.h" #include "message.h"
#include "callback.h"
#include "builtin16.h"
#include "debugtools.h" #include "debugtools.h"
#include "winerror.h" #include "winerror.h"
...@@ -38,34 +36,10 @@ typedef struct _KBINFO ...@@ -38,34 +36,10 @@ typedef struct _KBINFO
} KBINFO, *LPKBINFO; } KBINFO, *LPKBINFO;
#include "poppack.h" #include "poppack.h"
/**********************************************************************/ static FARPROC16 DefKeybEventProc;
typedef VOID CALLBACK (*LPKEYBD_EVENT_PROC)(BYTE,BYTE,DWORD,DWORD);
static LPKEYBD_EVENT_PROC DefKeybEventProc;
static LPBYTE pKeyStateTable; static LPBYTE pKeyStateTable;
/*********************************************************************** /***********************************************************************
* KEYBOARD_CallKeybdEventProc
*/
static VOID WINAPI KEYBOARD_CallKeybdEventProc( FARPROC16 proc,
BYTE bVk, BYTE bScan,
DWORD dwFlags, DWORD dwExtraInfo )
{
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
context.SegCs = SELECTOROF( proc );
context.Eip = OFFSETOF( proc );
context.Eax = bVk | ((dwFlags & KEYEVENTF_KEYUP)? 0x8000 : 0);
context.Ebx = bScan | ((dwFlags & KEYEVENTF_EXTENDEDKEY) ? 0x100 : 0);
context.Esi = LOWORD( dwExtraInfo );
context.Edi = HIWORD( dwExtraInfo );
wine_call_to_16_regs_short( &context, 0 );
}
/***********************************************************************
* Inquire (KEYBOARD.1) * Inquire (KEYBOARD.1)
*/ */
WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo) WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
...@@ -84,8 +58,7 @@ WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo) ...@@ -84,8 +58,7 @@ WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
*/ */
VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState ) VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
{ {
if (DefKeybEventProc) THUNK_Free( (FARPROC)DefKeybEventProc ); DefKeybEventProc = proc;
DefKeybEventProc = (LPKEYBD_EVENT_PROC)THUNK_Alloc( proc, (RELAY)KEYBOARD_CallKeybdEventProc );
pKeyStateTable = lpKeyState; pKeyStateTable = lpKeyState;
memset( lpKeyState, 0, 256 ); /* all states to false */ memset( lpKeyState, 0, 256 ); /* all states to false */
...@@ -96,10 +69,8 @@ VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState ) ...@@ -96,10 +69,8 @@ VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
*/ */
VOID WINAPI KEYBOARD_Disable(VOID) VOID WINAPI KEYBOARD_Disable(VOID)
{ {
THUNK_Free( (FARPROC)DefKeybEventProc ); DefKeybEventProc = NULL;
pKeyStateTable = NULL;
DefKeybEventProc = NULL;
pKeyStateTable = NULL;
} }
......
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