-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interfaces.cpp
97 lines (87 loc) · 5.36 KB
/
Interfaces.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "Interfaces.h"
#include "Utilities.h"
typedef void* (__cdecl* CreateInterface_t)(const char*, int*);
typedef void* (*CreateInterfaceFn)(const char *pName, int *pReturnCode);
CreateInterface_t EngineFactory = NULL;
CreateInterface_t ClientFactory = NULL;
CreateInterface_t VGUISurfaceFactory = NULL;
CreateInterface_t VGUI2Factory = NULL;
CreateInterface_t MatFactory = NULL;
CreateInterface_t PhysFactory = NULL;
CreateInterface_t StdFactory = NULL;
CreateInterface_t InputSystemPointer = NULL;
void Interfaces::Initialise()
{
EngineFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::Engine, "CreateInterface");
ClientFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::Client, "CreateInterface");
VGUI2Factory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::VGUI2, "CreateInterface");
VGUISurfaceFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::VGUISurface, "CreateInterface");
MatFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::Material, "CreateInterface");
PhysFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::VPhysics, "CreateInterface");
StdFactory = (CreateInterface_t)GetProcAddress((HMODULE)Offsets::Modules::Stdlib, "CreateInterface");
char* CHLClientInterfaceName = (char*)Utilities::Memory::FindTextPattern("client.dll", "VClient0");
char* VGUI2PanelsInterfaceName = (char*)Utilities::Memory::FindTextPattern("vgui2.dll", "VGUI_Panel0");
char* VGUISurfaceInterfaceName = (char*)Utilities::Memory::FindTextPattern("vguimatsurface.dll", "VGUI_Surface0");
char* EntityListInterfaceName = (char*)Utilities::Memory::FindTextPattern("client.dll", "VClientEntityList0");
char* EngineDebugThingInterface = (char*)Utilities::Memory::FindTextPattern("engine.dll", "VDebugOverlay0");
char* EngineClientInterfaceName = (char*)Utilities::Memory::FindTextPattern("engine.dll","VEngineClient0");
char* ClientPredictionInterface = (char*)Utilities::Memory::FindTextPattern("client.dll", "VClientPrediction0");
char* MatSystemInterfaceName = (char*)Utilities::Memory::FindTextPattern("materialsystem.dll", "VMaterialSystem0");
char* EngineRenderViewInterface = (char*)Utilities::Memory::FindTextPattern("engine.dll", "VEngineRenderView0");
char* EngineModelRenderInterface = (char*)Utilities::Memory::FindTextPattern("engine.dll", "VEngineModel0");
char* EngineModelInfoInterface = (char*)Utilities::Memory::FindTextPattern("engine.dll", "VModelInfoClient0");
char* EngineTraceInterfaceName = (char*)Utilities::Memory::FindTextPattern("engine.dll", "EngineTraceClient0");
char* PhysPropsInterfaces = (char*)Utilities::Memory::FindTextPattern("client.dll", "VPhysicsSurfaceProps0");
char* VEngineCvarName = (char*)Utilities::Memory::FindTextPattern("engine.dll", "VEngineCvar00");
InputSystemPointer = (CreateInterface_t)GetProcAddress((HMODULE)Utilities::Memory::WaitOnModuleHandle("inputsystem.dll"), "CreateInterface");
InputSystem = (IInputSystem*)InputSystemPointer("InputSystemVersion001", NULL);
Client = (IBaseClientDLL*)ClientFactory(CHLClientInterfaceName, NULL);
Engine = (IVEngineClient*)EngineFactory(EngineClientInterfaceName, NULL);
Panels = (IPanel*)VGUI2Factory(VGUI2PanelsInterfaceName, NULL);
Surface = (ISurface*)VGUISurfaceFactory(VGUISurfaceInterfaceName, NULL);
EntList = (IClientEntityList*)ClientFactory(EntityListInterfaceName, NULL);
DebugOverlay = (IVDebugOverlay*)EngineFactory(EngineDebugThingInterface, NULL);
Prediction = (DWORD*)ClientFactory(ClientPredictionInterface, NULL);
MaterialSystem = (CMaterialSystem*)MatFactory(MatSystemInterfaceName, NULL);
RenderView = (CVRenderView*)EngineFactory(EngineRenderViewInterface, NULL);
ModelRender = (IVModelRender*)EngineFactory(EngineModelRenderInterface, NULL);
ModelInfo = (CModelInfo*)EngineFactory(EngineModelInfoInterface, NULL);
Trace = (IEngineTrace*)EngineFactory(EngineTraceInterfaceName, NULL);
PhysProps = (IPhysicsSurfaceProps*)PhysFactory(PhysPropsInterfaces, NULL);
CVar = (ICVar*)StdFactory(VEngineCvarName, NULL);
EventManager = (IGameEventManager2*)EngineFactory("GAMEEVENTSMANAGER002", NULL);
g_pViewRenderBeams = *(IViewRenderBeams**)(GameUtils::FindPattern1("client.dll", "B9 ? ? ? ? A1 ? ? ? ? FF 10 A1 ? ? ? ? B9") + 1);
ClientMode = **(IClientModeShared***)((*(uintptr_t**)Client)[10] + 0x5);
Globals = **reinterpret_cast< CGlobalVarsBase*** >((*reinterpret_cast< DWORD** >(Client))[0] + 0x1B);
PDWORD pdwClientVMT = *(PDWORD*)Client;
pInput = *(CInput**)((*(DWORD**)Client)[15] + 0x1);
g_ClientState = **(CClientState***)(Utilities::Memory::pattern_scan(GetModuleHandle("engine.dll"), "A1 ? ? ? ? 8B 80 ? ? ? ? C3") + 1);
}
namespace Interfaces
{
IViewRenderBeams* g_pViewRenderBeams;
IInputSystem* InputSystem;
IBaseClientDLL* Client;
IVEngineClient* Engine;
IPanel* Panels;
IClientEntityList* EntList;
ISurface* Surface;
IVDebugOverlay* DebugOverlay;
IClientModeShared *ClientMode;
CGlobalVarsBase *Globals;
DWORD *Prediction;
CMaterialSystem* MaterialSystem;
CVRenderView* RenderView;
IVModelRender* ModelRender;
CModelInfo* ModelInfo;
IEngineTrace* Trace;
IPhysicsSurfaceProps* PhysProps;
ICVar *CVar;
CInput* pInput;
IGameEventManager2 *EventManager;
HANDLE __FNTHANDLE;
IMoveHelper* MoveHelper;
IPrediction *Prediction1;
IGameMovement* GameMovement;
CClientState* g_ClientState;
};