2022-04-12 02:48:46 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_Host_RunFrame;
|
2022-08-19 21:33:31 +02:00
|
|
|
inline auto v_Host_RunFrame = p_Host_RunFrame.RCast<void(*)(void* unused, float time)>();
|
2022-04-14 19:18:59 +02:00
|
|
|
|
2023-01-26 02:59:50 +01:00
|
|
|
//inline CMemory p_Host_RunFrame_Render; // DEDICATED PATCH!
|
|
|
|
//inline auto v_Host_RunFrame_Render = p_Host_RunFrame_Render.RCast<void(*)(void)>();
|
2022-04-14 19:18:59 +02:00
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_Host_Error;
|
2023-02-19 09:43:12 +01:00
|
|
|
inline auto v_Host_Error = p_Host_Error.RCast<void(*)(const char* error, ...)>();
|
2022-04-12 02:48:46 +02:00
|
|
|
|
2023-01-26 02:59:50 +01:00
|
|
|
//inline CMemory p_VCR_EnterPausedState; // DEDICATED PATCH!
|
|
|
|
//inline auto v_VCR_EnterPausedState = p_VCR_EnterPausedState.RCast<void(*)(void)>();
|
2022-04-14 19:18:59 +02:00
|
|
|
|
2022-04-12 02:48:46 +02:00
|
|
|
inline bool* g_bAbortServerSet = nullptr;
|
2022-08-18 02:15:23 +02:00
|
|
|
inline float* interval_per_tick = nullptr;
|
|
|
|
|
2023-02-18 00:08:10 +01:00
|
|
|
inline jmp_buf* host_abortserver = nullptr;
|
|
|
|
inline float* host_frametime_unbounded;
|
|
|
|
inline float* host_frametime_stddeviation;
|
|
|
|
|
2022-04-12 02:48:46 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-05-13 14:53:25 +02:00
|
|
|
class VHost : public IDetour
|
2022-04-12 02:48:46 +02:00
|
|
|
{
|
|
|
|
virtual void GetAdr(void) const
|
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("_Host_RunFrame", p_Host_RunFrame.GetPtr());
|
2023-01-26 02:59:50 +01:00
|
|
|
//LogFunAdr("_Host_RunFrame_Render", p_Host_RunFrame_Render.GetPtr());
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("Host_Error", p_Host_Error.GetPtr());
|
2023-01-26 02:59:50 +01:00
|
|
|
//LogFunAdr("VCR_EnterPausedState", p_VCR_EnterPausedState.GetPtr());
|
2023-02-18 00:08:10 +01:00
|
|
|
LogVarAdr("g_bAbortServerSet", reinterpret_cast<uintptr_t>(g_bAbortServerSet));
|
2023-01-25 02:26:52 +01:00
|
|
|
LogVarAdr("interval_per_tick", reinterpret_cast<uintptr_t>(interval_per_tick));
|
|
|
|
LogVarAdr("host_abortserver", reinterpret_cast<uintptr_t>(host_abortserver));
|
2023-02-18 00:08:10 +01:00
|
|
|
LogVarAdr("host_frametime_unbounded", reinterpret_cast<uintptr_t>(host_frametime_unbounded));
|
|
|
|
LogVarAdr("host_frametime_stddeviation", reinterpret_cast<uintptr_t>(host_frametime_stddeviation));
|
2022-04-12 02:48:46 +02:00
|
|
|
}
|
|
|
|
virtual void GetFun(void) const
|
|
|
|
{
|
2022-12-01 22:44:55 +01:00
|
|
|
p_Host_RunFrame = g_GameDll.FindPatternSIMD("48 8B C4 48 89 58 18 48 89 70 20 F3 0F 11 48 ??");
|
2022-04-14 19:18:59 +02:00
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
2023-01-26 02:59:50 +01:00
|
|
|
//p_Host_RunFrame_Render = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 33 FF");
|
2022-04-14 19:18:59 +02:00
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2023-01-26 02:59:50 +01:00
|
|
|
//p_Host_RunFrame_Render = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B 0D ?? ?? ?? ?? 48 85 C9 75 34");
|
2022-04-14 19:18:59 +02:00
|
|
|
#endif
|
2022-12-01 22:44:55 +01:00
|
|
|
p_Host_Error = g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 48 89 54 24 ?? 4C 89 44 24 ?? 4C 89 4C 24 ?? 53 57 48 81 EC ?? ?? ?? ??");
|
2023-01-26 02:59:50 +01:00
|
|
|
//p_VCR_EnterPausedState = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 65 48 8B 04 25 ?? ?? ?? ?? BB ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ??");
|
2022-04-14 19:18:59 +02:00
|
|
|
|
2022-08-19 21:33:31 +02:00
|
|
|
v_Host_RunFrame = p_Host_RunFrame.RCast<void(*)(void*, float)>();
|
2023-01-26 02:59:50 +01:00
|
|
|
//v_Host_RunFrame_Render = p_Host_Error.RCast<void(*)(void)>();
|
2023-02-19 09:43:12 +01:00
|
|
|
v_Host_Error = p_Host_Error.RCast<void(*)(const char*, ...)>();
|
2023-01-26 02:59:50 +01:00
|
|
|
//v_VCR_EnterPausedState = p_VCR_EnterPausedState.RCast<void(*)(void)>();
|
2022-04-12 02:48:46 +02:00
|
|
|
}
|
|
|
|
virtual void GetVar(void) const
|
|
|
|
{
|
2022-12-01 22:44:55 +01:00
|
|
|
interval_per_tick = g_GameDll.FindPatternSIMD("4C 8B DC 4D 89 4B 20 55 56 41 54").FindPatternSelf("F3 0F 5E", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x4, 0x8).RCast<float*>();
|
2022-04-19 00:00:45 +02:00
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
|
|
|
g_bAbortServerSet = p_Host_Error.FindPattern("40 38 3D", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddress(3, 7).RCast<bool*>();
|
|
|
|
host_abortserver = p_Host_Error.FindPattern("48 8D 0D", CMemory::Direction::DOWN, 512, 3).ResolveRelativeAddress(3, 7).RCast<jmp_buf*>();
|
2023-02-18 00:08:10 +01:00
|
|
|
|
2023-03-01 00:09:38 +01:00
|
|
|
static const int n_host_frametime_unbounded_search_offset = 0x380;
|
|
|
|
static const int n_host_frametime_stddeviation_search_offset = 0x1200;
|
2022-04-19 00:00:45 +02:00
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2022-04-12 02:48:46 +02:00
|
|
|
g_bAbortServerSet = p_Host_Error.FindPattern("40 38 3D", CMemory::Direction::DOWN, 512, 4).ResolveRelativeAddress(3, 7).RCast<bool*>();
|
|
|
|
host_abortserver = p_Host_Error.FindPattern("48 8D 0D", CMemory::Direction::DOWN, 512, 5).ResolveRelativeAddress(3, 7).RCast<jmp_buf*>();
|
2023-02-18 00:08:10 +01:00
|
|
|
|
|
|
|
static const int n_host_frametime_unbounded_search_offset = 0x330;
|
2023-03-01 00:09:38 +01:00
|
|
|
static const int n_host_frametime_stddeviation_search_offset = 0xFAA;
|
2022-04-19 00:00:45 +02:00
|
|
|
#endif
|
2023-03-01 00:09:38 +01:00
|
|
|
host_frametime_unbounded = p_Host_RunFrame.Offset(n_host_frametime_unbounded_search_offset).FindPatternSelf("F3 0F 11").ResolveRelativeAddressSelf(0x4, 0x8).RCast<float*>();
|
|
|
|
host_frametime_stddeviation = p_Host_RunFrame.Offset(n_host_frametime_stddeviation_search_offset).FindPatternSelf("F3 0F 11").ResolveRelativeAddressSelf(0x4, 0x8).RCast<float*>();
|
2022-04-12 02:48:46 +02:00
|
|
|
}
|
|
|
|
virtual void GetCon(void) const { }
|
2023-01-25 02:26:52 +01:00
|
|
|
virtual void Attach(void) const;
|
|
|
|
virtual void Detach(void) const;
|
2022-04-12 02:48:46 +02:00
|
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|