Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
caad1672
Commit
caad1672
authored
Aug 16, 2022
by
Jacek Caban
Committed by
Alexandre Julliard
Aug 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32u: Use a client copy of windows hook lparam when calling hook procs.
Instead of leaking kernel pointers.
parent
f48f5155
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
157 additions
and
55 deletions
+157
-55
hook.c
dlls/user32/hook.c
+36
-2
user_private.h
dlls/user32/user_private.h
+1
-1
defwnd.c
dlls/win32u/defwnd.c
+3
-3
hook.c
dlls/win32u/hook.c
+91
-25
input.c
dlls/win32u/input.c
+3
-3
message.c
dlls/win32u/message.c
+15
-13
win32u.c
dlls/win32u/tests/win32u.c
+0
-1
win32u_private.h
dlls/win32u/win32u_private.h
+2
-1
window.c
dlls/win32u/window.c
+5
-5
ntuser.h
include/ntuser.h
+1
-1
No files found.
dlls/user32/hook.c
View file @
caad1672
...
...
@@ -439,18 +439,52 @@ BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params,
return
TRUE
;
}
BOOL
WINAPI
User32CallWindowsHook
(
const
struct
win_hook_params
*
params
,
ULONG
size
)
BOOL
WINAPI
User32CallWindowsHook
(
struct
win_hook_params
*
params
,
ULONG
size
)
{
HOOKPROC
proc
=
params
->
proc
;
const
WCHAR
*
module
=
NULL
;
HMODULE
free_module
=
0
;
void
*
ret_lparam
=
NULL
;
CBT_CREATEWNDW
cbtc
;
UINT
ret_lparam_size
=
0
;
LRESULT
ret
;
if
(
params
->
module
[
0
]
&&
!
(
proc
=
get_hook_proc
(
proc
,
params
->
module
,
&
free_module
)))
return
FALSE
;
if
(
size
>
sizeof
(
*
params
)
+
params
->
lparam_size
)
module
=
(
const
WCHAR
*
)((
const
char
*
)(
params
+
1
)
+
params
->
lparam_size
);
if
(
params
->
lparam_size
)
{
ret_lparam
=
(
void
*
)
params
->
lparam
;
ret_lparam_size
=
params
->
lparam_size
;
params
->
lparam
=
(
LPARAM
)(
params
+
1
);
if
(
params
->
id
==
WH_CBT
&&
params
->
code
==
HCBT_CREATEWND
)
{
CREATESTRUCTW
*
cs
=
(
CREATESTRUCTW
*
)
params
->
lparam
;
const
WCHAR
*
ptr
=
(
const
WCHAR
*
)(
cs
+
1
);
if
(
!
IS_INTRESOURCE
(
cs
->
lpszName
))
{
cs
->
lpszName
=
ptr
;
ptr
+=
wcslen
(
ptr
)
+
1
;
}
if
(
!
IS_INTRESOURCE
(
cs
->
lpszClass
))
cs
->
lpszClass
=
ptr
;
cbtc
.
hwndInsertAfter
=
HWND_TOP
;
cbtc
.
lpcs
=
cs
;
params
->
lparam
=
(
LPARAM
)
&
cbtc
;
ret_lparam_size
=
sizeof
(
*
cs
);
}
}
if
(
module
&&
!
(
proc
=
get_hook_proc
(
proc
,
module
,
&
free_module
)))
return
FALSE
;
ret
=
call_hook_proc
(
proc
,
params
->
id
,
params
->
code
,
params
->
wparam
,
params
->
lparam
,
params
->
prev_unicode
,
params
->
next_unicode
);
if
(
free_module
)
FreeLibrary
(
free_module
);
if
(
ret_lparam
)
memcpy
(
ret_lparam
,
params
+
1
,
ret_lparam_size
);
else
if
(
ret_lparam_size
)
NtCallbackReturn
(
params
+
1
,
ret_lparam_size
,
ret
);
return
ret
;
}
...
...
dlls/user32/user_private.h
View file @
caad1672
...
...
@@ -83,7 +83,7 @@ BOOL WINAPI User32CallEnumDisplayMonitor( struct enum_display_monitor_params *pa
BOOL
WINAPI
User32CallSendAsyncCallback
(
const
struct
send_async_params
*
params
,
ULONG
size
);
BOOL
WINAPI
User32CallWinEventHook
(
const
struct
win_event_hook_params
*
params
,
ULONG
size
);
BOOL
WINAPI
User32CallWindowProc
(
struct
win_proc_params
*
params
,
ULONG
size
);
BOOL
WINAPI
User32CallWindowsHook
(
const
struct
win_hook_params
*
params
,
ULONG
size
);
BOOL
WINAPI
User32CallWindowsHook
(
struct
win_hook_params
*
params
,
ULONG
size
);
BOOL
WINAPI
User32InitBuiltinClasses
(
const
struct
win_hook_params
*
params
,
ULONG
size
);
/* message spy definitions */
...
...
dlls/win32u/defwnd.c
View file @
caad1672
...
...
@@ -883,7 +883,7 @@ static void sys_command_size_move( HWND hwnd, WPARAM wparam )
NtUserReleaseDC
(
parent
,
hdc
);
if
(
parent
)
map_window_points
(
0
,
parent
,
(
POINT
*
)
&
sizing_rect
,
2
,
get_thread_dpi
()
);
if
(
call_hooks
(
WH_CBT
,
HCBT_MOVESIZE
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
&
sizing_rect
))
if
(
call_hooks
(
WH_CBT
,
HCBT_MOVESIZE
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
&
sizing_rect
,
sizeof
(
sizing_rect
)
))
moved
=
FALSE
;
send_message
(
hwnd
,
WM_EXITSIZEMOVE
,
0
,
0
);
...
...
@@ -950,7 +950,7 @@ static LRESULT handle_sys_command( HWND hwnd, WPARAM wparam, LPARAM lparam )
if
(
!
is_window_enabled
(
hwnd
))
return
0
;
if
(
call_hooks
(
WH_CBT
,
HCBT_SYSCOMMAND
,
wparam
,
lparam
))
if
(
call_hooks
(
WH_CBT
,
HCBT_SYSCOMMAND
,
wparam
,
lparam
,
0
))
return
0
;
if
(
!
user_driver
->
pSysCommand
(
hwnd
,
wparam
,
lparam
))
...
...
@@ -2811,7 +2811,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
{
HWND
parent
=
get_parent
(
hwnd
);
if
(
!
parent
)
call_hooks
(
WH_SHELL
,
HSHELL_APPCOMMAND
,
wparam
,
lparam
);
call_hooks
(
WH_SHELL
,
HSHELL_APPCOMMAND
,
wparam
,
lparam
,
0
);
else
send_message
(
parent
,
msg
,
wparam
,
lparam
);
break
;
...
...
dlls/win32u/hook.c
View file @
caad1672
...
...
@@ -179,8 +179,8 @@ BOOL WINAPI NtUserCallMsgFilter( MSG *msg, INT code )
{
/* FIXME: We should use NtCallbackReturn instead of passing (potentially kernel) pointer
* like that, but we need to consequently use syscall thunks first for that to work. */
if
(
call_hooks
(
WH_SYSMSGFILTER
,
code
,
0
,
(
LPARAM
)
msg
))
return
TRUE
;
return
call_hooks
(
WH_MSGFILTER
,
code
,
0
,
(
LPARAM
)
msg
);
if
(
call_hooks
(
WH_SYSMSGFILTER
,
code
,
0
,
(
LPARAM
)
msg
,
sizeof
(
*
msg
)
))
return
TRUE
;
return
call_hooks
(
WH_MSGFILTER
,
code
,
0
,
(
LPARAM
)
msg
,
sizeof
(
*
msg
)
);
}
static
UINT
get_ll_hook_timeout
(
void
)
...
...
@@ -195,7 +195,7 @@ static UINT get_ll_hook_timeout(void)
* Call hook either in current thread or send message to the destination
* thread.
*/
static
LRESULT
call_hook
(
struct
win_hook_params
*
info
)
static
LRESULT
call_hook
(
struct
win_hook_params
*
info
,
const
WCHAR
*
module
)
{
DWORD_PTR
ret
=
0
;
...
...
@@ -231,10 +231,70 @@ static LRESULT call_hook( struct win_hook_params *info )
struct
user_thread_info
*
thread_info
=
get_user_thread_info
();
HHOOK
prev
=
thread_info
->
hook
;
BOOL
prev_unicode
=
thread_info
->
hook_unicode
;
size_t
len
=
lstrlenW
(
info
->
module
);
struct
win_hook_params
*
params
=
info
;
ULONG
size
=
sizeof
(
*
params
);
ULONG
lparam_ret_size
=
params
->
lparam_size
;
CREATESTRUCTW
*
cs
=
NULL
;
void
*
ret_ptr
;
ULONG
ret_len
;
if
(
params
->
lparam_size
)
{
lparam_ret_size
=
params
->
lparam_size
;
if
(
params
->
id
==
WH_CBT
&&
params
->
code
==
HCBT_CREATEWND
)
{
cs
=
((
CBT_CREATEWNDW
*
)
params
->
lparam
)
->
lpcs
;
params
->
lparam
=
0
;
lparam_ret_size
=
0
;
params
->
lparam_size
=
sizeof
(
*
cs
);
if
(
!
IS_INTRESOURCE
(
cs
->
lpszName
))
params
->
lparam_size
+=
(
wcslen
(
cs
->
lpszName
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
!
IS_INTRESOURCE
(
cs
->
lpszClass
))
params
->
lparam_size
+=
(
wcslen
(
cs
->
lpszClass
)
+
1
)
*
sizeof
(
WCHAR
);
}
size
+=
params
->
lparam_size
;
}
if
(
module
&&
module
[
0
])
size
+=
(
lstrlenW
(
module
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
size
!=
sizeof
(
*
params
))
{
if
(
!
(
params
=
malloc
(
size
)))
return
0
;
*
params
=
*
info
;
}
if
(
params
->
lparam_size
)
{
if
(
cs
)
{
CREATESTRUCTW
*
params_cs
=
(
CREATESTRUCTW
*
)(
params
+
1
);
WCHAR
*
ptr
=
(
WCHAR
*
)(
params_cs
+
1
);
const
void
*
inline_ptr
=
(
void
*
)
0xffffffff
;
*
params_cs
=
*
cs
;
if
(
!
IS_INTRESOURCE
(
cs
->
lpszName
))
{
UINT
len
=
wcslen
(
cs
->
lpszName
)
+
1
;
memcpy
(
ptr
,
cs
->
lpszName
,
len
*
sizeof
(
WCHAR
)
);
ptr
+=
len
;
params_cs
->
lpszName
=
inline_ptr
;
}
if
(
!
IS_INTRESOURCE
(
cs
->
lpszClass
))
{
wcscpy
(
ptr
,
cs
->
lpszClass
);
params_cs
->
lpszClass
=
inline_ptr
;
}
}
else
{
memcpy
(
params
+
1
,
(
const
void
*
)
params
->
lparam
,
params
->
lparam_size
);
}
}
if
(
module
&&
module
[
0
])
wcscpy
(
(
WCHAR
*
)((
char
*
)(
params
+
1
)
+
params
->
lparam_size
),
module
);
/*
* Windows protects from stack overflow in recursive hook calls. Different Windows
* allow different depths.
...
...
@@ -246,18 +306,20 @@ static LRESULT call_hook( struct win_hook_params *info )
}
TRACE
(
"calling hook %p %s code %x wp %lx lp %lx module %s
\n
"
,
info
->
proc
,
hook_names
[
info
->
id
-
WH_MINHOOK
],
info
->
code
,
info
->
wparam
,
info
->
lparam
,
debugstr_w
(
info
->
module
)
);
params
->
proc
,
hook_names
[
params
->
id
-
WH_MINHOOK
],
params
->
code
,
params
->
wparam
,
params
->
lparam
,
debugstr_w
(
module
)
);
thread_info
->
hook
=
info
->
handle
;
thread_info
->
hook_unicode
=
info
->
next_unicode
;
thread_info
->
hook
=
params
->
handle
;
thread_info
->
hook_unicode
=
params
->
next_unicode
;
thread_info
->
hook_call_depth
++
;
ret
=
KeUserModeCallback
(
NtUserCallWindowsHook
,
info
,
FIELD_OFFSET
(
struct
win_hook_params
,
module
[
len
+
1
]
),
&
ret_ptr
,
&
ret_len
);
ret
=
KeUserModeCallback
(
NtUserCallWindowsHook
,
params
,
size
,
&
ret_ptr
,
&
ret_len
);
if
(
ret_len
&&
ret_len
==
lparam_ret_size
)
memcpy
(
(
void
*
)
params
->
lparam
,
ret_ptr
,
lparam_ret_size
);
thread_info
->
hook
=
prev
;
thread_info
->
hook_unicode
=
prev_unicode
;
thread_info
->
hook_call_depth
--
;
if
(
params
!=
info
)
free
(
params
);
}
if
(
info
->
id
==
WH_KEYBOARD_LL
||
info
->
id
==
WH_MOUSE_LL
)
...
...
@@ -272,18 +334,19 @@ LRESULT WINAPI NtUserCallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARA
{
struct
user_thread_info
*
thread_info
=
get_user_thread_info
();
struct
win_hook_params
info
;
WCHAR
module
[
MAX_PATH
];
memset
(
&
info
,
0
,
sizeof
(
info
)
-
sizeof
(
info
.
module
)
);
memset
(
&
info
,
0
,
sizeof
(
info
)
);
SERVER_START_REQ
(
get_hook_info
)
{
req
->
handle
=
wine_server_user_handle
(
thread_info
->
hook
);
req
->
get_next
=
1
;
req
->
event
=
EVENT_MIN
;
wine_server_set_reply
(
req
,
info
.
module
,
sizeof
(
info
.
module
)
-
sizeof
(
WCHAR
)
);
wine_server_set_reply
(
req
,
module
,
sizeof
(
module
)
-
sizeof
(
WCHAR
)
);
if
(
!
wine_server_call_err
(
req
))
{
info
.
module
[
wine_server_reply_size
(
req
)
/
sizeof
(
WCHAR
)]
=
0
;
module
[
wine_server_reply_size
(
req
)
/
sizeof
(
WCHAR
)]
=
0
;
info
.
handle
=
wine_server_ptr_handle
(
reply
->
handle
);
info
.
id
=
reply
->
id
;
info
.
pid
=
reply
->
pid
;
...
...
@@ -298,24 +361,25 @@ LRESULT WINAPI NtUserCallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARA
info
.
wparam
=
wparam
;
info
.
lparam
=
lparam
;
info
.
prev_unicode
=
thread_info
->
hook_unicode
;
return
call_hook
(
&
info
);
return
call_hook
(
&
info
,
module
);
}
LRESULT
call_current_hook
(
HHOOK
hhook
,
INT
code
,
WPARAM
wparam
,
LPARAM
lparam
)
{
struct
win_hook_params
info
;
WCHAR
module
[
MAX_PATH
];
memset
(
&
info
,
0
,
sizeof
(
info
)
-
sizeof
(
info
.
module
)
);
memset
(
&
info
,
0
,
sizeof
(
info
)
);
SERVER_START_REQ
(
get_hook_info
)
{
req
->
handle
=
wine_server_user_handle
(
hhook
);
req
->
get_next
=
0
;
req
->
event
=
EVENT_MIN
;
wine_server_set_reply
(
req
,
info
.
module
,
sizeof
(
info
.
module
)
-
sizeof
(
WCHAR
)
);
wine_server_set_reply
(
req
,
module
,
sizeof
(
module
)
);
if
(
!
wine_server_call_err
(
req
))
{
info
.
module
[
wine_server_reply_size
(
req
)
/
sizeof
(
WCHAR
)]
=
0
;
module
[
wine_server_reply_size
(
req
)
/
sizeof
(
WCHAR
)]
=
0
;
info
.
handle
=
wine_server_ptr_handle
(
reply
->
handle
);
info
.
id
=
reply
->
id
;
info
.
pid
=
reply
->
pid
;
...
...
@@ -330,13 +394,14 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam )
info
.
wparam
=
wparam
;
info
.
lparam
=
lparam
;
info
.
prev_unicode
=
TRUE
;
/* assume Unicode for this function */
return
call_hook
(
&
info
);
return
call_hook
(
&
info
,
module
);
}
LRESULT
call_hooks
(
INT
id
,
INT
code
,
WPARAM
wparam
,
LPARAM
lparam
)
LRESULT
call_hooks
(
INT
id
,
INT
code
,
WPARAM
wparam
,
LPARAM
lparam
,
size_t
lparam_size
)
{
struct
user_thread_info
*
thread_info
=
get_user_thread_info
();
struct
win_hook_params
info
;
WCHAR
module
[
MAX_PATH
];
DWORD_PTR
ret
;
user_check_not_lock
();
...
...
@@ -347,7 +412,7 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam )
return
0
;
}
memset
(
&
info
,
0
,
sizeof
(
info
)
-
sizeof
(
info
.
module
)
);
memset
(
&
info
,
0
,
sizeof
(
info
)
);
info
.
prev_unicode
=
TRUE
;
info
.
id
=
id
;
...
...
@@ -355,10 +420,10 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam )
{
req
->
id
=
info
.
id
;
req
->
event
=
EVENT_MIN
;
wine_server_set_reply
(
req
,
info
.
module
,
sizeof
(
info
.
module
)
-
sizeof
(
WCHAR
)
);
wine_server_set_reply
(
req
,
module
,
sizeof
(
module
)
-
sizeof
(
WCHAR
)
);
if
(
!
wine_server_call
(
req
))
{
info
.
module
[
wine_server_reply_size
(
req
)
/
sizeof
(
WCHAR
)]
=
0
;
module
[
wine_server_reply_size
(
req
)
/
sizeof
(
WCHAR
)]
=
0
;
info
.
handle
=
wine_server_ptr_handle
(
reply
->
handle
);
info
.
pid
=
reply
->
pid
;
info
.
tid
=
reply
->
tid
;
...
...
@@ -373,7 +438,8 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam )
info
.
code
=
code
;
info
.
wparam
=
wparam
;
info
.
lparam
=
lparam
;
ret
=
call_hook
(
&
info
);
info
.
lparam_size
=
lparam_size
;
ret
=
call_hook
(
&
info
,
module
);
SERVER_START_REQ
(
finish_hook_chain
)
{
...
...
@@ -514,7 +580,7 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c
info
.
time
=
NtGetTickCount
();
KeUserModeCallback
(
NtUserCallWinEventHook
,
&
info
,
FIELD_OFFSET
(
struct
win_hook_params
,
module
[
lstrlenW
(
info
.
module
)
+
1
]
),
FIELD_OFFSET
(
struct
win_
event_
hook_params
,
module
[
lstrlenW
(
info
.
module
)
+
1
]
),
&
ret_ptr
,
&
ret_len
);
SERVER_START_REQ
(
get_hook_info
)
...
...
dlls/win32u/input.c
View file @
caad1672
...
...
@@ -1611,7 +1611,7 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
/* call CBT hook chain */
cbt
.
fMouse
=
mouse
;
cbt
.
hWndActive
=
previous
;
if
(
call_hooks
(
WH_CBT
,
HCBT_ACTIVATE
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
&
cbt
))
return
FALSE
;
if
(
call_hooks
(
WH_CBT
,
HCBT_ACTIVATE
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
&
cbt
,
sizeof
(
cbt
)
))
return
FALSE
;
if
(
is_window
(
previous
))
{
...
...
@@ -1763,7 +1763,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd )
}
/* call hooks */
if
(
call_hooks
(
WH_CBT
,
HCBT_SETFOCUS
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
previous
))
return
0
;
if
(
call_hooks
(
WH_CBT
,
HCBT_SETFOCUS
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
previous
,
0
))
return
0
;
/* activate hwndTop if needed. */
if
(
hwndTop
!=
get_active_window
())
...
...
@@ -1778,7 +1778,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd )
else
/* NULL hwnd passed in */
{
if
(
!
previous
)
return
0
;
/* nothing to do */
if
(
call_hooks
(
WH_CBT
,
HCBT_SETFOCUS
,
0
,
(
LPARAM
)
previous
))
return
0
;
if
(
call_hooks
(
WH_CBT
,
HCBT_SETFOCUS
,
0
,
(
LPARAM
)
previous
,
0
))
return
0
;
}
/* change focus and send messages */
...
...
dlls/win32u/message.c
View file @
caad1672
...
...
@@ -1365,7 +1365,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
cwp
.
wParam
=
wparam
;
cwp
.
message
=
msg
;
cwp
.
hwnd
=
params
->
hwnd
;
call_hooks
(
WH_CALLWNDPROC
,
HC_ACTION
,
same_thread
,
(
LPARAM
)
&
cwp
);
call_hooks
(
WH_CALLWNDPROC
,
HC_ACTION
,
same_thread
,
(
LPARAM
)
&
cwp
,
sizeof
(
cwp
)
);
dispatch_win_proc_params
(
params
,
sizeof
(
*
params
)
+
size
);
if
(
params
!=
&
p
)
free
(
params
);
...
...
@@ -1376,7 +1376,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
cwpret
.
wParam
=
wparam
;
cwpret
.
message
=
msg
;
cwpret
.
hwnd
=
params
->
hwnd
;
call_hooks
(
WH_CALLWNDPROCRET
,
HC_ACTION
,
same_thread
,
(
LPARAM
)
&
cwpret
);
call_hooks
(
WH_CALLWNDPROCRET
,
HC_ACTION
,
same_thread
,
(
LPARAM
)
&
cwpret
,
sizeof
(
cwpret
)
);
return
result
;
}
...
...
@@ -1483,7 +1483,7 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter,
event
.
paramL
=
(
msg
->
wParam
&
0xFF
)
|
(
HIWORD
(
msg
->
lParam
)
<<
8
);
event
.
paramH
=
msg
->
lParam
&
0x7FFF
;
if
(
HIWORD
(
msg
->
lParam
)
&
0x0100
)
event
.
paramH
|=
0x8000
;
/* special_key - bit */
call_hooks
(
WH_JOURNALRECORD
,
HC_ACTION
,
0
,
(
LPARAM
)
&
event
);
call_hooks
(
WH_JOURNALRECORD
,
HC_ACTION
,
0
,
(
LPARAM
)
&
event
,
sizeof
(
event
)
);
/* check message filters */
if
(
msg
->
message
<
first
||
msg
->
message
>
last
)
return
FALSE
;
...
...
@@ -1516,10 +1516,10 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter,
}
if
(
call_hooks
(
WH_KEYBOARD
,
remove
?
HC_ACTION
:
HC_NOREMOVE
,
LOWORD
(
msg
->
wParam
),
msg
->
lParam
))
LOWORD
(
msg
->
wParam
),
msg
->
lParam
,
0
))
{
/* skip this message */
call_hooks
(
WH_CBT
,
HCBT_KEYSKIPPED
,
LOWORD
(
msg
->
wParam
),
msg
->
lParam
);
call_hooks
(
WH_CBT
,
HCBT_KEYSKIPPED
,
LOWORD
(
msg
->
wParam
),
msg
->
lParam
,
0
);
accept_hardware_message
(
hw_id
);
return
FALSE
;
}
...
...
@@ -1591,7 +1591,7 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
event
.
hwnd
=
msg
->
hwnd
;
event
.
paramL
=
msg
->
pt
.
x
;
event
.
paramH
=
msg
->
pt
.
y
;
call_hooks
(
WH_JOURNALRECORD
,
HC_ACTION
,
0
,
(
LPARAM
)
&
event
);
call_hooks
(
WH_JOURNALRECORD
,
HC_ACTION
,
0
,
(
LPARAM
)
&
event
,
sizeof
(
event
)
);
if
(
!
check_hwnd_filter
(
msg
,
hwnd_filter
))
return
FALSE
;
...
...
@@ -1665,14 +1665,14 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
hook
.
wHitTestCode
=
hittest
;
hook
.
dwExtraInfo
=
extra_info
;
hook
.
mouseData
=
msg
->
wParam
;
if
(
call_hooks
(
WH_MOUSE
,
remove
?
HC_ACTION
:
HC_NOREMOVE
,
message
,
(
LPARAM
)
&
hook
))
if
(
call_hooks
(
WH_MOUSE
,
remove
?
HC_ACTION
:
HC_NOREMOVE
,
message
,
(
LPARAM
)
&
hook
,
sizeof
(
hook
)
))
{
hook
.
pt
=
msg
->
pt
;
hook
.
hwnd
=
msg
->
hwnd
;
hook
.
wHitTestCode
=
hittest
;
hook
.
dwExtraInfo
=
extra_info
;
hook
.
mouseData
=
msg
->
wParam
;
call_hooks
(
WH_CBT
,
HCBT_CLICKSKIPPED
,
message
,
(
LPARAM
)
&
hook
);
call_hooks
(
WH_CBT
,
HCBT_CLICKSKIPPED
,
message
,
(
LPARAM
)
&
hook
,
sizeof
(
hook
)
);
accept_hardware_message
(
hw_id
);
return
FALSE
;
}
...
...
@@ -1896,7 +1896,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
memcpy
(
params
.
module
,
&
msg_data
->
winevent
+
1
,
size
);
}
params
.
module
[
size
/
sizeof
(
WCHAR
)]
=
0
;
size
=
FIELD_OFFSET
(
struct
win_hook_params
,
module
[
size
/
sizeof
(
WCHAR
)
+
1
]
);
size
=
FIELD_OFFSET
(
struct
win_
event_
hook_params
,
module
[
size
/
sizeof
(
WCHAR
)
+
1
]
);
params
.
handle
=
wine_server_ptr_handle
(
msg_data
->
winevent
.
hook
);
params
.
event
=
info
.
msg
.
message
;
...
...
@@ -1923,7 +1923,8 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
hook
.
dwExtraInfo
=
msg_data
->
hardware
.
info
;
TRACE
(
"calling keyboard LL hook vk %x scan %x flags %x time %u info %lx
\n
"
,
hook
.
vkCode
,
hook
.
scanCode
,
hook
.
flags
,
hook
.
time
,
hook
.
dwExtraInfo
);
result
=
call_hooks
(
WH_KEYBOARD_LL
,
HC_ACTION
,
info
.
msg
.
wParam
,
(
LPARAM
)
&
hook
);
result
=
call_hooks
(
WH_KEYBOARD_LL
,
HC_ACTION
,
info
.
msg
.
wParam
,
(
LPARAM
)
&
hook
,
sizeof
(
hook
)
);
}
else
if
(
info
.
msg
.
message
==
WH_MOUSE_LL
&&
size
>=
sizeof
(
msg_data
->
hardware
))
{
...
...
@@ -1936,7 +1937,8 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
hook
.
dwExtraInfo
=
msg_data
->
hardware
.
info
;
TRACE
(
"calling mouse LL hook pos %d,%d data %x flags %x time %u info %lx
\n
"
,
hook
.
pt
.
x
,
hook
.
pt
.
y
,
hook
.
mouseData
,
hook
.
flags
,
hook
.
time
,
hook
.
dwExtraInfo
);
result
=
call_hooks
(
WH_MOUSE_LL
,
HC_ACTION
,
info
.
msg
.
wParam
,
(
LPARAM
)
&
hook
);
result
=
call_hooks
(
WH_MOUSE_LL
,
HC_ACTION
,
info
.
msg
.
wParam
,
(
LPARAM
)
&
hook
,
sizeof
(
hook
)
);
}
reply_message
(
&
info
,
result
,
&
info
.
msg
);
continue
;
...
...
@@ -1966,7 +1968,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
thread_info
->
client_info
.
message_time
=
info
.
msg
.
time
;
thread_info
->
client_info
.
message_extra
=
msg_data
->
hardware
.
info
;
free
(
buffer
);
call_hooks
(
WH_GETMESSAGE
,
HC_ACTION
,
flags
&
PM_REMOVE
,
(
LPARAM
)
msg
);
call_hooks
(
WH_GETMESSAGE
,
HC_ACTION
,
flags
&
PM_REMOVE
,
(
LPARAM
)
msg
,
sizeof
(
*
msg
)
);
return
1
;
}
continue
;
...
...
@@ -2019,7 +2021,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
thread_info
->
client_info
.
message_extra
=
0
;
thread_info
->
client_info
.
msg_source
=
msg_source_unavailable
;
free
(
buffer
);
call_hooks
(
WH_GETMESSAGE
,
HC_ACTION
,
flags
&
PM_REMOVE
,
(
LPARAM
)
msg
);
call_hooks
(
WH_GETMESSAGE
,
HC_ACTION
,
flags
&
PM_REMOVE
,
(
LPARAM
)
msg
,
sizeof
(
*
msg
)
);
return
1
;
}
...
...
dlls/win32u/tests/win32u.c
View file @
caad1672
...
...
@@ -618,7 +618,6 @@ static void test_message_filter(void)
msg
.
lParam
=
20
;
ret
=
NtUserCallMsgFilter
(
&
msg
,
100
);
ok
(
!
ret
,
"CallMsgFilterW returned: %x
\n
"
,
ret
);
todo_wine
ok
(
msg_ptr
!=
&
msg
,
"our ptr was passed directly to hook
\n
"
);
if
(
sizeof
(
void
*
)
==
8
)
/* on some Windows versions, msg is not modified on wow64 */
...
...
dlls/win32u/win32u_private.h
View file @
caad1672
...
...
@@ -251,7 +251,8 @@ extern LRESULT handle_nc_hit_test( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
/* hook.c */
extern
LRESULT
call_current_hook
(
HHOOK
hhook
,
INT
code
,
WPARAM
wparam
,
LPARAM
lparam
)
DECLSPEC_HIDDEN
;
extern
LRESULT
call_hooks
(
INT
id
,
INT
code
,
WPARAM
wparam
,
LPARAM
lparam
)
DECLSPEC_HIDDEN
;
extern
LRESULT
call_hooks
(
INT
id
,
INT
code
,
WPARAM
wparam
,
LPARAM
lparam
,
size_t
lparam_size
)
DECLSPEC_HIDDEN
;
extern
BOOL
is_hooked
(
INT
id
)
DECLSPEC_HIDDEN
;
extern
BOOL
unhook_windows_hook
(
INT
id
,
HOOKPROC
proc
)
DECLSPEC_HIDDEN
;
...
...
dlls/win32u/window.c
View file @
caad1672
...
...
@@ -4040,7 +4040,7 @@ static UINT window_min_maximize( HWND hwnd, UINT cmd, RECT *rect )
wpl
.
length
=
sizeof
(
wpl
);
NtUserGetWindowPlacement
(
hwnd
,
&
wpl
);
if
(
call_hooks
(
WH_CBT
,
HCBT_MINMAX
,
(
WPARAM
)
hwnd
,
cmd
))
if
(
call_hooks
(
WH_CBT
,
HCBT_MINMAX
,
(
WPARAM
)
hwnd
,
cmd
,
0
))
return
SWP_NOSIZE
|
SWP_NOMOVE
;
if
(
is_iconic
(
hwnd
))
...
...
@@ -4752,7 +4752,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd )
TRACE
(
"(%p)
\n
"
,
hwnd
);
if
(
call_hooks
(
WH_CBT
,
HCBT_DESTROYWND
,
(
WPARAM
)
hwnd
,
0
))
return
FALSE
;
if
(
call_hooks
(
WH_CBT
,
HCBT_DESTROYWND
,
(
WPARAM
)
hwnd
,
0
,
0
))
return
FALSE
;
if
(
is_menu_active
()
==
hwnd
)
NtUserEndMenu
();
...
...
@@ -4765,7 +4765,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd )
}
else
if
(
!
get_window_relative
(
hwnd
,
GW_OWNER
))
{
call_hooks
(
WH_SHELL
,
HSHELL_WINDOWDESTROYED
,
(
WPARAM
)
hwnd
,
0
);
call_hooks
(
WH_SHELL
,
HSHELL_WINDOWDESTROYED
,
(
WPARAM
)
hwnd
,
0
,
0
);
/* FIXME: clean up palette - see "Internals" p.352 */
}
...
...
@@ -5154,7 +5154,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
release_win_ptr
(
win
);
cbtc
.
hwndInsertAfter
=
HWND_TOP
;
cbtc
.
lpcs
=
&
cs
;
if
(
call_hooks
(
WH_CBT
,
HCBT_CREATEWND
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
&
cbtc
))
if
(
call_hooks
(
WH_CBT
,
HCBT_CREATEWND
,
(
WPARAM
)
hwnd
,
(
LPARAM
)
&
cbtc
,
sizeof
(
cbtc
)
))
{
free_window_handle
(
hwnd
);
return
0
;
...
...
@@ -5334,7 +5334,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
/* Call WH_SHELL hook */
if
(
!
(
get_window_long
(
hwnd
,
GWL_STYLE
)
&
WS_CHILD
)
&&
!
get_window_relative
(
hwnd
,
GW_OWNER
))
call_hooks
(
WH_SHELL
,
HSHELL_WINDOWCREATED
,
(
WPARAM
)
hwnd
,
0
);
call_hooks
(
WH_SHELL
,
HSHELL_WINDOWCREATED
,
(
WPARAM
)
hwnd
,
0
,
0
);
TRACE
(
"created window %p
\n
"
,
hwnd
);
SetThreadDpiAwarenessContext
(
context
);
...
...
include/ntuser.h
View file @
caad1672
...
...
@@ -164,9 +164,9 @@ struct win_hook_params
int
code
;
WPARAM
wparam
;
LPARAM
lparam
;
UINT
lparam_size
;
BOOL
prev_unicode
;
BOOL
next_unicode
;
WCHAR
module
[
MAX_PATH
];
};
/* NtUserCopyImage params */
...
...
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