From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user.exe16/message.c | 14 +++++--------- dlls/win32u/message.c | 13 +++++++++---- include/ntuser.h | 6 ++++++ 3 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index 227a8c114b0..0334aba28e4 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -2593,15 +2593,11 @@ static NTSTATUS WINAPI User16CallFreeIcon( void *args, ULONG size )
static NTSTATUS WINAPI User16ThunkLock( void *args, ULONG size ) { - DWORD *param = args; - if (size != sizeof(DWORD)) - { - DWORD lock; - ReleaseThunkLock( &lock ); - return NtCallbackReturn( &lock, sizeof(lock), STATUS_SUCCESS ); - } - RestoreThunkLock( *param ); - return STATUS_SUCCESS; + const struct thunk_lock_params *params = args; + DWORD locks = params->locks; + if (params->restore) RestoreThunkLock( locks ); + else ReleaseThunkLock( &locks ); + return NtCallbackReturn( &locks, sizeof(locks), STATUS_SUCCESS ); }
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 73c15defb04..faed9182d4f 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -3049,15 +3049,20 @@ static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout /* wait for message or signaled handle */ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags ) { + struct thunk_lock_params params = {0}; LARGE_INTEGER time; - DWORD ret, lock = 0; + DWORD ret; void *ret_ptr; ULONG ret_len;
if (enable_thunk_lock) { - if (!KeUserModeCallback( NtUserThunkLock, NULL, 0, &ret_ptr, &ret_len ) && ret_len == sizeof(lock)) - lock = *(DWORD *)ret_ptr; + if (!KeUserModeCallback( NtUserThunkLock, ¶ms, sizeof(params), &ret_ptr, &ret_len ) && + ret_len == sizeof(params.locks)) + { + params.locks = *(DWORD *)ret_ptr; + params.restore = TRUE; + } }
if (user_driver->pProcessEvents( mask )) ret = count - 1; @@ -3077,7 +3082,7 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW if (ret == count - 1) get_user_thread_info()->last_driver_time = NtGetTickCount();
if (enable_thunk_lock) - KeUserModeCallback( NtUserThunkLock, &lock, sizeof(lock), &ret_ptr, &ret_len ); + KeUserModeCallback( NtUserThunkLock, ¶ms, sizeof(params), &ret_ptr, &ret_len );
return ret; } diff --git a/include/ntuser.h b/include/ntuser.h index b132a1027b5..6a6c344e484 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -937,6 +937,12 @@ static inline WORD NtUserEnableDC( HDC hdc ) return NtUserCallOneParam( HandleToUlong(hdc), NtUserCallOneParam_EnableDC ); }
+struct thunk_lock_params +{ + BOOL restore; + DWORD locks; +}; + static inline void NtUserEnableThunkLock( BOOL enable ) { NtUserCallOneParam( enable, NtUserCallOneParam_EnableThunkLock );