From 717b66c2226e87ca04354e6451ab4c9889eaebb5 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Mon, 13 Nov 2017 23:58:28 +0300 Subject: [PATCH] unfinished changes - RENDERING_ENGINE_OPENGL is to be removed later. --- .cproject | 1 + include/catpackets.h | 86 ------------------ include/catsmclient.h | 36 -------- include/common.hpp | 8 +- include/hooks/hookedmethods.hpp | 4 - include/visual/drawex.hpp | 30 ++++-- include/xpcmutex.h | 36 -------- include/xshm.h | 30 ------ src/catsmclient.c | 103 --------------------- src/hack.cpp | 4 - src/hooks/sdl.cpp | 106 +++++++++++----------- src/visual/drawex.cpp | 83 +++++------------ src/visual/drawmgr.cpp | 156 +++++++++++++++----------------- src/xpcmutex.c | 75 --------------- src/xshm.c | 95 ------------------- 15 files changed, 179 insertions(+), 674 deletions(-) delete mode 100644 include/catpackets.h delete mode 100644 include/catsmclient.h delete mode 100644 include/xpcmutex.h delete mode 100644 include/xshm.h delete mode 100644 src/catsmclient.c delete mode 100644 src/xpcmutex.c delete mode 100644 src/xshm.c diff --git a/.cproject b/.cproject index 60c83d49..c51e4cad 100644 --- a/.cproject +++ b/.cproject @@ -110,6 +110,7 @@ diff --git a/include/catpackets.h b/include/catpackets.h deleted file mode 100644 index 758b3b2b..00000000 --- a/include/catpackets.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * catpackets.h - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#pragma once - -#include - -enum -{ - CATP_DRAW_BEGIN, - CATP_DRAW_END, - - CATP_DRAW_RECT, - CATP_DRAW_RECT_OUTLINE, - CATP_DRAW_LINE, - CATP_DRAW_STRING, - CATP_DRAW_CIRCLE, - -/* CATP_DRAW_ESP_BOX, - CATP_DRAW_ESP_BONE_LIST, */ - - CATP_TOTAL -}; - -struct catp_draw_begin_t -{ - float world_to_screen[16]; -}; - -struct catp_draw_rect_t -{ - float x; - float y; - float w; - float h; - float rgba[4]; -}; - -struct catp_draw_rect_outline_t -{ - float x; - float y; - float w; - float h; - float rgba[4]; - float thickness; -}; - -struct catp_draw_line_t -{ - float x; - float y; - float dx; - float dy; - float rgba[4]; - float thickness; -}; - -struct catp_draw_circle_t -{ - float x; - float y; - float radius; - float rgba[4]; - float thickness; - int steps; -}; - -struct catp_draw_string_t -{ - float x; - float y; - float rgba[4]; - uint32_t length; -}; - -/* -struct catp_draw_esp_box_t -{ - -}; -*/ diff --git a/include/catsmclient.h b/include/catsmclient.h deleted file mode 100644 index e1c2a421..00000000 --- a/include/catsmclient.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * catsmclient.h - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#pragma once - -#include "xshm.h" -#include "xpcmutex.h" -#include "shmstream.h" - -cat_shm_render_context_t -cat_shm_connect(const char *name); - -void -cat_shm_render_begin(cat_shm_render_context_t *ctx, const float *world_to_screen); - -void -cat_shm_render_end(cat_shm_render_context_t *ctx); - -void -cat_shm_render_rect(cat_shm_render_context_t *ctx, float x, float y, float w, float h, const float *rgba); - -void -cat_shm_render_rect_outline(cat_shm_render_context_t *ctx, float x, float y, float w, float h, const float *rgba, float thickness); - -void -cat_shm_render_line(cat_shm_render_context_t *ctx, float x, float y, float dx, float dy, const float *rgba, float thickness); - -void -cat_shm_render_string(cat_shm_render_context_t *ctx, float x, float y, const char *string, const float *rgba); - -void -cat_shm_render_circle(cat_shm_render_context_t *ctx, float x, float y, float radius, const float *rgba, float thickness, int steps); diff --git a/include/common.hpp b/include/common.hpp index 40ad17e6..eee86b11 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -43,6 +43,11 @@ #include #include #include +#include = +#include +#include +#include +#include #include "timer.hpp" #include "averager.hpp" @@ -62,7 +67,8 @@ extern "C" { #include #include #include "fidgetspinner.hpp" -#include#include +#include +#include #include #include #include diff --git a/include/hooks/hookedmethods.hpp b/include/hooks/hookedmethods.hpp index 276ffe67..776a92ee 100644 --- a/include/hooks/hookedmethods.hpp +++ b/include/hooks/hookedmethods.hpp @@ -42,8 +42,6 @@ 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); -#ifdef RENDERING_ENGINE_OPENGL - /* SDL HOOKS */ union SDL_Event; class SDL_Window; @@ -57,8 +55,6 @@ 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/visual/drawex.hpp b/include/visual/drawex.hpp index c44f7053..60f9b7b9 100644 --- a/include/visual/drawex.hpp +++ b/include/visual/drawex.hpp @@ -11,7 +11,7 @@ extern "C" { -#include "catsmclient.h" +#include "overlay.h" } #define draw_api drawex::api @@ -19,24 +19,36 @@ extern "C" namespace drawex { -extern cat_shm_render_context_t ctx; -extern std::thread rendering_thread; - -void rendering_routine(); - namespace api { -extern bool ready_state; +struct font_handle_t +{ + xoverlay_font_handle_t handle; +}; + +struct texture_handle_t +{ + xoverlay_texture_handle_t handle; +}; + +font_handle_t create_font(const char *path, float size); +texture_handle_t create_texture(const char *path); + +void destroy_font(font_handle_t font); +void destroy_texture(texture_handle_t texture); + +bool ready(); void initialize(); void draw_rect(float x, float y, float w, float h, const float* rgba); void draw_rect_outlined(float x, float y, float w, float h, const float* rgba, float thickness); void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness); -void draw_rect_textured(float x, float y, float w, float h, const float* rgba, float u, float v, float s, float t); +void draw_rect_textured(float x, float y, float w, float h, const float* rgba, texture_handle_t texture, float u, float v, float s, float t); void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps); -void draw_string(float x, float y, const char *string, const float *rgba); +void draw_string(float x, float y, const char *string, font_handle_t font, const float *rgba); +void draw_string_with_outline(float x, float y, const char *string, font_handle_t font, const float *rgba, float thickness); void draw_begin(); void draw_end(); diff --git a/include/xpcmutex.h b/include/xpcmutex.h deleted file mode 100644 index 7548b538..00000000 --- a/include/xpcmutex.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * xpcmutex.h - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#pragma once - -/* - * Cross-Process C shared mutex - */ - -typedef struct xpcmutex_s -{ - char name[64]; - int fd; -} xpcmutex_t; - -xpcmutex_t -xpcmutex_init(const char *name); - -xpcmutex_t -xpcmutex_connect(const char *name); - -void -xpcmutex_close(xpcmutex_t mutex); - -void -xpcmutex_destroy(xpcmutex_t mutex); - -void -xpcmutex_lock(xpcmutex_t mutex); - -void -xpcmutex_unlock(xpcmutex_t mutex); diff --git a/include/xshm.h b/include/xshm.h deleted file mode 100644 index b14fd6f3..00000000 --- a/include/xshm.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * xshm.h - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#pragma once - -#include - -typedef struct xshm_s -{ - void *data; - char name[64]; - uint32_t size; -} xshm_t; - -xshm_t -xshm_init(const char *name, uint32_t size); - -xshm_t -xshm_connect(const char *name, uint32_t size); - -void -xshm_destroy(xshm_t xshm); - -void -xshm_close(xshm_t xshm); - diff --git a/src/catsmclient.c b/src/catsmclient.c deleted file mode 100644 index cd890830..00000000 --- a/src/catsmclient.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * catsmclient.c - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#include "catsmclient.h" -#include "catpackets.h" -#include "shmstream.h" - -cat_shm_render_context_t -cat_shm_connect(const char *name) -{ - cat_shm_render_context_t ctx; - ctx.shm = xshm_connect(name, CAT_SHM_SIZE); - ctx.mutex = xpcmutex_connect(name); - ctx.curpos = 0; - ctx.lastpacket = 0; - return ctx; -} - -void -cat_shm_render_begin(cat_shm_render_context_t *ctx, const float *world_to_screen) -{ - xpcmutex_lock(ctx->mutex); - struct catp_draw_begin_t packet; - memcpy(packet.world_to_screen, world_to_screen, sizeof(float) * 16); - cat_shm_packet_send(ctx, CATP_DRAW_BEGIN, sizeof(packet), &packet); -} - -void -cat_shm_render_end(cat_shm_render_context_t *ctx) -{ - cat_shm_packet_send(ctx, CATP_DRAW_END, 0, 0); - xpcmutex_unlock(ctx->mutex); -} - -void -cat_shm_render_rect(cat_shm_render_context_t *ctx, float x, float y, float w, float h, const float *rgba) -{ - struct catp_draw_rect_t packet; - packet.x = x; - packet.y = y; - packet.h = h; - packet.w = w; - memcpy(packet.rgba, rgba, sizeof(float) * 4); - cat_shm_packet_send(ctx, CATP_DRAW_RECT, sizeof(packet), &packet); -} - -void -cat_shm_render_rect_outline(cat_shm_render_context_t *ctx, float x, float y, float w, float h, const float *rgba, float thickness) -{ - struct catp_draw_rect_outline_t packet; - packet.x = x; - packet.y = y; - packet.h = h; - packet.w = w; - memcpy(packet.rgba, rgba, sizeof(float) * 4); - packet.thickness = thickness; - cat_shm_packet_send(ctx, CATP_DRAW_RECT_OUTLINE, sizeof(packet), &packet); -} - -void -cat_shm_render_line(cat_shm_render_context_t *ctx, float x, float y, float dx, float dy, const float *rgba, float thickness) -{ - struct catp_draw_line_t packet; - packet.x = x; - packet.y = y; - packet.dx = dx; - packet.dy = dy; - memcpy(packet.rgba, rgba, sizeof(float) * 4); - packet.thickness = thickness; - cat_shm_packet_send(ctx, CATP_DRAW_LINE, sizeof(packet), &packet); -} - -void -cat_shm_render_string(cat_shm_render_context_t *ctx, float x, float y, const char *string, const float *rgba) -{ - struct catp_draw_string_t packet; - packet.x = x; - packet.y = y; - memcpy(packet.rgba, rgba, sizeof(float) * 4); - packet.length = strlen(string); - cat_shm_packet_send(ctx, CATP_DRAW_STRING, sizeof(packet), &packet); - cat_shm_packet_write_manual(ctx, packet.length, string); -} - -void -cat_shm_render_circle(cat_shm_render_context_t *ctx, float x, float y, float radius, const float *rgba, float thickness, int steps) -{ - struct catp_draw_circle_t packet; - packet.x = x; - packet.y = y; - packet.radius = radius; - packet.thickness = thickness; - packet.steps = steps; - memcpy(packet.rgba, rgba, sizeof(float) * 4); - cat_shm_packet_send(ctx, CATP_DRAW_CIRCLE, sizeof(packet), &packet); -} - - - diff --git a/src/hack.cpp b/src/hack.cpp index 2b3f62a5..efcee058 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -299,10 +299,8 @@ void hack::Initialize() { } logging::Info("SSE enabled.."); #endif -#if RENDERING_ENGINE_OPENGL DoSDLHooking(); logging::Info("SDL hooking done"); -#endif g_IGameEventManager->AddListener(&adv_event_listener, false); #endif /* TEXTMODE */ @@ -346,9 +344,7 @@ void hack::Shutdown() { if (hack::shutdown) return; hack::shutdown = true; playerlist::Save(); -#if RENDERING_ENGINE_OPENGL DoSDLUnhooking(); -#endif logging::Info("Unregistering convars.."); ConVar_Unregister(); logging::Info("Shutting down killsay..."); diff --git a/src/hooks/sdl.cpp b/src/hooks/sdl.cpp index a42fd95d..04be51e0 100644 --- a/src/hooks/sdl.cpp +++ b/src/hooks/sdl.cpp @@ -7,10 +7,8 @@ #include "common.hpp" -#ifdef RENDERING_ENGINE_OPENGL - -#include "hookedmethods.h" -#include "../hack.h" +#include "hooks/hookedmethods.hpp" +#include "hack.hpp" #include @@ -25,11 +23,11 @@ SDL_PollEvent_t SDL_PollEvent_o { nullptr }; SDL_GL_SwapWindow_t SDL_GL_SwapWindow_o { nullptr }; int SDL_PollEvent_hook(SDL_Event* event) { - int retval = SDL_PollEvent_o(event); - if (event && (event->key.keysym.sym & ~SDLK_SCANCODE_MASK) < 512) { - ImGui_ImplSdl_ProcessEvent(event); - } - return retval; + int retval = SDL_PollEvent_o(event); + if (event && (event->key.keysym.sym & ~SDLK_SCANCODE_MASK) < 512) { + ImGui_ImplSdl_ProcessEvent(event); + } + return retval; } #include @@ -38,44 +36,53 @@ int SDL_PollEvent_hook(SDL_Event* event) { #include "../gui/im/Im.hpp" void SDL_GL_SwapWindow_hook(SDL_Window* window) { - static SDL_GLContext ctx_tf2 = SDL_GL_GetCurrentContext(); - static SDL_GLContext ctx_imgui = nullptr; - static SDL_GLContext ctx_opengl = nullptr; - if (!disable_visuals) { - PROF_SECTION(DRAW_cheat); - if (!ctx_imgui) { - ctx_imgui = SDL_GL_CreateContext(window); - ImGui_ImplSdl_Init(window); - ctx_opengl = SDL_GL_CreateContext(window); - FTGL_Init(); - textures::Init(); - draw_api::initialize(); - } + static SDL_GLContext ctx_tf2 = SDL_GL_GetCurrentContext(); + static SDL_GLContext ctx_imgui = nullptr; + static SDL_GLContext ctx_cathook = nullptr; - if (!cathook) { - SDL_GL_MakeCurrent(window, ctx_tf2); - SDL_GL_SwapWindow_o(window); - return; - } + static bool init { false }; - SDL_GL_MakeCurrent(window, ctx_opengl); - { - std::lock_guard draw_lock(drawing_mutex); - draw_api::render(); - } - SDL_GL_MakeCurrent(window, ctx_imgui); - { - PROF_SECTION(DRAW_imgui); - ImGui_ImplSdl_NewFrame(window); - menu::im::Render(); - ImGui::Render(); - } - } - { - PROF_SECTION(DRAW_valve); - SDL_GL_MakeCurrent(window, ctx_tf2); - SDL_GL_SwapWindow_o(window); - } + if (!disable_visuals) { + PROF_SECTION(DRAW_cheat); + if (not init) { +#if RENDERING_ENGINE_OPENGL + ctx_imgui = SDL_GL_CreateContext(window); + ImGui_ImplSdl_Init(window); + ctx_cathook = SDL_GL_CreateContext(window); +#elif RENDERING_ENGINE_XOVERLAY + +#elif +#error "Unsupported rendering engine" +#endif + FTGL_Init(); + textures::Init(); + draw_api::initialize(); + } + + if (!cathook) { + SDL_GL_MakeCurrent(window, ctx_tf2); + SDL_GL_SwapWindow_o(window); + return; + } + + SDL_GL_MakeCurrent(window, ctx_cathook); + { + std::lock_guard draw_lock(drawing_mutex); + draw_api::render(); + } + SDL_GL_MakeCurrent(window, ctx_imgui); + { + PROF_SECTION(DRAW_imgui); + ImGui_ImplSdl_NewFrame(window); + menu::im::Render(); + ImGui::Render(); + } + } + { + PROF_SECTION(DRAW_valve); + SDL_GL_MakeCurrent(window, ctx_tf2); + SDL_GL_SwapWindow_o(window); + } } void DoSDLHooking() { @@ -85,14 +92,6 @@ void DoSDLHooking() { SDL_GL_SwapWindow_o = *SDL_GL_SwapWindow_loc; SDL_PollEvent_o = *SDL_PollEvent_loc; - /*char patch_1[4]; - char patch_2[4]; - *((unsigned*)patch_1) = (unsigned)SDL_GL_SwapWindow_hook; - *((unsigned*)patch_2) = (unsigned)SDL_PollEvent_hook; - - Patch(SDL_GL_SwapWindow_loc, patch_1, 4); - Patch(SDL_PollEvent_loc, patch_2, 4);*/ - *SDL_GL_SwapWindow_loc = SDL_GL_SwapWindow_hook; *SDL_PollEvent_loc = SDL_PollEvent_hook; } @@ -102,4 +101,3 @@ void DoSDLUnhooking() { *SDL_PollEvent_loc = SDL_PollEvent_o; } -#endif diff --git a/src/visual/drawex.cpp b/src/visual/drawex.cpp index 9c1f3a62..8ca972df 100644 --- a/src/visual/drawex.cpp +++ b/src/visual/drawex.cpp @@ -10,56 +10,12 @@ extern "C" { -#include "catsmclient.h" +#include "overlay.h" } -#include -#include -#include -#include -#include -#include -#include - -const char *drawex_pipe_name = "/tmp/cathook-rendering-pipe"; - namespace drawex { -cat_shm_render_context_t ctx; -std::thread rendering_thread; - -void rendering_routine() -{ - xpcmutex_t server_throttle_mutex = xpcmutex_connect("rendering-throttle"); - while (true) - { - xpcmutex_lock(server_throttle_mutex); - PROF_SECTION(DRAWEX_rendering_routine); - if (hack::initialized && api::ready_state) - { - BeginCheatVisuals(); - DrawCheatVisuals(); - -#if ENABLE_GUI - g_pGUI->Update(); -#endif - - EndCheatVisuals(); - } - xpcmutex_unlock(server_throttle_mutex); - usleep(1000000 / 45); - //std::this_thread::sleep_for(std::chrono::seconds(1)); - } -} - -CatCommand restart_render("debug_xoverlay_restart", "restart", []() { - api::ready_state = false; - xshm_close(ctx.shm); - xpcmutex_close(ctx.mutex); - api::initialize(); -}); - namespace api { @@ -68,58 +24,65 @@ bool init = false; void initialize() { - if (!init) - rendering_thread = std::thread(rendering_routine); - ctx = cat_shm_connect("cathook-rendering"); - ready_state = true; - init = true; + int status = xoverlay_init(); + if (status < 0) + { + logging::Info("ERROR: could not initialize Xoverlay"); + } } void draw_rect(float x, float y, float w, float h, const float* rgba) { PROF_SECTION(DRAWEX_draw_rect); - cat_shm_render_rect(&ctx, x, y, w, h, rgba); + xoverlay_draw_rect(x, y, w, h, *reinterpret_cast(rgba)); } void draw_rect_outlined(float x, float y, float w, float h, const float* rgba, float thickness) { PROF_SECTION(DRAWEX_draw_rect_outline); - cat_shm_render_rect_outline(&ctx, x, y, w, h, rgba, thickness); + xoverlay_draw_rect_outline(x, y, w, h, *reinterpret_cast(rgba), thickness); } void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness) { PROF_SECTION(DRAWEX_draw_line); - cat_shm_render_line(&ctx, x, y, dx, dy, rgba, thickness); + xoverlay_draw_line(x, y, dx, dy, *reinterpret_cast(rgba), thickness); } -void draw_rect_textured(float x, float y, float w, float h, const float* rgba, float u, float v, float s, float t) +void draw_rect_textured(float x, float y, float w, float h, const float* rgba, texture_handle_t texture, float u, float v, float s, float t) { - assert(0); + PROF_SECTION(DRAWEX_draw_rect_textured); + xoverlay_draw_rect_textured(x, y, w, h, *reinterpret_cast(rgba), texture.handle, u, v, s, t); } void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps) { PROF_SECTION(DRAWEX_draw_circle); - cat_shm_render_circle(&ctx, x, y, radius, rgba, thickness, steps); + xoverlay_draw_circle(x, y, radius, *reinterpret_cast(rgba), thickness, steps); } -void draw_string(float x, float y, const char *string, const float *rgba) +void draw_string(float x, float y, const char *string, font_handle_t font, const float *rgba) { PROF_SECTION(DRAWEX_draw_string); - cat_shm_render_string(&ctx, x, y, string, rgba); + xoverlay_draw_string(x, y, string, font.handle, *reinterpret_cast(rgba), nullptr, nullptr); +} + +void draw_string_with_outline(float x, float y, const char *string, font_handle_t font, const float *rgba, const float *rgba_outline, float thickness) +{ + PROF_SECTION(DRAWEX_draw_string_with_outline); + xoverlay_draw_string_with_outline(x, y, string, font.handle, *reinterpret_cast(rgba), *reinterpret_cast(rgba_outline), thickness, 1, nullptr, nullptr); } void draw_begin() { PROF_SECTION(DRAWEX_draw_begin); - cat_shm_render_begin(&ctx, draw::wts.Base()); + xoverlay_draw_begin(); } void draw_end() { PROF_SECTION(DRAWEX_draw_end); - cat_shm_render_end(&ctx); + xoverlay_draw_end(); } }} diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp index cf14cf80..d2efb569 100644 --- a/src/visual/drawmgr.cpp +++ b/src/visual/drawmgr.cpp @@ -12,10 +12,8 @@ void BeginCheatVisuals() { #if RENDERING_ENGINE_OPENGL std::lock_guard draw_lock(drawing_mutex); #endif - if (draw_api::ready_state) { - draw_api::draw_begin(); - ResetStrings(); - } + draw_api::draw_begin(); + ResetStrings(); } std::mutex drawing_mutex; @@ -27,95 +25,91 @@ void DrawCheatVisuals() { #if RENDERING_ENGINE_OPENGL std::lock_guard draw_lock(drawing_mutex); #endif - if (draw_api::ready_state) { - { - PROF_SECTION(DRAW_misc); - SAFE_CALL(hacks::shared::misc::DrawText()); - } - if (info_text) { - PROF_SECTION(DRAW_info); - std::string name_s, reason_s; - PROF_SECTION(PT_info_text); - AddSideString("cathook by nullifiedcat", colors::RainbowCurrent()); - if (!info_text_min) { - AddSideString(hack::GetVersion(), GUIColor()); // github commit and date - AddSideString(hack::GetType(), GUIColor()); // Compile type + { + PROF_SECTION(DRAW_misc); + SAFE_CALL(hacks::shared::misc::DrawText()); + } + if (info_text) { + PROF_SECTION(DRAW_info); + std::string name_s, reason_s; + PROF_SECTION(PT_info_text); + AddSideString("cathook by nullifiedcat", colors::RainbowCurrent()); + if (!info_text_min) { + AddSideString(hack::GetVersion(), GUIColor()); // github commit and date + AddSideString(hack::GetType(), GUIColor()); // Compile type #if ENABLE_GUI - AddSideString("Press 'INSERT' or 'F11' key to open/close cheat menu.", GUIColor()); - AddSideString("Use mouse to navigate in menu.", GUIColor()); + AddSideString("Press 'INSERT' or 'F11' key to open/close cheat menu.", GUIColor()); + AddSideString("Use mouse to navigate in menu.", GUIColor()); #endif - if (!g_IEngine->IsInGame() + if (!g_IEngine->IsInGame() #if ENABLE_GUI - || g_pGUI->Visible() + || g_pGUI->Visible() #endif - ) { - name_s = force_name.GetString(); - if (name_s.length() < 3) name_s = "*Not Set*"; - reason_s = disconnect_reason.GetString(); - if (reason_s.length() < 3) reason_s = "*Not Set*"; - AddSideString(""); // foolish - AddSideString(format("Custom Name: ", name_s), GUIColor()); - AddSideString(format("Custom Disconnect Reason: ", reason_s), GUIColor()); - } - } - } - if (spectator_target) { - AddCenterString("Press SPACE to stop spectating"); - } - if (CE_GOOD(g_pLocalPlayer->entity) && !g_Settings.bInvalid) { - PROF_SECTION(PT_total_hacks); - { - PROF_SECTION(DRAW_aimbot); - hacks::shared::aimbot::DrawText(); - } - IF_GAME(IsTF2()) { - PROF_SECTION(DRAW_skinchanger); - SAFE_CALL(hacks::tf2::skinchanger::DrawText()); - } + ) { + name_s = force_name.GetString(); + if (name_s.length() < 3) name_s = "*Not Set*"; + reason_s = disconnect_reason.GetString(); + if (reason_s.length() < 3) reason_s = "*Not Set*"; + AddSideString(""); // foolish + AddSideString(format("Custom Name: ", name_s), GUIColor()); + AddSideString(format("Custom Disconnect Reason: ", reason_s), GUIColor()); + } + } + } + if (spectator_target) { + AddCenterString("Press SPACE to stop spectating"); + } + if (CE_GOOD(g_pLocalPlayer->entity) && !g_Settings.bInvalid) { + PROF_SECTION(PT_total_hacks); + { + PROF_SECTION(DRAW_aimbot); + hacks::shared::aimbot::DrawText(); + } + IF_GAME(IsTF2()) { + PROF_SECTION(DRAW_skinchanger); + SAFE_CALL(hacks::tf2::skinchanger::DrawText()); + } #ifndef FEATURE_RADAR_DISABLED - IF_GAME(IsTF()) { - PROF_SECTION(DRAW_radar); - SAFE_CALL(hacks::tf::radar::Draw()); - } + IF_GAME(IsTF()) { + PROF_SECTION(DRAW_radar); + SAFE_CALL(hacks::tf::radar::Draw()); + } #endif - IF_GAME(IsTF2()) { - PROF_SECTION(DRAW_healarrows); - hacks::tf2::healarrow::Draw(); - } - { - PROF_SECTION(DRAW_walkbot); - hacks::shared::walkbot::Draw(); - } - IF_GAME(IsTF()) { - PROF_SECTION(PT_antidisguise); - SAFE_CALL(hacks::tf2::antidisguise::Draw()); - } - IF_GAME(IsTF()) { - PROF_SECTION(PT_spyalert); - SAFE_CALL(hacks::tf::spyalert::Draw()); - } + IF_GAME(IsTF2()) { + PROF_SECTION(DRAW_healarrows); + hacks::tf2::healarrow::Draw(); + } + { + PROF_SECTION(DRAW_walkbot); + hacks::shared::walkbot::Draw(); + } + IF_GAME(IsTF()) { + PROF_SECTION(PT_antidisguise); + SAFE_CALL(hacks::tf2::antidisguise::Draw()); + } + IF_GAME(IsTF()) { + PROF_SECTION(PT_spyalert); + SAFE_CALL(hacks::tf::spyalert::Draw()); + } #if ENABLE_IPC == 1 - IF_GAME(IsTF()) SAFE_CALL(hacks::shared::followbot::Draw()); + IF_GAME(IsTF()) SAFE_CALL(hacks::shared::followbot::Draw()); #endif - { - PROF_SECTION(DRAW_esp); - hacks::shared::esp::Draw(); - } + { + PROF_SECTION(DRAW_esp); + hacks::shared::esp::Draw(); + } #ifndef FEATURE_FIDGET_SPINNER_DISABLED - DrawSpinner(); + DrawSpinner(); #endif - Prediction_PaintTraverse(); - } - { - PROF_SECTION(DRAW_strings); - DrawStrings(); - } - } + Prediction_PaintTraverse(); + } + { + PROF_SECTION(DRAW_strings); + DrawStrings(); + } } void EndCheatVisuals() { - if (draw_api::ready_state) { - draw_api::draw_end(); - } + draw_api::draw_end(); } diff --git a/src/xpcmutex.c b/src/xpcmutex.c deleted file mode 100644 index 6f7e9b2c..00000000 --- a/src/xpcmutex.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * xpcmutex.c - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#include "xpcmutex.h" - -#include -#include -#include -#include -#include -#include - -xpcmutex_t -xpcmutex_init(const char *name) -{ - xpcmutex_t mutex; - strncpy(mutex.name, name, sizeof(mutex.name) - 1); - char filename[128]; - snprintf(filename, 127, "/tmp/.xpcmutex.%s", mutex.name); - int mask = umask(0); - remove(filename); - mkfifo(filename, 0666); - umask(mask); - mutex.fd = open(filename, O_RDWR); - xpcmutex_unlock(mutex); - return mutex; -} - -xpcmutex_t -xpcmutex_connect(const char *name) -{ - xpcmutex_t mutex; - strncpy(mutex.name, name, sizeof(mutex.name) - 1); - char filename[128]; - snprintf(filename, 127, "/tmp/.xpcmutex.%s", mutex.name); - mutex.fd = open(filename, O_RDWR); - return mutex; -} - -void -xpcmutex_close(xpcmutex_t mutex) -{ - close(mutex.fd); -} - -void -xpcmutex_destroy(xpcmutex_t mutex) -{ - char filename[128]; - snprintf(filename, 127, "/tmp/.xpcmutex.%s", mutex.name); - remove(filename); -} - -void -xpcmutex_lock(xpcmutex_t mutex) -{ - char buf[1]; - while (1 != read(mutex.fd, buf, 1)) - { - usleep(10); - } -} - -void -xpcmutex_unlock(xpcmutex_t mutex) -{ - while (1 != write(mutex.fd, "1", 1)) - { - usleep(10); - } -} diff --git a/src/xshm.c b/src/xshm.c deleted file mode 100644 index 224f77a4..00000000 --- a/src/xshm.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * xshm.c - * - * Created on: Nov 12, 2017 - * Author: nullifiedcat - */ - -#include "xshm.h" - -#include -#include -#include -#include -#include -#include - -xshm_t -xshm_init(const char *name, uint32_t size) -{ - xshm_t xshm; - strncpy(xshm.name, name, sizeof(xshm.name) - 1); - char filename[128]; - snprintf(filename, 127, "xshm_%s", xshm.name); - xshm.size = size; - shm_unlink(xshm.name); - int omask = umask(0); - int flags = O_RDWR | O_CREAT; - int fd = shm_open(xshm.name, flags, S_IRWXU | S_IRWXG | S_IRWXO); - if (fd < 0) - { - perror("xshm opening error\n"); - return xshm; - } - if (ftruncate(fd, size) != 0) - { - perror("xshm opening error\n"); - return xshm; - } - umask(omask); - xshm.data = mmap(0, size, PROT_WRITE | PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); - if (xshm.data == (void *) -1) - { - perror("xshm mapping error\n"); - return xshm; - } - close(fd); - return xshm; -} - -xshm_t -xshm_connect(const char *name, uint32_t size) -{ - xshm_t xshm; - strncpy(xshm.name, name, sizeof(xshm.name) - 1); - char filename[128]; - snprintf(filename, 127, "xshm_%s", xshm.name); - xshm.size = size; - int omask = umask(0); - int flags = O_RDWR; - int fd = shm_open(xshm.name, flags, S_IRWXU | S_IRWXG | S_IRWXO); - if (fd < 0) - { - perror("xshm opening error\n"); - return xshm; - } - if (ftruncate(fd, size) != 0) - { - perror("xshm opening error\n"); - return xshm; - } - umask(omask); - xshm.data = mmap(0, size, PROT_WRITE | PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); - if (xshm.data == (void *) -1) - { - perror("xshm mapping error\n"); - return xshm; - } - close(fd); - return xshm; -} - -void -xshm_destroy(xshm_t xshm) -{ - munmap(xshm.data, xshm.size); - shm_unlink(xshm.name); -} - -void -xshm_close(xshm_t xshm) -{ - munmap(xshm.data, xshm.size); -} - -