Skip to content

Commit

Permalink
Fixed instances of Removing Corrupted Hook for 'DirectInput8Create'..…
Browse files Browse the repository at this point in the history
…. software is probably going to explode!
  • Loading branch information
Kaldaien committed Sep 9, 2023
1 parent 1dfd850 commit 241bdc5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/input/dinput8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,10 +1683,9 @@ SK_Input_HookDI8 (void)
if (! config.input.gamepad.hook_dinput8)
return;

static volatile LONG hooked = FALSE;

if (SK_GetModuleHandle (L"dinput8.dll"))
if (SK_GetModuleHandle (L"dinput8.dll") && DirectInput8Create_Import == nullptr)
{
static volatile LONG hooked = FALSE;
if (! InterlockedCompareExchange (&hooked, TRUE, FALSE))
{
if (SK_GetDLLRole () & DLL_ROLE::DInput8)
Expand All @@ -1710,17 +1709,17 @@ SK_Input_HookDI8 (void)
static_cast_p2p <void> (&DirectInput8Create_Import) );
}

if (SK_GetModuleHandle (L"dinput.dll"))
{
SK_Input_HookDI7 ();
}

InterlockedIncrementRelease (&hooked);
}

else
SK_Thread_SpinUntilAtomicMin (&hooked, 2);
}

if (SK_GetModuleHandle (L"dinput.dll"))
{
SK_Input_HookDI7 ();
}
}


Expand Down

0 comments on commit 241bdc5

Please sign in to comment.