unfinished changes - RENDERING_ENGINE_OPENGL is to be removed later.
This commit is contained in:
parent
c78d9feb4c
commit
717b66c222
@ -110,6 +110,7 @@
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1494960833" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
|
||||
<option id="gnu.both.asm.option.include.paths.536294380" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/cathook/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/cathook/xoverlay}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.517639342" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* catpackets.h
|
||||
*
|
||||
* Created on: Nov 12, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
};
|
||||
*/
|
@ -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);
|
@ -43,6 +43,11 @@
|
||||
#include <elf.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>=
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "timer.hpp"
|
||||
#include "averager.hpp"
|
||||
@ -62,7 +67,8 @@ extern "C" {
|
||||
#include <visual/ftrender.hpp>
|
||||
#include <visual/drawing.hpp>
|
||||
#include "fidgetspinner.hpp"
|
||||
#include<visual/drawex.hpp>#include <visual/EffectGlow.hpp>
|
||||
#include <visual/drawex.hpp>
|
||||
#include <visual/EffectGlow.hpp>
|
||||
#include <visual/atlas.hpp>
|
||||
#include <visual/EffectChams.hpp>
|
||||
#include <visual/drawmgr.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"
|
||||
|
@ -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();
|
||||
|
@ -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);
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* xshm.h
|
||||
*
|
||||
* Created on: Nov 12, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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...");
|
||||
|
@ -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 <link.h>
|
||||
|
||||
@ -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 <GL/gl.h>
|
||||
@ -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<std::mutex> 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<std::mutex> 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
|
||||
|
@ -10,56 +10,12 @@
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "catsmclient.h"
|
||||
#include "overlay.h"
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
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<xoverlay_rgba_t *>(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<xoverlay_rgba_t *>(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<xoverlay_rgba_t *>(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<xoverlay_rgba_t *>(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<xoverlay_rgba_t *>(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<xoverlay_rgba_t *>(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<xoverlay_rgba_t *>(rgba), *reinterpret_cast<xoverlay_rgba_t *>(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();
|
||||
}
|
||||
|
||||
}}
|
||||
|
@ -12,10 +12,8 @@ void BeginCheatVisuals() {
|
||||
#if RENDERING_ENGINE_OPENGL
|
||||
std::lock_guard<std::mutex> 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<std::mutex> 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();
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* xpcmutex.c
|
||||
*
|
||||
* Created on: Nov 12, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "xpcmutex.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
95
src/xshm.c
95
src/xshm.c
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* xshm.c
|
||||
*
|
||||
* Created on: Nov 12, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "xshm.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user