Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SDK.h"
- #include "Client.h"
- #include "Panels.h"
- #include "Trace.hpp"
- #include "Helpers.hpp"
- #include "Glow.hpp"
- #include <memory>
- #include <d3dx9.h>
- #include "C_Player.hpp"
- #include "CDrawManager.h"
- #include "d3dsdk.hpp"
- #include "PredSys.hpp"
- #include <string>
- #include <iostream>
- #include "COM.hpp"
- #include "C_Colors.hpp"
- #include "GEvents.hpp"
- std::unique_ptr<VMTManager> g_pD3DDevice;
- uint32_t dxDevice;
- COffsets gOffsets;
- CPlayerVariables gPlayerVars;
- COptions g_Options;
- C_DXSDK g_D3dSdk;
- g g_Ifaces;
- CreateInterface_t EngineFactory = NULL;
- CreateInterface_t ClientFactory = NULL;
- CreateInterface_t VGUIFactory = NULL;
- CreateInterface_t VGUI2Factory = NULL;
- CreateInterface_t VSTD2Factory = NULL;
- using EndSceneFn = long(__stdcall*)(IDirect3DDevice9* device);
- int C_PredictionData008::old_conds = 0;
- EndSceneFn oEndSceneFn;
- HRESULT __stdcall hkEndScene_t(IDirect3DDevice9* pDevice)
- {
- static bool init = true;
- if (init)
- {
- g_D3dSdk.InitFonts(pDevice);
- init = false;
- }
- return g_pD3DDevice->GetMethod<EndSceneFn>(42)(pDevice);
- }
- DWORD WINAPI dwMainThread( LPVOID lpArguments )
- {
- if (g_Ifaces.Client == NULL) //Prevent repeat callings.
- {
- //Gottammove those factorys up.
- //Grab the factorys from their resptive module's EAT.
- ClientFactory = ( CreateInterfaceFn ) GetProcAddress( gSignatures.GetModuleHandleSafe( "client.dll" ), "CreateInterface" );
- g_Ifaces.Client = ( CHLClient* )ClientFactory( "VClient017", NULL);
- XASSERT(g_Ifaces.Client);
- g_Ifaces.EntList = ( CEntList* ) ClientFactory( "VClientEntityList003", NULL );
- XASSERT(g_Ifaces.EntList);
- EngineFactory = ( CreateInterfaceFn ) GetProcAddress( gSignatures.GetModuleHandleSafe( "engine.dll" ), "CreateInterface" );
- g_Ifaces.Engine = ( EngineClient* ) EngineFactory( "VEngineClient013", NULL );
- XASSERT(g_Ifaces.Engine);
- VGUIFactory = ( CreateInterfaceFn ) GetProcAddress( gSignatures.GetModuleHandleSafe( "vguimatsurface.dll" ), "CreateInterface" );
- g_Ifaces.Surface = ( ISurface* ) VGUIFactory( "VGUI_Surface030", NULL );
- XASSERT(g_Ifaces.Surface);
- g_Ifaces.Trace = (IEngineTrace*)EngineFactory("EngineTraceClient003", NULL);
- XASSERT(g_Ifaces.Trace);
- g_Ifaces.Prediction = (CPrediction*)ClientFactory("VClientPrediction001", NULL);
- XASSERT(g_Ifaces.Prediction);
- g_Ifaces.Globals = *reinterpret_cast<CGlobals **>(gSignatures.GetEngineSignature("A1 ? ? ? ? 8B 11 68") + 8);
- XASSERT(g_Ifaces.Globals);
- g_Ifaces.MdlInfo = (IVModelInfo*)EngineFactory("VModelInfoClient006", NULL);
- XASSERT(g_Ifaces.MdlInfo);
- g_Helpers.Maths = static_cast<I_MathHelper*>(new I_MathHelper());
- XASSERT(g_Helpers.Maths);
- g_Ifaces.Colors = static_cast<C_Colors*>(new C_Colors());
- XASSERT(g_Ifaces.Colors);
- VSTD2Factory = (CreateInterfaceFn)GetProcAddress(gSignatures.GetModuleHandleSafe("vstdlib.dll"), "CreateInterface");
- g_Ifaces.CVars = (ICvar*)VSTD2Factory("VEngineCvar004", NULL);
- XASSERT(g_Ifaces.CVars);
- g_Ifaces.Input = **reinterpret_cast<CInput ***>((*(DWORD **)g_Ifaces.Client)[15] + 0x2);
- XASSERT(g_Ifaces.Input);
- g_Ifaces.Movement = (IGameMovement*)ClientFactory("GameMovement001", NULL);
- XASSERT(g_Ifaces.Movement);
- g_Ifaces.MdlRender = (CModelRender*)EngineFactory("VEngineModel016", NULL);
- XASSERT(g_Ifaces.MdlRender);
- g_Ifaces.ClientState = *reinterpret_cast<CClientState **>(gSignatures.GetEngineSignature("B9 ? ? ? ? E8 ? ? ? ? 83 F8 FF 5E") + 0x1);
- XASSERT(g_Ifaces.ClientState);
- g_Ifaces.RenderView = (CRenderView*)EngineFactory("VEngineRenderView014", NULL);
- XASSERT(g_Ifaces.RenderView);
- g_Ifaces.GameEvents = (IGameEventManager2*)EngineFactory("GAMEEVENTSMANAGER002", NULL);
- XASSERT(g_Ifaces.GameEvents);
- dxDevice = **(uint32_t**)(gSignatures.GetDirectXSignature("A1 ? ? ? ? 50 8B 08 FF 51 0C") + 1);
- g_pD3DDevice = std::make_unique<VMTManager>((PDWORD*)dxDevice);
- pGlow_t.init();
- g_Ifaces.GameEvents->AddListener(new G_Events(), "player_hurt", true);
- //Setup the Panel hook so we can draw.
- if( !g_Ifaces.Panels )
- {
- VGUI2Factory = (CreateInterfaceFn)GetProcAddress(gSignatures.GetModuleHandleSafe("vgui2.dll"), "CreateInterface");
- g_Ifaces.Panels = ( IPanel* ) VGUI2Factory( "VGUI_Panel009", NULL );
- XASSERT( g_Ifaces.Panels );
- if( g_Ifaces.Panels )
- {
- VMTBaseManager* panelHook = new VMTBaseManager(); //Setup our VMTBaseManager for Panels.
- panelHook->Init(g_Ifaces.Panels);
- panelHook->HookMethod(&Hooked_PaintTraverse, gOffsets.iPaintTraverseOffset);
- panelHook->Rehook();
- }
- }
- DWORD dwClientModeAddress = gSignatures.GetClientSignature("8B 0D ? ? ? ? 8B 02 D9 05");
- XASSERT(dwClientModeAddress);
- g_Ifaces.ClientMode = **(ClientModeShared***)(dwClientModeAddress + 2);
- LOGDEBUG("g_pClientModeShared_ptr client.dll+0x%X", (DWORD)g_Ifaces.ClientMode - dwClientBase);
- VMTBaseManager* clientModeHook = new VMTBaseManager(); //Setup our VMTBaseManager for ClientMode.
- clientModeHook->Init(g_Ifaces.ClientMode);
- clientModeHook->HookMethod(&Hooked_CreateMove, gOffsets.iCreateMoveOffset);
- clientModeHook->HookMethod(&Hooked_OverrideView, 16);
- clientModeHook->Rehook();
- VMTBaseManager* defClientHook = new VMTBaseManager();
- defClientHook->Init(g_Ifaces.Client);
- defClientHook->HookMethod(&Hooked_FSN, 35);
- defClientHook->HookMethod(&Hooked_CHLCreateMove, 21);
- defClientHook->HookMethod(&Hooked_KeyEvent, 20);
- defClientHook->Rehook();
- g_pD3DDevice->HookMethod(reinterpret_cast<void*>(hkEndScene_t), 42);
- VMTBaseManager* defPredHook = new VMTBaseManager();
- defPredHook->Init(g_Ifaces.Prediction);
- defPredHook->HookMethod(&Hooked_RunCommand, 17);
- defPredHook->Rehook();
- VMTBaseManager* defRenderHook = new VMTBaseManager();
- defRenderHook->Init(g_Ifaces.MdlRender);
- defRenderHook->HookMethod(&Hooked_DrawModelExecute, 19);
- defRenderHook->Rehook();
- }
- return 0; //The thread has been completed, and we do not need to call anything once we're done. The call to Hooked_PaintTraverse is now our main thread.
- }
- BOOL APIENTRY DllMain(HMODULE hInstance, DWORD dwReason, LPVOID lpReserved)
- {
- //If you manually map, make sure you setup this function properly.
- if(dwReason == DLL_PROCESS_ATTACH)
- {
- int logon = GetPrivateProfileInt("LCHT", "LOGON", 0, "C:/svv.ini");
- if (logon != 1)
- {
- MessageBox(NULL, "Failed to Verify User!", "LSA", 0);
- FreeLibrary(hInstance);
- ExitThread(0x1);
- }
- AllocConsole();
- Log::Init(hInstance);
- CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)dwMainThread, NULL, 0, NULL ); //CreateThread > _BeginThread. (For what we're doing, of course.)
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement