From ec9a36c34084d7f9d153b7131588aa52f7d09e01 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sun, 31 Dec 2017 16:45:36 +0300 Subject: [PATCH] Paint --- include/hacks/CatBot.hpp | 1 + include/hitrate.hpp | 1 + include/hooks.hpp | 1 + include/hooks/hookedmethods.hpp | 5 ++ include/interfaces.hpp | 2 + include/sdk.hpp | 1 + src/hack.cpp | 6 +++ src/hacks/CatBot.cpp | 9 +++- src/hitrate.cpp | 2 + src/hooks.cpp | 1 + src/hooks/CreateMove.cpp | 5 ++ src/hooks/Paint.cpp | 91 +++++++++++++++++++++++++++++++++ src/hooks/others.cpp | 84 ++---------------------------- src/interfaces.cpp | 2 + 14 files changed, 129 insertions(+), 82 deletions(-) create mode 100644 src/hooks/Paint.cpp diff --git a/include/hacks/CatBot.hpp b/include/hacks/CatBot.hpp index 5a4d6b5e..40fe5c2a 100644 --- a/include/hacks/CatBot.hpp +++ b/include/hacks/CatBot.hpp @@ -16,6 +16,7 @@ bool should_ignore_player(CachedEntity *player); void update_ipc_data(ipc::user_data_s& data); void update(); void init(); +void level_init(); } } diff --git a/include/hitrate.hpp b/include/hitrate.hpp index 08fffff0..d773324c 100644 --- a/include/hitrate.hpp +++ b/include/hitrate.hpp @@ -13,6 +13,7 @@ namespace hitrate extern int count_shots; extern int count_hits; extern int count_hits_head; +extern CatVar hitrate_check; void Update(); diff --git a/include/hooks.hpp b/include/hooks.hpp index 1d8dc5b0..8921bdac 100644 --- a/include/hooks.hpp +++ b/include/hooks.hpp @@ -63,6 +63,7 @@ extern VMTHook baseclientstate; extern VMTHook baseclientstate8; extern VMTHook steamfriends; extern VMTHook materialsystem; +extern VMTHook enginevgui; } #endif /* HOOKS_H_ */ diff --git a/include/hooks/hookedmethods.hpp b/include/hooks/hookedmethods.hpp index 575b45f4..a99f2db6 100644 --- a/include/hooks/hookedmethods.hpp +++ b/include/hooks/hookedmethods.hpp @@ -29,6 +29,8 @@ typedef CUserCmd *(*GetUserCmd_t)(IInput *, int); typedef const char *(*GetClientName_t)(CBaseClientState *); typedef bool (*ProcessSetConVar_t)(CBaseClientState *, NET_SetConVar *); typedef bool (*ProcessGetCvarValue_t)(CBaseClientState *, SVC_GetCvarValue *); +typedef void (*Paint_t)(IEngineVGui *, PaintMode_t); + const char *GetClientName_hook(CBaseClientState *_this); bool ProcessSetConVar_hook(CBaseClientState *_this, NET_SetConVar *msg); bool ProcessGetCvarValue_hook(CBaseClientState *_this, SVC_GetCvarValue *msg); @@ -45,6 +47,9 @@ CUserCmd *GetUserCmd_hook(IInput *, int); void DrawModelExecute_hook(IVModelRender *_this, const DrawModelState_t &state, const ModelRenderInfo_t &info, matrix3x4_t *matrix); +void Paint_hook(IEngineVGui *_this, PaintMode_t mode); + + /* SDL HOOKS */ union SDL_Event; class SDL_Window; diff --git a/include/interfaces.hpp b/include/interfaces.hpp index 2cebea23..546bdeeb 100644 --- a/include/interfaces.hpp +++ b/include/interfaces.hpp @@ -51,6 +51,7 @@ class CHud; class IGameEventManager; class TFGCClientSystem; class CGameRules; +class IEngineVGui; extern TFGCClientSystem *g_TFGCClientSystem; extern CHud *g_CHUD; @@ -83,6 +84,7 @@ extern IMoveHelperServer *g_IMoveHelperServer; extern CBaseClientState *g_IBaseClientState; extern IGameEventManager *g_IGameEventManager; extern CGameRules *g_pGameRules; +extern IEngineVGui *g_IEngineVGui; void CreateInterfaces(); diff --git a/include/sdk.hpp b/include/sdk.hpp index 7757eba7..03a2fe99 100644 --- a/include/sdk.hpp +++ b/include/sdk.hpp @@ -54,6 +54,7 @@ #include #include #include +#include #include "sdk/in_buttons.h" #include "sdk/imaterialsystemfixed.h" diff --git a/src/hack.cpp b/src/hack.cpp index 68ae0b94..8b9a2c64 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -280,8 +280,11 @@ g_pGUI->Setup(); offsets::FireGameEvent()); hooks::clientmode4.Apply(); hooks::client.Set(g_IBaseClient); + +#if ENABLE_VISUALS == 1 hooks::client.HookMethod((void *) FrameStageNotify_hook, offsets::FrameStageNotify()); +#endif hooks::client.HookMethod((void *) DispatchUserMessage_hook, offsets::DispatchUserMessage()); @@ -322,6 +325,9 @@ g_pGUI->Setup(); hooks::modelrender.Apply(); #endif #endif + hooks::enginevgui.Set(g_IEngineVGui); + hooks::enginevgui.HookMethod((void *)Paint_hook, offsets::PlatformOffset(14, offsets::undefined, offsets::undefined)); + hooks::enginevgui.Apply(); hooks::steamfriends.Set(g_ISteamFriends); hooks::steamfriends.HookMethod((void *) GetFriendPersonaName_hook, offsets::GetFriendPersonaName()); diff --git a/src/hacks/CatBot.cpp b/src/hacks/CatBot.cpp index 6c405058..bc11628b 100644 --- a/src/hacks/CatBot.cpp +++ b/src/hacks/CatBot.cpp @@ -152,6 +152,8 @@ void update_ipc_data(ipc::user_data_s& data) data.ingame.bot_count = count_bots; } +Timer level_init_timer{}; + void update() { if (!enabled) @@ -167,7 +169,7 @@ void update() do_random_votekick(); if (timer_catbot_list.test_and_set(3000)) update_catbot_list(); - if (timer_abandon.test_and_set(2000)) + if (timer_abandon.test_and_set(2000) && level_init_timer.check(13000)) { count_bots = 0; int count_ipc = 0; @@ -235,6 +237,11 @@ void init() g_IEventManager2->AddListener(&listener(), "player_death", false); } +void level_init() +{ + level_init_timer.update(); +} + } } } diff --git a/src/hitrate.cpp b/src/hitrate.cpp index a593b6e5..a8574dd4 100644 --- a/src/hitrate.cpp +++ b/src/hitrate.cpp @@ -18,6 +18,8 @@ int count_shots{ 0 }; int count_hits{ 0 }; int count_hits_head{ 0 }; +CatVar hitrate_check(CV_SWITCH, "hitrate", "1", "Monitor hitrate"); + std::vector> shots{}; diff --git a/src/hooks.cpp b/src/hooks.cpp index 5761d22a..fedd6a05 100644 --- a/src/hooks.cpp +++ b/src/hooks.cpp @@ -103,4 +103,5 @@ VMTHook studiorender{}; VMTHook modelrender{}; VMTHook clientmode4{}; VMTHook materialsystem{}; +VMTHook enginevgui{}; } diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 8711354d..4f3b069b 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -423,6 +423,11 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd) PROF_SECTION(CM_spam); hacks::shared::spam::CreateMove(); } + { + PROF_SECTION(CM_AC); + angles::Update(); + hacks::shared::anticheat::CreateMove(); + } } if (time_replaced) g_GlobalVars->curtime = curtime_old; diff --git a/src/hooks/Paint.cpp b/src/hooks/Paint.cpp new file mode 100644 index 00000000..710de463 --- /dev/null +++ b/src/hooks/Paint.cpp @@ -0,0 +1,91 @@ +/* + * Paint.cpp + * + * Created on: Dec 31, 2017 + * Author: nullifiedcat + */ + +#include "common.hpp" +#include "hitrate.hpp" +#include "hack.hpp" + +static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1", + "Cursor fix"); + +void Paint_hook(IEngineVGui *_this, PaintMode_t mode) +{ + static const Paint_t original = (Paint_t)hooks::enginevgui.GetMethod(offsets::PlatformOffset(14, offsets::undefined, offsets::undefined)); + + if (!g_IEngine->IsInGame()) + g_Settings.bInvalid = true; + + if (mode & PaintMode_t::PAINT_UIPANELS) + { + hacks::tf2::killstreak::apply_killstreaks(); + hacks::shared::catbot::update(); + if (hitrate::hitrate_check) + { + hitrate::Update(); + } +#if ENABLE_IPC + static Timer nametimer{}; + if (nametimer.test_and_set(1000 * 10)) + { + if (ipc::peer) + { + ipc::StoreClientData(); + } + } + static Timer ipc_timer{}; + if (ipc_timer.test_and_set(1000)) + { + if (ipc::peer) + { + if (ipc::peer->HasCommands()) + { + ipc::peer->ProcessCommands(); + } + ipc::Heartbeat(); + ipc::UpdateTemporaryData(); + } + } +#endif + hacks::shared::autojoin::UpdateSearch(); + if (!hack::command_stack().empty()) + { + PROF_SECTION(PT_command_stack); + std::lock_guard guard(hack::command_stack_mutex); + while (!hack::command_stack().empty()) + { + //logging::Info("executing %s", + // hack::command_stack().top().c_str()); + g_IEngine->ClientCmd_Unrestricted( + hack::command_stack().top().c_str()); + hack::command_stack().pop(); + } + } +#if TEXTMODE_STDIN == 1 + static auto last_stdin = std::chrono::system_clock::from_time_t(0); + auto ms = std::chrono::duration_cast( + std::chrono::system_clock::now() - last_stdin) + .count(); + if (ms > 500) + { + UpdateInput(); + last_stdin = std::chrono::system_clock::now(); + } +#endif +#if ENABLE_GUI + if (cursor_fix_experimental) + { + /* if (gui_visible) { + g_ISurface->SetCursorAlwaysVisible(true); + } else { + g_ISurface->SetCursorAlwaysVisible(false); + }*/ + } +#endif + } + + original(_this, mode); +} diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 272a0336..84f3ba9a 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -557,9 +557,6 @@ const char *GetFriendPersonaName_hook(ISteamFriends *_this, CSteamID steamID) return original(_this, steamID); } -static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1", - "Cursor fix"); - void FireGameEvent_hook(void *_this, IGameEvent *event) { static const FireGameEvent_t original = @@ -582,36 +579,23 @@ void FireGameEvent_hook(void *_this, IGameEvent *event) original(_this, event); } -static CatVar hitrate_check(CV_SWITCH, "hitrate", "1", "Monitor hitrate"); - +#if ENABLE_VISUALS == 1 void FrameStageNotify_hook(void *_this, int stage) { static IClientEntity *ent; PROF_SECTION(FrameStageNotify_TOTAL); - hacks::tf2::killstreak::apply_killstreaks(); static const FrameStageNotify_t original = (FrameStageNotify_t) hooks::client.GetMethod( offsets::FrameStageNotify()); + if (!g_IEngine->IsInGame()) g_Settings.bInvalid = true; -#if ENABLE_VISUALS == 1 { PROF_SECTION(FSN_skinchanger); hacks::tf2::skinchanger::FrameStageNotify(stage); } -#endif - if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START && !g_Settings.bInvalid) - { - hacks::shared::catbot::update(); - angles::Update(); - hacks::shared::anticheat::CreateMove(); - if (hitrate_check) - { - hitrate::Update(); - } - } if (resolver && cathook && !g_Settings.bInvalid && stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) { @@ -635,70 +619,8 @@ void FrameStageNotify_hook(void *_this, int stage) } } } - if (stage == FRAME_START) - { -#if ENABLE_IPC - static Timer nametimer{}; - if (nametimer.test_and_set(1000 * 10)) - { - if (ipc::peer) - { - ipc::StoreClientData(); - } - } - static Timer ipc_timer{}; - if (ipc_timer.test_and_set(1000)) - { - if (ipc::peer) - { - if (ipc::peer->HasCommands()) - { - ipc::peer->ProcessCommands(); - } - ipc::Heartbeat(); - ipc::UpdateTemporaryData(); - } - } -#endif - hacks::shared::autojoin::UpdateSearch(); - if (!hack::command_stack().empty()) - { - PROF_SECTION(PT_command_stack); - std::lock_guard guard(hack::command_stack_mutex); - while (!hack::command_stack().empty()) - { - //logging::Info("executing %s", - // hack::command_stack().top().c_str()); - g_IEngine->ClientCmd_Unrestricted( - hack::command_stack().top().c_str()); - hack::command_stack().pop(); - } - } -#if TEXTMODE_STDIN == 1 - static auto last_stdin = std::chrono::system_clock::from_time_t(0); - auto ms = std::chrono::duration_cast( - std::chrono::system_clock::now() - last_stdin) - .count(); - if (ms > 500) - { - UpdateInput(); - last_stdin = std::chrono::system_clock::now(); - } -#endif - } -#if ENABLE_VISUALS == 1 if (cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { -#if ENABLE_GUI - if (cursor_fix_experimental) - { - /* if (gui_visible) { - g_ISurface->SetCursorAlwaysVisible(true); - } else { - g_ISurface->SetCursorAlwaysVisible(false); - }*/ - } -#endif IF_GAME(IsTF()) { if (CE_GOOD(LOCAL_E) && no_zoom) @@ -720,9 +642,9 @@ void FrameStageNotify_hook(void *_this, int stage) } } } -#endif /* TEXTMODE */ original(_this, stage); } +#endif /* TEXTMODE */ static CatVar clean_chat(CV_SWITCH, "clean_chat", "0", "Clean chat", "Removes newlines from chat"); diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 1f800f3f..6675f3ed 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -48,6 +48,7 @@ IGameEventManager *g_IGameEventManager = nullptr; TFGCClientSystem *g_TFGCClientSystem = nullptr; CHud *g_CHUD = nullptr; CGameRules *g_pGameRules = nullptr; +IEngineVGui *g_IEngineVGui = nullptr; template T *BruteforceInterface(std::string name, sharedobj::SharedObject &object, @@ -101,6 +102,7 @@ void CreateInterfaces() g_IVModelRender = BruteforceInterface( "VEngineModel", sharedobj::engine(), 16); g_ISteamFriends = nullptr; + g_IEngineVGui = BruteforceInterface("VEngineVGui", sharedobj::engine()); IF_GAME(IsTF2()) { uintptr_t sig_steamapi = gSignatures.GetEngineSignature(