mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
Updated MemoryMgr
This commit is contained in:
parent
1a8bb9dd6c
commit
bf08a40d1a
2 changed files with 21 additions and 14 deletions
|
@ -490,17 +490,18 @@ namespace Memory
|
|||
} while ( --count != 0 ); }
|
||||
#endif
|
||||
|
||||
template<typename AT, typename HT>
|
||||
inline void InjectHook(AT address, HT hook)
|
||||
template<typename AT, typename Func>
|
||||
inline void InjectHook(AT address, Func hook)
|
||||
{
|
||||
intptr_t dwHook;
|
||||
_asm
|
||||
union member_cast
|
||||
{
|
||||
mov eax, hook
|
||||
mov dwHook, eax
|
||||
}
|
||||
intptr_t addr;
|
||||
Func funcPtr;
|
||||
} cast;
|
||||
static_assert( sizeof(cast.addr) == sizeof(cast.funcPtr), "member_cast failure!" );
|
||||
|
||||
*(ptrdiff_t*)((intptr_t)address + 1) = dwHook - (intptr_t)address - 5;
|
||||
cast.funcPtr = hook;
|
||||
*(ptrdiff_t*)((intptr_t)address + 1) = cast.addr - (intptr_t)address - 5;
|
||||
}
|
||||
|
||||
template<typename AT, typename HT>
|
||||
|
@ -521,7 +522,15 @@ namespace Memory
|
|||
template<typename Func, typename AT>
|
||||
inline void ReadCall(AT address, Func& func)
|
||||
{
|
||||
func = Func(*(ptrdiff_t*)((intptr_t)address+1) + (intptr_t)address + 5);
|
||||
union member_cast
|
||||
{
|
||||
intptr_t addr;
|
||||
Func funcPtr;
|
||||
} cast;
|
||||
static_assert( sizeof(cast.addr) == sizeof(cast.funcPtr), "member_cast failure!" );
|
||||
|
||||
cast.addr = *(ptrdiff_t*)((intptr_t)address+1) + (intptr_t)address + 5;
|
||||
func = cast.funcPtr;
|
||||
}
|
||||
|
||||
template<typename AT>
|
||||
|
@ -643,9 +652,9 @@ namespace Memory
|
|||
{
|
||||
DWORD dwProtect[2];
|
||||
|
||||
VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
|
||||
VirtualProtect((void*)((DWORD_PTR)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
|
||||
Memory::InjectHook( address, hook );
|
||||
VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]);
|
||||
VirtualProtect((void*)((DWORD_PTR)address + 1), 4, dwProtect[0], &dwProtect[1]);
|
||||
}
|
||||
|
||||
template<typename AT, typename HT>
|
||||
|
|
|
@ -3456,9 +3456,7 @@ void Patch_SA_10()
|
|||
|
||||
|
||||
// Fixed animations for boats
|
||||
void* vehiclePreRender;
|
||||
ReadCall( 0x6F119E, vehiclePreRender );
|
||||
CVehicle::orgVehiclePreRender = *(decltype(CVehicle::orgVehiclePreRender)*)(&vehiclePreRender);
|
||||
ReadCall( 0x6F119E, CVehicle::orgVehiclePreRender );
|
||||
InjectHook( 0x6F119E, &CBoat::PreRender_SilentPatch );
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue