Commit e9282254 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winmm: Instanciate DirectInput8 class lazily using delay imported DLL.

Instead of statically importing dinput8 and creating the class at load time, which causes some native hooks to fail loading. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52222Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c521ec04
EXTRADEFS = -D_WINMM_ EXTRADEFS = -D_WINMM_
MODULE = winmm.dll MODULE = winmm.dll
IMPORTLIB = winmm IMPORTLIB = winmm
IMPORTS = uuid user32 advapi32 ole32 msacm32 dinput8 IMPORTS = uuid user32 advapi32 ole32 msacm32
DELAYIMPORTS = dinput8
C_SRCS = \ C_SRCS = \
driver.c \ driver.c \
......
...@@ -152,11 +152,12 @@ static BOOL CALLBACK enum_instances( const DIDEVICEINSTANCEW *instance, void *co ...@@ -152,11 +152,12 @@ static BOOL CALLBACK enum_instances( const DIDEVICEINSTANCEW *instance, void *co
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
void joystick_load( HINSTANCE instance ) static BOOL WINAPI joystick_load_once( INIT_ONCE *once, void *param, void **context )
{ {
HRESULT hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, HRESULT hr = DirectInput8Create( hWinMM32Instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W,
(void **)&dinput, NULL ); (void **)&dinput, NULL );
if (FAILED(hr)) WARN( "could not create dinput instance, hr %#x\n", hr ); if (FAILED(hr)) ERR( "Could not create dinput instance, hr %#x\n", hr );
return TRUE;
} }
void joystick_unload() void joystick_unload()
...@@ -177,11 +178,15 @@ void joystick_unload() ...@@ -177,11 +178,15 @@ void joystick_unload()
static void find_joysticks(void) static void find_joysticks(void)
{ {
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
IDirectInputDevice8W *device; IDirectInputDevice8W *device;
HANDLE event; HANDLE event;
DWORD index; DWORD index;
HRESULT hr; HRESULT hr;
InitOnceExecuteOnce( &init_once, joystick_load_once, NULL, NULL );
if (!dinput) return; if (!dinput) return;
index = 0; index = 0;
......
...@@ -153,7 +153,6 @@ MMRESULT WINMM_CheckCallback(DWORD_PTR dwCallback, DWORD fdwOpen, BOOL mixer) DE ...@@ -153,7 +153,6 @@ MMRESULT WINMM_CheckCallback(DWORD_PTR dwCallback, DWORD fdwOpen, BOOL mixer) DE
void WINMM_DeleteWaveform(void) DECLSPEC_HIDDEN; void WINMM_DeleteWaveform(void) DECLSPEC_HIDDEN;
void joystick_load( HMODULE instance ) DECLSPEC_HIDDEN;
void joystick_unload( void ) DECLSPEC_HIDDEN; void joystick_unload( void ) DECLSPEC_HIDDEN;
/* Global variables */ /* Global variables */
......
...@@ -144,8 +144,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) ...@@ -144,8 +144,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
if (!WINMM_CreateIData(hInstDLL)) if (!WINMM_CreateIData(hInstDLL))
return FALSE; return FALSE;
joystick_load( hInstDLL );
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if(fImpLoad) if(fImpLoad)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment