Skip to content

Commit

Permalink
Make IDirectInputDevice::Poll() not treat non-zero success codes as e…
Browse files Browse the repository at this point in the history
…rrors
  • Loading branch information
CookiePLMonster committed Sep 16, 2023
1 parent b7a9b4e commit 010e0ea
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions source/SilentPatchNFS90s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ __declspec(naked) void NFS2SE_MouseZeroEax()
}
}

__declspec(naked) void NFS4_PollZeroEdi()
{
// if (edi >= 0) edi = 0;
_asm
{
mov edi, eax
sar edi, 31
and edi, eax
test edi, edi
ret
}
}


void OnInitializeHook()
{
Expand Down Expand Up @@ -384,6 +397,28 @@ void OnInitializeHook()
}
TXN_CATCH();


// NFS2SE/NFS3: Make IDirectInputDevice::Poll() not treat non-zero success codes as errors
try
{
auto poll = get_pattern("FF 52 64 85 C0 74 ? 3D 1E 00 07 80", 3 + 2);

// je -> jge
Patch<uint8_t>(poll, 0x7D);
}
TXN_CATCH();


// NFS4: Make IDirectInputDevice::Poll() not treat non-zero success codes as errors
try
{
auto poll = get_pattern("8B 7D F4 85 FF 74 ? 81 7D F4 1E 00 07 80");

// 'flatten' edi not to contain positive numbers
InjectHook(poll, NFS4_PollZeroEdi, HookType::Call);
}
TXN_CATCH();


// NFS2SE/NFS4: Re-enable Alt+F4
try
Expand Down

0 comments on commit 010e0ea

Please sign in to comment.