Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1.  
  2. #pragma once
  3. #include "IniReader.h"
  4. #include "IniWriter.h"
  5. #include <vector>
  6. #include <algorithm>
  7. #include "stdafx.h"
  8. #include "resource.h"
  9. #include "SDK/SDK Headers/CGameEvent.h"
  10. #include <d3d9.h>
  11. #include "Globals.h"
  12. #include "stdint.h"
  13. #include "Config.h"
  14. #include "Chams.h"
  15.  
  16. //#include "Config.h
  17.  
  18. #include "Options.h"
  19.  
  20.  
  21. //cOptions Options;
  22.  
  23.  
  24. void __fastcall Hooked_Createmove(CInput* thisptr, void* _EAX, int sequence_number, float input_sample_frametime, bool active);
  25. void __stdcall Hooked_PaintTraverse(unsigned int vguiPanel, bool forceRepaint, bool allowForce);
  26. void __stdcall Hooked_Frame_Stage_Notify( ClientFrameStage_t curStage );
  27. void __stdcall Hooked_OverrideView( CViewSetup* pSetup );
  28. float __stdcall Hooked_ViewmodelFOV();
  29. HRESULT __stdcall Hooked_Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresParam);
  30. HRESULT __stdcall Hooked_EndScene(IDirect3DDevice9* pDevice);
  31. LRESULT __stdcall Hooked_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  32. void __fastcall Hooked_DrawModelExecute( void* thisptr, int edx, void* ctx, void* state, const ModelRenderInfo_t& pInfo, matrix3x4_t* pCustomBoneToWorld );
  33. void __stdcall Hooked_ClientCmdUnrestricted( const char* szCmdString, char flag );
  34. int __stdcall Hooked_DoPostScreenEffects(int a1);
  35. void __stdcall Hooked_PlaySound( const char* pSample );
  36.  
  37. void Init();
  38.  
  39. //void __stdcall Hooked_OverrideMouseInput(float *x, float* y);
  40.  
  41. extern VTHookManager VMTClientMode;
  42. extern VTHookManager VMTGameEvent;
  43.  
  44. class CHackManager
  45. {
  46. private:
  47. /* Typedefs */
  48. typedef float(__stdcall *GetViewModelFOVFn)();
  49. typedef long(__stdcall* tReset)(IDirect3DDevice9* dev, D3DPRESENT_PARAMETERS* pp);
  50. typedef void (__thiscall *iPaintTraverse)( void*, unsigned int, bool, bool );
  51. typedef long(__stdcall *EndSceneFn)(IDirect3DDevice9* device);
  52. typedef void (__stdcall *iCreateMoveFn)( CInput*, void*, int, float, bool );
  53. typedef void (__stdcall *iFrameStageNotifyFn)( ClientFrameStage_t );
  54. typedef int(__thiscall* DoPostScreenEffects)(IClientModeShared*, int);
  55. typedef void (__stdcall *iOverRideViewFn)( CViewSetup* );
  56. typedef void (__thiscall* IDrawModelExecute)( void*, void*, void*, const ModelRenderInfo_t&, matrix3x4_t* );
  57. typedef void (__stdcall* ClientCmdUnresticted)( const char* szCmdString, char flag );
  58. typedef bool ( __cdecl* ServerRankRevealAllFn)( float* );
  59. typedef void ( __stdcall* PlaySoundFn )( const char* pSample );
  60. typedef void ( __stdcall* IsReadyFn )();
  61. //typedef void(__stdcall* iOverrideMouseInput)(float *x, float *y);
  62.  
  63. public:
  64. std::vector<IGameEventListener2*> listeners = {};
  65.  
  66. /* Original Functions */
  67. DWORD oCreateMove;
  68. EndSceneFn oEndScene;
  69. tReset oResetScene;
  70. iPaintTraverse oPaintTraverse;
  71. iFrameStageNotifyFn oFrameStageNotify;
  72. IDrawModelExecute oDrawModelExecute;
  73. iOverRideViewFn oOverrideView;
  74. ClientCmdUnresticted oClientCmdUnresticted;
  75. PlaySoundFn oPlaySound;
  76. GetViewModelFOVFn GetViewModelFOV;
  77. ServerRankRevealAllFn ServerRankRevealEx;
  78. IsReadyFn IsReadyEx;
  79. DoPostScreenEffects oDoPostScreenEffects;
  80. //iOverrideMouseInput oOverrideMouseInput;
  81.  
  82. /* Holding Varialbles */
  83. CInput::CUserCmd* CurrentCmd;
  84. CBaseEntity* LocalPlayer;
  85. CBaseCombatWeapon* LocalWeapon;
  86. Vector LastAngles;
  87. bool SendPacket = true;
  88. float FOV;
  89.  
  90. DWORD Font_Watermark;
  91. DWORD Font_ESP;
  92. DWORD Font_Controls;
  93. DWORD Font_Icon;
  94. DWORD Font_Weapons;
  95. DWORD Font_Health;
  96. DWORD Font_Bomb;
  97.  
  98. /* Hooking */
  99. void Hook()
  100. {
  101. Font_Watermark = Interfaces.pSurface->Create_Font();
  102. Font_ESP = Interfaces.pSurface->Create_Font();
  103. Font_Controls = Interfaces.pSurface->Create_Font();
  104. Font_Icon = Interfaces.pSurface->Create_Font();
  105. Font_Weapons = Interfaces.pSurface->Create_Font();
  106. Font_Health = Interfaces.pSurface->Create_Font();
  107. Font_Bomb = Interfaces.pSurface->Create_Font();
  108.  
  109.  
  110. /*
  111. FONTFLAG_NONE,
  112. FONTFLAG_ITALIC = 0x001,
  113. FONTFLAG_UNDERLINE = 0x002,
  114. FONTFLAG_STRIKEOUT = 0x004,
  115. FONTFLAG_SYMBOL = 0x008,
  116. FONTFLAG_ANTIALIAS = 0x010,
  117. FONTFLAG_GAUSSIANBLUR = 0x020,
  118. FONTFLAG_ROTARY = 0x040,
  119. FONTFLAG_DROPSHADOW = 0x080,
  120. FONTFLAG_ADDITIVE = 0x100,
  121. FONTFLAG_OUTLINE = 0x200,
  122. FONTFLAG_CUSTOM = 0x400,
  123. FONTFLAG_BITMAP = 0x800,
  124. */
  125.  
  126. Interfaces.pSurface->SetFontGlyphSet( Font_Controls, "Verdana", 13, 400, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW | FONTFLAG_ADDITIVE | FONTFLAG_OUTLINE);
  127. Interfaces.pSurface->SetFontGlyphSet( Font_Watermark, "MS Sans Serif", 16, 600, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW | FONTFLAG_OUTLINE);
  128. Interfaces.pSurface->SetFontGlyphSet( Font_ESP, "Dotum", 12, 700, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_OUTLINE);
  129. Interfaces.pSurface->SetFontGlyphSet( Font_Icon, "icomoon", 42, 400, 0, 0, FONTFLAG_ANTIALIAS );
  130. Interfaces.pSurface->SetFontGlyphSet( Font_Weapons, "icomoon", 12, 500, 0, 0, FONTFLAG_ANTIALIAS);
  131. Interfaces.pSurface->SetFontGlyphSet(Font_Health, "Verdana", 13, 400, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW | FONTFLAG_ADDITIVE | FONTFLAG_OUTLINE);
  132. Interfaces.pSurface->SetFontGlyphSet(Font_Bomb, "Verdana", 15, 600, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_OUTLINE);
  133.  
  134.  
  135. DWORD dwDevice = **(DWORD**)(Utils.FindPatternIDA("shaderapidx9.dll", "A1 ?? ?? ?? ?? 50 8B 08 FF 51 0C") + 0x1);
  136. HRSRC hResInst = FindResource( nullptr, MAKEINTRESOURCE( IDR_FONT1 ), RT_FONT );
  137. HGLOBAL hGlobal = LoadResource( nullptr, hResInst );
  138. size_t __LEN = SizeofResource( nullptr, hResInst );
  139. DWORD dwFonts;
  140. Interfaces.__FNTHANDLE = AddFontMemResourceEx( nullptr, __LEN, nullptr, &dwFonts );
  141. auto __FONT = CreateFont( 16, 0, 0, 0, 500, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "undefeated.tff" );
  142.  
  143.  
  144. CreateDirectory("C:\\Octate", NULL);
  145. //Global::configpath = "C:\\Octate\\config.ini";
  146. // Hooks
  147. if( Interfaces.pClient )
  148. {
  149. VMTClient.bInitialize( reinterpret_cast< DWORD** >( Interfaces.pClient ) );
  150. oCreateMove = VMTClient.dwHookMethod( reinterpret_cast< DWORD >( &Hooked_Createmove ), 21 );
  151. cout << ired << "Create Move Hooked (21)." << iyellow << " oCreateMove = 0x" << oCreateMove << white << endl;
  152. oFrameStageNotify = reinterpret_cast< iFrameStageNotifyFn >( VMTClient.dwHookMethod( reinterpret_cast< DWORD >( &Hooked_Frame_Stage_Notify ), 36 ) );
  153. cout << ired << "Frame Stage Notfiy Hooked (36)." << iyellow << " oFrameStageNotify = 0x" << oFrameStageNotify << white << endl;
  154. }
  155.  
  156. if( Interfaces.pEngine )
  157. {
  158. VMTEngine.bInitialize( reinterpret_cast< DWORD** >( Interfaces.pEngine ) );
  159. oClientCmdUnresticted = reinterpret_cast< ClientCmdUnresticted >( VMTEngine.dwHookMethod( reinterpret_cast< DWORD >( &Hooked_ClientCmdUnrestricted ), 114 ) );
  160. }
  161.  
  162. if( Interfaces.pSurface )
  163. {
  164. VMTPanel.bInitialize( reinterpret_cast< unsigned long** >( Interfaces.pPanel ) );
  165. oPaintTraverse = reinterpret_cast< iPaintTraverse >( VMTPanel.dwHookMethod( reinterpret_cast< DWORD >( &Hooked_PaintTraverse ), 41 ) );
  166. cout << ired << "Paint Traverse Hooked (41)." << iyellow << " oPaintTraverse = 0x" << oPaintTraverse << white << endl;
  167. }
  168.  
  169. if (dwDevice)
  170. {
  171. VMTD3D.bInitialize(reinterpret_cast<DWORD**>(dwDevice));
  172. oEndScene = reinterpret_cast<EndSceneFn>(VMTD3D.dwHookMethod(reinterpret_cast<DWORD>(&Hooked_EndScene), 42));
  173. cout << ired << "DirectX Hooked (42)." << iyellow << "oEndScene = 0x" << oEndScene << white << endl;
  174. oResetScene = reinterpret_cast<tReset>(VMTD3D.dwHookMethod(reinterpret_cast<DWORD>(&Hooked_Reset), 16));
  175. cout << ired << "DirectReset Hooked (16)." << iyellow << "oResetScene = 0x" << oResetScene << white << endl;
  176. }
  177.  
  178.  
  179. if( Interfaces.g_pModelRender )
  180. {
  181. VMTModelRender.bInitialize( reinterpret_cast< DWORD** >( Interfaces.g_pModelRender ) );
  182. oDrawModelExecute = reinterpret_cast< IDrawModelExecute >( VMTModelRender.dwHookMethod( reinterpret_cast< DWORD >( &Hooked_DrawModelExecute ), 21 ) );
  183. cout << ired << "Draw Model Execute Hooked (21)." << iyellow << " oDrawModelExecute = 0x" << oDrawModelExecute << white << endl;
  184. }
  185.  
  186. if( Interfaces.pClientMode )
  187. {
  188. VMTClientMode.bInitialize( reinterpret_cast< DWORD** >( Interfaces.pClientMode ) );
  189. GetViewModelFOV = reinterpret_cast< GetViewModelFOVFn >(VMTClientMode.dwHookMethod(reinterpret_cast< DWORD >(&Hooked_ViewmodelFOV), 35));
  190. oOverrideView = reinterpret_cast< iOverRideViewFn >( VMTClientMode.dwHookMethod( reinterpret_cast< DWORD >( &Hooked_OverrideView ), 18 ) );
  191. oDoPostScreenEffects = reinterpret_cast<DoPostScreenEffects>(VMTClientMode.dwHookMethod(reinterpret_cast<DWORD>(&Hooked_DoPostScreenEffects), 44));
  192. }
  193.  
  194. if( Interfaces.pSurface )
  195. {
  196. VMTSurface.bInitialize( ( DWORD** )Interfaces.pSurface );
  197. //oPlaySound = ( PlaySoundFn )VMTSurface.dwHookMethod( ( DWORD )&Hooked_PlaySound, 82 );
  198. }
  199.  
  200. //while( !( INIT::Window = FindWindowA( "Valve001", nullptr ) ) )
  201. // Sleep( 100 );
  202. //if( INIT::Window )
  203. // INIT::OldWindow = ( WNDPROC )SetWindowLongPtr( INIT::Window, GWL_WNDPROC, ( LONG_PTR )Hooked_WndProc );
  204.  
  205. Init();
  206. }
  207.  
  208. void UnHook()
  209. {
  210. VMTClient.UnHook();
  211. Sleep( 150 );
  212. VMTClientMode.UnHook();
  213. Sleep( 150 );
  214. VMTEngine.UnHook();
  215. Sleep( 150 );
  216. VMTModelRender.UnHook();
  217. Sleep( 150 );
  218. VMTPanel.UnHook();
  219. Sleep( 150 );
  220. VMTGameEvent.UnHook();
  221. Sleep( 150 );
  222. VMTSurface.UnHook();
  223. Sleep( 150 );
  224. VMTD3D.UnHook();
  225. Sleep( 150 );
  226. for (auto listener : listeners)
  227. Interfaces.g_GameEventMgr->RemoveListener(listener);
  228. }
  229. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement