Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Hook.h"
- #include "intrin.h"
- //[enc_string_enable /]
- //[junk_enable /]
- CAimbot* g_Aim;
- namespace Engine
- {
- namespace Hook
- {
- vfunc_hook panel;
- vfunc_hook client;
- vfunc_hook clientmode;
- vfunc_hook modelrender;
- vfunc_hook sound;
- vfunc_hook surface;
- vfunc_hook eventmanager;
- vfunc_hook device;
- vfunc_hook SteamGameCoordinatorTable;
- IDirect3DDevice9* g_pDevice = nullptr;
- typedef HRESULT(WINAPI* Present_t)(IDirect3DDevice9* pDevice, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
- Present_t Present_o;
- typedef HRESULT(WINAPI* Reset_t)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
- Reset_t Reset_o;
- HRESULT WINAPI Hook_Present(IDirect3DDevice9* pDevice, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
- {
- Client::OnRender();
- return Present_o(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
- }
- void __stdcall Hook_Reset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
- {
- static auto ofunc = device.get_original<ResetHook>(D3D9::TABLE::Reset);
- ofunc(pDevice, pPresentationParameters);
- Client::OnLostDevice();
- HRESULT hRes = Reset_o(pDevice, pPresentationParameters);
- Client::OnResetDevice();
- }
- void __stdcall Hook_CreateMove(float flInputSampleTime, CUserCmd* pCmd)
- {
- static auto ofunc = clientmode.get_original<CreateMove>(TABLE::IClientMode::CreateMove);
- ofunc(Interfaces::ClientMode(), flInputSampleTime, pCmd);
- Client::OnCreateMove(pCmd);
- }
- EGCResults __fastcall Hook_RetrieveMessage(void* ecx, void* edx, uint32_t *punMsgType, void *pubDest, uint32_t cubDest, uint32_t *pcubMsgSize)
- {
- EGCResults status = Interfaces::SteamGameCoordinator()->RetrieveMessage(punMsgType, pubDest, cubDest, pcubMsgSize);
- if (status != k_EGCResultOK)
- return status;
- Client::OnRetrieveMessage(ecx, edx, punMsgType, pubDest, cubDest, pcubMsgSize);
- return status;
- }
- EGCResults __fastcall Hook_SendMessage(void* ecx, void* edx, uint32_t unMsgType, const void* pubData, uint32_t cubData)
- {
- uint32_t messageType = unMsgType & 0x7FFFFFFF;
- void* pubDataMutable = const_cast<void*>(pubData);
- Client::OnSendMessage(ecx, edx, unMsgType, pubData, cubData);
- EGCResults status = Interfaces::SteamGameCoordinator()->SendMessage(unMsgType, pubData, cubData);
- return status;
- }
- void __fastcall Hook_OverrideView(CViewSetup* pSetup)
- {
- static auto ofunc = clientmode.get_original<GetFov>(TABLE::IClientMode::OverrideView);
- Client::OnOverrideView(pSetup);
- ofunc(pSetup);
- }
- float __stdcall Hook_GetViewModelFOV()
- {
- //i dont need that
- return 0;
- }
- bool __fastcall Hook_FireEventClientSideThink(void* ecx, void* edx, IGameEvent* pEvent)
- {
- static auto ofunc = eventmanager.get_original<GameEvent>(TABLE::IGameEventManager2::FireEventClientSide);
- if (!pEvent)
- return ofunc(ecx, pEvent);
- Client::OnFireEventClientSideThink(pEvent);
- return ofunc(ecx, pEvent);
- }
- void __stdcall Hook_FrameStageNotify(ClientFrameStage_t stage)
- {
- static auto ofunc = client.get_original<FrameStageNotify>(TABLE::IBaseClientDLL::FrameStageNotify);
- ofunc(Interfaces::Client(), stage);
- Skin_OnFrameStageNotify(stage);
- Gloves_OnFrameStageNotify(stage);
- }
- void __stdcall Hook_EmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample,
- float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags = 0, int iPitch = PITCH_NORM,
- const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1, int test = 0)
- {
- auto oEmitsound = sound.get_original<EmitsoundXD>(TABLE::IEngineSound::EmitSound1);
- if (pSample && Client::g_pPlayers->GetPlayer(iEntIndex)->Team != Client::g_pPlayers->GetLocal()->Team)
- {
- Client::OnPlaySound(pOrigin, pSample);
- }
- return oEmitsound(filter, iEntIndex, iChannel, pSoundEntry, nSoundEntryHash, pSample,
- flVolume, iSoundlevel, nSeed, iFlags, iPitch,
- pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity, 0);
- }
- void __stdcall Hook_EmitSound2(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample,
- float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags = 0, int iPitch = PITCH_NORM,
- const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1, int test = 0)
- {
- auto oEmitsound = sound.get_original<EmitsoundXD>(TABLE::IEngineSound::EmitSound2);
- if (pSample && Client::g_pPlayers->GetPlayer(iEntIndex)->Team != Client::g_pPlayers->GetLocal()->Team)
- {
- Client::OnPlaySound(pOrigin, pSample);
- }
- return oEmitsound(filter, iEntIndex, iChannel, pSoundEntry, nSoundEntryHash, pSample,
- flVolume, iSoundlevel, nSeed, iFlags, iPitch,
- pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity, 0);
- }
- void __fastcall Hook_DrawModelExecute(IMatRenderContext* ctx, const DrawModelState_t &state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld)
- {
- // i dont like chams and other shit, use box or maybe you can write this forself... THIS IS FROM AZOR. WRITE YOUR OWN MODELS
- }
- void __stdcall Hook_PlaySound(const char* pszSoundName)
- {
- static auto ofunc = surface.get_original<PlaySound>(TABLE::ISurface::PlaySound);
- ofunc(Interfaces::Surface(), pszSoundName);
- if (pszSoundName)
- Client::OnPlaySound(pszSoundName);
- }
- bool SendClientHello()
- {
- CMsgClientHello Message;
- Message.set_client_session_need(1);
- Message.clear_socache_have_versions();
- void* ptr = malloc(Message.ByteSize() + 8);
- if (!ptr)
- return false;
- ((uint32_t*)ptr)[0] = k_EMsgGCClientHello | ((DWORD)1 << 31);
- ((uint32_t*)ptr)[1] = 0;
- Message.SerializeToArray((void*)((DWORD)ptr + 8), Message.ByteSize());
- bool result = Interfaces::SteamGameCoordinator()->SendMessage(k_EMsgGCClientHello | ((DWORD)1 << 31), ptr, Message.ByteSize() + 8) == k_EGCResultOK;
- free(ptr);
- return result;
- }
- void Hook_LockCursor()
- {
- Interfaces::Surface()->LockCursor();
- if (bIsGuiVisible)
- Interfaces::Surface()->UnlockCursor();
- }
- bool Initialize()
- {
- if (!CSX::Utils::IsModuleLoad(D3D9_DLL))
- return false;
- if (!CSX::Utils::IsModuleLoad(SHADERPIDX9_DLL))
- return false;
- if (!CSX::Utils::IsModuleLoad(GAMEOVERLAYRENDERER_DLL))
- return false;
- DWORD d3d9TablePtrPtr = CSX::Memory::FindPattern(SHADERPIDX9_DLL, D3D9_PATTERN, D3D9_MASK, 1);
- DWORD_PTR** dwPresent_o = (DWORD_PTR**)CSX::Memory::FindPattern(GAMEOVERLAYRENDERER_DLL, GMOR_PATTERN, GMOR_MASK, 1);
- if (d3d9TablePtrPtr && dwPresent_o)
- {
- g_pDevice = (IDirect3DDevice9*)(**(PDWORD*)d3d9TablePtrPtr);
- if (device.setup(g_pDevice))
- {
- //all undetect and rewrite
- DWORD_PTR* dwAddress = *dwPresent_o;
- Present_o = (Present_t)(*dwAddress);
- *dwAddress = (DWORD_PTR)(&Hook_Present);
- device.hook_index(D3D9::TABLE::Reset, Hook_Reset);
- if (!clientmode.setup(Interfaces::ClientMode()))
- return false;
- clientmode.hook_index(TABLE::IClientMode::CreateMove, Hook_CreateMove);
- clientmode.hook_index(TABLE::IClientMode::OverrideView, Hook_OverrideView);
- //clientmode.hook_index(TABLE::IClientMode::GetViewModelFOV, Hook_GetViewModelFOV);
- if (!panel.setup(Interfaces::VPanel()))
- return false;
- //panel.hook_index(41, hkPaintTraverse); //crashs game - someone update this
- if (!client.setup(Interfaces::Client()))
- return false;
- client.hook_index(TABLE::IBaseClientDLL::FrameStageNotify, Hook_FrameStageNotify);
- if (!SteamGameCoordinatorTable.setup(Interfaces::SteamGameCoordinator()))
- return false;
- SteamGameCoordinatorTable.hook_index(0, Hook_SendMessage);
- SteamGameCoordinatorTable.hook_index(2, Hook_RetrieveMessage);
- if (!eventmanager.setup(Interfaces::GameEvent()))
- return false;
- eventmanager.hook_index(TABLE::IGameEventManager2::FireEventClientSide, Hook_FireEventClientSideThink);
- if (!client.setup(Interfaces::Client()))
- return false;
- client.hook_index(TABLE::IBaseClientDLL::FrameStageNotify, Hook_FrameStageNotify);
- if (!sound.setup(Interfaces::Sound()))
- return false;
- sound.hook_index(TABLE::IEngineSound::EmitSound1, Hook_EmitSound2);
- /* THIS IS FOR CHAMS ETC! YOU CAN INCLUDE IT WITHOUT VAC BAN! IT IS VMT UNDETECTED!
- if (!modelrender.setup(Interfaces::ModelRender()))
- return false;
- modelrender.hook_index(TABLE::IVModelRender::DrawModelExecute, Hook_DrawModelExecute);
- */
- if (!surface.setup(Interfaces::Surface()))
- return false;
- surface.hook_index(TABLE::ISurface::PlaySound, Hook_PlaySound);
- surface.hook_index(TABLE::ISurface::LockCursor, Hook_LockCursor);
- if (Client::Initialize(g_pDevice))
- SendClientHello();
- return true;
- }
- }
- return false;
- }
- void Shutdown()
- {
- device.unhook_all();
- sound.unhook_all();
- clientmode.unhook_all();
- eventmanager.unhook_all();
- modelrender.unhook_all();
- client.unhook_all();
- SteamGameCoordinatorTable.unhook_all();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment