Advertisement
Guest User

hook.cpp

a guest
Nov 14th, 2018
2,843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 27.21 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. #include "hooks.hpp"
  6. #include <intrin.h>  
  7.  
  8. #include "menu.hpp"
  9. #include "options.hpp"
  10. #include "helpers/input.hpp"
  11. #include "helpers/utils.hpp"
  12. #include "features/misc.hpp"
  13. #include "features/chams.hpp"
  14. #include "features/visuals.hpp"
  15.  
  16. #include "features/Skinchanger.h"
  17. #include "features/legitbot.h"
  18. #include "features/GrenadePredict.h"
  19. #include "helpers/math.hpp"
  20. #include "GameEvents.h"
  21. #include "EnginePrediction.h"
  22.  
  23. #include "SpoofedConvar.h"
  24. #include "Resolver.h"
  25.  
  26. #include "steam_sdk/isteamfriends.h"
  27. #pragma intrinsic(_ReturnAddress)  
  28. vgui::HFont font;
  29.  
  30. std::unique_ptr<C_EventListener>          g_EventListener = nullptr;
  31.  
  32. void ConColorMsg( Color const &color , const char* buf , ... )
  33. {
  34.     using ConColFn = void( __stdcall* )( Color const & , const char* , ... );
  35.     auto ConCol = reinterpret_cast< ConColFn >( ( GetProcAddress( GetModuleHandle( L"tier0.dll" ) , "?ConColorMsg@@YAXABVColor@@PBDZZ" ) ) );
  36.     ConCol( color , buf );
  37. }
  38.  
  39. typedef void(__cdecl* MsgFn)(const char* msg, va_list);
  40. void ConMsg( const char* msg , ... )
  41. {
  42.     if ( msg == nullptr )
  43.         return; //If no string was passed, or it was null then don't do anything
  44.     static MsgFn fn = ( MsgFn ) GetProcAddress( GetModuleHandleA( "tier0.dll" ) , "Msg" ); //This gets the address of export "Msg" in the dll "tier0.dll". The static keyword means it's only called once and then isn't called again (but the variable is still there)
  45.     char buffer[989];
  46.     va_list list; //Normal varargs stuff http://stackoverflow.com/questions/10482960/varargs-to-printf-all-arguments
  47.     va_start( list , msg );
  48.     vsprintf( buffer , msg , list );
  49.     va_end( list );
  50.     fn( buffer , list ); //Calls the function, we got the address above.
  51. }
  52.  
  53. namespace Hooks
  54. {
  55.     vfunc_hook hlclient_hook;
  56.     vfunc_hook direct3d_hook;
  57.     vfunc_hook vguipanel_hook;
  58.     vfunc_hook vguisurf_hook;
  59.     vfunc_hook mdlrender_hook;
  60.     vfunc_hook clientmode_hook;
  61.     vfunc_hook sv_cheats;
  62.     vfunc_hook steamgamecoordinator;
  63.     vfunc_hook engine_sound;
  64.     vfunc_hook render_view;
  65.     vfunc_hook sound_hook;
  66.  
  67.     void Initialize( )
  68.     {
  69.         hlclient_hook.setup( g_CHLClient, "client_panorama.dll" );
  70.         direct3d_hook.setup( g_D3DDevice9, "shaderapidx9.dll" );
  71.         vguipanel_hook.setup( g_VGuiPanel );
  72.         vguisurf_hook.setup( g_VGuiSurface );
  73.         mdlrender_hook.setup( g_MdlRender, "engine.dll" );
  74.         clientmode_hook.setup( g_ClientMode, "client_panorama.dll" );
  75.         ConVar* sv_cheats_con = g_CVar->FindVar( "sv_cheats" );
  76.         sv_cheats.setup( sv_cheats_con );
  77.         render_view.setup( g_RenderView );
  78.         sound_hook.setup( g_EngineSound );
  79.  
  80.  
  81.         hlclient_hook.hook_index( 37, hkFrameStageNotify );
  82.         if ( !g_Options.light ) {
  83.             hlclient_hook.hook_index( 22, hkCreateMove_Proxy );
  84.             vguipanel_hook.hook_index( 41, hkPaintTraverse );
  85.             mdlrender_hook.hook_index( index::DrawModelExecute, hkDrawModelExecute );
  86.             clientmode_hook.hook_index( index::DoPostScreenSpaceEffects, hkDoPostScreenEffects );
  87.             clientmode_hook.hook_index( index::OverrideView, hkOverrideView );
  88.             clientmode_hook.hook_index( 35, hkGetViewModelFOV );
  89.             render_view.hook_index( 9, hkSceneEnd );
  90.         }
  91.  
  92.         vguisurf_hook.hook_index( 67, hkLockCursor );
  93.  
  94.         sound_hook.hook_index( 5, hkEmitSound1 );
  95.  
  96.         sv_cheats.hook_index( index::SvCheatsGetBool, hkSvCheatsGetBool );
  97.  
  98.         Visuals::CreateFonts( );
  99.  
  100.         direct3d_hook.hook_index( index::EndScene, hkEndScene );
  101.         direct3d_hook.hook_index( index::Reset, hkReset );
  102.  
  103.         g_EventListener = std::make_unique<C_EventListener>( );
  104.         std::cout << "Done!" << std::endl;
  105.  
  106.     }
  107.     //-------------------------------------------------------------------------------
  108.  
  109.     void Shutdown( )
  110.     {
  111.         hlclient_hook.unhook_all( );
  112.         direct3d_hook.unhook_all( );
  113.         vguipanel_hook.unhook_all( );
  114.         vguisurf_hook.unhook_all( );
  115.         mdlrender_hook.unhook_all( );
  116.         clientmode_hook.unhook_all( );
  117.         render_view.unhook_all( );
  118.         sound_hook.unhook_all( );
  119.  
  120.        
  121.  
  122.         Visuals::DestroyFonts( );
  123.     }
  124.  
  125.     void __stdcall hkEmitSound1( IRecipientFilter& filter , int iEntIndex , int iChannel , const char* pSoundEntry , unsigned int nSoundEntryHash , const char *pSample , float flVolume , int nSeed , float flAttenuation , int iFlags , int iPitch , const Vector* pOrigin , const Vector* pDirection , void* pUtlVecOrigins , bool bUpdatePositions , float soundtime , int speakerentity , int unk )
  126.     {
  127.         static auto ofunc = sound_hook.get_original<EmitSound1>( 5 );
  128.  
  129.  
  130.         if ( !strcmp( pSoundEntry , "UIPanorama.popup_accept_match_beep" ) )
  131.         {
  132.             if ( g_Options.misc_autoaccept )
  133.             {
  134.                 static auto fnAccept = reinterpret_cast< bool( __stdcall* )( const char* ) >( Utils::PatternScan( GetModuleHandleA( "client_panorama.dll" ) , "55 8B EC 83 E4 F8 8B 4D 08 BA ? ? ? ? E8 ? ? ? ? 85 C0 75 12" ) );
  135.  
  136.                 if ( fnAccept )
  137.                 {
  138.  
  139.                     fnAccept( "" );
  140.  
  141.                     //This will flash the CSGO window on the taskbar
  142.                     //so we know a game was found (you cant hear the beep sometimes cause it auto-accepts too fast)
  143.                     FLASHWINFO fi;
  144.                     fi.cbSize = sizeof( FLASHWINFO );
  145.                     fi.hwnd = InputSys::Get( ).GetMainWindow( );
  146.                     fi.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
  147.                     fi.uCount = 0;
  148.                     fi.dwTimeout = 0;
  149.                     FlashWindowEx( &fi );
  150.                 }
  151.             }
  152.         }
  153.  
  154.         ofunc( g_EngineSound , filter , iEntIndex , iChannel , pSoundEntry , nSoundEntryHash , pSample , flVolume , nSeed , flAttenuation , iFlags , iPitch , pOrigin , pDirection , pUtlVecOrigins , bUpdatePositions , soundtime , speakerentity , unk );
  155.  
  156.     }
  157.  
  158.     typedef void( __thiscall* LockCursor )( void* );
  159.     LockCursor oLockCursor;
  160.  
  161.     void __stdcall hkLockCursor( )
  162.     {
  163.         oLockCursor = Hooks::vguisurf_hook.get_original<LockCursor>( 67 );
  164.  
  165.         if ( Menu::Get( ).IsVisible( ) )
  166.         {
  167.             g_VGuiSurface->UnlockCursor( );
  168.             return;
  169.         }
  170.  
  171.         oLockCursor( g_VGuiSurface );
  172.     }
  173.  
  174.     void __fastcall hkSceneEnd( void* thisptr , void* edx )
  175.     {
  176.         auto ofunc = render_view.get_original<SceneEndFn>( 9 );
  177.  
  178.         bool update = false;
  179.  
  180.         if ( !g_LocalPlayer || !g_EngineClient->IsConnected( ) || !g_EngineClient->IsInGame( ) )
  181.         {
  182.             update = true;
  183.             return ofunc( thisptr );
  184.         }
  185.  
  186.         if ( g_Options.misc_thirdperson && g_Options.misc_legit_aa )
  187.         {
  188.             static IMaterial* mat = g_MatSystem->FindMaterial( "debug/debugdrawflat" , TEXTURE_GROUP_MODEL );
  189.             if ( !mat )
  190.                 return ofunc( thisptr );
  191.  
  192.             for ( int i = 1; i < g_GlobalVars->maxClients; ++i )
  193.             {
  194.                 auto ent = static_cast<C_BasePlayer*>( g_EntityList->GetClientEntity( i ) );
  195.                 if ( ent && ent->IsAlive( ) && !ent->IsDormant( ) )
  196.                 {
  197.                     if ( ent == g_LocalPlayer )
  198.                     {
  199.                         QAngle oAngle = ent->m_angEyeAngles( );
  200.  
  201.                         ent->SetAngle2( QAngle( oAngle.pitch ,
  202.                                                   g_Options.Real_yaw ,
  203.                                                   oAngle.roll ) );
  204.  
  205.                         g_RenderView->SetColorModulation( new const float[3] { 0.9f, 0.9f, 0.9f } );
  206.  
  207.                         mat->IncrementReferenceCount( );
  208.                         mat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ , false );   
  209.  
  210.                         g_MdlRender->ForcedMaterialOverride( mat );
  211.                         ent->DrawModel( 0x1 , 255 );
  212.                         g_MdlRender->ForcedMaterialOverride( nullptr );
  213.                         ent->SetAngle2( oAngle );
  214.                     }
  215.                 }
  216.             }
  217.         }
  218.  
  219.         if ( g_Options.update_world || update && !g_Options.bypass_obs)
  220.         {
  221.  
  222.             static auto fog_enableskybox = g_CVar->FindVar( "fog_enableskybox" );
  223.             static auto fog_override = g_CVar->FindVar( "fog_override" );
  224.             static auto fog_enable = g_CVar->FindVar( "fog_enable" );
  225.             static auto draw_specific_static_prop = g_CVar->FindVar( "r_DrawSpecificStaticProp" );
  226.  
  227.             fog_enableskybox->m_nFlags &= ~FCVAR_CHEAT;
  228.             fog_override->m_nFlags &= ~FCVAR_CHEAT;
  229.             fog_enable->m_nFlags &= ~FCVAR_CHEAT;
  230.             draw_specific_static_prop->m_nFlags &= ~FCVAR_CHEAT;
  231.  
  232.             // set values
  233.             fog_enable->SetValue( 0.0f );
  234.             fog_enableskybox->SetValue( 0.0f );
  235.             fog_override->SetValue( 1.0f );
  236.             draw_specific_static_prop->SetValue( 1.0f );
  237.  
  238.             for ( MaterialHandle_t i = g_MatSystem->FirstMaterial( ); i != g_MatSystem->InvalidMaterial( ); i = g_MatSystem->NextMaterial( i ) )
  239.             {
  240.                 IMaterial *pMaterial = g_MatSystem->GetMaterial( i );
  241.                 if ( !pMaterial || pMaterial->IsErrorMaterial( ) )
  242.                     continue;
  243.  
  244.                 if ( g_Options.misc_col_sky )
  245.                 {
  246.                     if ( strstr( pMaterial->GetTextureGroupName( ) , TEXTURE_GROUP_SKYBOX ) )
  247.                     {
  248.                         pMaterial->ColorModulate( g_Options.color_sky.r( ) / 255.f ,
  249.                                                   g_Options.color_sky.g( ) / 255.f ,
  250.                                                   g_Options.color_sky.b( ) / 255.f );
  251.                     }
  252.  
  253.                 }
  254.                 else
  255.                 {
  256.                     if ( !g_Options.misc_nightmode )
  257.                     {
  258.                         if ( strstr( pMaterial->GetTextureGroupName( ) , TEXTURE_GROUP_SKYBOX ) )
  259.                         {
  260.                             pMaterial->ColorModulate( 1 , 1 , 1 );
  261.                         }
  262.                     }
  263.                 }
  264.                 if ( g_Options.misc_nightmode )
  265.                 {
  266.                     if ( !g_Options.misc_col_sky )
  267.                     {
  268.                         if ( strstr( pMaterial->GetTextureGroupName( ) , TEXTURE_GROUP_SKYBOX ) )
  269.                         {
  270.                             pMaterial->ColorModulate( g_Options.color_nightmode.r( ) / 255.f ,
  271.                                                       g_Options.color_nightmode.g( ) / 255.f ,
  272.                                                       g_Options.color_nightmode.b( ) / 255.f );
  273.                         }
  274.                     }
  275.  
  276.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "World textures" ) )
  277.                     {
  278.                         pMaterial->ColorModulate( g_Options.color_nightmode.r( ) / 255.f ,
  279.                                                   g_Options.color_nightmode.g( ) / 255.f ,
  280.                                                   g_Options.color_nightmode.b( ) / 255.f );
  281.                     }
  282.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "StaticProp" ) )
  283.                     {
  284.                         pMaterial->ColorModulate( g_Options.color_nightmode.r( ) / 255.f ,
  285.                                                   g_Options.color_nightmode.g( ) / 255.f ,
  286.                                                   g_Options.color_nightmode.b( ) / 255.f );
  287.                     }
  288.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "models/props/de_dust/palace_bigdome" ) )
  289.                     {
  290.                         pMaterial->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW , true );
  291.                     }
  292.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "models/props/de_dust/palace_pillars" ) )
  293.                     {
  294.                         pMaterial->ColorModulate( g_Options.color_nightmode.r( ) / 255.f ,
  295.                                                   g_Options.color_nightmode.g( ) / 255.f ,
  296.                                                   g_Options.color_nightmode.b( ) / 255.f );
  297.                     }
  298.  
  299.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "Particle textures" ) )
  300.                     {
  301.                         pMaterial->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW , true );
  302.                     }
  303.  
  304.                 }
  305.                 else
  306.                 {
  307.                     if ( !g_Options.misc_col_sky )
  308.                     {
  309.                         if ( strstr( pMaterial->GetTextureGroupName( ) , TEXTURE_GROUP_SKYBOX ) )
  310.                         {
  311.                             pMaterial->ColorModulate( 1 , 1 , 1 );
  312.                         }
  313.                     }
  314.  
  315.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "World textures" ) )
  316.                     {
  317.                         pMaterial->ColorModulate( 1 , 1 , 1 );
  318.                     }
  319.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "StaticProp" ) )
  320.                     {
  321.                         pMaterial->ColorModulate( 1 , 1 , 1 );
  322.                     }
  323.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "models/props/de_dust/palace_bigdome" ) )
  324.                     {
  325.                         pMaterial->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW , false );
  326.                     }
  327.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "models/props/de_dust/palace_pillars" ) )
  328.                     {
  329.                         pMaterial->ColorModulate( 1 , 1 , 1 );
  330.                     }
  331.  
  332.                     if ( strstr( pMaterial->GetTextureGroupName( ) , "Particle textures" ) )
  333.                     {
  334.                         pMaterial->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW , false );
  335.                     }
  336.                 }
  337.  
  338.             }
  339.             update = false;
  340.             g_Options.update_world = false;
  341.         }
  342.  
  343.         ofunc( thisptr );
  344.     }
  345.  
  346.     void __fastcall hkDrawWorldLists( IVRenderView * ecx , uintptr_t edx , void * mat_render_context , void * render_list , unsigned long flags , float water_adjust )
  347.     {
  348.         auto ofunc = render_view.get_original<DrawWorldList>( 12 );
  349.  
  350.         ofunc( g_RenderView , edx , mat_render_context , render_list , flags , water_adjust );
  351.     }
  352.  
  353.     long __stdcall hkEndScene( IDirect3DDevice9* device )
  354.     {
  355.         auto oEndScene = direct3d_hook.get_original<EndScene>( index::EndScene );
  356.  
  357.         static uintptr_t gameoverlay_return_address = 0;
  358.  
  359.         if ( !gameoverlay_return_address ) {
  360.             MEMORY_BASIC_INFORMATION info;
  361.             VirtualQuery( _ReturnAddress( ), &info, sizeof( MEMORY_BASIC_INFORMATION ) );
  362.  
  363.             char mod[MAX_PATH];
  364.             GetModuleFileNameA( ( HMODULE ) info.AllocationBase, mod, MAX_PATH );
  365.  
  366.             if ( strstr( mod, "gameoverlay" ) )
  367.                 gameoverlay_return_address = ( uintptr_t ) ( _ReturnAddress( ) );
  368.         }
  369.  
  370.         if ( gameoverlay_return_address != ( uintptr_t ) ( _ReturnAddress( ) ) && g_Options.bypass_obs )
  371.             return oEndScene( device );
  372.  
  373.         DWORD colorwrite , srgbwrite;
  374.         device->GetRenderState( D3DRS_COLORWRITEENABLE , &colorwrite );
  375.         device->GetRenderState( D3DRS_SRGBWRITEENABLE , &srgbwrite );
  376.  
  377.         //fix drawing without calling engine functons/cl_showpos
  378.         device->SetRenderState( D3DRS_COLORWRITEENABLE , 0xffffffff );
  379.         //removes the source engine color correction
  380.         device->SetRenderState( D3DRS_SRGBWRITEENABLE , false );
  381.  
  382.         IDirect3DVertexDeclaration9* vertDec; IDirect3DVertexShader9* vertShader;
  383.         device->GetVertexDeclaration( &vertDec );
  384.         device->GetVertexShader( &vertShader );
  385.  
  386.         Menu::Get( ).Render( );
  387.  
  388.         device->SetRenderState( D3DRS_COLORWRITEENABLE , colorwrite );
  389.         device->SetRenderState( D3DRS_SRGBWRITEENABLE , srgbwrite );
  390.         device->SetVertexDeclaration( vertDec );
  391.         device->SetVertexShader( vertShader );
  392.  
  393.        
  394.  
  395.         return oEndScene( device );
  396.     }
  397.     //--------------------------------------------------------------------------------
  398.     long __stdcall hkReset( IDirect3DDevice9* device , D3DPRESENT_PARAMETERS* pPresentationParameters )
  399.     {
  400.         auto oReset = direct3d_hook.get_original<Reset>( index::Reset );
  401.  
  402.         Visuals::DestroyFonts( );
  403.         Menu::Get( ).OnDeviceLost( );
  404.  
  405.         auto hr = oReset( device , pPresentationParameters );
  406.  
  407.         if ( hr >= 0 )
  408.         {
  409.             Menu::Get( ).OnDeviceReset( );
  410.             Visuals::CreateFonts( );
  411.         }
  412.  
  413.         return hr;
  414.     }
  415.     //--------------------------------------------------------------------------------
  416.     QAngle m_oldangle;
  417.     float m_oldforward;
  418.     float m_oldsidemove;
  419.  
  420.     void StartFix( CUserCmd* cmd )
  421.     {
  422.         m_oldangle = cmd->viewangles;
  423.         m_oldforward = cmd->forwardmove;
  424.         m_oldsidemove = cmd->sidemove;
  425.     }
  426.  
  427.     void EndFix( CUserCmd* cmd )
  428.     {
  429.         float yaw_delta = cmd->viewangles.yaw - m_oldangle.yaw;
  430.         float f1;
  431.         float f2;
  432.  
  433.         if ( m_oldangle.yaw < 0.f )
  434.             f1 = 360.0f + m_oldangle.yaw;
  435.         else
  436.             f1 = m_oldangle.yaw;
  437.  
  438.         if ( cmd->viewangles.yaw < 0.0f )
  439.             f2 = 360.0f + cmd->viewangles.yaw;
  440.         else
  441.             f2 = cmd->viewangles.yaw;
  442.  
  443.         if ( f2 < f1 )
  444.             yaw_delta = abs( f2 - f1 );
  445.         else
  446.             yaw_delta = 360.0f - abs( f1 - f2 );
  447.         yaw_delta = 360.0f - yaw_delta;
  448.  
  449.         cmd->forwardmove = cos( DEG2RAD( yaw_delta ) ) * m_oldforward + cos( DEG2RAD( yaw_delta + 90.f ) ) * m_oldsidemove;
  450.         cmd->sidemove = sin( DEG2RAD( yaw_delta ) ) * m_oldforward + sin( DEG2RAD( yaw_delta + 90.f ) ) * m_oldsidemove;
  451.     }
  452.  
  453.     void do_legitaa( CUserCmd* cmd, C_BaseCombatWeapon* weapon )
  454.     {
  455.         StartFix( cmd );
  456.         QAngle oldAngle = cmd->viewangles;
  457.         float oldForward = cmd->forwardmove;
  458.         float oldSideMove = cmd->sidemove;
  459.  
  460.         if ( g_LocalPlayer->m_nMoveType( ) == MOVETYPE_LADDER )
  461.             return;
  462.         if ( cmd->buttons & IN_ATTACK )
  463.             return;
  464.  
  465.         if ( weapon )
  466.         {
  467.             if ( weapon->IsGrenade() )
  468.                 return;
  469.         }
  470.  
  471.         static int ChokedPackets = -1;
  472.         ChokedPackets++;
  473.         static bool yFlip;
  474.         if ( ChokedPackets < 1 )
  475.         {
  476.             G::bSendPacket = true;
  477.         }
  478.         else
  479.         {
  480.             G::bSendPacket = false;
  481.             yFlip ? cmd->viewangles.yaw += 90 : cmd->viewangles.yaw -= 90;
  482.             ChokedPackets = -1;
  483.         }
  484.         yFlip = !yFlip;
  485.         EndFix( cmd );
  486.     }
  487.  
  488.     void __stdcall hkCreateMove( int sequence_number , float input_sample_frametime , bool active , bool& bSendPacket )
  489.     {
  490.         auto oCreateMove = hlclient_hook.get_original<CreateMove>( 22 );
  491.  
  492.         oCreateMove( g_CHLClient , sequence_number , input_sample_frametime , active );
  493.  
  494.         auto cmd = g_Input->GetUserCmd( sequence_number );
  495.         auto verified = g_Input->GetVerifiedCmd( sequence_number );
  496.  
  497.         if ( !cmd || !cmd->command_number )
  498.             return;
  499.  
  500.         G::view_angle = cmd->viewangles;
  501.         G::bSendPacket = true;
  502.  
  503.         if ( g_LocalPlayer && !g_Options.PlayeName )
  504.             g_Options.PlayeName = g_LocalPlayer->GetPlayerInfo( ).szName;
  505.  
  506.         if ( g_LocalPlayer )
  507.         {
  508.             if ( InputSys::Get( ).IsKeyDown( VK_TAB ) && g_Options.misc_rankreveal )
  509.                 Utils::RankRevealAll( );
  510.  
  511.             if ( g_Options.misc_legit_aa )
  512.             {
  513.                 do_legitaa( cmd, g_LocalPlayer->m_hActiveWeapon( ).Get( ) );
  514.             }
  515.  
  516.             if ( g_Options.esp_grenadeprediction )
  517.                 C_GrenadePrediction::Get( ).Tick( cmd->buttons );
  518.  
  519.             C_Misc::Get( ).OnCreateMove( cmd );
  520.  
  521.             C_EnginePrediction::Get( ).Start( cmd );
  522.             {
  523.                 if ( g_Options.legit_enable )
  524.                     C_Legitbot::Get( ).OnCreateMove( cmd );
  525.  
  526.                
  527.             }
  528.             C_EnginePrediction::Get( ).End( );
  529.  
  530.  
  531.             if ( !G::bSendPacket )
  532.                 g_Options.Fake_yaw = cmd->viewangles.yaw;
  533.             else
  534.                 g_Options.Real_yaw = cmd->viewangles.yaw;
  535.         }
  536.  
  537.         auto view = cmd->viewangles;
  538.  
  539.         view.Normalize( );
  540.         Math::ClampAngles( view );
  541.  
  542.         if ( view.pitch > 89.f || view.pitch < -89.f )
  543.             return;
  544.         if ( view.yaw > 180.f || view.yaw < -180.f )
  545.             return;
  546.         if ( view.roll != 0 )
  547.             return;
  548.  
  549.         cmd->viewangles = view;
  550.  
  551.  
  552.         verified->m_cmd = *cmd;
  553.         verified->m_crc = cmd->GetChecksum( );
  554.  
  555.         bSendPacket = G::bSendPacket;
  556.  
  557.     }
  558.     //--------------------------------------------------------------------------------
  559.     __declspec( naked ) void __stdcall hkCreateMove_Proxy( int sequence_number , float input_sample_frametime , bool active )
  560.     {
  561.         __asm
  562.         {
  563.             push ebp
  564.             mov  ebp , esp
  565.             push ebx
  566.             lea  ecx , [esp]
  567.             push ecx
  568.             push dword ptr[active]
  569.             push dword ptr[input_sample_frametime]
  570.             push dword ptr[sequence_number]
  571.             call Hooks::hkCreateMove
  572.             pop  ebx
  573.             pop  ebp
  574.             retn 0Ch
  575.         }
  576.     }
  577.     //--------------------------------------------------------------------------------
  578.     void __stdcall hkPaintTraverse( vgui::VPANEL panel , bool forceRepaint , bool allowForce )
  579.     {
  580.         static auto panelId = vgui::VPANEL { 0 };
  581.         static auto oPaintTraverse = vguipanel_hook.get_original<PaintTraverse>( 41 );
  582.  
  583.         oPaintTraverse( g_VGuiPanel , panel , forceRepaint , allowForce );
  584.  
  585.         if ( !panelId )
  586.         {
  587.             const auto panelName = g_VGuiPanel->GetName( panel );
  588.             if ( !strcmp( panelName , "FocusOverlayPanel" ) )
  589.             {
  590.                 panelId = panel;
  591.             }
  592.         }
  593.         else if ( panelId == panel )
  594.         {
  595.  
  596.  
  597.             if ( GetAsyncKeyState( g_Options.misc_tp_key ) & 1 )
  598.                 g_Options.misc_thirdperson = !g_Options.misc_thirdperson;
  599.  
  600.             if ( !g_EngineClient->IsInGame( ) )
  601.                 g_Options.CurrentPlayer = 0;
  602.  
  603.             static ConVar* post_process = nullptr;
  604.             if ( g_Options.misc_disable_pp )
  605.             {
  606.                 post_process = g_CVar->FindVar( "mat_postprocess_enable" );
  607.                 post_process->RemoveFlags( FCVAR_CHEAT );
  608.                 post_process->SetValue( 0 );
  609.             }
  610.             else
  611.             {
  612.                 if ( post_process )
  613.                 {
  614.                     post_process->SetValue( 1 );
  615.                     post_process = nullptr;
  616.                 }
  617.             }
  618.  
  619.             g_InputSystem->EnableInput( !Menu::Get( ).IsVisible( ) );
  620.  
  621.             if ( g_EngineClient->IsInGame( ) && !g_EngineClient->IsTakingScreenshot( ) )
  622.             {
  623.  
  624.                 if ( !g_LocalPlayer )
  625.                     return;
  626.  
  627.            
  628.  
  629.                 if ( g_Options.bypass_obs )
  630.                     return;
  631.  
  632.                 static auto cross = g_CVar->FindVar("weapon_debug_spread_show");
  633.                 cross->RemoveFlags(FCVAR_CHEAT);
  634.                 cross->SetValue(g_Options.misc_sniper_crosshair && !g_LocalPlayer->m_bIsScoped() ? 3 : 0);
  635.  
  636.                 static auto linegoesthrusmoke = Utils::FindPattern( "client_panorama.dll" , ( PBYTE )"\x55\x8B\xEC\x83\xEC\x08\x8B\x15\x00\x00\x00\x00\x0F\x57\xC0" , "xxxxxxxx????xxx" );
  637.                 static auto smokecout = *( DWORD* ) ( linegoesthrusmoke + 0x8 );
  638.                 if ( g_Options.misc_nosmoke ) *( int* ) ( smokecout ) = 0;
  639.  
  640.                 if ( g_Options.misc_hitmark )
  641.                     Visuals::Misc::RenderHitmark( );
  642.  
  643.                 if ( g_Options.esp_grenadeprediction )
  644.                     C_GrenadePrediction::Get( ).Paint( );
  645.  
  646.                
  647.  
  648.                 if ( g_Options.misc_noflash )
  649.                 {
  650.                     g_LocalPlayer->m_flFlashMaxAlpha( ) = 0;
  651.                 }
  652.  
  653.                 if ( g_Options.esp_enabled || g_Options.misc_radar )
  654.                 {
  655.                     for ( auto i = 0; i <= g_EntityList->GetHighestEntityIndex( ); ++i )
  656.                     {
  657.                         C_BasePlayer* entity = ( C_BasePlayer* ) g_EntityList->GetClientEntity( i );
  658.  
  659.                         if ( !entity )
  660.                             continue;
  661.  
  662.                         if ( entity == g_LocalPlayer )
  663.                             continue;
  664.  
  665.                         if ( !entity->IsDormant( ) )
  666.                         {
  667.  
  668.                             if ( g_Options.misc_radar && entity->IsAlive( ) )
  669.                             {
  670.                                 static auto m_bSpotted = NetvarSys::Get( ).GetOffset( "DT_BaseEntity" , "m_bSpotted" );
  671.  
  672.                                 *( char* ) ( ( DWORD ) ( entity ) +m_bSpotted ) = 1;
  673.                             }
  674.  
  675.                             if ( g_Options.esp_planted_c4 && entity->GetClientClass( )->m_ClassID == ClassId::ClassId_CPlantedC4 )
  676.                                 Visuals::Misc::RenderPlantedC4( entity );
  677.  
  678.                             if ( !entity->IsAlive( ) ) continue;
  679.  
  680.                             if ( g_Options.esp_enabled )
  681.                             {
  682.                                 if ( entity->IsPlayer( ) )
  683.                                 {
  684.  
  685.                                     bool can_draw = true;
  686.  
  687.                                     if ( g_Options.esp_dead_only && g_LocalPlayer->IsAlive( ) )
  688.                                         continue;
  689.  
  690.                                     if ( Visuals::Player::Begin( entity ) )
  691.                                     {
  692.  
  693.                                         if (!g_Options.Players[entity->EntIndex()].is_forced_esp && g_Options.esp_playerlist)
  694.                                             can_draw = false;
  695.  
  696.                                         if (can_draw)
  697.                                         {
  698.                                            
  699.                                             if (g_Options.esp_player_boxes)     Visuals::Player::RenderBox();
  700.                                             if (g_Options.esp_player_weapons)   Visuals::Player::RenderWeapon();
  701.                                             if (g_Options.esp_player_names)     Visuals::Player::RenderName();
  702.                                             if (g_Options.esp_player_health)    Visuals::Player::RenderHealth();
  703.                                             if (g_Options.esp_player_armour)    Visuals::Player::RenderArmour();
  704.                                             if (g_Options.esp_history)          Visuals::Player::RenderHistory();
  705.                                        
  706.                                             if (g_Options.rage_aimbot_resolver) Visuals::Player::RenderResolver();
  707.                                         }
  708.  
  709.                                     }
  710.                                 }
  711.  
  712.                                 if ( g_Options.esp_dropped_weapons && entity->IsWeapon( ) )
  713.                                 {
  714.                                     Visuals::Misc::RenderWeapon( ( C_BaseCombatWeapon* ) entity );
  715.                                 }
  716.                                 if ( g_Options.esp_defuse_kit && entity->IsDefuseKit( ) )
  717.                                 {
  718.                                     Visuals::Misc::RenderDefuseKit( entity );
  719.                                 }
  720.                                 if (g_Options.esp_nade_esp)
  721.                                     Visuals::Misc::RenderNadeESP((C_BaseCombatWeapon*)entity);
  722.                             }
  723.                         }
  724.                     }
  725.                 }
  726.  
  727.             }
  728.         }
  729.     }
  730.     //--------------------------------------------------------------------------------
  731.     void __stdcall hkPlaySound( const char* name )
  732.     {
  733.         static auto oPlaySound = vguisurf_hook.get_original<PlaySound>( index::PlaySound );
  734.  
  735.         if ( g_Options.misc_autoaccept )
  736.         {
  737.             if ( strstr( name , "UI/competitive_accept_beep.wav" ) )
  738.             {
  739.                 static auto fnAccept =
  740.                     ( void( *)( ) )Utils::PatternScan( GetModuleHandleA( "client.dll" ) , "55 8B EC 83 E4 F8 83 EC 08 56 8B 35 ? ? ? ? 57 83 BE" );
  741.  
  742.                 fnAccept( );
  743.  
  744.                 //This will flash the CSGO window on the taskbar
  745.                 //so we know a game was found (you cant hear the beep sometimes cause it auto-accepts too fast)
  746.                 FLASHWINFO fi;
  747.                 fi.cbSize = sizeof( FLASHWINFO );
  748.                 fi.hwnd = InputSys::Get( ).GetMainWindow( );
  749.                 fi.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
  750.                 fi.uCount = 0;
  751.                 fi.dwTimeout = 0;
  752.                 FlashWindowEx( &fi );
  753.             }
  754.         }
  755.  
  756.         oPlaySound( g_VGuiSurface , name );
  757.     }
  758.     //--------------------------------------------------------------------------------
  759.     typedef float( __thiscall *get_fov_t )( void* );
  760.     float __fastcall hkGetViewModelFOV( void* ecx , void* edx )
  761.     {
  762.  
  763.         static auto ofunc = clientmode_hook.get_original<get_fov_t>( 35 );
  764.         float viewmodelFOV = ofunc( ecx );
  765.  
  766.         if ( g_Options.bypass_obs )
  767.             return 68;
  768.  
  769.         if ( !g_Options.misc_viewmodel_fov || !g_LocalPlayer )
  770.             return 68;
  771.         else
  772.         {
  773.             if ( !g_LocalPlayer->m_bIsScoped( ) )
  774.                 return g_Options.misc_viewmodel_fov;
  775.             else
  776.                 return 68;
  777.         }
  778.  
  779.         return 68;
  780.     }
  781.  
  782.     int __stdcall hkDoPostScreenEffects( int a1 )
  783.     {
  784.  
  785.         auto oDoPostScreenEffects = clientmode_hook.get_original<DoPostScreenEffects>( index::DoPostScreenSpaceEffects );
  786.  
  787.        
  788.  
  789.         return oDoPostScreenEffects( g_ClientMode , a1 );
  790.     }
  791.     //--------------------------------------------------------------------------------
  792.  
  793.     void __stdcall hkFrameStageNotify( ClientFrameStage_t stage )
  794.     {
  795.  
  796.         static auto ofunc = hlclient_hook.get_original<FrameStageNotify>( 37 );
  797.  
  798.         if ( stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START )
  799.         {
  800.             auto local_id = g_EngineClient->GetLocalPlayer( );
  801.             if ( local_id )
  802.             {
  803.                 C_BasePlayer* localplayer = ( C_BasePlayer* ) g_EntityList->GetClientEntity( local_id );
  804.  
  805.                 if ( localplayer && localplayer->IsAlive( ) )
  806.                 {
  807.                     C_Skins::Get( ).Skinchanger( );
  808.                     C_Skins::Get( ).Glovechanger( );
  809.                 }
  810.             }
  811.  
  812.  
  813.             if ( g_LocalPlayer )
  814.             {
  815.                 if ( g_Options.rage_aimbot_resolver && g_Options.rage_aimbot_enable && g_Options.rage_enable )
  816.                 {
  817.                     for ( int i = 0; i < g_EntityList->GetHighestEntityIndex( ); i++ )
  818.                     {
  819.                         C_BasePlayer* ent = ( C_BasePlayer* ) g_EntityList->GetClientEntity( i );
  820.                         if ( !ent ) continue;
  821.                         if ( !ent->IsPlayer( ) ) continue;
  822.                         if ( ent->IsDormant( ) ) continue;
  823.                         if ( !ent->IsAlive( ) ) continue;
  824.                         if ( ent->m_iTeamNum( ) == g_LocalPlayer->m_iTeamNum( ) ) continue;
  825.  
  826.                         C_Resolver::Get( ).resolve( ent );
  827.                     }
  828.                 }
  829.  
  830.             }
  831.         }
  832.  
  833.         if ( stage == FRAME_RENDER_START )
  834.         {
  835.             for ( int i = 1; i <= g_GlobalVars->maxClients; i++ )
  836.             {
  837.                 if ( i == g_EngineClient->GetLocalPlayer( ) ) continue;
  838.  
  839.                 IClientEntity* pCurEntity = g_EntityList->GetClientEntity( i );
  840.                 if ( !pCurEntity ) continue;
  841.  
  842.                 *( int* ) ( ( uintptr_t ) pCurEntity + 0xA30 ) = g_GlobalVars->framecount; //we'll skip occlusion checks now
  843.                 *( int* ) ( ( uintptr_t ) pCurEntity + 0xA28 ) = 0;//clear occlusion flags
  844.             }
  845.         }
  846.  
  847.         ofunc( g_CHLClient , stage );
  848.     }
  849.     //--------------------------------------------------------------------------------
  850.     void __stdcall hkOverrideView( CViewSetup* vsView )
  851.     {
  852.  
  853.         static auto ofunc = clientmode_hook.get_original<OverrideView>( index::OverrideView );
  854.  
  855.         if ( g_EngineClient->IsInGame( ) && vsView )
  856.         {
  857.             Visuals::Misc::ThirdPerson( );
  858.  
  859.             if ( g_LocalPlayer && g_Options.esp_grenadeprediction && !g_Options.bypass_obs)
  860.                 C_GrenadePrediction::Get( ).View( vsView );
  861.  
  862.         }
  863.         if ( g_LocalPlayer )
  864.         {
  865.             if ( !g_LocalPlayer->m_bIsScoped( ) && !g_Options.bypass_obs)
  866.             {
  867.                 static auto viewmodel = g_CVar->FindVar( "viewmodel_fov" );
  868.  
  869.                 if ( g_Options.misc_viewmodel_fov )
  870.                     viewmodel->SetValue( g_Options.misc_viewmodel_fov );
  871.                 else
  872.                     viewmodel->SetValue( viewmodel->GetDefault( ) );
  873.  
  874.                 if ( g_Options.misc_fov )
  875.                     vsView->fov = g_Options.misc_fov;
  876.             }
  877.  
  878.  
  879.         }
  880.  
  881.         ofunc( g_ClientMode , vsView );
  882.     }
  883.     //--------------------------------------------------------------------------------
  884.     void __stdcall hkDrawModelExecute( IMatRenderContext* ctx , const DrawModelState_t& state , const ModelRenderInfo_t& pInfo , matrix3x4_t* pCustomBoneToWorld )
  885.     {
  886.         static auto ofunc = mdlrender_hook.get_original<DrawModelExecute>( index::DrawModelExecute );
  887.  
  888.         if ( !g_Options.bypass_obs )
  889.             Chams::Get( ).OnDrawModelExecute( ctx , state , pInfo , pCustomBoneToWorld );
  890.         ofunc( g_MdlRender , ctx , state , pInfo , pCustomBoneToWorld );
  891.  
  892.         g_MdlRender->ForcedMaterialOverride( nullptr );
  893.     }
  894.  
  895.     auto dwCAM_Think = Utils::PatternScan( GetModuleHandleW( L"client_panorama.dll") , "85 C0 75 30 38 86" );
  896.     typedef bool( __thiscall *svc_get_bool_t )( PVOID );
  897.     bool __fastcall hkSvCheatsGetBool( PVOID pConVar , void* edx )
  898.     {
  899.         static auto ofunc = sv_cheats.get_original<svc_get_bool_t>( 13 );
  900.         if ( !ofunc )
  901.             return false;
  902.  
  903.         if ( reinterpret_cast< DWORD >( _ReturnAddress( ) ) == reinterpret_cast< DWORD >( dwCAM_Think ) )
  904.             return true;
  905.         return ofunc( pConVar );
  906.  
  907.  
  908.        
  909.  
  910.     }
  911. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement