win32u: Set user callbacks from user32 DllMain.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2353ef9bd5
commit
e557f48cdf
|
@ -208,6 +208,14 @@ static void dpiaware_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
static const struct user_callbacks user_funcs =
|
||||
{
|
||||
GetDesktopWindow,
|
||||
GetWindowRect,
|
||||
RedrawWindow,
|
||||
SendMessageTimeoutW,
|
||||
WindowFromDC,
|
||||
};
|
||||
|
||||
static const void *kernel_callback_table[NtUserCallCount] =
|
||||
{
|
||||
|
@ -223,6 +231,9 @@ static BOOL process_attach(void)
|
|||
{
|
||||
NtCurrentTeb()->Peb->KernelCallbackTable = kernel_callback_table;
|
||||
|
||||
/* FIXME: should not be needed */
|
||||
NtUserCallOneParam( (UINT_PTR)&user_funcs, NtUserSetCallbacks );
|
||||
|
||||
dpiaware_init();
|
||||
register_desktop_class();
|
||||
|
||||
|
|
|
@ -24,21 +24,13 @@
|
|||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winreg.h"
|
||||
#include "wine/winbase16.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#include "ntgdi_private.h"
|
||||
#include "ntuser_private.h"
|
||||
#include "wine/winbase16.h"
|
||||
#include "wine/list.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
|
|
|
@ -24,6 +24,15 @@
|
|||
|
||||
#include "ntuser.h"
|
||||
|
||||
struct user_callbacks
|
||||
{
|
||||
HWND (WINAPI *pGetDesktopWindow)(void);
|
||||
BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect );
|
||||
BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT );
|
||||
LRESULT (WINAPI *pSendMessageTimeoutW)( HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR );
|
||||
HWND (WINAPI *pWindowFromDC)( HDC );
|
||||
};
|
||||
|
||||
/* this is the structure stored in TEB->Win32ClientInfo */
|
||||
/* no attempt is made to keep the layout compatible with the Windows one */
|
||||
struct user_thread_info
|
||||
|
|
|
@ -27,17 +27,8 @@
|
|||
#pragma makedep unix
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#include "ntgdi_private.h"
|
||||
#include "ntuser_private.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(palette);
|
||||
|
|
|
@ -99,13 +99,8 @@ SOFTWARE.
|
|||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "ntgdi_private.h"
|
||||
#include "ntuser_private.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(region);
|
||||
|
|
|
@ -4544,6 +4544,8 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code )
|
|||
return get_entry( &entry_DESKPATTERN, 256, (WCHAR *)arg );
|
||||
case NtUserIncrementKeyStateCounter:
|
||||
return InterlockedAdd( &global_key_state_counter, arg );
|
||||
case NtUserSetCallbacks:
|
||||
return (UINT_PTR)InterlockedExchangePointer( (void **)&user_callbacks, (void *)arg );
|
||||
default:
|
||||
FIXME( "invalid code %u\n", code );
|
||||
return 0;
|
||||
|
|
|
@ -30,15 +30,6 @@
|
|||
#include "wine/unixlib.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
struct user_callbacks
|
||||
{
|
||||
HWND (WINAPI *pGetDesktopWindow)(void);
|
||||
BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect );
|
||||
BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT );
|
||||
LRESULT (WINAPI *pSendMessageTimeoutW)( HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR );
|
||||
HWND (WINAPI *pWindowFromDC)( HDC );
|
||||
};
|
||||
|
||||
extern const struct user_callbacks *user_callbacks DECLSPEC_HIDDEN;
|
||||
|
||||
struct unix_funcs
|
||||
|
|
|
@ -947,79 +947,8 @@ void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT vers
|
|||
return unix_funcs->set_display_driver( funcs, version );
|
||||
}
|
||||
|
||||
static void *get_user_proc( const char *name, BOOL force_load )
|
||||
{
|
||||
ANSI_STRING name_str;
|
||||
FARPROC proc = NULL;
|
||||
static HMODULE user32;
|
||||
|
||||
if (!user32)
|
||||
{
|
||||
UNICODE_STRING str;
|
||||
NTSTATUS status;
|
||||
RtlInitUnicodeString( &str, L"user32.dll" );
|
||||
status = force_load
|
||||
? LdrLoadDll( NULL, 0, &str, &user32 )
|
||||
: LdrGetDllHandle( NULL, 0, &str, &user32 );
|
||||
if (status < 0) return NULL;
|
||||
}
|
||||
RtlInitAnsiString( &name_str, name );
|
||||
LdrGetProcedureAddress( user32, &name_str, 0, (void**)&proc );
|
||||
return proc;
|
||||
}
|
||||
|
||||
static HWND WINAPI call_GetDesktopWindow(void)
|
||||
{
|
||||
static HWND (WINAPI *pGetDesktopWindow)(void);
|
||||
if (!pGetDesktopWindow)
|
||||
pGetDesktopWindow = get_user_proc( "GetDesktopWindow", TRUE );
|
||||
return pGetDesktopWindow ? pGetDesktopWindow() : NULL;
|
||||
}
|
||||
|
||||
static BOOL WINAPI call_GetWindowRect( HWND hwnd, LPRECT rect )
|
||||
{
|
||||
static BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect );
|
||||
if (!pGetWindowRect)
|
||||
pGetWindowRect = get_user_proc( "GetWindowRect", FALSE );
|
||||
return pGetWindowRect && pGetWindowRect( hwnd, rect );
|
||||
}
|
||||
|
||||
static BOOL WINAPI call_RedrawWindow( HWND hwnd, const RECT *rect, HRGN rgn, UINT flags )
|
||||
{
|
||||
static BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT );
|
||||
if (!pRedrawWindow)
|
||||
pRedrawWindow = get_user_proc( "RedrawWindow", FALSE );
|
||||
return pRedrawWindow && pRedrawWindow( hwnd, rect, rgn, flags );
|
||||
}
|
||||
|
||||
static LRESULT WINAPI call_SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
|
||||
UINT flags, UINT timeout, PDWORD_PTR res_ptr )
|
||||
{
|
||||
static LRESULT (WINAPI *pSendMessageTimeoutW)( HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR );
|
||||
if (!pSendMessageTimeoutW) pSendMessageTimeoutW = get_user_proc( "SendMessageTimeoutW", FALSE );
|
||||
if (!pSendMessageTimeoutW) return 0;
|
||||
return pSendMessageTimeoutW( hwnd, msg, wparam, lparam, flags, timeout, res_ptr );
|
||||
}
|
||||
|
||||
static HWND WINAPI call_WindowFromDC( HDC hdc )
|
||||
{
|
||||
static HWND (WINAPI *pWindowFromDC)( HDC );
|
||||
if (!pWindowFromDC)
|
||||
pWindowFromDC = get_user_proc( "WindowFromDC", FALSE );
|
||||
return pWindowFromDC ? pWindowFromDC( hdc ) : NULL;
|
||||
}
|
||||
|
||||
static const struct user_callbacks user_funcs =
|
||||
{
|
||||
call_GetDesktopWindow,
|
||||
call_GetWindowRect,
|
||||
call_RedrawWindow,
|
||||
call_SendMessageTimeoutW,
|
||||
call_WindowFromDC,
|
||||
};
|
||||
|
||||
extern void wrappers_init( unixlib_handle_t handle )
|
||||
{
|
||||
const void *args = &user_funcs;
|
||||
const void *args;
|
||||
if (!__wine_unix_call( handle, 1, &args )) unix_funcs = args;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ enum
|
|||
NtUserFlushWindowSurfaces,
|
||||
NtUserGetDeskPattern,
|
||||
NtUserIncrementKeyStateCounter,
|
||||
NtUserSetCallbacks,
|
||||
};
|
||||
|
||||
/* NtUserCallTwoParam codes, not compatible with Windows */
|
||||
|
|
Loading…
Reference in New Issue