2022-09-25 13:36:55 +02:00
|
|
|
|
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
|
|
|
|
//
|
|
|
|
|
// Purpose:
|
|
|
|
|
//
|
|
|
|
|
//===========================================================================//
|
2023-01-30 20:18:11 +01:00
|
|
|
|
#ifndef SYS_MAINWIND_H
|
|
|
|
|
#define SYS_MAINWIND_H
|
2022-09-25 13:36:55 +02:00
|
|
|
|
#include "public/igame.h"
|
|
|
|
|
|
2023-01-30 20:18:11 +01:00
|
|
|
|
inline CMemory p_CGame__AttachToWindow;
|
|
|
|
|
inline auto v_CGame__AttachToWindow= p_CGame__AttachToWindow.RCast<void (*)(void)>();
|
|
|
|
|
|
2022-09-25 13:36:55 +02:00
|
|
|
|
inline CMemory p_CGame__PlayStartupVideos;
|
2023-07-02 23:01:29 +02:00
|
|
|
|
inline void(*v_CGame__PlayStartupVideos)(void);
|
2023-01-30 20:18:11 +01:00
|
|
|
|
|
|
|
|
|
inline CMemory p_CGame__WindowProc;
|
2023-07-02 23:01:29 +02:00
|
|
|
|
inline int(*v_CGame__WindowProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
2022-09-25 13:36:55 +02:00
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Purpose: Main game interface, including message pump and window creation
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
class CGame : public IGame
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static void PlayStartupVideos(void);
|
2023-01-30 20:18:11 +01:00
|
|
|
|
static int WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
2022-09-25 13:36:55 +02:00
|
|
|
|
};
|
|
|
|
|
|
2023-01-30 20:18:11 +01:00
|
|
|
|
inline HWND* g_pGameWindow = nullptr;
|
|
|
|
|
|
2022-09-25 13:36:55 +02:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
class VGame : public IDetour
|
|
|
|
|
{
|
|
|
|
|
virtual void GetAdr(void) const
|
|
|
|
|
{
|
2023-01-30 20:18:11 +01:00
|
|
|
|
LogFunAdr("CGame::AttachToWindow", p_CGame__AttachToWindow.GetPtr());
|
2023-01-25 02:26:52 +01:00
|
|
|
|
LogFunAdr("CGame::PlayStartupVideos", p_CGame__PlayStartupVideos.GetPtr());
|
2023-01-30 20:18:11 +01:00
|
|
|
|
LogVarAdr("g_GameWindow", reinterpret_cast<uintptr_t>(g_pGameWindow));
|
2022-09-25 13:36:55 +02:00
|
|
|
|
}
|
|
|
|
|
virtual void GetFun(void) const
|
|
|
|
|
{
|
|
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
2023-01-30 20:18:11 +01:00
|
|
|
|
p_CGame__AttachToWindow = g_GameDll.FindPatternSIMD("48 83 EC 38 48 8B 0D ?? ?? ?? ?? 48 85 C9 0F 84 ?? ?? ?? ??");
|
2022-12-01 22:44:55 +01:00
|
|
|
|
p_CGame__PlayStartupVideos = g_GameDll.FindPatternSIMD("48 8B C4 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ??");
|
2023-01-30 20:18:11 +01:00
|
|
|
|
p_CGame__WindowProc = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 41 54 41 56 48 81 EC ?? ?? ?? ??");
|
2022-09-25 13:36:55 +02:00
|
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2023-01-30 20:18:11 +01:00
|
|
|
|
p_CGame__AttachToWindow = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 85 C9 0F 84 ?? ?? ?? ?? BA ?? ?? ?? ??");
|
2022-12-01 22:44:55 +01:00
|
|
|
|
p_CGame__PlayStartupVideos = g_GameDll.FindPatternSIMD("48 8B C4 55 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ??");
|
2023-01-30 20:18:11 +01:00
|
|
|
|
p_CGame__WindowProc = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 33 F6");
|
2022-09-25 13:36:55 +02:00
|
|
|
|
#endif
|
2023-01-30 20:18:11 +01:00
|
|
|
|
|
|
|
|
|
v_CGame__AttachToWindow = p_CGame__AttachToWindow.RCast<void (*)(void)>();
|
2022-09-25 13:36:55 +02:00
|
|
|
|
v_CGame__PlayStartupVideos = p_CGame__PlayStartupVideos.RCast<void (*)(void)>();
|
2023-01-30 20:18:11 +01:00
|
|
|
|
v_CGame__WindowProc = p_CGame__WindowProc.RCast<int (*)(HWND, UINT, WPARAM, LPARAM)>();
|
|
|
|
|
}
|
|
|
|
|
virtual void GetVar(void) const
|
|
|
|
|
{
|
|
|
|
|
g_pGameWindow = p_CGame__AttachToWindow.FindPattern("48 8B 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<HWND*>();
|
2022-09-25 13:36:55 +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-09-25 13:36:55 +02:00
|
|
|
|
};
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-01-30 20:18:11 +01:00
|
|
|
|
|
|
|
|
|
#endif // SYS_MAINWIND_H
|