Skip to content

Commit

Permalink
Inline asm hooks 1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed Oct 28, 2024
1 parent e92702c commit f56749c
Show file tree
Hide file tree
Showing 7 changed files with 697 additions and 938 deletions.
16 changes: 5 additions & 11 deletions Client/game_sa/CHandlingManagerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,14 @@ __declspec(noinline) void DumpHandlingData(tHandlingDataSA* pData)

static __declspec(naked) void Hook_Calculate()
{
tHandlingDataSA* pData;
DWORD dwHandlingData;
_asm
{
mov eax, [esp+4]
mov dwHandlingData, eax
}

pData = reinterpret_cast<tHandlingDataSA*>(dwHandlingData);
DumpHandlingData(pData);
mov eax, [esp+4]
push eax
call DumpHandlingData
add esp, 4

_asm
{
ret 4
ret 4
}
}

Expand Down
16 changes: 6 additions & 10 deletions Client/game_sa/CTaskManagementSystemSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,16 @@ __declspec(noinline) void OnMY_Task_Operator_Delete(CTaskSAInterface* pTaskInter
void _declspec(naked) HOOK_CTask_Operator_Delete()
{
_asm
{
mov eax, [esp+4]
mov pTempTaskInterface, eax
{
mov eax, [esp+4]
mov pTempTaskInterface, eax

pushad
}

OnMY_Task_Operator_Delete(pTempTaskInterface);

// Continue on our merry way....
_asm
{
push pTempTaskInterface
call OnMY_Task_Operator_Delete
popad

// Continue on our merry way....
mov eax, 0xB744A8
mov ecx, dword ptr [eax]
mov eax, FUNC_CTask_Operator_Delete
Expand Down
66 changes: 36 additions & 30 deletions Client/game_sa/CWorldSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,49 @@ DWORD CONTINUE_CWorld_FallenCars = 0x00565E8A;

void _declspec(naked) HOOK_FallenPeds()
{
if (pGame && pGame->IsUnderWorldWarpEnabled())
{
_asm
{
sub esp, 2Ch
push ebx
mov ebx, ds:0B74490h
jmp CONTINUE_CWorld_FallenPeds
}
}
else
_asm
{
_asm
{
ret
}
// if (pGame)
mov eax, pGame
test eax, eax
jz skip

// if (pGame->IsUnderWorldWarpEnabled())
call dword ptr [eax+80h]
test al, al
jz skip

sub esp, 2Ch
push ebx
mov ebx, ds:0B74490h
jmp CONTINUE_CWorld_FallenPeds

skip:
ret
}
}

void _declspec(naked) HOOK_FallenCars()
{
if (pGame && pGame->IsUnderWorldWarpEnabled())
{
_asm
{
sub esp, 2Ch
push ebx
mov ebx, ds:0B74494h
jmp CONTINUE_CWorld_FallenCars
}
}
else
_asm
{
_asm
{
ret
}
// if (pGame)
mov eax, pGame
test eax, eax
jz skip

// if (pGame->IsUnderWorldWarpEnabled())
call dword ptr [eax+80h]
test al, al
jz skip

sub esp, 2Ch
push ebx
mov ebx, ds:0B74494h
jmp CONTINUE_CWorld_FallenCars

skip:
ret
}
}

Expand Down
Loading

0 comments on commit f56749c

Please sign in to comment.