Skip to content

Commit

Permalink
Revert "Merge Verify pickup weapon component is valid on creation (pr…
Browse files Browse the repository at this point in the history
…-2797)"

This reverts commit a737e50, reversing
changes made to 9f4ea0e.
  • Loading branch information
prikolium-cfx committed Oct 7, 2024
1 parent 0bf3d3e commit 9a76e88
Showing 1 changed file with 0 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <jitasm.h>
#include <Hooking.h>
#include <Hooking.Stubs.h>
#include <CrossBuildRuntime.h>

static void (*origCPedModelInfo__SetupPedBuoyancyInfo)(void* BuoyancyInfo, const void* pCapsuleInfo, const void* FragType, bool bIsWeightless);

Expand Down Expand Up @@ -68,56 +67,4 @@ static HookFunction hookFunction([]
// CPedModelInfo::SetupPedBuoyancyInfo doesn't check that FragType isn't null.
origCPedModelInfo__SetupPedBuoyancyInfo = hook::trampoline(hook::get_call(hook::get_pattern("45 33 C9 4C 8B C0 48 8B D3 E8", 0x9)), &CPedModelInfo__SetupPedBuoyancyInfo);
}

// Not present on 1604 and we don't care about builds between 1604 and 2060
if (xbr::IsGameBuildOrGreater<2060>())
{
// Test for a valid weapon component info pointer before de-referencing it.
static struct : jitasm::Frontend
{
intptr_t retFail;
intptr_t retSuccess;

void Init(intptr_t location)
{
retFail = location + 14;
retSuccess = location + 6;
}

void InternalMain() override
{
test(rbx, rbx); // if ( rbx )
jz("fail"); // {
//
// * original code //
mov(rax, qword_ptr[rbx]); //
// [run original code]
mov(rcx, rbx); //
// * original code END //
//
mov(rax, retSuccess); //
jmp(rax); //
// }
L("fail"); //
mov(rax, retFail); //
jmp(rax); //
}

} patchStub;

// mov rax, [rbx]
auto location = hook::get_pattern<char>("7E ? 33 DB 48 8B 03", 4);

patchStub.Init(reinterpret_cast<intptr_t>(location));

/*
* nop:
*
* mov rax, [rbx]
* mov rcx, rbx
*/
hook::nop(location, 6);

hook::jump_rcx(location, patchStub.GetCode());
}
});

0 comments on commit 9a76e88

Please sign in to comment.