Skip to content

Commit 39f3d39

Browse files
committed
Implmented Global hook without using client render
1 parent e770a69 commit 39f3d39

File tree

1 file changed

+56
-8
lines changed

1 file changed

+56
-8
lines changed

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,26 +578,63 @@ CMultiplayerSA::CMultiplayerSA()
578578
m_dwLastStaticAnimID = eAnimID::ANIM_ID_WALK;
579579
}
580580

581-
void CVehicle__DoSunGlare(void* this_)
581+
// sun glare
582+
enum
582583
{
583-
//EAXJMP(0x6DD6F0);
584-
MemSet((void*)0x6DD6F0, 0x1, 1);
584+
PATCH_CALL,
585+
PATCH_JUMP,
586+
PATCH_NOTHING,
587+
};
588+
_declspec(naked) void CVehicle__DoSunGlare(void* this_)
589+
{
590+
#define EAXJMP(a) {_asm mov eax, a _asm jmp eax}
591+
EAXJMP(0x6DD6F0);
585592
}
586593

587-
void __declspec(naked) doglare(void)
594+
void _declspec(naked) doglare(void)
588595
{
596+
589597
_asm {
590-
mov ecx, 1
591-
cmp [ecx+8], 0 // doglare
592-
jle noglare
593598
mov ecx,esi
594599
call CVehicle__DoSunGlare
595-
noglare:
596600
mov [esp+0D4h], edi
597601
push 6ABD04h
598602
retn
603+
}
604+
605+
}
606+
template <typename AT, typename HT>
607+
inline void InjectHook(AT address, HT hook, unsigned int nType = PATCH_NOTHING)
608+
{
609+
DWORD dwProtect[2];
610+
switch (nType)
611+
{
612+
case PATCH_JUMP:
613+
VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
614+
*(BYTE*)address = 0xE9;
615+
break;
616+
case PATCH_CALL:
617+
VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
618+
*(BYTE*)address = 0xE8;
619+
break;
620+
default:
621+
VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
622+
break;
599623
}
624+
DWORD dwHook;
625+
_asm
626+
{
627+
mov eax, hook
628+
mov dwHook, eax
629+
}
630+
631+
*(ptrdiff_t*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5;
632+
if (nType == PATCH_NOTHING)
633+
VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]);
634+
else
635+
VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]);
600636
}
637+
601638
void CMultiplayerSA::InitHooks()
602639
{
603640
InitKeysyncHooks();
@@ -1541,7 +1578,10 @@ void CMultiplayerSA::InitHooks()
15411578
MemPut(uiAddr, &m_fShadowsOffset);
15421579
//Fuck Sun Glar
15431580
//MemPut((void*)0x6ABCFD, 0x6DD6F0);
1581+
//HookInstall(0x6ABCFD, (DWORD)CVehicle__DoSunGlare, 5);
1582+
15441583

1584+
15451585
//Fuck the wet road reflection
15461586
MemSet((void*)0x6FB9A0, 0x1C, 1);
15471587

@@ -1558,6 +1598,14 @@ void CMultiplayerSA::InitHooks()
15581598
InitHooks_VehicleWeapons();
15591599

15601600
InitHooks_Streaming();
1601+
1602+
1603+
//InjectHook(0x6ABCFD, doglare, PATCH_JUMP);
1604+
1605+
HookInstall(0x6ABCFD, (DWORD)doglare, 5);
1606+
1607+
1608+
15611609
}
15621610

15631611
// Used to store copied pointers for explosions in the FxSystem

0 commit comments

Comments
 (0)