Fixed game crash with no controller connected
This commit is contained in:
parent
ca20da9d23
commit
3ce0b25bd2
@ -1,4 +1,4 @@
|
||||
#include <StdInc.h>
|
||||
#include <StdInc.h>
|
||||
#include "Utility/InitFunction.h"
|
||||
#include "Functions/Global.h"
|
||||
#include "Utility\Hooking.Patterns.h"
|
||||
@ -41,6 +41,8 @@ static void InjectKeys()
|
||||
if (track != 0)
|
||||
{
|
||||
BYTE track1 = *(BYTE *)(track + 0x4);
|
||||
if (track1 != 0)
|
||||
{
|
||||
info(true, "%02X %02X", track1, gamestate);
|
||||
if ((track1 == 2 || track1 == 4) && (gamestate == 0x16))
|
||||
{
|
||||
@ -57,6 +59,7 @@ static void InjectKeys()
|
||||
info(true, "Normal wheel1");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*(BYTE *)(imageBase + 0x15B4678) = wheel;
|
||||
@ -65,30 +68,37 @@ static void InjectKeys()
|
||||
|
||||
|
||||
|
||||
if(wheel <= 0x40)
|
||||
if (wheel <= 0x40)
|
||||
{
|
||||
//Menu Left
|
||||
DWORD p = *(DWORD *)(imageBase + 0x1AAFFF0);
|
||||
DWORD p1 = *(DWORD *)(p + 0x00);
|
||||
if (p != 0)
|
||||
{
|
||||
DWORD p1 = *(DWORD *)(p + 0x00);
|
||||
if (p1 != 0)
|
||||
{
|
||||
*(BYTE *)(p1 + 0x25) = 0xFF;
|
||||
}
|
||||
|
||||
}
|
||||
else if(wheel >= 0xC0)
|
||||
}
|
||||
else if (wheel >= 0xC0)
|
||||
{
|
||||
//Menu Right
|
||||
DWORD p = *(DWORD *)(imageBase + 0x1AAFFF0);
|
||||
if (p != 0)
|
||||
{
|
||||
DWORD p1 = *(DWORD *)(p + 0x00);
|
||||
if (p1 != 0)
|
||||
{
|
||||
*(BYTE *)(p1 + 0x27) = 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD p = *(DWORD *)(imageBase + 0x1AAFFF0);
|
||||
if (p != 0)
|
||||
{
|
||||
DWORD p1 = *(DWORD *)(p + 0x00);
|
||||
if (p1 != 0)
|
||||
{
|
||||
@ -96,26 +106,33 @@ static void InjectKeys()
|
||||
*(BYTE *)(p1 + 0x27) = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buttons == 0x01)
|
||||
{
|
||||
//Inject Start
|
||||
DWORD p = *(DWORD *)(imageBase + 0x1AB0010);
|
||||
if (p != 0)
|
||||
{
|
||||
DWORD p1 = *(DWORD *)(p + 0x00);
|
||||
if (p1 != 0)
|
||||
{
|
||||
*(DWORD *)(p1 + 0x08) = 0x01;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD p = *(DWORD *)(imageBase + 0x1AB0010);
|
||||
if (p != 0)
|
||||
{
|
||||
DWORD p1 = *(DWORD *)(p + 0x00);
|
||||
if (p1 != 0)
|
||||
{
|
||||
*(DWORD *)(p1 + 0x08) = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((buttons == 0x02) && (gear < 0x03))
|
||||
{
|
||||
@ -130,7 +147,7 @@ static void InjectKeys()
|
||||
shiftup = false;
|
||||
}
|
||||
|
||||
if ((buttons == 0x04) && (gear > 0x00)) //crashes right now
|
||||
if ((buttons == 0x04) && (gear > 0x00))
|
||||
{
|
||||
if (!shiftdown)
|
||||
{
|
||||
|
@ -308,6 +308,10 @@ __in XINPUT_VIBRATION_EX* pVibration // The vibration information to send to
|
||||
}
|
||||
}
|
||||
|
||||
LPCWSTR libName = L"xinput1_3.dll";
|
||||
LPCWSTR daytonalibName = L"xinput9_1_0.dll";
|
||||
LPCWSTR ptrToUse;
|
||||
|
||||
static InitFunction XInputHook([]()
|
||||
{
|
||||
if (GameDetect::currentGame == GameID::PokkenTournament || GameDetect::currentGame == GameID::SchoolOfRagnarok || GameDetect::currentGame == GameID::Daytona3)
|
||||
@ -316,17 +320,22 @@ static InitFunction XInputHook([]()
|
||||
|
||||
MH_Initialize();
|
||||
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputGetState", &XInputGetState, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputSetState", &XInputSetState, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputGetCapabilities", &XInputGetCapabilities, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputEnable", &XInputEnable, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputGetDSoundAudioDeviceGuids", &XInputGetDSoundAudioDeviceGuids, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputGetBatteryInformation", &XInputGetBatteryInformation, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputGetKeystroke", &XInputGetKeystroke, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputGetStateEx", &XInputGetStateEx, NULL);
|
||||
MH_CreateHookApi(L"xinput1_3.dll", "XInputSetStateEx", &XInputSetStateEx, NULL);
|
||||
if (GameDetect::currentGame == GameID::Daytona3)
|
||||
ptrToUse = daytonalibName;
|
||||
else
|
||||
ptrToUse = libName;
|
||||
|
||||
MH_CreateHookApi(ptrToUse, "XInputGetState", &XInputGetState, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputSetState", &XInputSetState, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputGetCapabilities", &XInputGetCapabilities, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputEnable", &XInputEnable, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputGetDSoundAudioDeviceGuids", &XInputGetDSoundAudioDeviceGuids, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputGetBatteryInformation", &XInputGetBatteryInformation, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputGetKeystroke", &XInputGetKeystroke, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputGetStateEx", &XInputGetStateEx, NULL);
|
||||
MH_CreateHookApi(ptrToUse, "XInputSetStateEx", &XInputSetStateEx, NULL);
|
||||
|
||||
MH_EnableHook(MH_ALL_HOOKS);
|
||||
}
|
||||
});
|
||||
#pragma optimize("", on)
|
||||
#pragma optimize("", on)´
|
Loading…
Reference in New Issue
Block a user