1
0
mirror of synced 2025-01-20 17:48:51 +01:00

Dirty Drivin: Make all characters selectable in name selection

Hate this game and its stupid issues
This commit is contained in:
Aaron M 2021-04-25 23:02:25 +12:00
parent 19600926a7
commit 0e3fc64dd3

View File

@ -43,6 +43,8 @@ static bool MenuHack = false;
static bool RiptideHack = false; static bool RiptideHack = false;
static bool MenuHackStopWriting = false; static bool MenuHackStopWriting = false;
static bool CoinPressed = false; static bool CoinPressed = false;
static bool NameEntryHack;
static BYTE GameState;
// controls // controls
extern int* ffbOffset; extern int* ffbOffset;
@ -259,13 +261,229 @@ static void CoinInput(Helpers* helpers)
} }
} }
static void NameScreenInput(Helpers* helpers)
{
if (!NameEntryHack)
{
NameEntryHack = true;
injector::MakeNOP(0x7CC26 + BaseAddress9, 6);
injector::MakeNOP(0x7CC2C + BaseAddress9, 6);
injector::MakeNOP(0x76864 + BaseAddress9, 3);
injector::MakeNOP(0x76867 + BaseAddress9, 5);
}
INT_PTR NameBase = helpers->ReadIntPtr(0x5AE500, true);
INT_PTR NameBaseOff1 = helpers->ReadIntPtr(NameBase + 0x10, false);
UINT8 NameNum = helpers->ReadByte(NameBaseOff1 + 0x388, false);
DWORD LetterAddr{};
switch (NameNum)
{
case 0:
injector::WriteMemoryRaw((0x57057D + BaseAddress9), "\x00\x00\x00\x00\x00\x00", 6, true);
LetterAddr = 0x57057C;
break;
case 1:
LetterAddr = 0x57057D;
break;
case 2:
LetterAddr = 0x57057E;
break;
case 3:
LetterAddr = 0x57057F;
break;
case 4:
LetterAddr = 0x570580;
break;
case 5:
LetterAddr = 0x570581;
break;
case 6:
helpers->WriteFloat32(0x4AD0FC, 1.0, true);
LetterAddr = 0x570582;
break;
}
if (*ffbOffset2 >= 0xF3)
{
helpers->WriteFloat32(0x4AD0FC, 1.0, true);
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x10;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x1B;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x10;
}
else if (*ffbOffset2 >= 0xEA)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x5A;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x1A;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x5A;
}
else if (*ffbOffset2 >= 0xE1)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x59;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x19;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x59;
}
else if (*ffbOffset2 >= 0xD8)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x58;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x18;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x58;
}
else if (*ffbOffset2 >= 0xCF)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x57;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x17;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x57;
}
else if (*ffbOffset2 >= 0xC6)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x56;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x16;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x56;
}
else if (*ffbOffset2 >= 0xBD)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x55;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x15;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x55;
}
else if (*ffbOffset2 >= 0xB4)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x54;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x14;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x54;
}
else if (*ffbOffset2 >= 0xAB)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x53;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x13;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x53;
}
else if (*ffbOffset2 >= 0xA2)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x52;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x12;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x52;
}
else if (*ffbOffset2 >= 0x99)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x51;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x11;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x51;
}
else if (*ffbOffset2 >= 0x90)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x50;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x10;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x50;
}
else if (*ffbOffset2 >= 0x87)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x4F;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x0F;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x4F;
}
else if (*ffbOffset2 >= 0x7E)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x4E;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x0E;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x4E;
}
else if (*ffbOffset2 >= 0x75)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x4D;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x0D;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x4D;
}
else if (*ffbOffset2 >= 0x6C)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x4C;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x0C;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x4C;
}
else if (*ffbOffset2 >= 0x63)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x4B;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x0B;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x4B;
}
else if (*ffbOffset2 >= 0x5A)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x4A;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x0A;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x4A;
}
else if (*ffbOffset2 >= 0x51)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x49;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x09;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x49;
}
else if (*ffbOffset2 >= 0x48)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x48;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x08;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x48;
}
else if (*ffbOffset2 >= 0x3F)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x47;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x07;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x47;
}
else if (*ffbOffset2 >= 0x36)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x46;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x06;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x46;
}
else if (*ffbOffset2 >= 0x2D)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x45;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x05;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x45;
}
else if (*ffbOffset2 >= 0x24)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x44;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x04;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x44;
}
else if (*ffbOffset2 >= 0x1B)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x43;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x03;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x43;
}
else if (*ffbOffset2 >= 0x12)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x42;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x02;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x42;
}
else if (*ffbOffset2 >= 0x09)
{
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x41;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x01;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x41;
}
else if (*ffbOffset2 >= 0x00)
{
helpers->WriteFloat32(0x4AD0FC, -1.0, true);
*(BYTE*)(0x5705A0 + BaseAddress9) = 0x08;
*(BYTE*)(0x5705A4 + BaseAddress9) = 0x00;
*(BYTE*)(LetterAddr + BaseAddress9) = 0x00;
}
}
DWORD WINAPI InputRT9(LPVOID lpParam) DWORD WINAPI InputRT9(LPVOID lpParam)
{ {
int deltaTimer = 16; int deltaTimer = 16;
while (true) while (true)
{ {
BYTE GameState = *(BYTE*)(0x570190 + BaseAddress9); GameState = *(BYTE*)(0x570190 + BaseAddress9);
BYTE Chosen = *(BYTE*)(0x5705E8 + BaseAddress9); BYTE Chosen = *(BYTE*)(0x5705E8 + BaseAddress9);
if (GameState == 0x05) if (GameState == 0x05)
@ -360,6 +578,20 @@ DWORD WINAPI InputRT9(LPVOID lpParam)
} }
} }
if (GameState == 0x09)
NameScreenInput(0);
else
{
if (NameEntryHack)
{
NameEntryHack = false;
injector::WriteMemoryRaw((0x7CC26 + BaseAddress9), "\x89\x83\xB4\x06\x00\x00", 6, true);
injector::WriteMemoryRaw((0x7CC2C + BaseAddress9), "\x89\xB3\xB0\x06\x00\x00", 6, true);
injector::WriteMemoryRaw((0x76864 + BaseAddress9), "\x88\x0C\x06", 3, true);
injector::WriteMemoryRaw((0x76867 + BaseAddress9), "\xC6\x44\x06\x01\x00", 5, true);
}
}
if (ToBool(config["General"]["Windowed"])) if (ToBool(config["General"]["Windowed"]))
{ {
if (hWndRT9 == 0) if (hWndRT9 == 0)
@ -374,7 +606,7 @@ DWORD WINAPI InputRT9(LPVOID lpParam)
} }
} }
// ESCAPE QUITS GAME // ESCAPE QUITS GAME
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000) if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
{ {
HWND hWndTMP = GetForegroundWindow(); HWND hWndTMP = GetForegroundWindow();
@ -467,19 +699,22 @@ DWORD WINAPI InputRT9(LPVOID lpParam)
*(BYTE*)(0x44BAD0 + BaseAddress9) = 0x0B; *(BYTE*)(0x44BAD0 + BaseAddress9) = 0x0B;
} }
int iWheel = (((float)*ffbOffset2) - 128); if (GameState != 9)
float wheel = (iWheel * 0.0078125f); {
injector::WriteMemory<float>((0x4AD0FC + BaseAddress9), wheel, true); int iWheel = (((float)*ffbOffset2) - 128);
float wheel = (iWheel * 0.0078125f);
injector::WriteMemory<float>((0x4AD0FC + BaseAddress9), wheel, true);
}
} }
//// GAS //// GAS
float gas = (float)*ffbOffset3 / 255.0f; float gas = (float)*ffbOffset3 / 255.0f;
float brake = (float)*ffbOffset4 / 255.0f; float brake = (float)*ffbOffset4 / 255.0f;
// injector::WriteMemory<float>((0x4AD0F8 + BaseAddress9), gas, true); // injector::WriteMemory<float>((0x4AD0F8 + BaseAddress9), gas, true);
// BRAKE BUTTON HACK = if brake pressed gas is reduced // BRAKE BUTTON HACK = if brake pressed gas is reduced
injector::WriteMemory<float>((0x4AD0F8 + BaseAddress9), gas - brake, true); injector::WriteMemory<float>((0x4AD0F8 + BaseAddress9), gas - brake, true);
//DEBUG////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //DEBUG//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// info(true, "test value %f %f ", *ffbOffset2, x); // info(true, "test value %f %f ", *ffbOffset2, x);
//DEBUG////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //DEBUG//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Sleep(deltaTimer); Sleep(deltaTimer);
@ -492,18 +727,18 @@ D3DPRESENT_PARAMETERS* pPresentationParameters_RT9;
uintptr_t d3dcall; uintptr_t d3dcall;
void __stdcall D3D9CreateParamPatch() void __stdcall D3D9CreateParamPatch()
{ {
#if _M_IX86 #if _M_IX86
__asm mov d3dcall , edx __asm mov d3dcall, edx
__asm mov edx, [ebp + 0x1c] __asm mov edx, [ebp + 0x1c]
__asm mov pPresentationParameters_RT9 , edx __asm mov pPresentationParameters_RT9, edx
pPresentationParameters_RT9->Windowed = TRUE; pPresentationParameters_RT9->Windowed = TRUE;
pPresentationParameters_RT9->FullScreen_RefreshRateInHz = 0; pPresentationParameters_RT9->FullScreen_RefreshRateInHz = 0;
pPresentationParameters_RT9->hDeviceWindow = NULL; pPresentationParameters_RT9->hDeviceWindow = NULL;
injector::WriteMemoryRaw(0x63B332, "\xFF\xD2\x3D\x68\x08", 5, true); injector::WriteMemoryRaw(0x63B332, "\xFF\xD2\x3D\x68\x08", 5, true);
__asm mov edx , pPresentationParameters_RT9 __asm mov edx, pPresentationParameters_RT9
__asm mov [ebp + 0x1c], edx __asm mov[ebp + 0x1c], edx
__asm mov edx , d3dcall __asm mov edx, d3dcall
#endif #endif
return; return;
} }
@ -574,7 +809,7 @@ static InitFunction DirtyDrivinFunc([]()
{ {
injector::MakeNOP((0xAA6E6 + BaseAddress9), 6, true); injector::MakeNOP((0xAA6E6 + BaseAddress9), 6, true);
// alternative patch // alternative patch
// injector::WriteMemoryRaw((0x96fd70), "\x00", 1, true); // injector::WriteMemoryRaw((0x96fd70), "\x00", 1, true);
} }
if (ToBool(config["General"]["Windowed"])) if (ToBool(config["General"]["Windowed"]))