diff --git a/CMakeLists.txt b/CMakeLists.txt index 14588e66..b86eeea5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ set(EnableGUI 1 CACHE BOOL "Enable GUI") set(EnableIPC 1 CACHE BOOL "Enable IPC") set(DataPath "/opt/cathook/data" CACHE STRING "Data location") set(VACBypass 0 CACHE BOOL "Textmode VAC bypass") +set(Textmode 0 CACHE BOOL "Various textmode-only features for bots") +set(EnableTextmodeStdin 0 CACHE BOOL "Textmode Stdin -> Console bridge (EXPERIMENTAL)") +set(EnableWarnings 1 CACHE BOOL "Enable compile warnings") +set(EnableNullGraphics 0 CACHE BOOL "Enable experimental textmode hooks (CRASHES)") find_package(Git REQUIRED) find_package(SDL2 REQUIRED) @@ -57,7 +61,7 @@ target_compile_definitions(cathook PRIVATE GNUC=1 NO_MALLOC_OVERRIDE=1) -target_include_directories(cathook PRIVATE +target_include_directories(cathook SYSTEM PRIVATE "source-sdk-2013-headers/mp/src/mathlib" "source-sdk-2013-headers/mp/src/public" "source-sdk-2013-headers/mp/src/common" @@ -74,6 +78,10 @@ target_include_directories(cathook PRIVATE "${xoverlay_INCLUDE_DIRS}" "${SimpleIPC_INCLUDE_DIRS}") +if(EnableWarnings) + target_compile_options(cathook PRIVATE -Wundef -Werror) +endif() + add_subdirectory(include) add_subdirectory(src) diff --git a/include/config.h.in b/include/config.h.in index bbb0f1e4..bfe053d3 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -10,4 +10,7 @@ #define ENABLE_GUI @EnableGUI@ #define ENABLE_IPC @EnableIPC@ #define DATA_PATH "@DataPath@" -#define ENABLE_VAC_BYPASS @VACBypass@ \ No newline at end of file +#define ENABLE_VAC_BYPASS @VACBypass@ +#define ENABLE_TEXTMODE_STDIN @EnableTextmodeStdin@ +#define ENABLE_NULL_GRAPHICS @EnableNullGraphics@ +#define TEXTMODE @Textmode@ \ No newline at end of file diff --git a/include/copypasted/CSignature.h b/include/copypasted/CSignature.h index bc164722..c5991737 100755 --- a/include/copypasted/CSignature.h +++ b/include/copypasted/CSignature.h @@ -11,9 +11,9 @@ public: uintptr_t dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength, const char *szPattern); void *GetModuleHandleSafe(const char *pszModuleName); - uintptr_t GetClientSignature(char *chPattern); - uintptr_t GetEngineSignature(char *chPattern); - uintptr_t GetVstdSignature(char *chPattern); + uintptr_t GetClientSignature(const char *chPattern); + uintptr_t GetEngineSignature(const char *chPattern); + uintptr_t GetVstdSignature(const char *chPattern); }; extern CSignature gSignatures; diff --git a/include/hooks/others.hpp b/include/hooks/others.hpp index c7919cbd..4f284fc4 100755 --- a/include/hooks/others.hpp +++ b/include/hooks/others.hpp @@ -7,6 +7,8 @@ #pragma once +#include "config.h" + class INetMessage; class CViewSetup; class bf_read; @@ -14,7 +16,7 @@ class SDL_Window; class CatVar; extern CatVar disconnect_reason; -#if ENABLE_VISUALS == 1 +#if ENABLE_VISUALS extern int spectator_target; #endif @@ -29,7 +31,7 @@ void LevelInit_hook(void *, const char *); void LevelShutdown_hook(void *); int RandomInt_hook(void *, int, int); -#if ENABLE_NULL_GRAPHICS == 1 +#if ENABLE_NULL_GRAPHICS typedef ITexture *(*FindTexture_t)(void *, const char *, const char *, bool, int); typedef IMaterial *(*FindMaterialEx_t)(void *, const char *, const char *, int, diff --git a/include/menu/compatlayer.hpp b/include/menu/compatlayer.hpp index 5b49e159..825cfd23 100755 --- a/include/menu/compatlayer.hpp +++ b/include/menu/compatlayer.hpp @@ -1,4 +1,3 @@ -#if TEXTMODE_VAC != 1 namespace colorsint { constexpr int Create(int r, int g, int b, int a) @@ -50,8 +49,7 @@ void FString(unsigned long font, int x, int y, int color, int shadow, void DrawRect(int x, int y, int w, int h, int color); void DrawLine(int x, int y, int dx, int dy, int color); void OutlineRect(int x, int y, int w, int h, int color); -void GetStringLength(unsigned long font, char *string, int &length, +void GetStringLength(unsigned long font, const char *string, int &length, int &height); std::pair GetStringLength(unsigned long font, std::string string); } -#endif diff --git a/include/sharedobj.hpp b/include/sharedobj.hpp index 965a7ea7..7211e977 100755 --- a/include/sharedobj.hpp +++ b/include/sharedobj.hpp @@ -9,6 +9,7 @@ #include #include +#include "config.h" struct link_map; typedef void *(*fn_CreateInterface_t)(const char *, int *); @@ -43,7 +44,7 @@ SharedObject &vstdlib(); SharedObject &tier0(); SharedObject &inputsystem(); SharedObject &materialsystem(); -#if ENABLE_VISUALS == 1 +#if ENABLE_VISUALS SharedObject &vguimatsurface(); SharedObject &vgui2(); SharedObject &studiorender(); diff --git a/include/version.h.in b/include/version.h.in index 15bcb959..e4f26097 100644 --- a/include/version.h.in +++ b/include/version.h.in @@ -1,4 +1,4 @@ #pragma once -#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" -#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@" \ No newline at end of file +#define GIT_COMMIT_HASH @GIT_COMMIT_HASH@ +#define GIT_COMMIT_DATE @GIT_COMMIT_DATE@ \ No newline at end of file diff --git a/src/copypasted/CSignature.cpp b/src/copypasted/CSignature.cpp index 2ca9e495..197f61e8 100755 --- a/src/copypasted/CSignature.cpp +++ b/src/copypasted/CSignature.cpp @@ -67,10 +67,8 @@ uintptr_t CSignature::dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength, firstMatch = pCur; if (!pat[2]) return firstMatch; - if (*(uintptr_t *) pat == '\?\?' || *(uint8_t *) pat != '\?') + if (*pat == '\?') pat += 3; - else - pat += 2; } else { @@ -94,7 +92,7 @@ void *CSignature::GetModuleHandleSafe(const char *pszModuleName) return moduleHandle; } //=================================================================================== -uintptr_t CSignature::GetClientSignature(char *chPattern) +uintptr_t CSignature::GetClientSignature(const char *chPattern) { // we need to do this becuase (i assume that) under the hood, dlopen only // loads up the sections that it needs into memory, meaning that we cannot @@ -121,7 +119,7 @@ uintptr_t CSignature::GetClientSignature(char *chPattern) (uintptr_t)(module) + moduleMap->l_addr; } //=================================================================================== -uintptr_t CSignature::GetEngineSignature(char *chPattern) +uintptr_t CSignature::GetEngineSignature(const char *chPattern) { // we need to do this becuase (i assume that) under the hood, dlopen only // loads up the sections that it needs into memory, meaning that we cannot @@ -148,7 +146,7 @@ uintptr_t CSignature::GetEngineSignature(char *chPattern) (uintptr_t)(module) + moduleMap->l_addr; } //=================================================================================== -uintptr_t CSignature::GetVstdSignature(char *chPattern) +uintptr_t CSignature::GetVstdSignature(const char *chPattern) { // we need to do this becuase (i assume that) under the hood, dlopen only // loads up the sections that it needs into memory, meaning that we cannot diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 140ff1f2..70d32c36 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -243,7 +243,7 @@ void WorldTick() void DrawTick() { -#if TEXTMODE_VAC != 1 +#if ENABLE_VISUALS if (!followbot || !draw_crumb) return; if (breadcrumbs.size() < 2) diff --git a/src/hacks/SkinChanger.cpp b/src/hacks/SkinChanger.cpp index 227e3251..eae1044e 100755 --- a/src/hacks/SkinChanger.cpp +++ b/src/hacks/SkinChanger.cpp @@ -398,7 +398,7 @@ void def_attribute_modifier::Set(int id, float value) logging::Info("Woah there, that's too many! Remove some."); return; } - modifiers.push_back(attribute_s{ id, value }); + modifiers.push_back(attribute_s{ (uint16_t)id, value }); logging::Info("Added new attribute: %i %.2f (%i)", id, value, modifiers.size()); } diff --git a/src/hooks/Paint.cpp b/src/hooks/Paint.cpp index 4c9e6d7d..86b8729b 100755 --- a/src/hooks/Paint.cpp +++ b/src/hooks/Paint.cpp @@ -65,7 +65,7 @@ void Paint_hook(IEngineVGui *_this, PaintMode_t mode) hack::command_stack().pop(); } } -#if TEXTMODE_STDIN == 1 +#if ENABLE_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) diff --git a/src/menu/CBaseContainer.cpp b/src/menu/CBaseContainer.cpp index 5237836a..1ecade33 100755 --- a/src/menu/CBaseContainer.cpp +++ b/src/menu/CBaseContainer.cpp @@ -10,7 +10,6 @@ #include "common.hpp" #include "sdk.hpp" -#if TEXTMODE_VAC != 1 class IMemAlloc; IMemAlloc *g_pMemAlloc = 0; @@ -256,4 +255,3 @@ void CBaseContainer::Update() } CBaseWidget::Update(); } -#endif diff --git a/src/menu/CBaseWidget.cpp b/src/menu/CBaseWidget.cpp index 4f3c5505..9b848538 100755 --- a/src/menu/CBaseWidget.cpp +++ b/src/menu/CBaseWidget.cpp @@ -9,7 +9,6 @@ #include "common.hpp" #include "GUI.h" -#if TEXTMODE_VAC != 1 void CBaseWidget::DrawBounds(int x, int y) { if (m_KeyValues->IsEmpty("bounds_color")) @@ -68,4 +67,3 @@ std::pair CBaseWidget::AbsolutePosition() } return result; } -#endif diff --git a/src/menu/CBaseWindow.cpp b/src/menu/CBaseWindow.cpp index 80b0967a..ad2c056a 100755 --- a/src/menu/CBaseWindow.cpp +++ b/src/menu/CBaseWindow.cpp @@ -9,7 +9,6 @@ #include "common.hpp" #include "menu/GUI.h" -#if TEXTMODE_VAC != 1 void CBaseWindow::MoveChildren() { @@ -63,4 +62,3 @@ void CBaseWindow::Draw(int x, int y) NCGUIColor()); CBaseContainer::Draw(x, y); } -#endif diff --git a/src/menu/CTextLabel.cpp b/src/menu/CTextLabel.cpp index 412a168a..2da8fe9e 100755 --- a/src/menu/CTextLabel.cpp +++ b/src/menu/CTextLabel.cpp @@ -11,7 +11,6 @@ #include "sdk.hpp" #include "GUI.h" -#if TEXTMODE_VAC != 1 std::string WordWrap(std::string &in, int max, unsigned long font) { std::stringstream result, line, wordstream, next; @@ -134,4 +133,3 @@ void CTextLabel::Draw(int x, int y) else draw::String(fonts::MENU, x, y, colorsint::white, 1, GetText()); } -#endif diff --git a/src/menu/GUI.cpp b/src/menu/GUI.cpp index 0754c629..5c2fa26b 100644 --- a/src/menu/GUI.cpp +++ b/src/menu/GUI.cpp @@ -11,7 +11,6 @@ #include "common.hpp" #include "sdk.hpp" -#if TEXTMODE_VAC != 1 #undef RootWindow void GUIVisibleCallback(IConVar *var, const char *pOldValue, float flOldValue) @@ -239,4 +238,3 @@ bool CatGUI::ConsumesKey(ButtonCode_t key) } CatGUI *g_pGUI = 0; -#endif diff --git a/src/menu/IWidget.cpp b/src/menu/IWidget.cpp index 24c23c8f..f4cda6d1 100755 --- a/src/menu/IWidget.cpp +++ b/src/menu/IWidget.cpp @@ -6,8 +6,7 @@ */ #include "menu/IWidget.h" -#if TEXTMODE_VAC != 1 + IWidget::~IWidget() { } -#endif diff --git a/src/menu/compatibilitylayer.cpp b/src/menu/compatibilitylayer.cpp index ae79fdb9..b6a4300b 100755 --- a/src/menu/compatibilitylayer.cpp +++ b/src/menu/compatibilitylayer.cpp @@ -1,6 +1,5 @@ #include "common.hpp" -#if TEXTMODE_VAC != 1 namespace fonts { unsigned long MENU = 0; @@ -74,7 +73,7 @@ void draw::OutlineRect(int x, int y, int w, int h, int color) g_ISurface->DrawOutlinedRect(x, y, x + w, y + h); } -void draw::GetStringLength(unsigned long font, char *string, int &length, +void draw::GetStringLength(unsigned long font, const char *string, int &length, int &height) { wchar_t buf[512]; @@ -186,4 +185,3 @@ std::pair draw::GetStringLength(unsigned long font, draw::GetStringLength(font, (char *) string.c_str(), l, h); return std::make_pair(l, h); } -#endif diff --git a/src/textmode.cpp b/src/textmode.cpp index 563c511c..3e4c35d0 100755 --- a/src/textmode.cpp +++ b/src/textmode.cpp @@ -7,9 +7,6 @@ #include "common.hpp" -#include -#include - bool *allowSecureServers{ nullptr }; // valve pls no ban @@ -42,19 +39,19 @@ CatCommand fixvac("fixvac", "Lemme in to secure servers", []() { *allowSecureServers = true; }); InitRoutine init([]() { -#if TEXTMODE_STDIN == 1 +#if ENABLE_TEXTMODE_STDIN logging::Info("[TEXTMODE] Setting up input handling"); int flags = fcntl(0, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(0, F_SETFL, flags); logging::Info("[TEXTMODE] stdin is now non-blocking"); #endif -#if TEXTMODE_VAC == 1 +#if ENABLE_VAC_BYPASS EXPOSED_Epic_VACBypass_1337_DoNotSteal_xXx_$1_xXx_MLG(); #endif }); -#if TEXTMODE_STDIN == 1 +#if ENABLE_TEXTMODE_STDIN void UpdateInput() { char buffer[256];