Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gta-streaming-five): sanitize ragdoll component based in attach bone #3186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions code/components/gta-streaming-five/src/PatchSkeletonCrash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,42 @@ static HookFunction hookFunction([]()
}
}

// CPedWeaponManager::SwitchToRagdoll
{
static struct : jitasm::Frontend
{
intptr_t retSuccess = 0;
intptr_t retFail = 0;

void Init(intptr_t success, intptr_t fail)
{
this->retSuccess = success;
this->retFail = fail;
}

virtual void InternalMain() override
{
mov(rax, qword_ptr[rdx+0x118]); // Original code
movsxd(r13, dword_ptr[rax+rcx*4]); // Original code
cmp(r13, -1); // Check if the index of the bone map is -1 that represents a invalid position
je("fail");
mov(rax, this->retSuccess);
jmp(rax);
L("fail");
mov(rax, this->retFail);
jmp(rax);
}
} patchStub;

auto location = hook::get_pattern("48 8B 82 ? ? ? ? 4C 63 2C 88");
hook::nop(location, 11);
const auto successPtr = reinterpret_cast<intptr_t>(location) + 11;
const auto failPtr = reinterpret_cast<intptr_t>(hook::get_pattern("4C 8D 85 ? ? ? ? E8 ? ? ? ? 4C 8D 9C 24 ? ? ? ? 49 8B 5B ? 41 0F 28 73", 12));
assert((failPtr - reinterpret_cast<intptr_t>(location)) < 3000);
patchStub.Init(successPtr, failPtr);
hook::jump(location, patchStub.GetCode());
}

#if 0
// fwEntity::_GetGlobalMatrix: If required hook the dynamic-dispatch bits.
{
Expand Down
Loading