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

window hooks.
This commit is contained in:
Alexandre Julliard 2001-12-17 21:35:42 +00:00
parent de51f61584
commit 9ec81d1673
3 changed files with 19 additions and 97 deletions

View File

@ -7,16 +7,11 @@
#include <string.h>
#include "debugtools.h"
#include "callback.h"
#include "builtin16.h"
#include "windef.h"
#include "wingdi.h"
#include "winbase.h"
#include "winuser.h"
#include "wine/winbase16.h"
DEFAULT_DEBUG_CHANNEL(event);
#include "pshpack1.h"
typedef struct _MOUSEINFO
{
@ -32,11 +27,7 @@ typedef struct _MOUSEINFO
} MOUSEINFO, *LPMOUSEINFO;
#include "poppack.h"
/**********************************************************************/
typedef VOID CALLBACK (*LPMOUSE_EVENT_PROC)(DWORD,DWORD,DWORD,DWORD,DWORD);
static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
static FARPROC16 DefMouseEventProc;
/***********************************************************************
* Inquire (MOUSE.1)
@ -56,34 +47,12 @@ WORD WINAPI MOUSE_Inquire(LPMOUSEINFO 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)
*/
VOID WINAPI MOUSE_Enable( FARPROC16 proc )
{
THUNK_Free( (FARPROC)DefMouseEventProc );
DefMouseEventProc = (LPMOUSE_EVENT_PROC)THUNK_Alloc( proc, (RELAY)MOUSE_CallMouseEventProc );
DefMouseEventProc = proc;
}
/***********************************************************************
@ -91,6 +60,5 @@ VOID WINAPI MOUSE_Enable( FARPROC16 proc )
*/
VOID WINAPI MOUSE_Disable(VOID)
{
THUNK_Free( (FARPROC)DefMouseEventProc );
DefMouseEventProc = 0;
}

View File

@ -20,7 +20,6 @@
#include "winuser.h"
#include "wine/winuser16.h"
#include "wine/winbase16.h"
#include "callback.h"
#include "hook.h"
#include "win.h"
#include "queue.h"
@ -43,7 +42,6 @@ typedef struct
HQUEUE16 ownerQueue; /* 08 Owner queue (0 for system hook) */
HMODULE16 ownerModule; /* 0a Owner module */
WORD flags; /* 0c flags */
HOOKPROC thunk; /* 0e Hook procedure (CallTo16 thunk) */
} HOOKDATA;
#include "poppack.h"
@ -894,20 +892,6 @@ static HHOOK HOOK_SetHook( INT16 id, LPVOID proc, INT type,
data->ownerModule = hModule;
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 */
if (hQueue)
@ -969,9 +953,6 @@ static BOOL HOOK_RemoveHook( HANDLE16 hook )
if (!*prevHook) return FALSE;
*prevHook = data->next;
if ( (data->flags & HOOK_MAPTYPE) == HOOK_WIN16 )
THUNK_Free( (FARPROC)data->thunk );
USER_HEAP_FREE( hook );
return TRUE;
}
@ -1031,16 +1012,18 @@ static LRESULT HOOK_CallHook( HANDLE16 hook, INT fromtype, INT code,
/* Suspend window structure locks before calling user code */
iWndsLocks = WIN_SuspendWndsLock();
ret = data->thunk(code, wParam, lParam);
/* Grrr. While the hook procedure is supposed to have an LRESULT return
value even in Win16, it seems that for those hook types where the
return value is interpreted as BOOL, Windows doesn't actually check
the HIWORD ... Some buggy Win16 programs, notably WINFILE, rely on
that, because they neglect to clear DX ... */
if ( (data->flags & HOOK_MAPTYPE) == HOOK_WIN16
&& data->id != WH_JOURNALPLAYBACK )
ret = LOWORD( ret );
if ((data->flags & HOOK_MAPTYPE) == HOOK_WIN16)
{
ret = HOOK_CallTo16_long_wwl( data->proc, code, wParam, lParam );
/* Grrr. While the hook procedure is supposed to have an LRESULT return
value even in Win16, it seems that for those hook types where the
return value is interpreted as BOOL, Windows doesn't actually check
the HIWORD ... Some buggy Win16 programs, notably WINFILE, rely on
that, because they neglect to clear DX ... */
if (data->id != WH_JOURNALPLAYBACK) ret = LOWORD( ret );
}
else
ret = data->proc(code, wParam, lParam);
WIN_RestoreWndsLock(iWndsLocks);

View File

@ -20,8 +20,6 @@
#include "win.h"
#include "user.h"
#include "message.h"
#include "callback.h"
#include "builtin16.h"
#include "debugtools.h"
#include "winerror.h"
@ -38,33 +36,9 @@ typedef struct _KBINFO
} KBINFO, *LPKBINFO;
#include "poppack.h"
/**********************************************************************/
typedef VOID CALLBACK (*LPKEYBD_EVENT_PROC)(BYTE,BYTE,DWORD,DWORD);
static LPKEYBD_EVENT_PROC DefKeybEventProc;
static FARPROC16 DefKeybEventProc;
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)
*/
@ -84,8 +58,7 @@ WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
*/
VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
{
if (DefKeybEventProc) THUNK_Free( (FARPROC)DefKeybEventProc );
DefKeybEventProc = (LPKEYBD_EVENT_PROC)THUNK_Alloc( proc, (RELAY)KEYBOARD_CallKeybdEventProc );
DefKeybEventProc = proc;
pKeyStateTable = lpKeyState;
memset( lpKeyState, 0, 256 ); /* all states to false */
@ -96,10 +69,8 @@ VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
*/
VOID WINAPI KEYBOARD_Disable(VOID)
{
THUNK_Free( (FARPROC)DefKeybEventProc );
DefKeybEventProc = NULL;
pKeyStateTable = NULL;
DefKeybEventProc = NULL;
pKeyStateTable = NULL;
}