Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f4edf237
Commit
f4edf237
authored
Sep 20, 1999
by
Ulrich Weigand
Committed by
Alexandre Julliard
Sep 20, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Windows hook proc thunk management simplified.
parent
2dec1ba4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
45 deletions
+58
-45
shell.c
dlls/shell32/shell.c
+26
-22
user.spec
if1632/user.spec
+4
-4
hook.h
include/hook.h
+0
-2
.cvsignore
windows/.cvsignore
+1
-0
Makefile.in
windows/Makefile.in
+2
-0
hook.c
windows/hook.c
+25
-17
No files found.
dlls/shell32/shell.c
View file @
f4edf237
...
...
@@ -1154,30 +1154,34 @@ LRESULT WINAPI ShellHookProc16(INT16 code, WPARAM16 wParam, LPARAM lParam)
* RegisterShellHook [SHELL.102]
*/
BOOL
WINAPI
RegisterShellHook16
(
HWND16
hWnd
,
UINT16
uAction
)
{
TRACE_
(
shell
)(
"%04x [%u]
\n
"
,
hWnd
,
uAction
);
{
TRACE_
(
shell
)(
"%04x [%u]
\n
"
,
hWnd
,
uAction
);
switch
(
uAction
)
{
case
2
:
/* register hWnd as a shell window */
if
(
!
SHELL_hHook
)
{
HMODULE16
hShell
=
GetModuleHandle16
(
"SHELL"
);
SHELL_hHook
=
SetWindowsHookEx16
(
WH_SHELL
,
ShellHookProc16
,
hShell
,
0
);
if
(
SHELL_hHook
)
{
uMsgWndCreated
=
RegisterWindowMessageA
(
lpstrMsgWndCreated
);
uMsgWndDestroyed
=
RegisterWindowMessageA
(
lpstrMsgWndDestroyed
);
uMsgShellActivate
=
RegisterWindowMessageA
(
lpstrMsgShellActivate
);
}
else
WARN_
(
shell
)(
"-- unable to install ShellHookProc()!
\n
"
);
}
if
(
SHELL_hHook
)
return
((
SHELL_hWnd
=
hWnd
)
!=
0
);
break
;
default:
WARN_
(
shell
)(
"-- unknown code %i
\n
"
,
uAction
);
/* just in case */
SHELL_hWnd
=
0
;
{
case
2
:
/* register hWnd as a shell window */
if
(
!
SHELL_hHook
)
{
HMODULE16
hShell
=
GetModuleHandle16
(
"SHELL"
);
HOOKPROC16
hookProc
=
(
HOOKPROC16
)
NE_GetEntryPoint
(
hShell
,
103
);
SHELL_hHook
=
SetWindowsHookEx16
(
WH_SHELL
,
hookProc
,
hShell
,
0
);
if
(
SHELL_hHook
)
{
uMsgWndCreated
=
RegisterWindowMessageA
(
lpstrMsgWndCreated
);
uMsgWndDestroyed
=
RegisterWindowMessageA
(
lpstrMsgWndDestroyed
);
uMsgShellActivate
=
RegisterWindowMessageA
(
lpstrMsgShellActivate
);
}
else
WARN_
(
shell
)(
"-- unable to install ShellHookProc()!
\n
"
);
}
if
(
SHELL_hHook
)
return
((
SHELL_hWnd
=
hWnd
)
!=
0
);
break
;
default:
WARN_
(
shell
)(
"-- unknown code %i
\n
"
,
uAction
);
SHELL_hWnd
=
0
;
/* just in case */
}
return
FALSE
;
}
if1632/user.spec
View file @
f4edf237
...
...
@@ -122,7 +122,7 @@ file user.exe
117 pascal16 WindowFromDC(word) WindowFromDC16
119 pascal GetMessagePos() GetMessagePos
120 pascal GetMessageTime() GetMessageTime
121 pascal SetWindowsHook(s_word segptr)
THUNK_
SetWindowsHook16
121 pascal SetWindowsHook(s_word segptr) SetWindowsHook16
122 pascal CallWindowProc(segptr word word word long) CallWindowProc16
123 pascal16 CallMsgFilter(segptr s_word) CallMsgFilter16
124 pascal16 UpdateWindow(word) UpdateWindow16
...
...
@@ -236,7 +236,7 @@ file user.exe
231 pascal16 GetSystemDebugState() GetSystemDebugState16
232 pascal16 SetWindowPos(word word word word word word word) SetWindowPos16
233 pascal16 SetParent(word word) SetParent16
234 pascal16 UnhookWindowsHook(s_word segptr)
THUNK_
UnhookWindowsHook16
234 pascal16 UnhookWindowsHook(s_word segptr) UnhookWindowsHook16
235 pascal DefHookProc(s_word word long ptr) DefHookProc16
236 pascal16 GetCapture() GetCapture16
237 pascal16 GetUpdateRgn(word word word) GetUpdateRgn16
...
...
@@ -296,8 +296,8 @@ file user.exe
288 pascal GetMessageExtraInfo() GetMessageExtraInfo
289 register keybd_event() WIN16_keybd_event
290 pascal16 RedrawWindow(word ptr word word) RedrawWindow16
291 pascal SetWindowsHookEx(s_word segptr word word)
THUNK_
SetWindowsHookEx16
292 pascal16 UnhookWindowsHookEx(segptr)
THUNK_
UnhookWindowsHookEx16
291 pascal SetWindowsHookEx(s_word segptr word word) SetWindowsHookEx16
292 pascal16 UnhookWindowsHookEx(segptr) UnhookWindowsHookEx16
293 pascal CallNextHookEx(segptr s_word word long) CallNextHookEx16
294 pascal16 LockWindowUpdate(word) LockWindowUpdate16
299 register mouse_event() WIN16_mouse_event
...
...
include/hook.h
View file @
f4edf237
...
...
@@ -18,7 +18,6 @@
/* hook type mask */
#define HOOK_MAPTYPE (HOOK_WIN16 | HOOK_WIN32A | HOOK_WIN32W)
extern
HOOKPROC16
HOOK_GetProc16
(
HHOOK
hhook
);
extern
BOOL
HOOK_IsHooked
(
INT16
id
);
extern
LRESULT
HOOK_CallHooks16
(
INT16
id
,
INT16
code
,
WPARAM16
wParam
,
LPARAM
lParam
);
...
...
@@ -29,6 +28,5 @@ extern LRESULT HOOK_CallHooksW( INT id, INT code, WPARAM wParam,
extern
void
HOOK_FreeModuleHooks
(
HMODULE16
hModule
);
extern
void
HOOK_FreeQueueHooks
(
HQUEUE16
hQueue
);
extern
void
HOOK_ResetQueueHooks
(
HQUEUE16
hQueue
);
extern
HOOKPROC
HOOK_GetProc
(
HHOOK
hook
);
#endif
/* __WINE_HOOK_H */
windows/.cvsignore
View file @
f4edf237
Makefile
hook.glue.c
windows/Makefile.in
View file @
f4edf237
...
...
@@ -41,6 +41,8 @@ C_SRCS = \
winpos.c
\
winproc.c
GLUE
=
hook.c
all
:
$(MODULE).o
@MAKE_RULES@
...
...
windows/hook.c
View file @
f4edf237
...
...
@@ -17,6 +17,7 @@
#include "winuser.h"
#include "wine/winuser16.h"
#include "wine/winbase16.h"
#include "callback.h"
#include "hook.h"
#include "win.h"
#include "queue.h"
...
...
@@ -35,11 +36,12 @@ DEFAULT_DEBUG_CHANNEL(hook)
typedef
struct
{
HANDLE16
next
;
/* 00 Next hook in chain */
HOOKPROC
proc
WINE_PACKED
;
/* 02 Hook procedure
*/
HOOKPROC
proc
;
/* 02 Hook procedure (original)
*/
INT16
id
;
/* 06 Hook id (WH_xxx) */
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"
...
...
@@ -850,6 +852,9 @@ static HANDLE16 HOOK_GetHook( INT16 id, HQUEUE16 hQueue )
*
* Install a given hook.
*/
/* ### start build ### */
extern
LONG
CALLBACK
HOOK_CallTo16_long_wwl
(
FARPROC16
,
WORD
,
WORD
,
LONG
);
/* ### stop build ### */
static
HHOOK
HOOK_SetHook
(
INT16
id
,
LPVOID
proc
,
INT
type
,
HMODULE16
hModule
,
DWORD
dwThreadId
)
{
...
...
@@ -885,6 +890,20 @@ 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
)
...
...
@@ -945,6 +964,10 @@ 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
;
}
...
...
@@ -1004,7 +1027,7 @@ static LRESULT HOOK_CallHook( HANDLE16 hook, INT fromtype, INT code,
/* Suspend window structure locks before calling user code */
iWndsLocks
=
WIN_SuspendWndsLock
();
ret
=
data
->
proc
(
code
,
wParam
,
lParam
);
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
...
...
@@ -1037,21 +1060,6 @@ static LRESULT HOOK_CallHook( HANDLE16 hook, INT fromtype, INT code,
*/
/***********************************************************************
* HOOK_GetProc16
*
* Don't call this unless you are the if1632/thunk.c.
*/
HOOKPROC16
HOOK_GetProc16
(
HHOOK
hhook
)
{
HOOKDATA
*
data
;
if
(
HIWORD
(
hhook
)
!=
HOOK_MAGIC
)
return
NULL
;
if
(
!
(
data
=
(
HOOKDATA
*
)
USER_HEAP_LIN_ADDR
(
LOWORD
(
hhook
)
)))
return
NULL
;
if
((
data
->
flags
&
HOOK_MAPTYPE
)
!=
HOOK_WIN16
)
return
NULL
;
return
(
HOOKPROC16
)
data
->
proc
;
}
/***********************************************************************
* HOOK_IsHooked
*
* Replacement for calling HOOK_GetHook from other modules.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment