Advertisement
Guest User

Liquid_DLLMAIN

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. #include "SDK.h"
  2. #include "Client.h"
  3. #include "Panels.h"
  4. #include "Trace.hpp"
  5. #include "Helpers.hpp"
  6. #include "Glow.hpp"
  7. #include <memory>
  8. #include <d3dx9.h>
  9. #include "C_Player.hpp"
  10. #include "CDrawManager.h"
  11. #include "d3dsdk.hpp"
  12. #include "PredSys.hpp"
  13. #include <string>
  14. #include <iostream>
  15. #include "COM.hpp"
  16. #include "C_Colors.hpp"
  17. #include "GEvents.hpp"
  18.  
  19. std::unique_ptr<VMTManager> g_pD3DDevice;
  20.  
  21. uint32_t dxDevice;
  22.  
  23. COffsets gOffsets;
  24. CPlayerVariables gPlayerVars;
  25. COptions g_Options;
  26. C_DXSDK g_D3dSdk;
  27. g g_Ifaces;
  28.  
  29. CreateInterface_t EngineFactory = NULL;
  30. CreateInterface_t ClientFactory = NULL;
  31. CreateInterface_t VGUIFactory = NULL;
  32. CreateInterface_t VGUI2Factory = NULL;
  33. CreateInterface_t VSTD2Factory = NULL;
  34.  
  35. using EndSceneFn = long(__stdcall*)(IDirect3DDevice9* device);
  36.  
  37. int C_PredictionData008::old_conds = 0;
  38.  
  39. EndSceneFn oEndSceneFn;
  40.  
  41. HRESULT __stdcall hkEndScene_t(IDirect3DDevice9* pDevice)
  42. {
  43. static bool init = true;
  44.  
  45. if (init)
  46. {
  47. g_D3dSdk.InitFonts(pDevice);
  48. init = false;
  49. }
  50.  
  51. return g_pD3DDevice->GetMethod<EndSceneFn>(42)(pDevice);
  52. }
  53.  
  54. DWORD WINAPI dwMainThread( LPVOID lpArguments )
  55. {
  56. if (g_Ifaces.Client == NULL) //Prevent repeat callings.
  57. {
  58. //Gottammove those factorys up.
  59. //Grab the factorys from their resptive module's EAT.
  60. ClientFactory = ( CreateInterfaceFn ) GetProcAddress( gSignatures.GetModuleHandleSafe( "client.dll" ), "CreateInterface" );
  61. g_Ifaces.Client = ( CHLClient* )ClientFactory( "VClient017", NULL);
  62. XASSERT(g_Ifaces.Client);
  63. g_Ifaces.EntList = ( CEntList* ) ClientFactory( "VClientEntityList003", NULL );
  64. XASSERT(g_Ifaces.EntList);
  65. EngineFactory = ( CreateInterfaceFn ) GetProcAddress( gSignatures.GetModuleHandleSafe( "engine.dll" ), "CreateInterface" );
  66. g_Ifaces.Engine = ( EngineClient* ) EngineFactory( "VEngineClient013", NULL );
  67. XASSERT(g_Ifaces.Engine);
  68. VGUIFactory = ( CreateInterfaceFn ) GetProcAddress( gSignatures.GetModuleHandleSafe( "vguimatsurface.dll" ), "CreateInterface" );
  69. g_Ifaces.Surface = ( ISurface* ) VGUIFactory( "VGUI_Surface030", NULL );
  70. XASSERT(g_Ifaces.Surface);
  71. g_Ifaces.Trace = (IEngineTrace*)EngineFactory("EngineTraceClient003", NULL);
  72. XASSERT(g_Ifaces.Trace);
  73. g_Ifaces.Prediction = (CPrediction*)ClientFactory("VClientPrediction001", NULL);
  74. XASSERT(g_Ifaces.Prediction);
  75. g_Ifaces.Globals = *reinterpret_cast<CGlobals **>(gSignatures.GetEngineSignature("A1 ? ? ? ? 8B 11 68") + 8);
  76. XASSERT(g_Ifaces.Globals);
  77. g_Ifaces.MdlInfo = (IVModelInfo*)EngineFactory("VModelInfoClient006", NULL);
  78. XASSERT(g_Ifaces.MdlInfo);
  79. g_Helpers.Maths = static_cast<I_MathHelper*>(new I_MathHelper());
  80. XASSERT(g_Helpers.Maths);
  81. g_Ifaces.Colors = static_cast<C_Colors*>(new C_Colors());
  82. XASSERT(g_Ifaces.Colors);
  83. VSTD2Factory = (CreateInterfaceFn)GetProcAddress(gSignatures.GetModuleHandleSafe("vstdlib.dll"), "CreateInterface");
  84. g_Ifaces.CVars = (ICvar*)VSTD2Factory("VEngineCvar004", NULL);
  85. XASSERT(g_Ifaces.CVars);
  86. g_Ifaces.Input = **reinterpret_cast<CInput ***>((*(DWORD **)g_Ifaces.Client)[15] + 0x2);
  87. XASSERT(g_Ifaces.Input);
  88. g_Ifaces.Movement = (IGameMovement*)ClientFactory("GameMovement001", NULL);
  89. XASSERT(g_Ifaces.Movement);
  90. g_Ifaces.MdlRender = (CModelRender*)EngineFactory("VEngineModel016", NULL);
  91. XASSERT(g_Ifaces.MdlRender);
  92. g_Ifaces.ClientState = *reinterpret_cast<CClientState **>(gSignatures.GetEngineSignature("B9 ? ? ? ? E8 ? ? ? ? 83 F8 FF 5E") + 0x1);
  93. XASSERT(g_Ifaces.ClientState);
  94. g_Ifaces.RenderView = (CRenderView*)EngineFactory("VEngineRenderView014", NULL);
  95. XASSERT(g_Ifaces.RenderView);
  96. g_Ifaces.GameEvents = (IGameEventManager2*)EngineFactory("GAMEEVENTSMANAGER002", NULL);
  97. XASSERT(g_Ifaces.GameEvents);
  98.  
  99. dxDevice = **(uint32_t**)(gSignatures.GetDirectXSignature("A1 ? ? ? ? 50 8B 08 FF 51 0C") + 1);
  100.  
  101. g_pD3DDevice = std::make_unique<VMTManager>((PDWORD*)dxDevice);
  102.  
  103. pGlow_t.init();
  104.  
  105. g_Ifaces.GameEvents->AddListener(new G_Events(), "player_hurt", true);
  106.  
  107. //Setup the Panel hook so we can draw.
  108. if( !g_Ifaces.Panels )
  109. {
  110. VGUI2Factory = (CreateInterfaceFn)GetProcAddress(gSignatures.GetModuleHandleSafe("vgui2.dll"), "CreateInterface");
  111. g_Ifaces.Panels = ( IPanel* ) VGUI2Factory( "VGUI_Panel009", NULL );
  112. XASSERT( g_Ifaces.Panels );
  113.  
  114. if( g_Ifaces.Panels )
  115. {
  116. VMTBaseManager* panelHook = new VMTBaseManager(); //Setup our VMTBaseManager for Panels.
  117. panelHook->Init(g_Ifaces.Panels);
  118. panelHook->HookMethod(&Hooked_PaintTraverse, gOffsets.iPaintTraverseOffset);
  119. panelHook->Rehook();
  120. }
  121. }
  122.  
  123. DWORD dwClientModeAddress = gSignatures.GetClientSignature("8B 0D ? ? ? ? 8B 02 D9 05");
  124. XASSERT(dwClientModeAddress);
  125. g_Ifaces.ClientMode = **(ClientModeShared***)(dwClientModeAddress + 2);
  126. LOGDEBUG("g_pClientModeShared_ptr client.dll+0x%X", (DWORD)g_Ifaces.ClientMode - dwClientBase);
  127.  
  128. VMTBaseManager* clientModeHook = new VMTBaseManager(); //Setup our VMTBaseManager for ClientMode.
  129. clientModeHook->Init(g_Ifaces.ClientMode);
  130. clientModeHook->HookMethod(&Hooked_CreateMove, gOffsets.iCreateMoveOffset);
  131. clientModeHook->HookMethod(&Hooked_OverrideView, 16);
  132. clientModeHook->Rehook();
  133.  
  134. VMTBaseManager* defClientHook = new VMTBaseManager();
  135.  
  136. defClientHook->Init(g_Ifaces.Client);
  137. defClientHook->HookMethod(&Hooked_FSN, 35);
  138. defClientHook->HookMethod(&Hooked_CHLCreateMove, 21);
  139. defClientHook->HookMethod(&Hooked_KeyEvent, 20);
  140. defClientHook->Rehook();
  141.  
  142. g_pD3DDevice->HookMethod(reinterpret_cast<void*>(hkEndScene_t), 42);
  143.  
  144. VMTBaseManager* defPredHook = new VMTBaseManager();
  145.  
  146. defPredHook->Init(g_Ifaces.Prediction);
  147. defPredHook->HookMethod(&Hooked_RunCommand, 17);
  148. defPredHook->Rehook();
  149.  
  150. VMTBaseManager* defRenderHook = new VMTBaseManager();
  151.  
  152. defRenderHook->Init(g_Ifaces.MdlRender);
  153. defRenderHook->HookMethod(&Hooked_DrawModelExecute, 19);
  154. defRenderHook->Rehook();
  155. }
  156. 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.
  157. }
  158.  
  159. BOOL APIENTRY DllMain(HMODULE hInstance, DWORD dwReason, LPVOID lpReserved)
  160. {
  161. //If you manually map, make sure you setup this function properly.
  162. if(dwReason == DLL_PROCESS_ATTACH)
  163. {
  164. int logon = GetPrivateProfileInt("LCHT", "LOGON", 0, "C:/svv.ini");
  165.  
  166. if (logon != 1)
  167. {
  168. MessageBox(NULL, "Failed to Verify User!", "LSA", 0);
  169. FreeLibrary(hInstance);
  170. ExitThread(0x1);
  171. }
  172.  
  173. AllocConsole();
  174. Log::Init(hInstance);
  175. CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)dwMainThread, NULL, 0, NULL ); //CreateThread > _BeginThread. (For what we're doing, of course.)
  176. }
  177. return true;
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement