diff --git a/.cproject b/.cproject
index 6995721c..357841bb 100755
--- a/.cproject
+++ b/.cproject
@@ -43,7 +43,7 @@
-
-
-
@@ -88,7 +88,7 @@
-
-
@@ -107,7 +107,7 @@
-
@@ -130,8 +130,6 @@
-
-
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02a21605..b55e91a7 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ set(EnableVisuals 1 CACHE BOOL "Enable Visuals")
set(ExternalDrawing 0 CACHE BOOL "External Visuals")
set(EnableGUI 1 CACHE BOOL "Enable GUI")
set(EnableIPC 1 CACHE BOOL "Enable IPC")
-set(DataPath "/opt/cathook/data" CACHE STRING "Data location")
+set(DataPath "/opt/cathook/data" CACHE FILEPATH "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)")
@@ -79,7 +79,7 @@ endif()
configure_file(include/config.h.in ${CMAKE_SOURCE_DIR}/include/config.h @ONLY)
configure_file(include/version.h.in ${CMAKE_SOURCE_DIR}/include/version.h @ONLY)
-set_target_properties(cathook PROPERTIES COMPILE_FLAGS "-m32 -msse -msse2 -msse3" LINK_FLAGS "-m32 -static")
+set_target_properties(cathook PROPERTIES COMPILE_FLAGS "-m32 -msse -msse2 -msse3 -fexceptions" LINK_FLAGS "-m32 -fno-gnu-unique -fexceptions")
target_compile_definitions(cathook PRIVATE
_GLIBCXX_USE_CXX11_ABI=0
@@ -117,7 +117,7 @@ add_custom_target(data
VERBATIM)
# TODO glez_LIBRARIES?
-target_link_libraries(cathook ${ValveLibraryTier0} ${ValveLibraryVStdLib} ssl stdc++)
+target_link_libraries(cathook ${ValveLibraryTier0} ${ValveLibraryVStdLib} ssl)
set_target_properties(cathook PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Strip
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index fb289fd6..e14e12a5 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -53,7 +53,8 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/velocity.hpp"
"${CMAKE_CURRENT_LIST_DIR}/vfunc.hpp"
"${CMAKE_CURRENT_LIST_DIR}/votelogger.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/xorstring.hpp")
+ "${CMAKE_CURRENT_LIST_DIR}/xorstring.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/MiscTemporary.hpp")
target_include_directories(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/include/MiscTemporary.hpp b/include/MiscTemporary.hpp
new file mode 100644
index 00000000..f36c6301
--- /dev/null
+++ b/include/MiscTemporary.hpp
@@ -0,0 +1,29 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#pragma once
+
+#include "common.hpp"
+
+// This is a temporary file to put code that needs moving/refactoring in.
+
+extern bool *bSendPackets;
+extern CatVar no_zoom;
+extern CatVar clean_screenshots;
+extern CatVar disable_visuals;
+extern CatVar disconnect_reason;
+extern CatVar crypt_chat;
+extern CatVar minigun_jump;
+extern CatVar nolerp;
+extern CatVar joinclass;
+extern CatVar jointeam;
+extern CatVar fakelag_amount;
+extern CatVar serverlag_amount;
+extern CatVar debug_projectiles;
+extern CatVar semiauto;
+extern CatVar engine_pred;
+#if ENABLE_VISUALS
+extern int spectator_target;
+#endif
\ No newline at end of file
diff --git a/include/chatlog.hpp b/include/chatlog.hpp
index 3ef6295d..d39c7e8d 100755
--- a/include/chatlog.hpp
+++ b/include/chatlog.hpp
@@ -7,6 +7,8 @@
#pragma once
+#include
+
namespace chatlog
{
diff --git a/include/common.hpp b/include/common.hpp
index 0df4b0f6..d76b439c 100755
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -94,7 +94,7 @@
#include "textfile.hpp"
#include "ipc.hpp"
#include "tfmm.hpp"
-#include "hooks/hookedmethods.hpp"
+#include "hooks/HookedMethods.hpp"
#include "classinfo/classinfo.hpp"
#include "votelogger.hpp"
#include "crits.hpp"
diff --git a/include/hooks.hpp b/include/hooks.hpp
old mode 100755
new mode 100644
index 0fc2b157..ccbe0b17
--- a/include/hooks.hpp
+++ b/include/hooks.hpp
@@ -37,7 +37,12 @@ public:
~VMTHook();
void Set(ptr_t inst, uint32_t offset = 0);
void Release();
- void HookMethod(ptr_t func, uint32_t idx);
+ template
+ inline void HookMethod(T func, uint32_t idx, T *backup)
+ {
+ HookMethod(ptr_t(func), idx, (ptr_t *) (backup));
+ }
+ void HookMethod(ptr_t func, uint32_t idx, ptr_t *backup);
void *GetMethod(uint32_t idx) const;
void Apply();
@@ -64,4 +69,5 @@ extern VMTHook steamfriends;
extern VMTHook materialsystem;
extern VMTHook enginevgui;
extern VMTHook vstd;
+extern VMTHook eventmanager2;
}
diff --git a/include/hooks/CMakeLists.txt b/include/hooks/CMakeLists.txt
index cb48678f..2151284f 100644
--- a/include/hooks/CMakeLists.txt
+++ b/include/hooks/CMakeLists.txt
@@ -1,11 +1,4 @@
target_sources(cathook PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/CreateMove.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/hookedmethods.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/others.hpp")
-
-if(EnableVisuals)
- target_sources(cathook PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.hpp")
-endif()
+ "${CMAKE_CURRENT_LIST_DIR}/HookedMethods.hpp")
target_include_directories(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
\ No newline at end of file
diff --git a/include/hooks/CreateMove.hpp b/include/hooks/CreateMove.hpp
deleted file mode 100755
index b5a13f77..00000000
--- a/include/hooks/CreateMove.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * CreateMove.h
- *
- * Created on: Jan 8, 2017
- * Author: nullifiedcat
- */
-
-#pragma once
-
-class CUserCmd;
-
-extern bool *bSendPackets;
-bool CreateMove_hook(void *, float, CUserCmd *);
diff --git a/include/hooks/HookedMethods.hpp b/include/hooks/HookedMethods.hpp
new file mode 100644
index 00000000..9a39fa00
--- /dev/null
+++ b/include/hooks/HookedMethods.hpp
@@ -0,0 +1,122 @@
+
+/*
+ Created by Jenny White on 28.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#pragma once
+
+#include "common.hpp"
+
+#if ENABLE_VISUALS
+union SDL_Event;
+struct SDL_Window;
+#endif
+
+#define DECLARE_HOOKED_METHOD(name, rtype, ...) \
+ namespace types \
+ { \
+ using name = rtype (*)(__VA_ARGS__); \
+ } \
+ namespace methods \
+ { \
+ rtype name(__VA_ARGS__); \
+ } \
+ namespace original \
+ { \
+ extern types::name name; \
+ }
+
+#define DEFINE_HOOKED_METHOD(name, rtype, ...) \
+ types::name original::name{ nullptr }; \
+ rtype methods::name(__VA_ARGS__)
+
+#define HOOK_ARGS(name) \
+ hooked_methods::methods::name, offsets::name(), \
+ &hooked_methods::original::name
+
+namespace hooked_methods
+{
+// ClientMode
+DECLARE_HOOKED_METHOD(CreateMove, bool, void *, float, CUserCmd *);
+DECLARE_HOOKED_METHOD(LevelInit, void, void *, const char *);
+DECLARE_HOOKED_METHOD(LevelShutdown, void, void *);
+// ClientMode + 4
+DECLARE_HOOKED_METHOD(FireGameEvent, void, void *, IGameEvent *);
+// IBaseClient
+DECLARE_HOOKED_METHOD(DispatchUserMessage, bool, void *, int, bf_read &);
+DECLARE_HOOKED_METHOD(IN_KeyEvent, int, void *, int, ButtonCode_t,
+ const char *);
+// IInput
+DECLARE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *, int);
+// INetChannel
+DECLARE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *, INetMessage &, bool,
+ bool);
+DECLARE_HOOKED_METHOD(CanPacket, bool, INetChannel *);
+DECLARE_HOOKED_METHOD(Shutdown, void, INetChannel *, const char *);
+// ISteamFriends
+DECLARE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *,
+ CSteamID);
+// IEngineVGui
+DECLARE_HOOKED_METHOD(Paint, void, IEngineVGui *, PaintMode_t);
+// IGameEventManager2
+DECLARE_HOOKED_METHOD(FireEvent, bool, IGameEventManager2 *, IGameEvent *,
+ bool);
+DECLARE_HOOKED_METHOD(FireEventClientSide, bool, IGameEventManager2 *,
+ IGameEvent *);
+
+#if ENABLE_VISUALS
+// ClientMode
+DECLARE_HOOKED_METHOD(OverrideView, void, void *, CViewSetup *);
+// IVModelRender
+DECLARE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *,
+ const DrawModelState_t &, const ModelRenderInfo_t &,
+ matrix3x4_t *);
+// IStudioRender
+DECLARE_HOOKED_METHOD(BeginFrame, void, IStudioRender *);
+// IBaseClient
+DECLARE_HOOKED_METHOD(FrameStageNotify, void, void *, ClientFrameStage_t);
+// vgui::IPanel
+DECLARE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *, unsigned int, bool,
+ bool);
+// SDL
+DECLARE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *);
+DECLARE_HOOKED_METHOD(SDL_PollEvent, int, SDL_Event *);
+// IUniformRandomStream
+DECLARE_HOOKED_METHOD(RandomInt, int, IUniformRandomStream *, int, int);
+#endif
+}
+
+// TODO
+// wontfix.club
+#if 0
+
+#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,
+ bool, const char *);
+typedef IMaterial *(*FindMaterial_t)(void *, const char *, const char *, bool,
+ const char *);
+
+/* 70 */ void ReloadTextures_null_hook(void *this_);
+/* 71 */ void ReloadMaterials_null_hook(void *this_, const char *pSubString);
+/* 73 */ IMaterial *FindMaterial_null_hook(void *this_,
+ char const *pMaterialName,
+ const char *pTextureGroupName,
+ bool complain,
+ const char *pComplainPrefix);
+/* 81 */ ITexture *FindTexture_null_hook(void *this_, char const *pTextureName,
+ const char *pTextureGroupName,
+ bool complain,
+ int nAdditionalCreationFlags);
+/* 121 */ void ReloadFilesInList_null_hook(void *this_,
+ IFileList *pFilesToReload);
+/* 123 */ IMaterial *FindMaterialEx_null_hook(void *this_,
+ char const *pMaterialName,
+ const char *pTextureGroupName,
+ int nContext, bool complain,
+ const char *pComplainPrefix);
+#endif
+
+#endif
\ No newline at end of file
diff --git a/include/hooks/PaintTraverse.hpp b/include/hooks/PaintTraverse.hpp
deleted file mode 100755
index 147ab016..00000000
--- a/include/hooks/PaintTraverse.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * PaintTraverse.h
- *
- * Created on: Jan 8, 2017
- * Author: nullifiedcat
- */
-
-#pragma once
-
-class CatVar;
-
-extern CatVar no_zoom;
-extern CatVar clean_screenshots;
-extern CatVar disable_visuals;
-void PaintTraverse_hook(void *, unsigned int, bool, bool);
diff --git a/include/hooks/hookedmethods.hpp b/include/hooks/hookedmethods.hpp
deleted file mode 100644
index 15513884..00000000
--- a/include/hooks/hookedmethods.hpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * hooks.h
- *
- * Created on: Jan 8, 2017
- * Author: nullifiedcat
- */
-
-#pragma once
-
-#include "common.hpp"
-
-typedef bool (*CreateMove_t)(void *, float, CUserCmd *);
-typedef void (*PaintTraverse_t)(void *, unsigned int, bool, bool);
-typedef bool (*CanPacket_t)(void *);
-typedef int (*IN_KeyEvent_t)(void *, int, int, const char *);
-typedef bool (*SendNetMsg_t)(void *, INetMessage &, bool, bool);
-typedef void (*Shutdown_t)(void *, const char *);
-typedef void (*OverrideView_t)(void *, CViewSetup *);
-typedef bool (*DispatchUserMessage_t)(void *, int, bf_read &);
-typedef void (*FrameStageNotify_t)(void *, int);
-typedef void (*LevelInit_t)(void *, const char *);
-typedef void (*LevelShutdown_t)(void *);
-
-typedef void (*BeginFrame_t)(IStudioRender *);
-typedef bool (*CanInspect_t)(IClientEntity *);
-typedef void (*DrawModelExecute_t)(IVModelRender *, const DrawModelState_t &,
- const ModelRenderInfo_t &, matrix3x4_t *);
-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);
-
-typedef int (*RandomInt_t)(void *, int, int);
-
-const char *GetClientName_hook(CBaseClientState *_this);
-bool ProcessSetConVar_hook(CBaseClientState *_this, NET_SetConVar *msg);
-bool ProcessGetCvarValue_hook(CBaseClientState *_this, SVC_GetCvarValue *msg);
-// typedef void(*CInput__CreateMove_t)(void*, int, float, bool);
-// void CInput__CreateMove_hook(void*, int sequence_number, float
-// input_sample_frametime, bool active);
-typedef const char *(*GetFriendPersonaName_t)(ISteamFriends *, CSteamID);
-const char *GetFriendPersonaName_hook(ISteamFriends *_this, CSteamID steamID);
-
-typedef void (*FireGameEvent_t)(void *_this, IGameEvent *event);
-void FireGameEvent_hook(void *_this, IGameEvent *event);
-
-CUserCmd *GetUserCmd_hook(IInput *, int);
-void DrawModelExecute_hook(IVModelRender *_this, const DrawModelState_t &state,
- const ModelRenderInfo_t &info, matrix3x4_t *matrix);
-
-#if ENABLE_VISUALS
-void Paint_hook(IEngineVGui *_this, PaintMode_t mode);
-
-/* SDL HOOKS */
-union SDL_Event;
-class SDL_Window;
-
-extern SDL_Window *sdl_current_window;
-
-typedef int (*SDL_PollEvent_t)(SDL_Event *event);
-typedef void (*SDL_GL_SwapWindow_t)(SDL_Window *window);
-
-int SDL_PollEvent_hook(SDL_Event *event);
-void SDL_GL_SwapWindow_hook(SDL_Window *window);
-
-void DoSDLHooking();
-void DoSDLUnhooking();
-#endif
-
-#include "CreateMove.hpp"
-#include "PaintTraverse.hpp"
-#include "others.hpp"
diff --git a/include/hooks/others.hpp b/include/hooks/others.hpp
deleted file mode 100755
index 4f284fc4..00000000
--- a/include/hooks/others.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * others.h
- *
- * Created on: Jan 8, 2017
- * Author: nullifiedcat
- */
-
-#pragma once
-
-#include "config.h"
-
-class INetMessage;
-class CViewSetup;
-class bf_read;
-class SDL_Window;
-class CatVar;
-
-extern CatVar disconnect_reason;
-#if ENABLE_VISUALS
-extern int spectator_target;
-#endif
-
-bool CanPacket_hook(void *);
-int IN_KeyEvent_hook(void *, int, int, const char *);
-bool SendNetMsg_hook(void *, INetMessage &, bool, bool);
-void Shutdown_hook(void *, const char *);
-void OverrideView_hook(void *, CViewSetup *);
-bool DispatchUserMessage_hook(void *, int, bf_read &);
-void FrameStageNotify_hook(void *, int);
-void LevelInit_hook(void *, const char *);
-void LevelShutdown_hook(void *);
-int RandomInt_hook(void *, int, int);
-
-#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,
- bool, const char *);
-typedef IMaterial *(*FindMaterial_t)(void *, const char *, const char *, bool,
- const char *);
-
-/* 70 */ void ReloadTextures_null_hook(void *this_);
-/* 71 */ void ReloadMaterials_null_hook(void *this_, const char *pSubString);
-/* 73 */ IMaterial *FindMaterial_null_hook(void *this_,
- char const *pMaterialName,
- const char *pTextureGroupName,
- bool complain,
- const char *pComplainPrefix);
-/* 81 */ ITexture *FindTexture_null_hook(void *this_, char const *pTextureName,
- const char *pTextureGroupName,
- bool complain,
- int nAdditionalCreationFlags);
-/* 121 */ void ReloadFilesInList_null_hook(void *this_,
- IFileList *pFilesToReload);
-/* 123 */ IMaterial *FindMaterialEx_null_hook(void *this_,
- char const *pMaterialName,
- const char *pTextureGroupName,
- int nContext, bool complain,
- const char *pComplainPrefix);
-#endif
-
-// extern unsigned int* swapwindow_ptr;
-// extern unsigned int swapwindow_orig;
diff --git a/include/interfaces.hpp b/include/interfaces.hpp
index 36674986..d1518acd 100755
--- a/include/interfaces.hpp
+++ b/include/interfaces.hpp
@@ -51,6 +51,7 @@ class IGameEventManager;
class TFGCClientSystem;
class CGameRules;
class IEngineVGui;
+class IUniformRandomStream;
extern TFGCClientSystem *g_TFGCClientSystem;
extern CHud *g_CHUD;
diff --git a/include/offsets.hpp b/include/offsets.hpp
index 8f78a6b7..36d86047 100755
--- a/include/offsets.hpp
+++ b/include/offsets.hpp
@@ -164,4 +164,8 @@ struct offsets
{
return PlatformOffset(2, undefined, undefined);
}
+ static constexpr uint32_t Paint()
+ {
+ return PlatformOffset(14, undefined, undefined);
+ }
};
diff --git a/include/projlogging.hpp b/include/projlogging.hpp
old mode 100755
new mode 100644
index e7ab9b17..bef24f2e
--- a/include/projlogging.hpp
+++ b/include/projlogging.hpp
@@ -5,7 +5,6 @@
* Author: nullifiedcat
*/
-
#pragma once
namespace projectile_logging
diff --git a/include/sdk/ScreenSpaceEffects.h b/include/sdk/ScreenSpaceEffects.h
old mode 100755
new mode 100644
index 8818d482..58cae8a5
--- a/include/sdk/ScreenSpaceEffects.h
+++ b/include/sdk/ScreenSpaceEffects.h
@@ -87,4 +87,3 @@ extern CScreenSpaceEffectRegistration **g_ppScreenSpaceRegistrationHead;
CEffect pEffectName##_effect; \
CScreenSpaceEffectRegistration pEffectName##_reg(#pEffectName, \
&pEffectName##_effect);
-
diff --git a/include/visual/CMakeLists.txt b/include/visual/CMakeLists.txt
index ef6ce432..33ff88bf 100644
--- a/include/visual/CMakeLists.txt
+++ b/include/visual/CMakeLists.txt
@@ -6,7 +6,8 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/drawmgr.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectChams.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectGlow.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp")
+ "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/SDLHooks.hpp")
if(EnableGUI)
add_subdirectory(menu)
diff --git a/include/visual/SDLHooks.hpp b/include/visual/SDLHooks.hpp
new file mode 100644
index 00000000..662fdc08
--- /dev/null
+++ b/include/visual/SDLHooks.hpp
@@ -0,0 +1,18 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#pragma once
+
+struct SDL_Window;
+
+namespace sdl_hooks
+{
+
+extern SDL_Window *window;
+
+void applySdlHooks();
+void cleanSdlHooks();
+
+}
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4b38b43f..e23bd60e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,7 +39,8 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/trace.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ucccccp_cmds.cpp"
"${CMAKE_CURRENT_LIST_DIR}/velocity.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/votelogger.cpp")
+ "${CMAKE_CURRENT_LIST_DIR}/votelogger.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/MiscTemporary.cpp")
add_subdirectory(classinfo)
add_subdirectory(copypasted)
diff --git a/src/MiscTemporary.cpp b/src/MiscTemporary.cpp
new file mode 100644
index 00000000..cb15851b
--- /dev/null
+++ b/src/MiscTemporary.cpp
@@ -0,0 +1,36 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "MiscTemporary.hpp"
+
+CatVar minigun_jump(CV_SWITCH, "minigun_jump", "0", "TF2C minigun jump",
+ "Allows jumping while shooting with minigun");
+
+CatVar jointeam(CV_SWITCH, "fb_autoteam", "1",
+ "Joins player team automatically (NYI)");
+CatVar joinclass(CV_STRING, "fb_autoclass", "spy",
+ "Class that will be picked after joining a team (NYI)");
+
+CatVar nolerp(CV_SWITCH, "nolerp", "0", "NoLerp mode (experimental)");
+
+CatVar engine_pred(CV_SWITCH, "engine_prediction", "0", "Engine Prediction");
+CatVar debug_projectiles(CV_SWITCH, "debug_projectiles", "0",
+ "Debug Projectiles");
+
+CatVar fakelag_amount(CV_INT, "fakelag", "0", "Bad Fakelag");
+CatVar serverlag_amount(
+ CV_INT, "serverlag", "0", "serverlag",
+ "Lag the server by spamming this many voicecommands per tick");
+CatVar semiauto(CV_INT, "semiauto", "0", "Semiauto");
+CatVar servercrash(CV_SWITCH, "servercrash", "0", "crash servers",
+ "Crash servers by spamming signon net messages");
+bool *bSendPackets;
+
+
+CatVar crypt_chat(
+ CV_SWITCH, "chat_crypto", "1", "Crypto chat",
+ "Start message with !! and it will be only visible to cathook users");
+
+int spectator_target;
\ No newline at end of file
diff --git a/src/chatlog.cpp b/src/chatlog.cpp
old mode 100755
new mode 100644
index 6fa8e67c..0f225c69
--- a/src/chatlog.cpp
+++ b/src/chatlog.cpp
@@ -27,6 +27,7 @@ public:
{
};
static end_t end;
+
public:
csv_stream()
{
diff --git a/src/copypasted/CSignature.cpp b/src/copypasted/CSignature.cpp
old mode 100755
new mode 100644
index fc077bf2..d92b45a3
--- a/src/copypasted/CSignature.cpp
+++ b/src/copypasted/CSignature.cpp
@@ -79,7 +79,9 @@ uintptr_t CSignature::dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength,
}
}
- logging::Info("THIS IS SERIOUS: Could not locate signature: \n============\n\"%s\"\n============", szPattern);
+ logging::Info("THIS IS SERIOUS: Could not locate signature: "
+ "\n============\n\"%s\"\n============",
+ szPattern);
return NULL;
}
diff --git a/src/crits.cpp b/src/crits.cpp
index a1e277ee..5076ebc4 100644
--- a/src/crits.cpp
+++ b/src/crits.cpp
@@ -17,6 +17,7 @@ CatVar crit_experimental(CV_SWITCH, "crit_experimental", "0",
"Experimental crithack");
std::unordered_map command_number_mod{};
+
int *g_PredictionRandomSeed = nullptr;
namespace criticals
diff --git a/src/hack.cpp b/src/hack.cpp
index ddbcdf2a..2cba698a 100644
--- a/src/hack.cpp
+++ b/src/hack.cpp
@@ -5,6 +5,7 @@
* Author: nullifiedcat
*/
+#include
#include "hack.hpp"
#include "common.hpp"
@@ -79,7 +80,7 @@ std::stack &hack::command_stack()
return stack;
}
-#if ENABLE_VISUALS /* Why would we need colored chat stuff in textmode? \
+#if ENABLE_VISUALS /* Why would we need colored chat stuff in textmode? \
*/
#define red 184, 56, 59, 255
#define blu 88, 133, 162, 255
@@ -245,8 +246,9 @@ free(logname);*/
if (not exists)
{
Error(("Missing essential file: " + s +
- "/%s\nYou MUST run install-data script to finish "
- "installation").c_str(),
+ "/%s\nYou MUST run install-data script to finish "
+ "installation")
+ .c_str(),
s.c_str());
}
}
@@ -287,12 +289,7 @@ free(logname);*/
InitNetVars();
g_pLocalPlayer = new LocalPlayer();
g_pPlayerResource = new TFPlayerResource();
-#if ENABLE_VISUALS
- hooks::panel.Set(g_IPanel);
- hooks::panel.HookMethod((void *) PaintTraverse_hook,
- offsets::PaintTraverse());
- hooks::panel.Apply();
-#endif
+
uintptr_t *clientMode = 0;
// Bad way to get clientmode.
// FIXME [MP]?
@@ -303,35 +300,58 @@ free(logname);*/
usleep(10000);
}
hooks::clientmode.Set((void *) clientMode);
- hooks::clientmode.HookMethod((void *) CreateMove_hook,
- offsets::CreateMove());
+ hooks::clientmode.HookMethod(HOOK_ARGS(CreateMove));
#if ENABLE_VISUALS
- hooks::clientmode.HookMethod((void *) OverrideView_hook,
- offsets::OverrideView());
+ hooks::clientmode.HookMethod(HOOK_ARGS(OverrideView));
#endif
- hooks::clientmode.HookMethod((void *) LevelInit_hook, offsets::LevelInit());
- hooks::clientmode.HookMethod((void *) LevelShutdown_hook,
- offsets::LevelShutdown());
+ hooks::clientmode.HookMethod(HOOK_ARGS(LevelInit));
+ hooks::clientmode.HookMethod(HOOK_ARGS(LevelShutdown));
hooks::clientmode.Apply();
- hooks::clientmode4.Set((void *) (clientMode), 4);
- hooks::clientmode4.HookMethod((void *) FireGameEvent_hook,
- offsets::FireGameEvent());
- hooks::clientmode4.Apply();
- hooks::client.Set(g_IBaseClient);
+ hooks::clientmode4.Set((void *) (clientMode), 4);
+ hooks::clientmode4.HookMethod(HOOK_ARGS(FireGameEvent));
+ hooks::clientmode4.Apply();
+
+ hooks::client.Set(g_IBaseClient);
+ hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage));
#if ENABLE_VISUALS
- hooks::client.HookMethod((void *) FrameStageNotify_hook,
- offsets::FrameStageNotify());
+ hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
+ hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
#endif
- hooks::client.HookMethod((void *) DispatchUserMessage_hook,
- offsets::DispatchUserMessage());
+ hooks::client.Apply();
#if ENABLE_VISUALS
hooks::vstd.Set((void *) g_pUniformStream);
- hooks::vstd.HookMethod((void *) RandomInt_hook, offsets::RandomInt());
+ hooks::vstd.HookMethod(HOOK_ARGS(RandomInt));
hooks::vstd.Apply();
+
+ hooks::panel.Set(g_IPanel);
+ hooks::panel.HookMethod(hooked_methods::methods::PaintTraverse,
+ offsets::PaintTraverse(), &hooked_methods::original::PaintTraverse);
+ hooks::panel.Apply();
#endif
+ hooks::input.Set(g_IInput);
+ hooks::input.HookMethod(HOOK_ARGS(GetUserCmd));
+ hooks::input.Apply();
+#if ENABLE_VISUALS
+ hooks::modelrender.Set(g_IVModelRender);
+ hooks::modelrender.HookMethod(HOOK_ARGS(DrawModelExecute));
+ hooks::modelrender.Apply();
+#endif
+ hooks::enginevgui.Set(g_IEngineVGui);
+ hooks::enginevgui.HookMethod(HOOK_ARGS(Paint));
+ hooks::enginevgui.Apply();
+
+ hooks::eventmanager2.Set(g_IEventManager2);
+ hooks::eventmanager2.HookMethod(HOOK_ARGS(FireEvent));
+ hooks::eventmanager2.HookMethod(HOOK_ARGS(FireEventClientSide));
+ hooks::eventmanager2.Apply();
+
+ hooks::steamfriends.Set(g_ISteamFriends);
+ hooks::steamfriends.HookMethod(HOOK_ARGS(GetFriendPersonaName));
+ hooks::steamfriends.Apply();
+
#if ENABLE_NULL_GRAPHICS
g_IMaterialSystem->SetInStubMode(true);
IF_GAME(IsTF2())
@@ -354,42 +374,6 @@ free(logname);*/
// hooks::materialsystem.HookMethod();
}
#endif
-#if ENABLE_VISUALS
- hooks::client.HookMethod((void *) IN_KeyEvent_hook, offsets::IN_KeyEvent());
-#endif
- hooks::client.Apply();
- hooks::input.Set(g_IInput);
- hooks::input.HookMethod((void *) GetUserCmd_hook, offsets::GetUserCmd());
- hooks::input.Apply();
-#ifndef HOOK_DME_DISABLED
-#if ENABLE_VISUALS
- hooks::modelrender.Set(g_IVModelRender);
- hooks::modelrender.HookMethod((void *) DrawModelExecute_hook,
- offsets::DrawModelExecute());
- hooks::modelrender.Apply();
- hooks::enginevgui.Set(g_IEngineVGui);
- hooks::enginevgui.HookMethod(
- (void *) Paint_hook,
- offsets::PlatformOffset(14, offsets::undefined, offsets::undefined));
- hooks::enginevgui.Apply();
-#endif
-#endif
- hooks::steamfriends.Set(g_ISteamFriends);
- hooks::steamfriends.HookMethod((void *) GetFriendPersonaName_hook,
- offsets::GetFriendPersonaName());
- hooks::steamfriends.Apply();
- // logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName());
- // Sadly, it doesn't work as expected :(
- /*hooks::hkBaseClientState = new hooks::VMTHook();
- hooks::hkBaseClientState->Init((void*)g_IBaseClientState, 0);
- hooks::hkBaseClientState->HookMethod((void*)GetClientName_hook,
- hooks::offGetClientName); hooks::hkBaseClientState->Apply();*/
- // hooks::hkBaseClientState8 = new hooks::VMTHook();
- // hooks::hkBaseClientState8->Init((void*)g_IBaseClientState, 8);
- // hooks::hkBaseClientState8->HookMethod((void*)ProcessSetConVar_hook,
- // hooks::offProcessSetConVar);
- // hooks::hkBaseClientState8->HookMethod((void*)ProcessGetCvarValue_hook,
- // hooks::offProcessGetCvarValue); hooks::hkBaseClientState8->Apply();
// FIXME [MP]
hacks::shared::killsay::Init();
@@ -420,7 +404,7 @@ free(logname);*/
}
logging::Info("SSE enabled..");
#endif
- DoSDLHooking();
+ sdl_hooks::applySdlHooks();
logging::Info("SDL hooking done");
g_IGameEventManager->AddListener(&adv_event_listener, false);
@@ -470,7 +454,7 @@ void hack::Shutdown()
hack::shutdown = true;
playerlist::Save();
#if ENABLE_VISUALS
- DoSDLUnhooking();
+ sdl_hooks::cleanSdlHooks();
#endif
logging::Info("Unregistering convars..");
ConVar_Unregister();
diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp
index 43e9f65b..c7423100 100644
--- a/src/hacks/ESP.cpp
+++ b/src/hacks/ESP.cpp
@@ -402,8 +402,8 @@ void _FASTCALL emoji(CachedEntity *ent)
}
glez_rgba_t white = glez_rgba(255, 255, 255, 255);
while (!textur || textur == 4294967295)
- textur = glez_texture_load_png_rgba(DATA_PATH
- "/textures/atlas.png");
+ textur = glez_texture_load_png_rgba(
+ DATA_PATH "/textures/atlas.png");
player_info_s info;
unsigned int steamID;
unsigned int steamidarray[32]{};
diff --git a/src/hacks/Killstreak.cpp b/src/hacks/Killstreak.cpp
old mode 100755
new mode 100644
index bba4a810..0419f27b
--- a/src/hacks/Killstreak.cpp
+++ b/src/hacks/Killstreak.cpp
@@ -137,11 +137,6 @@ bool FireEventClientSide(IGameEventManager2 *manager, IGameEvent *event)
void init()
{
- hook.Set(g_IEventManager2, 0);
- // hook.HookMethod(FireEvent_hook, offsets::FireEvent());
- hook.HookMethod((void *) FireEventClientSide,
- offsets::FireEventClientSide());
- hook.Apply();
}
}
}
diff --git a/src/hacks/SkinChanger.cpp b/src/hacks/SkinChanger.cpp
old mode 100755
new mode 100644
index eae1044e..6facc80d
--- 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{ (uint16_t)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/hacks/Walkbot.cpp b/src/hacks/Walkbot.cpp
index cdd255fc..ec587150 100644
--- a/src/hacks/Walkbot.cpp
+++ b/src/hacks/Walkbot.cpp
@@ -1194,7 +1194,8 @@ void Move()
prevlvlname = g_IEngine->GetLevelName();
std::string prvlvlname = format(prevlvlname);
logging::Info("%s %s", prevlvlname, prvlvlname.c_str());
- if (boost::contains(prvlvlname, "pl_") || boost::contains(prvlvlname, "cp_"))
+ if (boost::contains(prvlvlname, "pl_") ||
+ boost::contains(prvlvlname, "cp_"))
{
logging::Info("1");
bool ret = false;
diff --git a/src/hooks.cpp b/src/hooks.cpp
old mode 100755
new mode 100644
index dfca7408..058e06fa
--- a/src/hooks.cpp
+++ b/src/hooks.cpp
@@ -77,10 +77,13 @@ void *VMTHook::GetMethod(uint32_t idx) const
return vtable_original[idx];
}
-void VMTHook::HookMethod(ptr_t func, uint32_t idx)
+void VMTHook::HookMethod(ptr_t func, uint32_t idx, ptr_t *backup)
{
- logging::Info("Hooking method %d of vtable 0x%08x, replacing 0x%08x with 0x%08x", idx,
- vtable_original, GetMethod(idx), func);
+ logging::Info(
+ "Hooking method %d of vtable 0x%08x, replacing 0x%08x with 0x%08x", idx,
+ vtable_original, GetMethod(idx), func);
+ if (backup)
+ *backup = vtable_hooked[2 + idx];
vtable_hooked[2 + idx] = func;
}
@@ -106,4 +109,5 @@ VMTHook clientmode4{};
VMTHook materialsystem{};
VMTHook enginevgui{};
VMTHook vstd{};
+VMTHook eventmanager2{};
}
diff --git a/src/hooks/CMakeLists.txt b/src/hooks/CMakeLists.txt
index 7b815ce0..90257059 100644
--- a/src/hooks/CMakeLists.txt
+++ b/src/hooks/CMakeLists.txt
@@ -1,11 +1,20 @@
target_sources(cathook PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/CanPacket.cpp"
"${CMAKE_CURRENT_LIST_DIR}/CreateMove.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/DispatchUserMessage.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/FireGameEvent.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/GetFriendPersonaName.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/GetUserCmd.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/LevelInit.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/LevelShutdown.cpp"
"${CMAKE_CURRENT_LIST_DIR}/nographics.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/others.cpp")
+ "${CMAKE_CURRENT_LIST_DIR}/others.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/Paint.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/SendNetMsg.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/Shutdown.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/FireEvent.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/FireEventClientSide.cpp")
if(EnableVisuals)
- target_sources(cathook PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/Paint.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/sdl.cpp")
+ add_subdirectory(visual)
endif()
\ No newline at end of file
diff --git a/src/hooks/CanPacket.cpp b/src/hooks/CanPacket.cpp
new file mode 100644
index 00000000..a9a8f529
--- /dev/null
+++ b/src/hooks/CanPacket.cpp
@@ -0,0 +1,15 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(CanPacket, bool, INetChannel *this_)
+{
+ return original::CanPacket(this_);
+}
+}
diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp
index 6c045fae..d496cb88 100644
--- a/src/hooks/CreateMove.cpp
+++ b/src/hooks/CreateMove.cpp
@@ -7,18 +7,12 @@
#include "common.hpp"
#include "hack.hpp"
+#include "MiscTemporary.hpp"
#include
-static CatVar minigun_jump(CV_SWITCH, "minigun_jump", "0", "TF2C minigun jump",
- "Allows jumping while shooting with minigun");
+#include "HookedMethods.hpp"
-CatVar jointeam(CV_SWITCH, "fb_autoteam", "1",
- "Joins player team automatically (NYI)");
-CatVar joinclass(CV_STRING, "fb_autoclass", "spy",
- "Class that will be picked after joining a team (NYI)");
-
-CatVar nolerp(CV_SWITCH, "nolerp", "0", "NoLerp mode (experimental)");
class CMoveData;
namespace engine_prediction
@@ -36,9 +30,9 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
void **predictionVtable = *((void ***) g_IPrediction);
SetupMoveFn oSetupMove =
- (SetupMoveFn)(*(unsigned *) (predictionVtable + 19));
+ (SetupMoveFn) (*(unsigned *) (predictionVtable + 19));
FinishMoveFn oFinishMove =
- (FinishMoveFn)(*(unsigned *) (predictionVtable + 20));
+ (FinishMoveFn) (*(unsigned *) (predictionVtable + 20));
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
// 0x1F69C0C); CMoveData movedata {};
@@ -46,7 +40,7 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
CMoveData *pMoveData = (CMoveData *) object;
float frameTime = g_GlobalVars->frametime;
- float curTime = g_GlobalVars->curtime;
+ float curTime = g_GlobalVars->curtime;
CUserCmd defaultCmd;
if (ucmd == NULL)
@@ -57,76 +51,40 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
NET_VAR(ent, 4188, CUserCmd *) = ucmd;
g_GlobalVars->curtime =
- g_GlobalVars->interval_per_tick * NET_INT(ent, netvar.nTickBase);
+ g_GlobalVars->interval_per_tick * NET_INT(ent, netvar.nTickBase);
g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
*g_PredictionRandomSeed =
- MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF;
+ MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF;
g_IGameMovement->StartTrackPredictionErrors(
- reinterpret_cast(ent));
+ reinterpret_cast(ent));
oSetupMove(g_IPrediction, ent, ucmd, NULL, pMoveData);
g_IGameMovement->ProcessMovement(reinterpret_cast(ent),
pMoveData);
oFinishMove(g_IPrediction, ent, ucmd, pMoveData);
g_IGameMovement->FinishTrackPredictionErrors(
- reinterpret_cast(ent));
+ reinterpret_cast(ent));
NET_VAR(ent, 4188, CUserCmd *) = nullptr;
g_GlobalVars->frametime = frameTime;
- g_GlobalVars->curtime = curTime;
+ g_GlobalVars->curtime = curTime;
return;
}
-
-/*float o_curtime;
-float o_frametime;
-
-void Start() {
- g_IGameMovement->StartTrackPredictionErrors((CBasePlayer*)(RAW_ENT(LOCAL_E)));
-
- IClientEntity* player = RAW_ENT(LOCAL_E);
- // CPredictableId::ResetInstanceCounters();
- *(reinterpret_cast(reinterpret_cast(player) + 1047)) =
-g_pUserCmd; o_curtime = g_GlobalVars->curtime; o_frametime =
-g_GlobalVars->frametime; *g_PredictionRandomSeed =
-MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF; g_GlobalVars->curtime
-= CE_INT(LOCAL_E, netvar.nTickBase) * g_GlobalVars->interval_per_tick;
- g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
-
- CMoveData data;
-
}
-void End() {
- *g_PredictionRandomSeed = -1;
- g_GlobalVars->curtime = o_curtime;
- g_GlobalVars->frametime = o_frametime;
-}*/
-}
+namespace hooked_methods
+{
-static CatVar engine_pred(CV_SWITCH, "engine_prediction", "0",
- "Engine Prediction");
-static CatVar debug_projectiles(CV_SWITCH, "debug_projectiles", "0",
- "Debug Projectiles");
-
-static CatVar fakelag_amount(CV_INT, "fakelag", "0", "Bad Fakelag");
-static CatVar serverlag_amount(
- CV_INT, "serverlag", "0", "serverlag",
- "Lag the server by spamming this many voicecommands per tick");
-CatVar semiauto(CV_INT, "semiauto", "0", "Semiauto");
-CatVar servercrash(CV_SWITCH, "servercrash", "0", "crash servers",
- "Crash servers by spamming signon net messages");
-bool *bSendPackets;
-bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
+DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
+ CUserCmd *cmd)
{
uintptr_t **fp;
__asm__("mov %%ebp, %0" : "=r"(fp));
bSendPackets = reinterpret_cast(**fp - 8);
g_Settings.is_create_move = true;
- static CreateMove_t original_method =
- (CreateMove_t) hooks::clientmode.GetMethod(offsets::CreateMove());
bool time_replaced, ret, speedapplied;
float curtime_old, servertime, speed, yaw;
Vector vsilent, ang;
@@ -143,7 +101,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
}
}
- ret = original_method(thisptr, inputSample, cmd);
+ ret = original::CreateMove(this_, input_sample_time, cmd);
PROF_SECTION(CreateMove);
@@ -260,7 +218,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
{
logging::Info("Trying to change CLASS");
g_IEngine->ExecuteClientCmd(
- format("join_class ", joinclass.GetString()).c_str());
+ format("join_class ", joinclass.GetString()).c_str());
}
team_joining_state = 0;
}
@@ -482,7 +440,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
speedapplied = false;
if (roll_speedhack &&
g_IInputSystem->IsButtonDown(
- (ButtonCode_t)((int) roll_speedhack)) &&
+ (ButtonCode_t)((int) roll_speedhack)) &&
!(cmd->buttons & IN_ATTACK))
{
speed = cmd->forwardmove;
@@ -542,3 +500,30 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd)
g_Settings.is_create_move = false;
return ret;
}
+}
+
+
+/*float o_curtime;
+float o_frametime;
+
+void Start() {
+ g_IGameMovement->StartTrackPredictionErrors((CBasePlayer*)(RAW_ENT(LOCAL_E)));
+
+ IClientEntity* player = RAW_ENT(LOCAL_E);
+ // CPredictableId::ResetInstanceCounters();
+ *(reinterpret_cast(reinterpret_cast(player) + 1047)) =
+g_pUserCmd; o_curtime = g_GlobalVars->curtime; o_frametime =
+g_GlobalVars->frametime; *g_PredictionRandomSeed =
+MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF; g_GlobalVars->curtime
+= CE_INT(LOCAL_E, netvar.nTickBase) * g_GlobalVars->interval_per_tick;
+ g_GlobalVars->frametime = g_GlobalVars->interval_per_tick;
+
+ CMoveData data;
+
+}
+
+void End() {
+ *g_PredictionRandomSeed = -1;
+ g_GlobalVars->curtime = o_curtime;
+ g_GlobalVars->frametime = o_frametime;
+}*/
diff --git a/src/hooks/DispatchUserMessage.cpp b/src/hooks/DispatchUserMessage.cpp
new file mode 100644
index 00000000..c150fb95
--- /dev/null
+++ b/src/hooks/DispatchUserMessage.cpp
@@ -0,0 +1,272 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include
+#include
+#include
+#include
+#include "HookedMethods.hpp"
+
+static bool retrun = false;
+static Timer sendmsg{};
+static Timer gitgud{};
+static CatVar clean_chat(CV_SWITCH, "clean_chat", "0", "Clean chat",
+ "Removes newlines from chat");
+static CatVar dispatch_log(CV_SWITCH, "debug_log_usermessages", "0",
+ "Log dispatched user messages");
+static CatVar chat_filter(CV_STRING, "chat_censor", "", "Censor words",
+ "Spam Chat with newlines if the chosen words are "
+ "said, seperate with commas");
+static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0",
+ "Enable censor", "Censor Words in chat");
+std::string clear = "";
+std::string lastfilter{};
+std::string lastname{};
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type,
+ bf_read &buf)
+{
+ if (retrun && gitgud.test_and_set(10000))
+ {
+ PrintChat("\x07%06X%s\x01: %s", 0xe05938, lastname.c_str(),
+ lastfilter.c_str());
+ retrun = false;
+ }
+ int loop_index, s, i, j;
+ char *data, c;
+
+ if (type == 4)
+ {
+ loop_index = 0;
+ s = buf.GetNumBytesLeft();
+ if (s < 256)
+ {
+ data = (char *) alloca(s);
+ for (i = 0; i < s; i++)
+ data[i] = buf.ReadByte();
+ j = 0;
+ std::string name;
+ std::string message;
+ for (i = 0; i < 3; i++)
+ {
+ while ((c = data[j++]) && (loop_index < 128))
+ {
+ loop_index++;
+ if (clean_chat)
+ if ((c == '\n' || c == '\r') && (i == 1 || i == 2))
+ data[j - 1] = '*';
+ if (i == 1)
+ name.push_back(c);
+ if (i == 2)
+ message.push_back(c);
+ }
+ }
+ if (chat_filter_enabled && data[0] != LOCAL_E->m_IDX)
+ {
+ if (!strcmp(chat_filter.GetString(), ""))
+ {
+ std::string tmp = {};
+ std::string tmp2 = {};
+ int iii = 0;
+ player_info_s info;
+ g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info);
+ std::string name1 = info.name;
+ std::vector name2{};
+ std::vector name3{};
+ std::string claz = {};
+ switch (g_pLocalPlayer->clazz)
+ {
+ case tf_scout:
+ claz = "scout";
+ break;
+ case tf_soldier:
+ claz = "soldier";
+ break;
+ case tf_pyro:
+ claz = "pyro";
+ break;
+ case tf_demoman:
+ claz = "demo";
+ break;
+ case tf_engineer:
+ claz = "engi";
+ break;
+ case tf_heavy:
+ claz = "heavy";
+ break;
+ case tf_medic:
+ claz = "med";
+ break;
+ case tf_sniper:
+ claz = "sniper";
+ break;
+ case tf_spy:
+ claz = "spy";
+ break;
+ default:
+ break;
+ }
+ for (char i : name1)
+ {
+ if (iii == 2)
+ {
+ iii = 0;
+ tmp += i;
+ name2.push_back(tmp);
+ tmp = "";
+ }
+ else if (iii < 2)
+ {
+ iii++;
+ tmp += i;
+ }
+ }
+ iii = 0;
+ for (char i : name1)
+ {
+ if (iii == 3)
+ {
+ iii = 0;
+ tmp += i;
+ name3.push_back(tmp2);
+ tmp2 = "";
+ }
+ else if (iii < 3)
+ {
+ iii++;
+ tmp2 += i;
+ }
+ }
+ if (tmp.size() > 2)
+ name2.push_back(tmp);
+ if (tmp2.size() > 2)
+ name3.push_back(tmp2);
+ iii = 0;
+ std::vector res = {
+ "skid", "script", "cheat", "hak", "hac", "f1",
+ "hax", "vac", "ban", "lmao", "bot", "report",
+ "cat", "insta", "revv", "brass", "kick", claz
+ };
+ for (auto i : name2)
+ {
+ boost::to_lower(i);
+ res.push_back(i);
+ }
+ for (auto i : name3)
+ {
+ boost::to_lower(i);
+ res.push_back(i);
+ }
+ std::string message2 = message;
+ boost::to_lower(message2);
+ boost::replace_all(message2, "4", "a");
+ boost::replace_all(message2, "3", "e");
+ boost::replace_all(message2, "0", "o");
+ boost::replace_all(message2, "6", "g");
+ boost::replace_all(message2, "5", "s");
+ boost::replace_all(message2, "7", "t");
+ for (auto filter : res)
+ {
+ if (retrun)
+ break;
+ if (boost::contains(message2, filter))
+ {
+
+ if (clear == "")
+ {
+ for (int i = 0; i < 120; i++)
+ clear += "\n";
+ }
+ *bSendPackets = true;
+ chat_stack::Say(". " + clear, true);
+ retrun = true;
+ lastfilter = format(filter);
+ lastname = format(name);
+ }
+ }
+ }
+ else if (data[0] != LOCAL_E->m_IDX)
+ {
+ std::string input = chat_filter.GetString();
+ boost::to_lower(input);
+ std::string message2 = message;
+ std::vector result{};
+ boost::split(result, input, boost::is_any_of(","));
+ boost::replace_all(message2, "4", "a");
+ boost::replace_all(message2, "3", "e");
+ boost::replace_all(message2, "0", "o");
+ boost::replace_all(message2, "6", "g");
+ boost::replace_all(message2, "5", "s");
+ boost::replace_all(message2, "7", "t");
+ for (auto filter : result)
+ {
+ if (retrun)
+ break;
+ if (boost::contains(message2, filter))
+ {
+ if (clear == "")
+ {
+ clear = "";
+ for (int i = 0; i < 120; i++)
+ clear += "\n";
+ }
+ *bSendPackets = true;
+ chat_stack::Say(". " + clear, true);
+ retrun = true;
+ lastfilter = format(filter);
+ lastname = format(name);
+ }
+ }
+ }
+ }
+ if (sendmsg.test_and_set(300000) &&
+ hacks::shared::antiaim::communicate)
+ chat_stack::Say("!!meow");
+ if (crypt_chat)
+ {
+ if (message.find("!!") == 0)
+ {
+ if (ucccccp::validate(message))
+ {
+ if (ucccccp::decrypt(message) == "meow" &&
+ hacks::shared::antiaim::communicate &&
+ data[0] != LOCAL_E->m_IDX &&
+ playerlist::AccessData(ENTITY(data[0])).state !=
+ playerlist::k_EState::CAT)
+ {
+ playerlist::AccessData(ENTITY(data[0])).state =
+ playerlist::k_EState::CAT;
+ chat_stack::Say("!!meow");
+ }
+ PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(),
+ ucccccp::decrypt(message).c_str());
+ }
+ }
+ }
+ chatlog::LogMessage(data[0], message);
+ buf = bf_read(data, s);
+ buf.Seek(0);
+ }
+ }
+ if (dispatch_log)
+ {
+ logging::Info("D> %i", type);
+ std::ostringstream str{};
+ while (buf.GetNumBytesLeft())
+ {
+ unsigned char byte = buf.ReadByte();
+ str << std::hex << std::setw(2) << std::setfill('0')
+ << static_cast(byte) << ' ';
+ }
+ logging::Info("MESSAGE %d, DATA = [ %s ]", type, str.str().c_str());
+ buf.Seek(0);
+ }
+ votelogger::user_message(buf, type);
+ return original::DispatchUserMessage(this_, type, buf);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/FireEvent.cpp b/src/hooks/FireEvent.cpp
new file mode 100644
index 00000000..73cf86e4
--- /dev/null
+++ b/src/hooks/FireEvent.cpp
@@ -0,0 +1,16 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(FireEvent, bool, IGameEventManager2 *this_,
+ IGameEvent *event, bool no_broadcast)
+{
+ return original::FireEvent(this_, event, no_broadcast);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/FireEventClientSide.cpp b/src/hooks/FireEventClientSide.cpp
new file mode 100644
index 00000000..e7646693
--- /dev/null
+++ b/src/hooks/FireEventClientSide.cpp
@@ -0,0 +1,16 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(FireEventClientSide, bool, IGameEventManager2 *this_,
+ IGameEvent *event)
+{
+ return original::FireEventClientSide(this_, event);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/FireGameEvent.cpp b/src/hooks/FireGameEvent.cpp
new file mode 100644
index 00000000..ffc5a916
--- /dev/null
+++ b/src/hooks/FireGameEvent.cpp
@@ -0,0 +1,29 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(FireGameEvent, void, void *this_, IGameEvent *event)
+{
+ const char *name = event->GetName();
+ if (name)
+ {
+ if (event_log)
+ {
+ if (!strcmp(name, "player_connect_client") ||
+ !strcmp(name, "player_disconnect") ||
+ !strcmp(name, "player_team"))
+ {
+ return;
+ }
+ }
+ // hacks::tf2::killstreak::fire_event(event);
+ }
+ original::FireGameEvent(this_, event);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/GetFriendPersonaName.cpp b/src/hooks/GetFriendPersonaName.cpp
new file mode 100644
index 00000000..baac83e3
--- /dev/null
+++ b/src/hooks/GetFriendPersonaName.cpp
@@ -0,0 +1,153 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+static CatVar ipc_name(CV_STRING, "name_ipc", "", "IPC Name");
+
+CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" });
+CatVar namesteal(namesteal_enum, "name_stealer", "0", "Name Stealer",
+ "Attemt to steal your teammates names. Usefull for avoiding "
+ "kicks\nPassive only changes when the name stolen is no "
+ "longer the best name to use\nActive Attemps to change the "
+ "name whenever possible");
+
+static std::string stolen_name;
+
+// Func to get a new entity to steal name from and returns true if a target has
+// been found
+bool StolenName()
+{
+
+ // Array to store potential namestealer targets with a bookkeeper to tell
+ // how full it is
+ int potential_targets[32];
+ int potential_targets_length = 0;
+
+ // Go through entities looking for potential targets
+ for (int i = 1; i < HIGHEST_ENTITY; i++)
+ {
+ CachedEntity *ent = ENTITY(i);
+
+ // Check if ent is a good target
+ if (!ent)
+ continue;
+ if (ent == LOCAL_E)
+ continue;
+ if (!ent->m_Type == ENTITY_PLAYER)
+ continue;
+ if (ent->m_bEnemy)
+ continue;
+
+ // Check if name is current one
+ player_info_s info;
+ if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info))
+ {
+
+ // If our name is the same as current, than change it
+ if (std::string(info.name) == stolen_name)
+ {
+ // Since we found the ent we stole our name from and it is still
+ // good, if user settings are passive, then we return true and
+ // dont alter our name
+ if ((int) namesteal == 1)
+ {
+ return true;
+ // Otherwise we continue to change our name to something
+ // else
+ }
+ else
+ continue;
+ }
+
+ // a ent without a name is no ent we need, contine for a different
+ // one
+ }
+ else
+ continue;
+
+ // Save the ent to our array
+ potential_targets[potential_targets_length] = i;
+ potential_targets_length++;
+
+ // With our maximum amount of players reached, dont search for anymore
+ if (potential_targets_length >= 32)
+ break;
+ }
+
+ // Checks to prevent crashes
+ if (potential_targets_length == 0)
+ return false;
+
+ // Get random number that we can use with our array
+ int target_random_num =
+ floor(RandFloatRange(0, potential_targets_length - 0.1F));
+
+ // Get a idx from our random array position
+ int new_target = potential_targets[target_random_num];
+
+ // Grab username of user
+ player_info_s info;
+ if (g_IEngine->GetPlayerInfo(new_target, &info))
+ {
+
+ // If our name is the same as current, than change it and return true
+ stolen_name = std::string(info.name);
+ return true;
+ }
+
+ // Didnt get playerinfo
+ return false;
+}
+
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *this_,
+ CSteamID steam_id)
+{
+#if ENABLE_IPC
+ if (ipc::peer)
+ {
+ static std::string namestr(ipc_name.GetString());
+ namestr.assign(ipc_name.GetString());
+ if (namestr.length() > 3)
+ {
+ ReplaceString(namestr, "%%", std::to_string(ipc::peer->client_id));
+ return namestr.c_str();
+ }
+ }
+#endif
+
+ // Check User settings if namesteal is allowed
+ if (namesteal && steam_id == g_ISteamUser->GetSteamID())
+ {
+
+ // We dont want to steal names while not in-game as there are no targets
+ // to steal from. We want to be on a team as well to get teammates names
+ if (g_IEngine->IsInGame() && g_pLocalPlayer->team)
+ {
+
+ // Check if we have a username to steal, func automaticly steals a
+ // name in it.
+ if (StolenName())
+ {
+
+ // Return the name that has changed from the func above
+ return format(stolen_name, "\x0F").c_str();
+ }
+ }
+ }
+
+ if ((strlen(force_name.GetString()) > 1) &&
+ steam_id == g_ISteamUser->GetSteamID())
+ {
+
+ return force_name_newlined;
+ }
+ return original::GetFriendPersonaName(this_, steam_id);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/GetUserCmd.cpp b/src/hooks/GetUserCmd.cpp
new file mode 100644
index 00000000..6f3b7642
--- /dev/null
+++ b/src/hooks/GetUserCmd.cpp
@@ -0,0 +1,42 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *this_, int sequence_number)
+{
+ CUserCmd *def = original::GetUserCmd(this_, sequence_number);
+ int oldcmd;
+ INetChannel *ch;
+
+ if (def == nullptr)
+ return def;
+
+ if (command_number_mod.find(def->command_number) !=
+ command_number_mod.end())
+ {
+ // logging::Info("Replacing command %i with %i", def->command_number,
+ // command_number_mod[def->command_number]);
+ oldcmd = def->command_number;
+ def->command_number = command_number_mod[def->command_number];
+ def->random_seed =
+ MD5_PseudoRandom(unsigned(def->command_number)) &
+ 0x7fffffff;
+ command_number_mod.erase(command_number_mod.find(oldcmd));
+ *(int *) ((unsigned) g_IBaseClientState +
+ offsets::lastoutgoingcommand()) = def->command_number - 1;
+ ch =
+ (INetChannel *) g_IEngine
+ ->GetNetChannelInfo(); //*(INetChannel**)((unsigned)g_IBaseClientState
+ //+ offsets::m_NetChannel());
+ *(int *) ((unsigned) ch + offsets::m_nOutSequenceNr()) =
+ def->command_number - 1;
+ }
+ return def;
+}
+}
\ No newline at end of file
diff --git a/src/hooks/LevelInit.cpp b/src/hooks/LevelInit.cpp
new file mode 100644
index 00000000..43de342f
--- /dev/null
+++ b/src/hooks/LevelInit.cpp
@@ -0,0 +1,125 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+
+
+const char *skynum[] = { "sky_tf2_04",
+ "sky_upward",
+ "sky_dustbowl_01",
+ "sky_goldrush_01",
+ "sky_granary_01",
+ "sky_well_01",
+ "sky_gravel_01",
+ "sky_badlands_01",
+ "sky_hydro_01",
+ "sky_night_01",
+ "sky_nightfall_01",
+ "sky_trainyard_01",
+ "sky_stormfront_01",
+ "sky_morningsnow_01",
+ "sky_alpinestorm_01",
+ "sky_harvest_01",
+ "sky_harvest_night_01",
+ "sky_halloween",
+ "sky_halloween_night_01",
+ "sky_halloween_night2014_01",
+ "sky_island_01",
+ "sky_jungle_01",
+ "sky_invasion2fort_01",
+ "sky_well_02",
+ "sky_outpost_01",
+ "sky_coastal_01",
+ "sky_rainbow_01",
+ "sky_badlands_pyroland_01",
+ "sky_pyroland_01",
+ "sky_pyroland_02",
+ "sky_pyroland_03" };
+CatEnum skys({ "sky_tf2_04",
+ "sky_upward",
+ "sky_dustbowl_01",
+ "sky_goldrush_01",
+ "sky_granary_01",
+ "sky_well_01",
+ "sky_gravel_01",
+ "sky_badlands_01",
+ "sky_hydro_01",
+ "sky_night_01",
+ "sky_nightfall_01",
+ "sky_trainyard_01",
+ "sky_stormfront_01",
+ "sky_morningsnow_01",
+ "sky_alpinestorm_01",
+ "sky_harvest_01",
+ "sky_harvest_night_01",
+ "sky_halloween",
+ "sky_halloween_night_01",
+ "sky_halloween_night2014_01",
+ "sky_island_01",
+ "sky_jungle_01",
+ "sky_invasion2fort_01",
+ "sky_well_02",
+ "sky_outpost_01",
+ "sky_coastal_01",
+ "sky_rainbow_01",
+ "sky_badlands_pyroland_01",
+ "sky_pyroland_01",
+ "sky_pyroland_02",
+ "sky_pyroland_03" });
+static CatVar
+ skybox_changer(skys, "skybox_changer", "0", "Change Skybox to this skybox",
+ "Change Skybox to this skybox, only changes on map load");
+static CatVar halloween_mode(CV_SWITCH, "halloween_mode", "0",
+ "Forced Halloween mode",
+ "forced tf_forced_holiday 2");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
+{
+ playerlist::Save();
+ votelogger::antikick_ticks = 0;
+ hacks::shared::lagexploit::bcalled = false;
+#if ENABLE_VISUALS
+ typedef bool *(*LoadNamedSkys_Fn)(const char *);
+ uintptr_t addr = gSignatures.GetEngineSignature(
+ "55 89 E5 57 31 FF 56 8D B5 ? ? ? ? 53 81 EC 6C 01 00 00");
+ static LoadNamedSkys_Fn LoadNamedSkys = LoadNamedSkys_Fn(addr);
+ bool succ;
+ logging::Info("Going to load the skybox");
+#ifdef __clang__
+ asm("movl %1, %%edi; push skynum[(int) skybox_changer]; call %%edi; mov "
+ "%%eax, %0; add %%esp, 4h"
+ : "=r"(succ)
+ : "r"(LoadNamedSkys));
+#else
+ succ = LoadNamedSkys(skynum[(int) skybox_changer]);
+#endif
+ logging::Info("Loaded Skybox: %s", succ ? "true" : "false");
+ ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday");
+
+ if (halloween_mode)
+ holiday->SetValue(2);
+ else if (holiday->m_nValue == 2)
+ holiday->SetValue(2);
+#endif
+
+ g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec");
+ hacks::shared::aimbot::Reset();
+ chat_stack::Reset();
+ hacks::shared::anticheat::ResetEverything();
+ original::LevelInit(this_, name);
+ hacks::shared::walkbot::OnLevelInit();
+#if ENABLE_IPC
+ if (ipc::peer)
+ {
+ ipc::peer->memory->peer_user_data[ipc::peer->client_id].ts_connected =
+ time(nullptr);
+ }
+#endif
+}
+}
\ No newline at end of file
diff --git a/src/hooks/LevelShutdown.cpp b/src/hooks/LevelShutdown.cpp
new file mode 100644
index 00000000..dacbc42b
--- /dev/null
+++ b/src/hooks/LevelShutdown.cpp
@@ -0,0 +1,28 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
+{
+ need_name_change = true;
+ playerlist::Save();
+ g_Settings.bInvalid = true;
+ hacks::shared::aimbot::Reset();
+ chat_stack::Reset();
+ hacks::shared::anticheat::ResetEverything();
+#if ENABLE_IPC
+ if (ipc::peer)
+ {
+ ipc::peer->memory->peer_user_data[ipc::peer->client_id]
+ .ts_disconnected = time(nullptr);
+ }
+#endif
+ return original::LevelShutdown(this_);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/Paint.cpp b/src/hooks/Paint.cpp
old mode 100755
new mode 100644
index 86b8729b..beb9d9b8
--- a/src/hooks/Paint.cpp
+++ b/src/hooks/Paint.cpp
@@ -12,11 +12,11 @@
static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1",
"Cursor fix");
-void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
+namespace hooked_methods
{
- static const Paint_t original = (Paint_t) hooks::enginevgui.GetMethod(
- offsets::PlatformOffset(14, offsets::undefined, offsets::undefined));
+DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode)
+{
if (!g_IEngine->IsInGame())
g_Settings.bInvalid = true;
@@ -61,7 +61,7 @@ void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
// logging::Info("executing %s",
// hack::command_stack().top().c_str());
g_IEngine->ClientCmd_Unrestricted(
- hack::command_stack().top().c_str());
+ hack::command_stack().top().c_str());
hack::command_stack().pop();
}
}
@@ -88,5 +88,6 @@ void Paint_hook(IEngineVGui *_this, PaintMode_t mode)
#endif
}
- original(_this, mode);
+ return original::Paint(this_, mode);
}
+}
\ No newline at end of file
diff --git a/src/hooks/SendNetMsg.cpp b/src/hooks/SendNetMsg.cpp
new file mode 100644
index 00000000..54ffaf05
--- /dev/null
+++ b/src/hooks/SendNetMsg.cpp
@@ -0,0 +1,106 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include
+#include
+#include "HookedMethods.hpp"
+
+static CatVar newlines_msg(CV_INT, "chat_newlines", "0", "Prefix newlines",
+ "Add # newlines before each your message", 0, 24);
+
+
+static CatVar log_sent(CV_SWITCH, "debug_log_sent_messages", "0",
+ "Log sent messages");
+static CatVar airstuck(CV_KEY, "airstuck", "0", "Airstuck", "");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &msg,
+ bool force_reliable, bool voice)
+{
+ size_t say_idx, say_team_idx;
+ int offset;
+ std::string newlines;
+ NET_StringCmd stringcmd;
+
+ // net_StringCmd
+ if (msg.GetType() == 4 && (newlines_msg || crypt_chat))
+ {
+ std::string str(msg.ToString());
+ say_idx = str.find("net_StringCmd: \"say \"");
+ say_team_idx = str.find("net_StringCmd: \"say_team \"");
+ if (!say_idx || !say_team_idx)
+ {
+ offset = say_idx ? 26 : 21;
+ bool crpt = false;
+ if (crypt_chat)
+ {
+ std::string msg(str.substr(offset));
+ msg = msg.substr(0, msg.length() - 2);
+ if (msg.find("!!") == 0)
+ {
+ msg = ucccccp::encrypt(msg.substr(2));
+ str = str.substr(0, offset) + msg + "\"\"";
+ crpt = true;
+ }
+ }
+ if (!crpt && newlines_msg)
+ {
+ // TODO move out? update in a value change callback?
+ newlines = std::string((int) newlines_msg, '\n');
+ str.insert(offset, newlines);
+ }
+ str = str.substr(16, str.length() - 17);
+ // if (queue_messages && !chat_stack::CanSend()) {
+ stringcmd.m_szCommand = str.c_str();
+ return original::SendNetMsg(this_, stringcmd, force_reliable, voice);
+ //}
+ }
+ }
+ static ConVar *sv_player_usercommand_timeout =
+ g_ICvar->FindVar("sv_player_usercommand_timeout");
+ static float lastcmd = 0.0f;
+ if (lastcmd > g_GlobalVars->absoluteframetime)
+ {
+ lastcmd = g_GlobalVars->absoluteframetime;
+ }
+ if (airstuck.KeyDown() && !g_Settings.bInvalid)
+ {
+ if (CE_GOOD(LOCAL_E))
+ {
+ if (lastcmd + sv_player_usercommand_timeout->GetFloat() - 0.1f <
+ g_GlobalVars->curtime)
+ {
+ if (msg.GetType() == clc_Move)
+ return false;
+ }
+ else
+ {
+ lastcmd = g_GlobalVars->absoluteframetime;
+ }
+ }
+ }
+ if (log_sent && msg.GetType() != 3 && msg.GetType() != 9)
+ {
+ logging::Info("=> %s [%i] %s", msg.GetName(), msg.GetType(),
+ msg.ToString());
+ unsigned char buf[4096];
+ bf_write buffer("cathook_debug_buffer", buf, 4096);
+ logging::Info("Writing %i", msg.WriteToBuffer(buffer));
+ std::string bytes = "";
+ constexpr char h2c[] = "0123456789abcdef";
+ for (int i = 0; i < buffer.GetNumBytesWritten(); i++)
+ {
+ // bytes += format(h2c[(buf[i] & 0xF0) >> 4], h2c[(buf[i] & 0xF)], '
+ // ');
+ bytes += format((unsigned short) buf[i], ' ');
+ }
+ logging::Info("%i bytes => %s", buffer.GetNumBytesWritten(),
+ bytes.c_str());
+ }
+ return original::SendNetMsg(this_, msg, force_reliable, voice);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/Shutdown.cpp b/src/hooks/Shutdown.cpp
new file mode 100644
index 00000000..6e88f445
--- /dev/null
+++ b/src/hooks/Shutdown.cpp
@@ -0,0 +1,44 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+static CatVar die_if_vac(CV_SWITCH, "die_if_vac", "0", "Die if VAC banned");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
+{
+ g_Settings.bInvalid = true;
+ // This is a INetChannel hook - it SHOULDN'T be static because netchannel
+ // changes.
+ logging::Info("Disconnect: %s", reason);
+ if (strstr(reason, "banned"))
+ {
+ if (die_if_vac)
+ {
+ logging::Info("VAC banned");
+ *(int *) 0 = 0;
+ exit(1);
+ }
+ }
+#if ENABLE_IPC
+ ipc::UpdateServerAddress(true);
+#endif
+ if (cathook && (disconnect_reason.convar_parent->m_StringLength > 3) &&
+ strstr(reason, "user"))
+ {
+ original::Shutdown(this_, disconnect_reason_newlined);
+ }
+ else
+ {
+ original::Shutdown(this_, reason);
+ }
+
+ if (hacks::shared::autojoin::auto_queue)
+ tfmm::queue_start();
+}
+}
\ No newline at end of file
diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp
index 0e11dee4..8952533c 100644
--- a/src/hooks/others.cpp
+++ b/src/hooks/others.cpp
@@ -12,12 +12,10 @@
#include "chatlog.hpp"
#include "netmessage.hpp"
#include
+#include
#if ENABLE_VISUALS
-static CatVar medal_flip(CV_SWITCH, "medal_flip", "0", "Infinite Medal Flip",
- "");
-
// This hook isn't used yet!
/*int C_TFPlayer__DrawModel_hook(IClientEntity *_this, int flags)
{
@@ -33,97 +31,10 @@ static CatVar medal_flip(CV_SWITCH, "medal_flip", "0", "Infinite Medal Flip",
*(float *) ((uintptr_t) _this + 79u) = old_invis;
}*/
-static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms",
- "Removes arms from first person");
-static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats",
- "Removes non-stock hats");
+
float last_say = 0.0f;
-void DrawModelExecute_hook(IVModelRender *_this, const DrawModelState_t &state,
- const ModelRenderInfo_t &info, matrix3x4_t *matrix)
-{
- static const DrawModelExecute_t original =
- (DrawModelExecute_t) hooks::modelrender.GetMethod(
- offsets::DrawModelExecute());
- static const char *name;
- static std::string sname;
- static IClientUnknown *unk;
- static IClientEntity *ent;
- if (!cathook ||
- !(spectator_target || no_arms || no_hats ||
- (clean_screenshots && g_IEngine->IsTakingScreenshot())))
- {
- original(_this, state, info, matrix);
- return;
- }
- PROF_SECTION(DrawModelExecute);
-
- if (no_arms || no_hats)
- {
- if (info.pModel)
- {
- name = g_IModelInfo->GetModelName(info.pModel);
- if (name)
- {
- sname = name;
- if (no_arms && sname.find("arms") != std::string::npos)
- {
- return;
- }
- else if (no_hats &&
- sname.find("player/items") != std::string::npos)
- {
- return;
- }
- }
- }
- }
-
- unk = info.pRenderable->GetIClientUnknown();
- if (unk)
- {
- ent = unk->GetIClientEntity();
- if (ent)
- {
- if (ent->entindex() == spectator_target)
- {
- return;
- }
- }
- if (ent && !effect_chams::g_EffectChams.drawing &&
- effect_chams::g_EffectChams.ShouldRenderChams(ent))
- {
- return;
- }
- }
-
- original(_this, state, info, matrix);
-}
-
-int IN_KeyEvent_hook(void *_this, int eventcode, int keynum,
- const char *pszCurrentBinding)
-{
- static const IN_KeyEvent_t original =
- (IN_KeyEvent_t) hooks::client.GetMethod(offsets::IN_KeyEvent());
-#if ENABLE_GUI
-/*
-if (g_pGUI->ConsumesKey((ButtonCode_t)keynum) && g_pGUI->Visible()) {
- return 0;
-}
-*/
-#endif
- return original(_this, eventcode, keynum, pszCurrentBinding);
-}
-
-CatVar override_fov_zoomed(CV_FLOAT, "fov_zoomed", "0", "FOV override (zoomed)",
- "Overrides FOV with this value when zoomed in "
- "(default FOV when zoomed is 20)");
-CatVar override_fov(CV_FLOAT, "fov", "0", "FOV override",
- "Overrides FOV with this value");
-
-CatVar freecam(CV_KEY, "debug_freecam", "0", "Freecam");
-int spectator_target{ 0 };
CatCommand spectate("spectate", "Spectate", [](const CCommand &args) {
if (args.ArgC() < 1)
@@ -140,124 +51,8 @@ CatCommand spectate("spectate", "Spectate", [](const CCommand &args) {
}
});
-void OverrideView_hook(void *_this, CViewSetup *setup)
-{
- static const OverrideView_t original =
- (OverrideView_t) hooks::clientmode.GetMethod(offsets::OverrideView());
- static bool zoomed;
- original(_this, setup);
- if (!cathook)
- return;
- if (g_pLocalPlayer->bZoomed && override_fov_zoomed)
- {
- setup->fov = override_fov_zoomed;
- }
- else
- {
- if (override_fov)
- {
- setup->fov = override_fov;
- }
- }
-
- if (spectator_target)
- {
- CachedEntity *spec = ENTITY(spectator_target);
- if (CE_GOOD(spec) && !CE_BYTE(spec, netvar.iLifeState))
- {
- setup->origin =
- spec->m_vecOrigin + CE_VECTOR(spec, netvar.vViewOffset);
- // why not spectate yourself
- if (spec == LOCAL_E)
- {
- setup->angles =
- CE_VAR(spec, netvar.m_angEyeAnglesLocal, QAngle);
- }
- else
- {
- setup->angles = CE_VAR(spec, netvar.m_angEyeAngles, QAngle);
- }
- }
- if (g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_SPACE))
- {
- spectator_target = 0;
- }
- }
-
- if (freecam)
- {
- static Vector freecam_origin{ 0 };
- static bool freecam_last{ false };
- if (freecam.KeyDown())
- {
- if (not freecam_last)
- {
- freecam_origin = setup->origin;
- }
- float sp, sy, cp, cy;
- QAngle angle;
- Vector forward;
- g_IEngine->GetViewAngles(angle);
- sy = sinf(DEG2RAD(angle[1]));
- cy = cosf(DEG2RAD(angle[1]));
- sp = sinf(DEG2RAD(angle[0]));
- cp = cosf(DEG2RAD(angle[0]));
- forward.x = cp * cy;
- forward.y = cp * sy;
- forward.z = -sp;
- forward *= 4;
- freecam_origin += forward;
- setup->origin = freecam_origin;
- }
- freecam_last = freecam.KeyDown();
- }
-
- draw::fov = setup->fov;
-}
-
#endif
-bool CanPacket_hook(void *_this)
-{
- const CanPacket_t original =
- (CanPacket_t) hooks::netchannel.GetMethod(offsets::CanPacket());
- return *bSendPackets && original(_this);
-}
-
-CUserCmd *GetUserCmd_hook(IInput *_this, int sequence_number)
-{
- static const GetUserCmd_t original =
- (GetUserCmd_t) hooks::input.GetMethod(offsets::GetUserCmd());
- static CUserCmd *def;
- static int oldcmd;
- static INetChannel *ch;
-
- def = original(_this, sequence_number);
- if (def &&
- command_number_mod.find(def->command_number) !=
- command_number_mod.end())
- {
- // logging::Info("Replacing command %i with %i", def->command_number,
- // command_number_mod[def->command_number]);
- oldcmd = def->command_number;
- def->command_number = command_number_mod[def->command_number];
- def->random_seed =
- MD5_PseudoRandom(unsigned(def->command_number)) & 0x7fffffff;
- command_number_mod.erase(command_number_mod.find(oldcmd));
- *(int *) ((unsigned) g_IBaseClientState +
- offsets::lastoutgoingcommand()) = def->command_number - 1;
- ch =
- (INetChannel *) g_IEngine
- ->GetNetChannelInfo(); //*(INetChannel**)((unsigned)g_IBaseClientState
- //+ offsets::m_NetChannel());
- *(int *) ((unsigned) ch + offsets::m_nOutSequenceNr()) =
- def->command_number - 1;
- }
- return def;
-}
-
-static CatVar log_sent(CV_SWITCH, "debug_log_sent_messages", "0",
- "Log sent messages");
static CatCommand plus_use_action_slot_item_server(
"+cat_use_action_slot_item_server", "use_action_slot_item_server", []() {
@@ -273,843 +68,17 @@ static CatCommand minus_use_action_slot_item_server(
g_IEngine->ServerCmdKeyValues(kv);
});
-static CatVar newlines_msg(CV_INT, "chat_newlines", "0", "Prefix newlines",
- "Add # newlines before each your message", 0, 24);
// TODO replace \\n with \n
// TODO name \\n = \n
// static CatVar queue_messages(CV_SWITCH, "chat_queue", "0", "Queue messages",
// "Use this if you want to use spam/killsay and still be able to chat normally
// (without having your msgs eaten by valve cooldown)");
-static CatVar airstuck(CV_KEY, "airstuck", "0", "Airstuck", "");
-static CatVar crypt_chat(
- CV_SWITCH, "chat_crypto", "1", "Crypto chat",
- "Start message with !! and it will be only visible to cathook users");
-static CatVar chat_filter(CV_STRING, "chat_censor", "", "Censor words",
- "Spam Chat with newlines if the chosen words are "
- "said, seperate with commas");
-static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0",
- "Enable censor", "Censor Words in chat");
static CatVar server_crash_key(CV_KEY, "crash_server", "0", "Server crash key",
"hold key and wait...");
-bool SendNetMsg_hook(void *_this, INetMessage &msg, bool bForceReliable = false,
- bool bVoice = false)
-{
- static size_t say_idx, say_team_idx;
- static int offset;
- static std::string newlines;
- static NET_StringCmd stringcmd;
- // This is a INetChannel hook - it SHOULDN'T be static because netchannel
- // changes.
- const SendNetMsg_t original =
- (SendNetMsg_t) hooks::netchannel.GetMethod(offsets::SendNetMsg());
- // net_StringCmd
- if (msg.GetType() == 4 && (newlines_msg || crypt_chat))
- {
- std::string str(msg.ToString());
- say_idx = str.find("net_StringCmd: \"say \"");
- say_team_idx = str.find("net_StringCmd: \"say_team \"");
- if (!say_idx || !say_team_idx)
- {
- offset = say_idx ? 26 : 21;
- bool crpt = false;
- if (crypt_chat)
- {
- std::string msg(str.substr(offset));
- msg = msg.substr(0, msg.length() - 2);
- if (msg.find("!!") == 0)
- {
- msg = ucccccp::encrypt(msg.substr(2));
- str = str.substr(0, offset) + msg + "\"\"";
- crpt = true;
- }
- }
- if (!crpt && newlines_msg)
- {
- // TODO move out? update in a value change callback?
- newlines = std::string((int) newlines_msg, '\n');
- str.insert(offset, newlines);
- }
- str = str.substr(16, str.length() - 17);
- // if (queue_messages && !chat_stack::CanSend()) {
- stringcmd.m_szCommand = str.c_str();
- return original(_this, stringcmd, bForceReliable, bVoice);
- //}
- }
- }
- static ConVar *sv_player_usercommand_timeout =
- g_ICvar->FindVar("sv_player_usercommand_timeout");
- static float lastcmd = 0.0f;
- if (lastcmd > g_GlobalVars->absoluteframetime)
- {
- lastcmd = g_GlobalVars->absoluteframetime;
- }
- if (airstuck.KeyDown() && !g_Settings.bInvalid)
- {
- if (CE_GOOD(LOCAL_E))
- {
- if (lastcmd + sv_player_usercommand_timeout->GetFloat() - 0.1f <
- g_GlobalVars->curtime)
- {
- if (msg.GetType() == clc_Move)
- return false;
- }
- else
- {
- lastcmd = g_GlobalVars->absoluteframetime;
- }
- }
- }
- if (log_sent && msg.GetType() != 3 && msg.GetType() != 9)
- {
- logging::Info("=> %s [%i] %s", msg.GetName(), msg.GetType(),
- msg.ToString());
- unsigned char buf[4096];
- bf_write buffer("cathook_debug_buffer", buf, 4096);
- logging::Info("Writing %i", msg.WriteToBuffer(buffer));
- std::string bytes = "";
- constexpr char h2c[] = "0123456789abcdef";
- for (int i = 0; i < buffer.GetNumBytesWritten(); i++)
- {
- // bytes += format(h2c[(buf[i] & 0xF0) >> 4], h2c[(buf[i] & 0xF)], '
- // ');
- bytes += format((unsigned short) buf[i], ' ');
- }
- logging::Info("%i bytes => %s", buffer.GetNumBytesWritten(),
- bytes.c_str());
- }
- return original(_this, msg, bForceReliable, bVoice);
-}
-static CatVar die_if_vac(CV_SWITCH, "die_if_vac", "0", "Die if VAC banned");
-void Shutdown_hook(void *_this, const char *reason)
-{
- g_Settings.bInvalid = true;
- // This is a INetChannel hook - it SHOULDN'T be static because netchannel
- // changes.
- const Shutdown_t original =
- (Shutdown_t) hooks::netchannel.GetMethod(offsets::Shutdown());
- logging::Info("Disconnect: %s", reason);
- if (strstr(reason, "banned"))
- {
- if (die_if_vac)
- {
- logging::Info("VAC banned");
- *(int *) 0 = 0;
- exit(1);
- }
- }
-#if ENABLE_IPC
- ipc::UpdateServerAddress(true);
-#endif
- if (cathook && (disconnect_reason.convar_parent->m_StringLength > 3) &&
- strstr(reason, "user"))
- {
- original(_this, disconnect_reason_newlined);
- }
- else
- {
- original(_this, reason);
- }
- if (hacks::shared::autojoin::auto_queue)
- tfmm::queue_start();
-}
-static CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles");
-CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" });
-CatVar namesteal(namesteal_enum, "name_stealer", "0", "Name Stealer",
- "Attemt to steal your teammates names. Usefull for avoiding "
- "kicks\nPassive only changes when the name stolen is no "
- "longer the best name to use\nActive Attemps to change the "
- "name whenever possible");
-
-static std::string stolen_name;
-
-// Func to get a new entity to steal name from and returns true if a target has
-// been found
-bool StolenName()
-{
-
- // Array to store potential namestealer targets with a bookkeeper to tell
- // how full it is
- int potential_targets[32];
- int potential_targets_length = 0;
-
- // Go through entities looking for potential targets
- for (int i = 1; i < HIGHEST_ENTITY; i++)
- {
- CachedEntity *ent = ENTITY(i);
-
- // Check if ent is a good target
- if (!ent)
- continue;
- if (ent == LOCAL_E)
- continue;
- if (!ent->m_Type == ENTITY_PLAYER)
- continue;
- if (ent->m_bEnemy)
- continue;
-
- // Check if name is current one
- player_info_s info;
- if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info))
- {
-
- // If our name is the same as current, than change it
- if (std::string(info.name) == stolen_name)
- {
- // Since we found the ent we stole our name from and it is still
- // good, if user settings are passive, then we return true and
- // dont alter our name
- if ((int) namesteal == 1)
- {
- return true;
- // Otherwise we continue to change our name to something
- // else
- }
- else
- continue;
- }
-
- // a ent without a name is no ent we need, contine for a different
- // one
- }
- else
- continue;
-
- // Save the ent to our array
- potential_targets[potential_targets_length] = i;
- potential_targets_length++;
-
- // With our maximum amount of players reached, dont search for anymore
- if (potential_targets_length >= 32)
- break;
- }
-
- // Checks to prevent crashes
- if (potential_targets_length == 0)
- return false;
-
- // Get random number that we can use with our array
- int target_random_num =
- floor(RandFloatRange(0, potential_targets_length - 0.1F));
-
- // Get a idx from our random array position
- int new_target = potential_targets[target_random_num];
-
- // Grab username of user
- player_info_s info;
- if (g_IEngine->GetPlayerInfo(new_target, &info))
- {
-
- // If our name is the same as current, than change it and return true
- stolen_name = std::string(info.name);
- return true;
- }
-
- // Didnt get playerinfo
- return false;
-}
-
-static CatVar ipc_name(CV_STRING, "name_ipc", "", "IPC Name");
-
-const char *GetFriendPersonaName_hook(ISteamFriends *_this, CSteamID steamID)
-{
- static const GetFriendPersonaName_t original =
- (GetFriendPersonaName_t) hooks::steamfriends.GetMethod(
- offsets::GetFriendPersonaName());
-
-#if ENABLE_IPC
- if (ipc::peer)
- {
- static std::string namestr(ipc_name.GetString());
- namestr.assign(ipc_name.GetString());
- if (namestr.length() > 3)
- {
- ReplaceString(namestr, "%%", std::to_string(ipc::peer->client_id));
- return namestr.c_str();
- }
- }
-#endif
-
- // Check User settings if namesteal is allowed
- if (namesteal && steamID == g_ISteamUser->GetSteamID())
- {
-
- // We dont want to steal names while not in-game as there are no targets
- // to steal from. We want to be on a team as well to get teammates names
- if (g_IEngine->IsInGame() && g_pLocalPlayer->team)
- {
-
- // Check if we have a username to steal, func automaticly steals a
- // name in it.
- if (StolenName())
- {
-
- // Return the name that has changed from the func above
- return format(stolen_name, "\x0F").c_str();
- }
- }
- }
-
- if ((strlen(force_name.GetString()) > 1) &&
- steamID == g_ISteamUser->GetSteamID())
- {
-
- return force_name_newlined;
- }
- return original(_this, steamID);
-}
-
-void FireGameEvent_hook(void *_this, IGameEvent *event)
-{
- static const FireGameEvent_t original =
- (FireGameEvent_t) hooks::clientmode4.GetMethod(
- offsets::FireGameEvent());
- const char *name = event->GetName();
- if (name)
- {
- if (event_log)
- {
- if (!strcmp(name, "player_connect_client") ||
- !strcmp(name, "player_disconnect") ||
- !strcmp(name, "player_team"))
- {
- return;
- }
- }
- // hacks::tf2::killstreak::fire_event(event);
- }
- original(_this, event);
-}
-CatVar nightmode(CV_SWITCH, "nightmode", "0", "Enable nightmode", "");
-#if ENABLE_VISUALS
-void FrameStageNotify_hook(void *_this, int stage)
-{
- if (nightmode)
- {
- static int OldNightmode = 0;
- if (OldNightmode != (int) nightmode)
- {
-
- static ConVar *r_DrawSpecificStaticProp =
- g_ICvar->FindVar("r_DrawSpecificStaticProp");
- if (!r_DrawSpecificStaticProp)
- {
- r_DrawSpecificStaticProp =
- g_ICvar->FindVar("r_DrawSpecificStaticProp");
- return;
- }
- r_DrawSpecificStaticProp->SetValue(0);
-
- for (MaterialHandle_t i = g_IMaterialSystem->FirstMaterial();
- i != g_IMaterialSystem->InvalidMaterial();
- i = g_IMaterialSystem->NextMaterial(i))
- {
- IMaterial *pMaterial = g_IMaterialSystem->GetMaterial(i);
-
- if (!pMaterial)
- continue;
- if (strstr(pMaterial->GetTextureGroupName(), "World") ||
- strstr(pMaterial->GetTextureGroupName(), "StaticProp"))
- {
- if (nightmode)
- if (strstr(pMaterial->GetTextureGroupName(),
- "StaticProp"))
- pMaterial->ColorModulate(0.3f, 0.3f, 0.3f);
- else
- pMaterial->ColorModulate(0.05f, 0.05f, 0.05f);
- else
- pMaterial->ColorModulate(1.0f, 1.0f, 1.0f);
- }
- }
- OldNightmode = nightmode;
- }
- }
- static IClientEntity *ent;
-
- PROF_SECTION(FrameStageNotify_TOTAL);
-
- static const FrameStageNotify_t original =
- (FrameStageNotify_t) hooks::client.GetMethod(
- offsets::FrameStageNotify());
-
- if (!g_IEngine->IsInGame())
- g_Settings.bInvalid = true;
- {
- PROF_SECTION(FSN_skinchanger);
- hacks::tf2::skinchanger::FrameStageNotify(stage);
- }
- if (resolver && cathook && !g_Settings.bInvalid &&
- stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
- {
- PROF_SECTION(FSN_resolver);
- for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++)
- {
- if (i == g_IEngine->GetLocalPlayer())
- continue;
- ent = g_IEntityList->GetClientEntity(i);
- if (ent && !ent->IsDormant() && !NET_BYTE(ent, netvar.iLifeState))
- {
- Vector &angles = NET_VECTOR(ent, netvar.m_angEyeAngles);
- if (angles.x >= 90)
- angles.x = -89;
- if (angles.x <= -90)
- angles.x = 89;
- angles.y = fmod(angles.y + 180.0f, 360.0f);
- if (angles.y < 0)
- angles.y += 360.0f;
- angles.y -= 180.0f;
- }
- }
- }
- if (cathook && stage == FRAME_RENDER_START)
- {
- INetChannel *ch;
- ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
- if (ch && !hooks::IsHooked((void *) ch))
- {
- hooks::netchannel.Set(ch);
- hooks::netchannel.HookMethod((void *) CanPacket_hook,
- offsets::CanPacket());
- hooks::netchannel.HookMethod((void *) SendNetMsg_hook,
- offsets::SendNetMsg());
- hooks::netchannel.HookMethod((void *) Shutdown_hook,
- offsets::Shutdown());
- hooks::netchannel.Apply();
-#if ENABLE_IPC
- ipc::UpdateServerAddress();
-#endif
- }
- }
- if (cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START)
- {
- IF_GAME(IsTF())
- {
- if (CE_GOOD(LOCAL_E) && no_zoom)
- RemoveCondition(LOCAL_E);
- }
- if (force_thirdperson && !g_pLocalPlayer->life_state &&
- CE_GOOD(g_pLocalPlayer->entity))
- {
- CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
- }
- if (stage == 5 && show_antiaim && g_IInput->CAM_IsThirdPerson())
- {
- if (CE_GOOD(g_pLocalPlayer->entity))
- {
- CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) =
- g_Settings.last_angles.x;
- CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) =
- g_Settings.last_angles.y;
- }
- }
- }
- original(_this, stage);
-}
-#endif /* TEXTMODE */
-
-static CatVar clean_chat(CV_SWITCH, "clean_chat", "0", "Clean chat",
- "Removes newlines from chat");
-static CatVar dispatch_log(CV_SWITCH, "debug_log_usermessages", "0",
- "Log dispatched user messages");
-std::string clear = "";
-std::string lastfilter{};
-std::string lastname{};
-static bool retrun = false;
-
-static Timer sendmsg{};
-static Timer gitgud{};
-
-bool DispatchUserMessage_hook(void *_this, int type, bf_read &buf)
-{
- if (retrun && gitgud.test_and_set(10000))
- {
- PrintChat("\x07%06X%s\x01: %s", 0xe05938, lastname.c_str(),
- lastfilter.c_str());
- retrun = false;
- }
- int loop_index, s, i, j;
- char *data, c;
-
- static const DispatchUserMessage_t original =
- (DispatchUserMessage_t) hooks::client.GetMethod(
- offsets::DispatchUserMessage());
- if (type == 4)
- {
- loop_index = 0;
- s = buf.GetNumBytesLeft();
- if (s < 256)
- {
- data = (char *) alloca(s);
- for (i = 0; i < s; i++)
- data[i] = buf.ReadByte();
- j = 0;
- std::string name;
- std::string message;
- for (i = 0; i < 3; i++)
- {
- while ((c = data[j++]) && (loop_index < 128))
- {
- loop_index++;
- if (clean_chat)
- if ((c == '\n' || c == '\r') && (i == 1 || i == 2))
- data[j - 1] = '*';
- if (i == 1)
- name.push_back(c);
- if (i == 2)
- message.push_back(c);
- }
- }
- if (chat_filter_enabled && data[0] != LOCAL_E->m_IDX)
- {
- if (!strcmp(chat_filter.GetString(), ""))
- {
- std::string tmp = {};
- std::string tmp2 = {};
- int iii = 0;
- player_info_s info;
- g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info);
- std::string name1 = info.name;
- std::vector name2{};
- std::vector name3{};
- std::string claz = {};
- switch (g_pLocalPlayer->clazz)
- {
- case tf_scout:
- claz = "scout";
- break;
- case tf_soldier:
- claz = "soldier";
- break;
- case tf_pyro:
- claz = "pyro";
- break;
- case tf_demoman:
- claz = "demo";
- break;
- case tf_engineer:
- claz = "engi";
- break;
- case tf_heavy:
- claz = "heavy";
- break;
- case tf_medic:
- claz = "med";
- break;
- case tf_sniper:
- claz = "sniper";
- break;
- case tf_spy:
- claz = "spy";
- break;
- default:
- break;
- }
- for (char i : name1)
- {
- if (iii == 2)
- {
- iii = 0;
- tmp += i;
- name2.push_back(tmp);
- tmp = "";
- }
- else if (iii < 2)
- {
- iii++;
- tmp += i;
- }
- }
- iii = 0;
- for (char i : name1)
- {
- if (iii == 3)
- {
- iii = 0;
- tmp += i;
- name3.push_back(tmp2);
- tmp2 = "";
- }
- else if (iii < 3)
- {
- iii++;
- tmp2 += i;
- }
- }
- if (tmp.size() > 2)
- name2.push_back(tmp);
- if (tmp2.size() > 2)
- name3.push_back(tmp2);
- iii = 0;
- std::vector res = {
- "skid", "script", "cheat", "hak", "hac", "f1",
- "hax", "vac", "ban", "lmao", "bot", "report",
- "cat", "insta", "revv", "brass", "kick", claz
- };
- for (auto i : name2)
- {
- boost::to_lower(i);
- res.push_back(i);
- }
- for (auto i : name3)
- {
- boost::to_lower(i);
- res.push_back(i);
- }
- std::string message2 = message;
- boost::to_lower(message2);
- boost::replace_all(message2, "4", "a");
- boost::replace_all(message2, "3", "e");
- boost::replace_all(message2, "0", "o");
- boost::replace_all(message2, "6", "g");
- boost::replace_all(message2, "5", "s");
- boost::replace_all(message2, "7", "t");
- for (auto filter : res)
- {
- if (retrun)
- break;
- if (boost::contains(message2, filter))
- {
-
- if (clear == "")
- {
- for (int i = 0; i < 120; i++)
- clear += "\n";
- }
- *bSendPackets = true;
- chat_stack::Say(". " + clear, true);
- retrun = true;
- lastfilter = format(filter);
- lastname = format(name);
- }
- }
- }
- else if (data[0] != LOCAL_E->m_IDX)
- {
- std::string input = chat_filter.GetString();
- boost::to_lower(input);
- std::string message2 = message;
- std::vector result{};
- boost::split(result, input, boost::is_any_of(","));
- boost::replace_all(message2, "4", "a");
- boost::replace_all(message2, "3", "e");
- boost::replace_all(message2, "0", "o");
- boost::replace_all(message2, "6", "g");
- boost::replace_all(message2, "5", "s");
- boost::replace_all(message2, "7", "t");
- for (auto filter : result)
- {
- if (retrun)
- break;
- if (boost::contains(message2, filter))
- {
- if (clear == "")
- {
- clear = "";
- for (int i = 0; i < 120; i++)
- clear += "\n";
- }
- *bSendPackets = true;
- chat_stack::Say(". " + clear, true);
- retrun = true;
- lastfilter = format(filter);
- lastname = format(name);
- }
- }
- }
- }
- if (sendmsg.test_and_set(300000) &&
- hacks::shared::antiaim::communicate)
- chat_stack::Say("!!meow");
- if (crypt_chat)
- {
- if (message.find("!!") == 0)
- {
- if (ucccccp::validate(message))
- {
- if (ucccccp::decrypt(message) == "meow" &&
- hacks::shared::antiaim::communicate &&
- data[0] != LOCAL_E->m_IDX &&
- playerlist::AccessData(ENTITY(data[0])).state !=
- playerlist::k_EState::CAT)
- {
- playerlist::AccessData(ENTITY(data[0])).state =
- playerlist::k_EState::CAT;
- chat_stack::Say("!!meow");
- }
- PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(),
- ucccccp::decrypt(message).c_str());
- }
- }
- }
- chatlog::LogMessage(data[0], message);
- buf = bf_read(data, s);
- buf.Seek(0);
- }
- }
- if (dispatch_log)
- {
- logging::Info("D> %i", type);
- std::ostringstream str{};
- while (buf.GetNumBytesLeft())
- {
- unsigned char byte = buf.ReadByte();
- str << std::hex << std::setw(2) << std::setfill('0')
- << static_cast(byte) << ' ';
- }
- logging::Info("MESSAGE %d, DATA = [ %s ]", type, str.str().c_str());
- buf.Seek(0);
- }
- votelogger::user_message(buf, type);
- return original(_this, type, buf);
-}
-const char *skynum[] = { "sky_tf2_04",
- "sky_upward",
- "sky_dustbowl_01",
- "sky_goldrush_01",
- "sky_granary_01",
- "sky_well_01",
- "sky_gravel_01",
- "sky_badlands_01",
- "sky_hydro_01",
- "sky_night_01",
- "sky_nightfall_01",
- "sky_trainyard_01",
- "sky_stormfront_01",
- "sky_morningsnow_01",
- "sky_alpinestorm_01",
- "sky_harvest_01",
- "sky_harvest_night_01",
- "sky_halloween",
- "sky_halloween_night_01",
- "sky_halloween_night2014_01",
- "sky_island_01",
- "sky_jungle_01",
- "sky_invasion2fort_01",
- "sky_well_02",
- "sky_outpost_01",
- "sky_coastal_01",
- "sky_rainbow_01",
- "sky_badlands_pyroland_01",
- "sky_pyroland_01",
- "sky_pyroland_02",
- "sky_pyroland_03" };
-CatEnum skys({ "sky_tf2_04",
- "sky_upward",
- "sky_dustbowl_01",
- "sky_goldrush_01",
- "sky_granary_01",
- "sky_well_01",
- "sky_gravel_01",
- "sky_badlands_01",
- "sky_hydro_01",
- "sky_night_01",
- "sky_nightfall_01",
- "sky_trainyard_01",
- "sky_stormfront_01",
- "sky_morningsnow_01",
- "sky_alpinestorm_01",
- "sky_harvest_01",
- "sky_harvest_night_01",
- "sky_halloween",
- "sky_halloween_night_01",
- "sky_halloween_night2014_01",
- "sky_island_01",
- "sky_jungle_01",
- "sky_invasion2fort_01",
- "sky_well_02",
- "sky_outpost_01",
- "sky_coastal_01",
- "sky_rainbow_01",
- "sky_badlands_pyroland_01",
- "sky_pyroland_01",
- "sky_pyroland_02",
- "sky_pyroland_03" });
-static CatVar
- skybox_changer(skys, "skybox_changer", "0", "Change Skybox to this skybox",
- "Change Skybox to this skybox, only changes on map load");
-static CatVar halloween_mode(CV_SWITCH, "halloween_mode", "0",
- "Forced Halloween mode",
- "forced tf_forced_holiday 2");
-void LevelInit_hook(void *_this, const char *newmap)
-{
- static const LevelInit_t original =
- (LevelInit_t) hooks::clientmode.GetMethod(offsets::LevelInit());
- playerlist::Save();
- votelogger::antikick_ticks = 0;
- hacks::shared::lagexploit::bcalled = false;
-#if ENABLE_VISUALS
- typedef bool *(*LoadNamedSkys_Fn)(const char *);
- uintptr_t addr =
- gSignatures.GetEngineSignature("55 89 E5 57 31 FF 56 8D B5 ? ? ? ? 53 81 EC 6C 01 00 00");
- static LoadNamedSkys_Fn LoadNamedSkys = LoadNamedSkys_Fn(addr);
- bool succ;
- logging::Info("Going to load the skybox");
-#ifdef __clang__
- asm("movl %1, %%edi; push skynum[(int) skybox_changer]; call %%edi; mov "
- "%%eax, %0; add %%esp, 4h"
- : "=r"(succ)
- : "r"(LoadNamedSkys));
-#else
- succ = LoadNamedSkys(skynum[(int) skybox_changer]);
-#endif
- logging::Info("Loaded Skybox: %s", succ ? "true" : "false");
- ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday");
-
- if (halloween_mode)
- holiday->SetValue(2);
- else if (holiday->m_nValue == 2)
- holiday->SetValue(2);
-#endif
-
- g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec");
- hacks::shared::aimbot::Reset();
- chat_stack::Reset();
- hacks::shared::anticheat::ResetEverything();
- original(_this, newmap);
- hacks::shared::walkbot::OnLevelInit();
-#if ENABLE_IPC
- if (ipc::peer)
- {
- ipc::peer->memory->peer_user_data[ipc::peer->client_id].ts_connected =
- time(nullptr);
- }
-#endif
-}
-
-void LevelShutdown_hook(void *_this)
-{
- static const LevelShutdown_t original =
- LevelShutdown_t(hooks::clientmode.GetMethod(offsets::LevelShutdown()));
- need_name_change = true;
- playerlist::Save();
- g_Settings.bInvalid = true;
- hacks::shared::aimbot::Reset();
- chat_stack::Reset();
- hacks::shared::anticheat::ResetEverything();
- original(_this);
-#if ENABLE_IPC
- if (ipc::peer)
- {
- ipc::peer->memory->peer_user_data[ipc::peer->client_id]
- .ts_disconnected = time(nullptr);
- }
-#endif
-}
-#if ENABLE_VISUALS
-int RandomInt_hook(void *_this, int iMinVal, int iMaxVal)
-{
- static const RandomInt_t original =
- RandomInt_t(hooks::vstd.GetMethod(offsets::RandomInt()));
-
- if (medal_flip && iMinVal == 0 && iMaxVal == 9)
- return 0;
-
- return original(_this, iMinVal, iMaxVal);
-}
-#endif
diff --git a/src/hooks/sdl.cpp b/src/hooks/sdl.cpp
deleted file mode 100755
index 092e7ec6..00000000
--- a/src/hooks/sdl.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * sdl.cpp
- *
- * Created on: May 19, 2017
- * Author: nullifiedcat
- */
-
-#include "common.hpp"
-
-#include "hooks/hookedmethods.hpp"
-#include "hack.hpp"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-SDL_Window *sdl_current_window{ nullptr };
-SDL_GL_SwapWindow_t *SDL_GL_SwapWindow_loc{ nullptr };
-SDL_GL_SwapWindow_t SDL_GL_SwapWindow_o{ nullptr };
-
-SDL_PollEvent_t *SDL_PollEvent_loc{ nullptr };
-SDL_PollEvent_t SDL_PollEvent_o{ nullptr };
-
-typedef uint32_t (*SDL_GetWindowFlags_t)(SDL_Window *window);
-
-SDL_GetWindowFlags_t *SDL_GetWindowFlags_loc{ nullptr };
-SDL_GetWindowFlags_t SDL_GetWindowFlags_o{ nullptr };
-
-uint32_t SDL_GetWindowFlags_hook(SDL_Window *window)
-{
- uint32_t flags = SDL_GetWindowFlags_o(window);
- flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN);
- flags |= SDL_WINDOW_SHOWN;
- return flags;
-}
-
-void SDL_GL_SwapWindow_hook(SDL_Window *window)
-{
- static SDL_SysWMinfo wminfo;
- wminfo.version.major = 2;
- wminfo.version.minor = 0;
- typedef SDL_bool (*SDL_GetWindowWMInfo_t)(SDL_Window * window,
- SDL_SysWMinfo * info);
- static SDL_GetWindowWMInfo_t GetWindowWMInfo =
- *reinterpret_cast(
- sharedobj::libsdl().Pointer(0xFD4D8));
- static bool init_wminfo{ false };
- if (!init_wminfo)
- {
- GetWindowWMInfo(window, &wminfo);
- init_wminfo = true;
- }
- if (!sdl_current_window)
- sdl_current_window = window;
-
- static bool init{ false };
-
- static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext();
-
- if (cathook && !disable_visuals)
- {
- PROF_SECTION(SWAPWINDOW_cathook);
- if (not init)
- {
- draw_api::initialize();
- init = true;
- }
- render_cheat_visuals();
- }
- {
- PROF_SECTION(SWAPWINDOW_tf2);
- SDL_GL_MakeCurrent(window, tf2_sdl);
- SDL_GL_SwapWindow_o(window);
- // glXMakeContextCurrent(wminfo.info.x11.display,
- // wminfo.info.x11.window,
- // wminfo.info.x11.window, tf2);
- // glXSwapBuffers(wminfo.info.x11.display, wminfo.info.x11.window);
- }
-}
-
-int SDL_PollEvent_hook(SDL_Event *event)
-{
- int ret = SDL_PollEvent_o(event);
- if (ret)
- {
- logging::Info("event %x %x", event->type, event->common.type);
- if (event->type == SDL_WINDOWEVENT)
- {
- switch (event->window.event)
- {
- case SDL_WINDOWEVENT_HIDDEN:
- logging::Info("Window hidden");
- return 0;
- case SDL_WINDOWEVENT_MINIMIZED:
- logging::Info("Window minimized");
- return 0;
- }
- }
- }
- return ret;
-}
-
-void DoSDLHooking()
-{
- SDL_GL_SwapWindow_loc = reinterpret_cast(
- sharedobj::libsdl().Pointer(0xFD648));
-
- SDL_GL_SwapWindow_o = *SDL_GL_SwapWindow_loc;
- *SDL_GL_SwapWindow_loc = SDL_GL_SwapWindow_hook;
-
- // SDL_GetWindowFlags_loc =
- // reinterpret_cast(sharedobj::libsdl().Pointer(0xFD588));
-
- // SDL_GetWindowFlags_o = *SDL_GetWindowFlags_loc;
- // *SDL_GetWindowFlags_loc = SDL_GetWindowFlags_hook;
-
- // SDL_PollEvent_loc =
- // reinterpret_cast(sharedobj::libsdl().Pointer(0xFCF64));
-
- // SDL_PollEvent_o = *SDL_PollEvent_loc;
- // *SDL_PollEvent_loc = SDL_PollEvent_hook;
-}
-
-void DoSDLUnhooking()
-{
- *SDL_GL_SwapWindow_loc = SDL_GL_SwapWindow_o;
- // *SDL_GetWindowFlags_loc = SDL_GetWindowFlags_o;
- // *SDL_PollEvent_loc = SDL_PollEvent_o;
-}
diff --git a/src/hooks/visual/BeginFrame.cpp b/src/hooks/visual/BeginFrame.cpp
new file mode 100644
index 00000000..48a53e12
--- /dev/null
+++ b/src/hooks/visual/BeginFrame.cpp
@@ -0,0 +1,15 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(BeginFrame, void, IStudioRender *this_)
+{
+ return original::BeginFrame(this_);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/CMakeLists.txt b/src/hooks/visual/CMakeLists.txt
new file mode 100644
index 00000000..7cc96c5e
--- /dev/null
+++ b/src/hooks/visual/CMakeLists.txt
@@ -0,0 +1,10 @@
+target_sources(cathook PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/BeginFrame.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/DrawModelExecute.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/FrameStageNotify.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/OverrideView.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/RandomInt.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/SDL_GL_SwapWindow.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/SDL_PollEvent.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/IN_KeyEvent.cpp")
\ No newline at end of file
diff --git a/src/hooks/visual/DrawModelExecute.cpp b/src/hooks/visual/DrawModelExecute.cpp
new file mode 100644
index 00000000..e8b90e40
--- /dev/null
+++ b/src/hooks/visual/DrawModelExecute.cpp
@@ -0,0 +1,76 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include
+#include "HookedMethods.hpp"
+
+static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms",
+ "Removes arms from first person");
+static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats",
+ "Removes non-stock hats");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_,
+ const DrawModelState_t &state,
+ const ModelRenderInfo_t &info, matrix3x4_t *bone)
+{
+ static const char *name;
+ static std::string sname;
+ static IClientUnknown *unk;
+ static IClientEntity *ent;
+
+ if (!cathook ||
+ !(spectator_target || no_arms || no_hats ||
+ (clean_screenshots && g_IEngine->IsTakingScreenshot())))
+ {
+ return original::DrawModelExecute(this_, state, info, bone);
+ }
+
+ PROF_SECTION(DrawModelExecute);
+
+ if (no_arms || no_hats)
+ {
+ if (info.pModel)
+ {
+ name = g_IModelInfo->GetModelName(info.pModel);
+ if (name)
+ {
+ sname = name;
+ if (no_arms && sname.find("arms") != std::string::npos)
+ {
+ return;
+ }
+ else if (no_hats &&
+ sname.find("player/items") != std::string::npos)
+ {
+ return;
+ }
+ }
+ }
+ }
+
+ unk = info.pRenderable->GetIClientUnknown();
+ if (unk)
+ {
+ ent = unk->GetIClientEntity();
+ if (ent)
+ {
+ if (ent->entindex() == spectator_target)
+ {
+ return;
+ }
+ }
+ if (ent && !effect_chams::g_EffectChams.drawing &&
+ effect_chams::g_EffectChams.ShouldRenderChams(ent))
+ {
+ return;
+ }
+ }
+
+ return original::DrawModelExecute(this_, state, info, bone);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/FrameStageNotify.cpp b/src/hooks/visual/FrameStageNotify.cpp
new file mode 100644
index 00000000..e3d073f6
--- /dev/null
+++ b/src/hooks/visual/FrameStageNotify.cpp
@@ -0,0 +1,132 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include
+#include "HookedMethods.hpp"
+
+CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles");
+CatVar nightmode(CV_SWITCH, "nightmode", "0", "Enable nightmode", "");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(FrameStageNotify, void, void *this_,
+ ClientFrameStage_t stage)
+{
+ if (nightmode)
+ {
+ static int OldNightmode = 0;
+ if (OldNightmode != (int) nightmode)
+ {
+
+ static ConVar *r_DrawSpecificStaticProp =
+ g_ICvar->FindVar("r_DrawSpecificStaticProp");
+ if (!r_DrawSpecificStaticProp)
+ {
+ r_DrawSpecificStaticProp =
+ g_ICvar->FindVar("r_DrawSpecificStaticProp");
+ return;
+ }
+ r_DrawSpecificStaticProp->SetValue(0);
+
+ for (MaterialHandle_t i = g_IMaterialSystem->FirstMaterial();
+ i != g_IMaterialSystem->InvalidMaterial();
+ i = g_IMaterialSystem->NextMaterial(i))
+ {
+ IMaterial *pMaterial = g_IMaterialSystem->GetMaterial(i);
+
+ if (!pMaterial)
+ continue;
+ if (strstr(pMaterial->GetTextureGroupName(), "World") ||
+ strstr(pMaterial->GetTextureGroupName(), "StaticProp"))
+ {
+ if (nightmode)
+ if (strstr(pMaterial->GetTextureGroupName(),
+ "StaticProp"))
+ pMaterial->ColorModulate(0.3f, 0.3f, 0.3f);
+ else
+ pMaterial->ColorModulate(0.05f, 0.05f, 0.05f);
+ else
+ pMaterial->ColorModulate(1.0f, 1.0f, 1.0f);
+ }
+ }
+ OldNightmode = nightmode;
+ }
+ }
+ static IClientEntity *ent;
+
+ PROF_SECTION(FrameStageNotify_TOTAL);
+
+ if (!g_IEngine->IsInGame())
+ g_Settings.bInvalid = true;
+ {
+ PROF_SECTION(FSN_skinchanger);
+ hacks::tf2::skinchanger::FrameStageNotify(stage);
+ }
+ if (resolver && cathook && !g_Settings.bInvalid &&
+ stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
+ {
+ PROF_SECTION(FSN_resolver);
+ for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++)
+ {
+ if (i == g_IEngine->GetLocalPlayer())
+ continue;
+ ent = g_IEntityList->GetClientEntity(i);
+ if (ent && !ent->IsDormant() && !NET_BYTE(ent, netvar.iLifeState))
+ {
+ Vector &angles = NET_VECTOR(ent, netvar.m_angEyeAngles);
+ if (angles.x >= 90)
+ angles.x = -89;
+ if (angles.x <= -90)
+ angles.x = 89;
+ angles.y = fmod(angles.y + 180.0f, 360.0f);
+ if (angles.y < 0)
+ angles.y += 360.0f;
+ angles.y -= 180.0f;
+ }
+ }
+ }
+ if (cathook && stage == FRAME_RENDER_START)
+ {
+ INetChannel *ch;
+ ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
+ if (ch && !hooks::IsHooked((void *) ch))
+ {
+ hooks::netchannel.Set(ch);
+ hooks::netchannel.HookMethod(HOOK_ARGS(CanPacket));
+ hooks::netchannel.HookMethod(HOOK_ARGS(SendNetMsg));
+ hooks::netchannel.HookMethod(HOOK_ARGS(Shutdown));
+ hooks::netchannel.Apply();
+#if ENABLE_IPC
+ ipc::UpdateServerAddress();
+#endif
+ }
+ }
+ if (cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START)
+ {
+ IF_GAME(IsTF())
+ {
+ if (CE_GOOD(LOCAL_E) && no_zoom)
+ RemoveCondition(LOCAL_E);
+ }
+ if (force_thirdperson && !g_pLocalPlayer->life_state &&
+ CE_GOOD(g_pLocalPlayer->entity))
+ {
+ CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
+ }
+ if (stage == 5 && show_antiaim && g_IInput->CAM_IsThirdPerson())
+ {
+ if (CE_GOOD(g_pLocalPlayer->entity))
+ {
+ CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) =
+ g_Settings.last_angles.x;
+ CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) =
+ g_Settings.last_angles.y;
+ }
+ }
+ }
+ return original::FrameStageNotify(this_, stage);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/IN_KeyEvent.cpp b/src/hooks/visual/IN_KeyEvent.cpp
new file mode 100644
index 00000000..7ec5742f
--- /dev/null
+++ b/src/hooks/visual/IN_KeyEvent.cpp
@@ -0,0 +1,23 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(IN_KeyEvent, int, void *this_, int eventcode,
+ ButtonCode_t keynum, const char *binding)
+{
+#if ENABLE_GUI
+/*
+if (g_pGUI->ConsumesKey((ButtonCode_t)keynum) && g_pGUI->Visible()) {
+ return 0;
+}
+*/
+#endif
+ return original::IN_KeyEvent(this_, eventcode, keynum, binding);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/OverrideView.cpp b/src/hooks/visual/OverrideView.cpp
new file mode 100644
index 00000000..78a27691
--- /dev/null
+++ b/src/hooks/visual/OverrideView.cpp
@@ -0,0 +1,92 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include
+#include "HookedMethods.hpp"
+
+CatVar override_fov_zoomed(CV_FLOAT, "fov_zoomed", "0", "FOV override (zoomed)",
+ "Overrides FOV with this value when zoomed in "
+ "(default FOV when zoomed is 20)");
+CatVar override_fov(CV_FLOAT, "fov", "0", "FOV override",
+ "Overrides FOV with this value");
+
+CatVar freecam(CV_KEY, "debug_freecam", "0", "Freecam");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(OverrideView, void, void *this_, CViewSetup *setup)
+{
+ static bool zoomed;
+ original::OverrideView(this_, setup);
+ if (!cathook)
+ return;
+ if (g_pLocalPlayer->bZoomed && override_fov_zoomed)
+ {
+ setup->fov = override_fov_zoomed;
+ }
+ else
+ {
+ if (override_fov)
+ {
+ setup->fov = override_fov;
+ }
+ }
+
+ if (spectator_target)
+ {
+ CachedEntity *spec = ENTITY(spectator_target);
+ if (CE_GOOD(spec) && !CE_BYTE(spec, netvar.iLifeState))
+ {
+ setup->origin =
+ spec->m_vecOrigin + CE_VECTOR(spec, netvar.vViewOffset);
+ // why not spectate yourself
+ if (spec == LOCAL_E)
+ {
+ setup->angles =
+ CE_VAR(spec, netvar.m_angEyeAnglesLocal, QAngle);
+ }
+ else
+ {
+ setup->angles = CE_VAR(spec, netvar.m_angEyeAngles, QAngle);
+ }
+ }
+ if (g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_SPACE))
+ {
+ spectator_target = 0;
+ }
+ }
+
+ if (freecam)
+ {
+ static Vector freecam_origin{ 0 };
+ static bool freecam_last{ false };
+ if (freecam.KeyDown())
+ {
+ if (not freecam_last)
+ {
+ freecam_origin = setup->origin;
+ }
+ float sp, sy, cp, cy;
+ QAngle angle;
+ Vector forward;
+ g_IEngine->GetViewAngles(angle);
+ sy = sinf(DEG2RAD(angle[1]));
+ cy = cosf(DEG2RAD(angle[1]));
+ sp = sinf(DEG2RAD(angle[0]));
+ cp = cosf(DEG2RAD(angle[0]));
+ forward.x = cp * cy;
+ forward.y = cp * sy;
+ forward.z = -sp;
+ forward *= 4;
+ freecam_origin += forward;
+ setup->origin = freecam_origin;
+ }
+ freecam_last = freecam.KeyDown();
+ }
+
+ draw::fov = setup->fov;
+}
+}
\ No newline at end of file
diff --git a/src/hooks/PaintTraverse.cpp b/src/hooks/visual/PaintTraverse.cpp
similarity index 75%
rename from src/hooks/PaintTraverse.cpp
rename to src/hooks/visual/PaintTraverse.cpp
index dbb5e442..202fc1bf 100644
--- a/src/hooks/PaintTraverse.cpp
+++ b/src/hooks/visual/PaintTraverse.cpp
@@ -1,15 +1,9 @@
/*
- * PaintTraverse.cpp
- *
- * Created on: Jan 8, 2017
- * Author: nullifiedcat
- */
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
-#include "common.hpp"
-
-#if ENABLE_GUI
-#include "GUI.h"
-#endif
+#include "HookedMethods.hpp"
CatVar clean_screenshots(CV_SWITCH, "clean_screenshots", "1",
"Clean screenshots",
@@ -26,14 +20,16 @@ void **pure_addr = nullptr;
CatEnum software_cursor_enum({ "KEEP", "ALWAYS", "NEVER", "MENU ON",
"MENU OFF" });
CatVar
- software_cursor_mode(software_cursor_enum, "software_cursor_mode", "0",
- "Software cursor",
- "Try to change this and see what works best for you");
+ software_cursor_mode(software_cursor_enum, "software_cursor_mode", "0",
+ "Software cursor",
+ "Try to change this and see what works best for you");
-void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_,
+ unsigned int panel, bool force, bool allow_force)
{
- static const PaintTraverse_t original =
- (PaintTraverse_t) hooks::panel.GetMethod(offsets::PaintTraverse());
static bool textures_loaded = false;
static unsigned long panel_focus = 0;
static unsigned long panel_scope = 0;
@@ -58,9 +54,9 @@ void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
if (!pure_addr)
{
pure_addr = *reinterpret_cast(
- gSignatures.GetEngineSignature(
- "A1 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? 89 04 24") +
- 1);
+ gSignatures.GetEngineSignature(
+ "A1 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? 89 04 24") +
+ 1);
}
if (*pure_addr)
pure_orig = *pure_addr;
@@ -72,7 +68,7 @@ void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
pure_orig = (void *) 0;
}
call_default = true;
- if (cathook && panel_scope && no_zoom && vp == panel_scope)
+ if (cathook && panel_scope && no_zoom && panel == panel_scope)
call_default = false;
if (software_cursor_mode)
@@ -105,44 +101,44 @@ void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
}
if (call_default)
- original(_this, vp, fr, ar);
+ original::PaintTraverse(this_, panel, force, allow_force);
// To avoid threading problems.
PROF_SECTION(PT_total);
- if (vp == panel_top)
+ if (panel == panel_top)
draw_flag = true;
if (!cathook)
return;
if (!panel_top)
{
- name = g_IPanel->GetName(vp);
+ name = g_IPanel->GetName(panel);
if (strlen(name) > 4)
{
if (name[0] == 'M' && name[3] == 'S')
{
- panel_top = vp;
+ panel_top = panel;
}
}
}
if (!panel_focus)
{
- name = g_IPanel->GetName(vp);
+ name = g_IPanel->GetName(panel);
if (strlen(name) > 5)
{
if (name[0] == 'F' && name[5] == 'O')
{
- panel_focus = vp;
+ panel_focus = panel;
}
}
}
if (!panel_scope)
{
- name = g_IPanel->GetName(vp);
+ name = g_IPanel->GetName(panel);
if (!strcmp(name, "HudScope"))
{
- panel_scope = vp;
+ panel_scope = panel;
}
}
if (!g_IEngine->IsInGame())
@@ -150,7 +146,7 @@ void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
g_Settings.bInvalid = true;
}
- if (vp != panel_focus)
+ if (panel != panel_focus)
return;
g_IPanel->SetTopmostPopup(panel_focus, true);
if (!draw_flag)
@@ -168,3 +164,4 @@ void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar)
PROF_SECTION(PT_active);
draw::UpdateWTS();
}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/RandomInt.cpp b/src/hooks/visual/RandomInt.cpp
new file mode 100644
index 00000000..0d8264dd
--- /dev/null
+++ b/src/hooks/visual/RandomInt.cpp
@@ -0,0 +1,22 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+static CatVar medal_flip(CV_SWITCH, "medal_flip", "0", "Infinite Medal Flip",
+ "");
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(RandomInt, int, IUniformRandomStream *this_, int min,
+ int max)
+{
+ if (medal_flip && min == 0 && max == 9)
+ return 0;
+
+ return original::RandomInt(this_, min, max);
+}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/SDL_GL_SwapWindow.cpp b/src/hooks/visual/SDL_GL_SwapWindow.cpp
new file mode 100644
index 00000000..985c4011
--- /dev/null
+++ b/src/hooks/visual/SDL_GL_SwapWindow.cpp
@@ -0,0 +1,57 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include
+#include
+#include
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
+{
+ static SDL_SysWMinfo wminfo;
+ wminfo.version.major = 2;
+ wminfo.version.minor = 0;
+ typedef SDL_bool (*SDL_GetWindowWMInfo_t)(SDL_Window * window,
+ SDL_SysWMinfo * info);
+ static SDL_GetWindowWMInfo_t GetWindowWMInfo =
+ *reinterpret_cast(
+ sharedobj::libsdl().Pointer(0xFD4D8));
+ static bool init_wminfo{ false };
+ if (!init_wminfo)
+ {
+ GetWindowWMInfo(window, &wminfo);
+ init_wminfo = true;
+ }
+ if (!sdl_hooks::window)
+ sdl_hooks::window = window;
+
+ static bool init{ false };
+
+ static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext();
+
+ if (cathook && !disable_visuals)
+ {
+ PROF_SECTION(SWAPWINDOW_cathook);
+ if (not init)
+ {
+ draw_api::initialize();
+ init = true;
+ }
+ render_cheat_visuals();
+ }
+ {
+ PROF_SECTION(SWAPWINDOW_tf2);
+ SDL_GL_MakeCurrent(window, tf2_sdl);
+ original::SDL_GL_SwapWindow(window);
+ // glXMakeContextCurrent(wminfo.info.x11.display,
+ // wminfo.info.x11.window,
+ // wminfo.info.x11.window, tf2);
+ // glXSwapBuffers(wminfo.info.x11.display, wminfo.info.x11.window);
+ }
+}
+}
\ No newline at end of file
diff --git a/src/hooks/visual/SDL_PollEvent.cpp b/src/hooks/visual/SDL_PollEvent.cpp
new file mode 100644
index 00000000..1dd95b8b
--- /dev/null
+++ b/src/hooks/visual/SDL_PollEvent.cpp
@@ -0,0 +1,15 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "HookedMethods.hpp"
+
+namespace hooked_methods
+{
+
+DEFINE_HOOKED_METHOD(SDL_PollEvent, int, SDL_Event *event)
+{
+ return original::SDL_PollEvent(event);
+}
+}
\ No newline at end of file
diff --git a/src/ipc.cpp b/src/ipc.cpp
old mode 100755
new mode 100644
index b5d02af7..72cd6953
--- a/src/ipc.cpp
+++ b/src/ipc.cpp
@@ -261,8 +261,8 @@ void StoreClientData()
user_data_s &data = peer->memory->peer_user_data[peer->client_id];
data.friendid = g_ISteamUser->GetSteamID().GetAccountID();
data.ts_injected = time_injected;
- strncpy(data.name, GetFriendPersonaName_hook(g_ISteamFriends,
- g_ISteamUser->GetSteamID()),
+ strncpy(data.name, hooked_methods::methods::GetFriendPersonaName(
+ g_ISteamFriends, g_ISteamUser->GetSteamID()),
sizeof(data.name));
}
diff --git a/src/menu.tar.xz b/src/menu.tar.xz
deleted file mode 100644
index d3cbc9b6..00000000
Binary files a/src/menu.tar.xz and /dev/null differ
diff --git a/src/playerlist.cpp b/src/playerlist.cpp
old mode 100755
new mode 100644
index 4daef66a..88668741
--- a/src/playerlist.cpp
+++ b/src/playerlist.cpp
@@ -140,15 +140,7 @@ rgba_t Color(CachedEntity *player)
userdata &AccessData(unsigned steamid)
{
- try
- {
- return data.at(steamid);
- }
- catch (std::out_of_range &oor)
- {
- data.emplace(steamid, userdata{});
- return data.at(steamid);
- }
+ return data[steamid];
}
// Assume player is non-null
diff --git a/src/reclasses/CTFInventoryManager.cpp b/src/reclasses/CTFInventoryManager.cpp
index bb8a2ca6..d0f04b14 100644
--- a/src/reclasses/CTFInventoryManager.cpp
+++ b/src/reclasses/CTFInventoryManager.cpp
@@ -12,7 +12,7 @@ CTFInventoryManager *CTFInventoryManager::GTFInventoryManager()
typedef CTFInventoryManager *(*GTFInventoryManager_t)();
uintptr_t address = gSignatures.GetClientSignature(
"55 A1 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 89 E5 56 53 83 EC ? 8B "
- "5D ? C7 44 24 ? ? ? ? ?");
+ "5D ? C7 44 24");
GTFInventoryManager_t GTFInventoryManager_fn =
GTFInventoryManager_t(address);
return GTFInventoryManager_fn();
@@ -34,7 +34,7 @@ CTFPlayerInventory *CTFPlayerInventory::GTFPlayerInventory()
typedef CTFPlayerInventory *(*GTFPlayerInventory_t)();
uintptr_t address = gSignatures.GetClientSignature(
"55 B8 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 B8 ? ? ? ? 89 E5 5D C3 "
- "8D B6 00 00 00 00 55 89 E5 57 56 53 83 EC ? 8B 45 ? 8B 5D ?");
+ "8D B6 00 00 00 00 55 89 E5 57 56 53 83 EC ? 8B 45 ? 8B 5D");
GTFPlayerInventory_t GTFPlayerInventory_fn = GTFPlayerInventory_t(address);
return GTFPlayerInventory_fn();
}
@@ -42,7 +42,7 @@ CEconItem *CTFPlayerInventory::GetFirstItemOfItemDef(int id)
{
typedef CEconItem *(*GetFirstItemOfItemDef_t)(CTFPlayerInventory *, int);
uintptr_t address = gSignatures.GetClientSignature(
- "55 89 E5 57 56 53 83 EC ? 8B 4D ? 0F B7 45 ?");
+ "55 89 E5 57 56 53 83 EC ? 8B 4D ? 0F B7 45");
GetFirstItemOfItemDef_t GetFirstItemOfItemDef_fn =
GetFirstItemOfItemDef_t(address);
return GetFirstItemOfItemDef_fn(this, id);
diff --git a/src/reclasses/CTFPartyClient.cpp b/src/reclasses/CTFPartyClient.cpp
index 9da525b0..951bdac3 100644
--- a/src/reclasses/CTFPartyClient.cpp
+++ b/src/reclasses/CTFPartyClient.cpp
@@ -46,8 +46,8 @@ re::CTFPartyClient::MutLocalGroupCriteria(re::CTFPartyClient *client)
{
typedef re::ITFGroupMatchCriteria *(*MutLocalGroupCriteria_t)(
re::CTFPartyClient *);
- static uintptr_t addr = gSignatures.GetClientSignature(
- "55 89 E5 8B 45 ? 8B 50 ? C6 80 ? ? ? ? ?");
+ static uintptr_t addr =
+ gSignatures.GetClientSignature("55 89 E5 8B 45 ? 8B 50 ? C6 80");
static MutLocalGroupCriteria_t MutLocalGroupCriteria_fn =
MutLocalGroupCriteria_t(addr);
@@ -58,7 +58,7 @@ int re::CTFPartyClient::LoadSavedCasualCriteria()
{
typedef int (*LoadSavedCasualCriteria_t)(re::CTFPartyClient *);
uintptr_t addr = gSignatures.GetClientSignature(
- "55 89 E5 83 EC ? 8B 45 ? 8B 50 ? C6 80 ? ? ? ? ?");
+ "55 89 E5 83 EC ? 8B 45 ? 8B 50 ? C6 80");
LoadSavedCasualCriteria_t LoadSavedCasualCriteria_fn =
LoadSavedCasualCriteria_t(addr);
@@ -69,7 +69,7 @@ char re::CTFPartyClient::RequestQueueForMatch(int type)
{
typedef char (*RequestQueueForMatch_t)(re::CTFPartyClient *, int);
uintptr_t addr = gSignatures.GetClientSignature(
- "55 89 E5 57 56 53 81 EC ? ? ? ? 8B 75 ? 89 F0");
+ "55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? E8");
RequestQueueForMatch_t RequestQueueForMatch_fn =
RequestQueueForMatch_t(addr);
@@ -80,7 +80,7 @@ char re::CTFPartyClient::RequestLeaveForMatch(int type)
typedef char (*RequestLeaveForMatch_t)(re::CTFPartyClient *, int);
uintptr_t addr = gSignatures.GetClientSignature(
"55 89 E5 57 56 53 83 EC ? 8B 45 ? 89 44 24 ? 8B 45 ? 89 04 24 E8 ? ? "
- "? ? 84 C0 89 C6 75 ?");
+ "? ? 84 C0 89 C6 75");
RequestLeaveForMatch_t RequestLeaveForMatch_fn =
RequestLeaveForMatch_t(addr);
diff --git a/src/velocity.cpp b/src/velocity.cpp
old mode 100755
new mode 100644
index 4e3b5a11..23f4bd08
--- a/src/velocity.cpp
+++ b/src/velocity.cpp
@@ -14,14 +14,15 @@ namespace velocity
EstimateAbsVelocity_t EstimateAbsVelocity{};
-void Init() {
+void Init()
+{
EstimateAbsVelocity =
- (void (*)(IClientEntity *, Vector &)) gSignatures.GetClientSignature(
- "55 89 E5 56 53 83 EC 20 8B 5D 08 8B 75 0C E8 ? ? ? ? 39 D8 74 79 "
- "0F B6 05 ? ? ? ? 81 C3 B8 02 00 00 C6 05 ? ? ? ? 01 F3 0F 10 05 ? "
- "? ? ? F3 0F 11 45 F0 88 45 EC A1 ? ? ? ? 89 45 E8 8D 45 E8 A3 ? ? "
- "? ? A1 ? ? ? ? F3 0F 10 40 0C 89 74 24 04 89 1C 24 F3 0F 11 44 24 "
- "08 E8 ? ? ? ? 0F B6 45 EC F3 0F 10 45 F0 F3 0F 11 05 ? ? ? ? A2 ? "
- "? ? ? 8B 45 E8 A3 ? ? ? ? 83 C4 20 5B 5E 5D C3");
+ (void (*)(IClientEntity *, Vector &)) gSignatures.GetClientSignature(
+ "55 89 E5 56 53 83 EC 20 8B 5D 08 8B 75 0C E8 ? ? ? ? 39 D8 74 79 "
+ "0F B6 05 ? ? ? ? 81 C3 B8 02 00 00 C6 05 ? ? ? ? 01 F3 0F 10 05 ? "
+ "? ? ? F3 0F 11 45 F0 88 45 EC A1 ? ? ? ? 89 45 E8 8D 45 E8 A3 ? ? "
+ "? ? A1 ? ? ? ? F3 0F 10 40 0C 89 74 24 04 89 1C 24 F3 0F 11 44 24 "
+ "08 E8 ? ? ? ? 0F B6 45 EC F3 0F 10 45 F0 F3 0F 11 05 ? ? ? ? A2 ? "
+ "? ? ? 8B 45 E8 A3 ? ? ? ? 83 C4 20 5B 5E 5D C3");
}
}
diff --git a/src/visual/CMakeLists.txt b/src/visual/CMakeLists.txt
index 580c2e88..8ede8cc0 100644
--- a/src/visual/CMakeLists.txt
+++ b/src/visual/CMakeLists.txt
@@ -6,7 +6,8 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/drawmgr.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectChams.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp")
+ "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/SDLHooks.cpp")
if(EnableGUI)
add_subdirectory(menu)
diff --git a/src/visual/EffectChams.cpp b/src/visual/EffectChams.cpp
index 365e529c..0ca807bd 100644
--- a/src/visual/EffectChams.cpp
+++ b/src/visual/EffectChams.cpp
@@ -6,6 +6,7 @@
*/
#include
+#include
#include "common.hpp"
// static CatVar chams_experimental(CV_SWITCH, "chams_effect", "0",
diff --git a/src/visual/EffectGlow.cpp b/src/visual/EffectGlow.cpp
index 1f7c3538..4cf7cc04 100755
--- a/src/visual/EffectGlow.cpp
+++ b/src/visual/EffectGlow.cpp
@@ -6,6 +6,7 @@
*/
#include
+#include
#include "common.hpp"
IMaterialSystem *materials = nullptr;
diff --git a/src/visual/SDLHooks.cpp b/src/visual/SDLHooks.cpp
new file mode 100644
index 00000000..31696d31
--- /dev/null
+++ b/src/visual/SDLHooks.cpp
@@ -0,0 +1,33 @@
+/*
+ Created by Jenny White on 29.04.18.
+ Copyright (c) 2018 nullworks. All rights reserved.
+*/
+
+#include "SDLHooks.hpp"
+#include "HookedMethods.hpp"
+
+namespace sdl_hooks
+{
+
+SDL_Window *window{ nullptr };
+
+namespace pointers
+{
+hooked_methods::types::SDL_GL_SwapWindow *SDL_GL_SwapWindow{ nullptr };
+}
+
+
+void applySdlHooks()
+{
+ pointers::SDL_GL_SwapWindow = reinterpret_cast(sharedobj::libsdl().Pointer(0xFD648));
+
+ hooked_methods::original::SDL_GL_SwapWindow = *pointers::SDL_GL_SwapWindow;
+ *pointers::SDL_GL_SwapWindow = hooked_methods::methods::SDL_GL_SwapWindow;
+}
+
+void cleanSdlHooks()
+{
+ *pointers::SDL_GL_SwapWindow = hooked_methods::original::SDL_GL_SwapWindow;
+}
+
+}
\ No newline at end of file
diff --git a/src/visual/drawex.cpp b/src/visual/drawex.cpp
index 7b5ccfde..cd36e0cc 100755
--- a/src/visual/drawex.cpp
+++ b/src/visual/drawex.cpp
@@ -12,6 +12,7 @@
#include
#include
+#include
#if EXTERNAL_DRAWING
extern "C" {
@@ -77,7 +78,7 @@ void initialize()
}
xoverlay_show();
#else
- context = SDL_GL_CreateContext(sdl_current_window);
+ context = SDL_GL_CreateContext(sdl_hooks::window);
glClearColor(1.0, 0.0, 0.0, 0.5);
glewExperimental = GL_TRUE;
glewInit();
@@ -159,7 +160,7 @@ void draw_begin()
#if EXTERNAL_DRAWING
xoverlay_draw_begin();
#else
- SDL_GL_MakeCurrent(sdl_current_window, context);
+ SDL_GL_MakeCurrent(sdl_hooks::window, context);
#endif
glez_begin();
}
@@ -168,7 +169,7 @@ void draw_end()
{
PROF_SECTION(DRAWEX_draw_end);
glez_end();
- SDL_GL_MakeCurrent(sdl_current_window, nullptr);
+ SDL_GL_MakeCurrent(sdl_hooks::window, nullptr);
#if EXTERNAL_DRAWING
xoverlay_draw_end();
#endif
diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp
index 96340e1c..dbbec05d 100644
--- a/src/visual/drawmgr.cpp
+++ b/src/visual/drawmgr.cpp
@@ -5,6 +5,7 @@
* Author: nullifiedcat
*/
+#include
#include "common.hpp"
#include "visual/drawing.hpp"
#include "hack.hpp"
@@ -27,9 +28,9 @@ void render_cheat_visuals()
void BeginCheatVisuals()
{
-/*#if RENDERING_ENGINE_OPENGL
- std::lock_guard draw_lock(drawing_mutex);
-#endif*/
+ /*#if RENDERING_ENGINE_OPENGL
+ std::lock_guard draw_lock(drawing_mutex);
+ #endif*/
draw_api::draw_begin();
ResetStrings();
}
@@ -45,9 +46,9 @@ CatVar enable_logo(CV_SWITCH, "nullcore_mode_logo", "1",
void DrawCheatVisuals()
{
-/*#if RENDERING_ENGINE_OPENGL
- std::lock_guard draw_lock(drawing_mutex);
-#endif*/
+ /*#if RENDERING_ENGINE_OPENGL
+ std::lock_guard draw_lock(drawing_mutex);
+ #endif*/
{
PROF_SECTION(DRAW_misc);
hacks::shared::misc::DrawText();