diff --git a/README.md b/README.md index 63193cfe..1dffa5ed 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ I know that the style sucks. There is a lot of design errors and cancerous patte # Compilation `git submodule update --init --recursive` after cloning, then -`make` +`cd cathook && make -j4` + +Compilation issues? Try installing `g++-multilib`! # Injection `sudo ./attach-backtrace` if you want to see backtrace after the game crashes. diff --git a/src/globals.cpp b/src/globals.cpp index 21a9ebbf..ba661ad2 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -20,13 +20,12 @@ void ThirdpersonCallback(IConVar* var, const char* pOldValue, float flOldValue) } } +CatVar cathook(CV_SWITCH, "enabled", "1", "CatHook enabled", "Disabling this completely disables cathook (can be re-enabled)"); + void GlobalSettings::Init() { EstimateAbsVelocity = (EstimateAbsVelocity_t*)gSignatures.GetClientSignature("55 89 E5 56 53 83 EC 30 8B 5D 08 8B 75 0C E8 4D 2E 01 00 39 D8 74 69 0F B6 05 24 3F 00 02 81 C3 B8 02 00 00 C6 05 24 3F 00 02 01 88 45 F0 A1 20 3F 00 02 89 45 F4 A1 28 3F 00 02 89 45 EC 8D 45 EC A3 28 3F 00 02 A1 14 C8 F6 01 8B 40 0C 89 74 24 04 89 1C 24 89 44 24 08 E8 A2 41 00 00 0F B6 45 F0 A2 24 3F 00 02 8B 45 F4 A3 20 3F 00 02 8B 45 EC A3 28 3F 00 02 83 C4 30 5B 5E 5D C3"); - - this->sDisconnectMsg = new CatVar(CV_STRING, "disconnect_msg", "", "Disconnect reason", NULL, "A custom disconnect message"); this->bFastVischeck = new CatVar(CV_SWITCH, "fast_vischeck", "1", "Fast VisCheck", NULL, "VisChecks only certain hitboxes"); // this->bMaxPerformance = CREATE_CV(CV_SWITCH, "optimize_performance", "0", "deprecated"); - this->bHackEnabled = new CatVar(CV_SWITCH, "enabled", "1", "CatHook enabled", NULL, "Master Hack Switch"); this->bIgnoreTaunting = new CatVar(CV_SWITCH, "ignore_taunting", "1", "Ignore taunting", NULL, "Aimbot/Triggerbot won't attack taunting enemies"); // this->bNoFlinch = CREATE_CV(CV_SWITCH, "noflinch", "0", "No Flinch (broken)"); this->bSendPackets = new CatVar(CV_SWITCH, "sendpackets", "1", "Send packets", NULL, "bSendPackets"); diff --git a/src/globals.h b/src/globals.h index 8dd635ca..c5225b30 100644 --- a/src/globals.h +++ b/src/globals.h @@ -17,17 +17,17 @@ extern EstimateAbsVelocity_t* EstimateAbsVelocity; extern int g_AppID; +extern CatVar cathook; // Master switch + class GlobalSettings { public: void Init(); // TODO // CatVar* bMaxPerformance; - CatVar* bHackEnabled; CatVar* bIgnoreTaunting; // CatVar* bProfiler; // CatVar* bNoFlinch; CatVar* bSendPackets; - CatVar* sDisconnectMsg; CatVar* bShowAntiAim; CatVar* bThirdperson; CatVar* bDebugLog; diff --git a/src/gui/CMenuWindow.cpp b/src/gui/CMenuWindow.cpp index 290815c4..cb9c2a4b 100644 --- a/src/gui/CMenuWindow.cpp +++ b/src/gui/CMenuWindow.cpp @@ -134,7 +134,7 @@ void CMenuWindow::AddElements() { ADDCVAR(g_phMisc->v_bAntiAFK); // FIXME add CVARS TO MENU!! //ADDCVAR(g_Settings.bCleanScreenshots); - ADDCVAR(g_Settings.bHackEnabled); + ADDCVAR(&cathook); if (TF) ADDCVAR(g_Settings.bIgnoreTaunting); //ADDCVAR(g_Settings.bNoVisuals); //if (TF) ADDCVAR(g_Settings.bNoZoom); @@ -145,7 +145,8 @@ void CMenuWindow::AddElements() { //ADDCVAR(g_Settings.bZoomedFOV); //ADDCVAR(g_Settings.flForceFOVZoomed); //ADDCVAR(g_Settings.flForceFOV); - ADDCVAR(g_Settings.sDisconnectMsg); + // FIXME add ConVars to menu!! + //ADDCVAR(g_Settings.sDisconnectMsg); if (TF2C) ADDCVAR(g_Settings.kRollSpeedhack); ADDCVAR(g_phMisc->v_bCleanChat); if (TF2) { diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 0c67024e..48fef6be 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -50,7 +50,7 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { return ret; } - if (!g_Settings.bHackEnabled->GetBool()) { + if (!cathook) { return ret; } diff --git a/src/hooks/PaintTraverse.cpp b/src/hooks/PaintTraverse.cpp index 914a241a..546f4b64 100644 --- a/src/hooks/PaintTraverse.cpp +++ b/src/hooks/PaintTraverse.cpp @@ -31,8 +31,8 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) { static unsigned long panel_top = 0; static bool draw_flag = false; bool call_default = true; - if (g_Settings.bHackEnabled->GetBool() && panel_scope && no_zoom && vp == panel_scope) call_default = false; - if (g_Settings.bHackEnabled->GetBool()) { + if (cathook && panel_scope && no_zoom && vp == panel_scope) call_default = false; + if (cathook) { bool vis = gui_visible; interfaces::surface->SetCursorAlwaysVisible(vis); } @@ -41,7 +41,7 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) { if (call_default) SAFE_CALL(((PaintTraverse_t*)hooks::hkPanel->GetMethod(hooks::offPaintTraverse))(p, vp, fr, ar)); PROF_SECTION(PaintTraverse); if (vp == panel_top) draw_flag = true; - if (!g_Settings.bHackEnabled->GetBool()) return; + if (!cathook) return; // Because of single-multi thread shit I'm gonna put this thing riiiight here. static bool autoexec_done = false; diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 62196ec5..fa5baddb 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -31,7 +31,7 @@ bool SendNetMsg_hook(void* thisptr, INetMessage& msg, bool bForceReliable = fals SEGV_BEGIN; //logging::Info("Sending NetMsg! %i", msg.GetType()); - if (hacks::shared::airstuck::IsStuck() && g_Settings.bHackEnabled->GetBool() && !g_Settings.bInvalid) { + if (hacks::shared::airstuck::IsStuck() && cathook && !g_Settings.bInvalid) { switch (msg.GetType()) { case net_NOP: case net_SignonState: @@ -46,14 +46,12 @@ bool SendNetMsg_hook(void* thisptr, INetMessage& msg, bool bForceReliable = fals return false; } +CatVar disconnect_reason(CV_STRING, "disconnect_reason", "", "Disconnect reason", "A custom disconnect reason"); + void Shutdown_hook(void* thisptr, const char* reason) { SEGV_BEGIN; - if (g_Settings.bHackEnabled->GetBool()) { - const char* new_reason = reason; - if (g_Settings.sDisconnectMsg->convar->m_StringLength > 3) { - new_reason = g_Settings.sDisconnectMsg->GetString(); - } - ((Shutdown_t*)hooks::hkNetChannel->GetMethod(hooks::offShutdown))(thisptr, new_reason); + if (cathook && (disconnect_reason.convar_parent->m_StringLength > 3) && strstr(reason, "user")) { + ((Shutdown_t*)hooks::hkNetChannel->GetMethod(hooks::offShutdown))(thisptr, disconnect_reason.GetString()); } else { ((Shutdown_t*)hooks::hkNetChannel->GetMethod(hooks::offShutdown))(thisptr, reason); } @@ -68,7 +66,7 @@ void FrameStageNotify_hook(void* thisptr, int stage) { //logging::Info("fsi begin");// TODO dbg SVDBG("FSN %i", __LINE__); // TODO hack FSN hook - if (TF && g_Settings.bHackEnabled->GetBool() && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { + if (TF && cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { SVDBG("FSN %i", __LINE__); if (g_Settings.bThirdperson->GetBool() && !g_pLocalPlayer->life_state && CE_GOOD(g_pLocalPlayer->entity)) { SVDBG("FSN %i", __LINE__); @@ -95,7 +93,7 @@ CatVar override_fov(CV_FLOAT, "fov", "0", "FOV override", "Overrides FOV with th void OverrideView_hook(void* thisptr, CViewSetup* setup) { SEGV_BEGIN; ((OverrideView_t*)hooks::hkClientMode->GetMethod(hooks::offOverrideView))(thisptr, setup); - if (!g_Settings.bHackEnabled->GetBool()) return; + if (!cathook) return; bool zoomed = g_pLocalPlayer->bZoomed; if (zoomed && override_fov_zoomed) { setup->fov = override_fov_zoomed;