doesn't work

This commit is contained in:
nullifiedcat 2017-11-12 20:00:57 +03:00
parent c3b41f9acb
commit 8cc5db22dc
31 changed files with 692 additions and 359 deletions

View File

@ -34,8 +34,8 @@
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1168214098" name="Main" parent="cdt.managedbuild.config.gnu.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1168214098." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.965909756" name="Linux GCC" nonInternalBuilderId="cdt.managedbuild.target.gnu.builder.exe.debug" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1799148153" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder arguments="BUILD_DEBUG=1" buildPath="${workspace_loc:/cathook}" command="make" id="cdt.managedbuild.target.gnu.builder.exe.debug.1548213350" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<targetPlatform binaryParser="org.eclipse.cdt.core.GNU_ELF" id="cdt.managedbuild.target.gnu.platform.exe.debug.1799148153" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder arguments="BUILD_DEBUG=1 NO_WARNINGS=1 RENDERING_ENGINE=XOVERLAY" buildPath="${workspace_loc:/cathook}" command="make" id="cdt.managedbuild.target.gnu.builder.exe.debug.1548213350" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.782611349" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.883030293" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.908662295" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>

View File

@ -72,7 +72,7 @@ endif
DEFINES=
ifeq ($(EXTERNAL_RENDERING), 1)
ifeq ($(RENDERING_ENGINE), XOVERLAY)
ENABLE_GUI=0
endif
@ -106,9 +106,6 @@ CXXFLAGS+=$(WARNING_FLAGS)
endif
ifeq ($(ENABLE_VISUALS),1)
ifeq ($(RENDERING_ENGINE), xoverlay)
LDLIBS+=-loverlay
endif
INCLUDES+=-isystemsrc/freetype-gl -isystemsrc/imgui -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2
LDLIBS+=-lssl -l:libSDL2-2.0.so.0 -l:libGLEW.so -l:libfreetype.so
CXXFLAGS+=$(shell sdl2-config --cflags)

View File

@ -1,87 +0,0 @@
/*
* catpclient.c
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#include "catpclient.h"
#include "catpackets.h"
#include "pipepacket.h"
void
cat_send_render_packet_begin(int fd, const float *world_to_screen)
{
struct catp_draw_begin_t packet;
memcpy(packet.world_to_screen, world_to_screen, sizeof(float) * 16);
pipe_packet_send(fd, CATP_DRAW_BEGIN, sizeof(packet), &packet);
}
void
cat_send_render_packet_end(int fd)
{
pipe_packet_send(fd, CATP_DRAW_END, 0, 0);
}
void
cat_send_render_packet_rect(int fd, 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);
pipe_packet_send(fd, CATP_DRAW_RECT, sizeof(packet), &packet);
}
void
cat_send_render_packet_rect_outline(int fd, 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;
pipe_packet_send(fd, CATP_DRAW_RECT_OUTLINE, sizeof(packet), &packet);
}
void
cat_send_render_packet_line(int fd, 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;
pipe_packet_send(fd, CATP_DRAW_LINE, sizeof(packet), &packet);
}
void
cat_send_render_packet_string(int fd, 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);
pipe_packet_send(fd, CATP_DRAW_STRING, sizeof(packet), &packet);
pipe_packet_write_manual(fd, packet.length, string);
}
void
cat_send_render_packet_circle(int fd, 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);
pipe_packet_send(fd, CATP_DRAW_CIRCLE, sizeof(packet), &packet);
}

View File

@ -1,29 +0,0 @@
/*
* catpclient.h
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#pragma once
void
cat_send_render_packet_begin(int fd, const float *world_to_screen);
void
cat_send_render_packet_end(int fd);
void
cat_send_render_packet_rect(int fd, float x, float y, float w, float h, const float *rgba);
void
cat_send_render_packet_rect_outline(int fd, float x, float y, float w, float h, const float *rgba, float thickness);
void
cat_send_render_packet_line(int fd, float x, float y, float dx, float dy, const float *rgba, float thickness);
void
cat_send_render_packet_string(int fd, float x, float y, const char *string, const float *rgba);
void
cat_send_render_packet_circle(int fd, float x, float y, float radius, const float *rgba, float thickness, int steps);

103
src/catsmclient.c Normal file
View File

@ -0,0 +1,103 @@
/*
* 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)
{
xpcmutex_unlock(ctx->mutex);
cat_shm_packet_send(ctx, CATP_DRAW_END, 0, 0);
}
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);
}

36
src/catsmclient.h Normal file
View File

@ -0,0 +1,36 @@
/*
* 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);

View File

@ -8,7 +8,11 @@
#include "drawing.h"
#include "colors.hpp"
#include "drawex.hpp"
#include "hack.h"
extern "C"
{
#include "catpclient.h"
}
#include <stdio.h>
#include <fcntl.h>
@ -24,30 +28,58 @@ namespace drawex
{
int pipe_fd;
std::thread rendering_thread;
void rendering_routine()
{
while (true)
{
PROF_SECTION(DRAWEX_rendering_routine)
if (hack::initialized)
{
draw::UpdateWTS();
BeginCheatVisuals();
DrawCheatVisuals();
#if ENABLE_GUI
g_pGUI->Update();
#endif
EndCheatVisuals();
}
std::this_thread::sleep_for(std::chrono::microseconds(100));
}
}
namespace api
{
bool ready_state = false;
void intialize()
void initialize()
{
rendering_thread = std::thread(rendering_routine);
pipe_fd = open(drawex_pipe_name, O_WRONLY);
ready_state = true;
logging::Info("Xoverlay initialized, pipe: %d", pipe_fd);
logging::Info("errno: %d", errno);
}
void draw_rect(float x, float y, float w, float h, const float* rgba)
{
PROF_SECTION(DRAWEX_draw_rect);
cat_send_render_packet_rect(pipe_fd, x, y, w, h, 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_send_render_packet_rect_outline(pipe_fd, x, y, w, h, rgba, thickness);
}
void draw_line(float x, float y, float dx, float dy, const float* rgba, float thickness)
{
PROF_SECTION(DRAWEX_draw_line);
cat_send_render_packet_line(pipe_fd, x, y, dx, dy, rgba, thickness);
}
@ -58,16 +90,25 @@ void draw_rect_textured(float x, float y, float w, float h, const float* rgba, f
void draw_circle(float x, float y, float radius, const float *rgba, float thickness, int steps)
{
PROF_SECTION(DRAWEX_draw_circle);
cat_send_render_packet_circle(pipe_fd, x, y, radius, rgba, thickness, steps);
}
void draw_string(float x, float y, const char *string, const float *rgba)
{
PROF_SECTION(DRAWEX_draw_string);
cat_send_render_packet_string(pipe_fd, x, y, string, rgba);
}
void draw_begin()
{
PROF_SECTION(DRAWEX_draw_begin);
cat_send_render_packet_begin(pipe_fd, draw::wts.Base());
}
void draw_end()
{
PROF_SECTION(DRAWEX_draw_end);
cat_send_render_packet_end(pipe_fd);
}

View File

@ -7,25 +7,31 @@
#pragma once
#include <thread>
#define draw_api drawex::api
namespace drawex
{
extern int pipe_fd;
extern std::thread rendering_thread;
void rendering_routine();
namespace api
{
extern bool ready_state;
void intialize();
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_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_begin();
void draw_end();

View File

@ -32,7 +32,7 @@ mat4 model, view, projection;
bool ready_state = false;
void intialize() {
void initialize() {
buffer_lines = vertex_buffer_new("vertex:2f,color:4f");
buffer_triangles_plain = vertex_buffer_new("vertex:2f,color:4f");
buffer_triangles_textured = vertex_buffer_new("vertex:2f,tex_coord:2f,color:4f");
@ -146,10 +146,16 @@ void draw_circle(float x, float y, float radius, const float *rgba, float thickn
}
}
void draw_string(float x, float y, const char *string, const float *rgba)
{
FTGL_Draw(std::string(string), x, y, fonts::font_main, rgba_t(rgba[0], rgba[1], rgba[2], rgba[3]), nullptr, nullptr);
}
void draw_begin() {
vertex_buffer_clear(buffer_triangles_plain);
vertex_buffer_clear(buffer_triangles_textured);
vertex_buffer_clear(buffer_lines);
FTGL_NewFrame();
}
void render_begin() {

View File

@ -36,13 +36,14 @@ extern ftgl::vertex_buffer_t* buffer_triangles_textured;
extern const float white[4];
void intialize();
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_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_begin();
void draw_end();

View File

@ -39,15 +39,15 @@ void AddSideString(const std::string& string, const rgba_t& color) {
void DrawStrings() {
int y { 8 };
for (size_t i = 0; i < side_strings_count; ++i) {
FTGL_Draw(side_strings[i], 8, y, fonts::font_main, side_strings_colors[i]);
y += fonts::font_main->height + 1;
draw_api::draw_string(8, y, side_strings[i].c_str(), side_strings_colors[i]);
y += /*((int)fonts::font_main->height)*/ 14 + 1;
}
y = draw::height / 2;
for (size_t i = 0; i < center_strings_count; ++i) {
int sx;
FTGL_StringLength(center_strings[i], fonts::font_main, &sx, nullptr);
FTGL_Draw(center_strings[i], (draw::width - sx) / 2, y, fonts::font_main, center_strings_colors[i]);
y += fonts::font_main->height + 1;
//FTGL_StringLength(center_strings[i], fonts::font_main, &sx, nullptr);
draw_api::draw_string((draw::width) / 2, y, center_strings[i].c_str(), center_strings_colors[i]);
y += /*((int)fonts::font_main->height)*/ 14 + 1;
}
}
@ -74,8 +74,8 @@ void draw::Initialize() {
if (!draw::width || !draw::height) {
g_IEngine->GetScreenSize(draw::width, draw::height);
}
draw_api::intialize();
#ifdef RENDERING_ENGINE_OPENGL
draw_api::initialize();
#if RENDERING_ENGINE_OPENGL
FTGL_PreInit();
fonts::font_ftgl.InstallChangeCallback([](IConVar* var, const char* pOldValue, float flOldValue) {
@ -100,7 +100,7 @@ bool draw::EntityCenterToScreen(CachedEntity* entity, Vector& out) {
VMatrix draw::wts {};
void draw::UpdateWTS() {
memcpy(&wts, &g_IEngine->WorldToScreenMatrix(), sizeof(VMatrix));
memcpy(&draw::wts, &g_IEngine->WorldToScreenMatrix(), sizeof(VMatrix));
}
bool draw::WorldToScreen(const Vector& origin, Vector& screen) {

View File

@ -8,9 +8,9 @@
#ifndef DRAWING_H_
#define DRAWING_H_
#if RENDERING_ENGINE_OPENGL
#if defined(RENDERING_ENGINE_OPENGL)
#define DRAW_API "drawgl.hpp"
#elif RENDERING_ENGINE_XOVERLAY
#elif defined(RENDERING_ENGINE_XOVERLAY)
#define DRAW_API "drawex.hpp"
#endif

View File

@ -9,9 +9,10 @@
#include "hack.h"
void BeginCheatVisuals() {
#if RENDERING_ENGINE_OPENGL
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
#endif
if (draw_api::ready_state) {
FTGL_NewFrame();
draw_api::draw_begin();
ResetStrings();
}
@ -23,7 +24,9 @@ CatVar info_text(CV_SWITCH, "info", "1", "Show info", "Show cathook version in t
CatVar info_text_min(CV_SWITCH, "info_min", "0", "Show minimal info", "Only show cathook title in top left corner");
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);
@ -69,7 +72,7 @@ void DrawCheatVisuals() {
PROF_SECTION(DRAW_skinchanger);
SAFE_CALL(hacks::tf2::skinchanger::DrawText());
}
#ifndef FEATURES_RADAR_DISABLED
#ifndef FEATURE_RADAR_DISABLED
IF_GAME(IsTF()) {
PROF_SECTION(DRAW_radar);
SAFE_CALL(hacks::tf::radar::Draw());
@ -113,6 +116,6 @@ void DrawCheatVisuals() {
void EndCheatVisuals() {
if (draw_api::ready_state) {
draw_api::draw_end();
}
}

View File

@ -5,6 +5,10 @@
* Author: nullifiedcat
*/
#include "common.h"
#ifdef RENDERING_ENGINE_OPENGL
#include "ftrender.hpp"
extern "C" {
@ -170,3 +174,5 @@ void FTGL_StringLength(const std::string& text, ftgl::texture_font_t* font, int
if (size_x) *size_x = pen.x;
if (size_y) *size_y = pen.y;
}
#endif

View File

@ -59,6 +59,7 @@
*/
bool hack::shutdown = false;
bool hack::initialized = false;
const std::string& hack::GetVersion() {
static std::string version("Unknown Version");
@ -251,7 +252,7 @@ void hack::Initialize() {
hooks::clientmode.HookMethod((void*)CreateMove_hook, offsets::CreateMove());
#if ENABLE_VISUALS == 1
hooks::clientmode.HookMethod((void*)OverrideView_hook, offsets::OverrideView());
#endif /* TEXTMODE */
#endif
hooks::clientmode.HookMethod((void*)LevelInit_hook, offsets::LevelInit());
hooks::clientmode.HookMethod((void*)LevelShutdown_hook, offsets::LevelShutdown());
hooks::clientmode.Apply();
@ -282,7 +283,7 @@ void hack::Initialize() {
#endif
#if ENABLE_VISUALS == 1
hooks::client.HookMethod((void*)IN_KeyEvent_hook, offsets::IN_KeyEvent());
#endif /* TEXTMODE */
#endif
hooks::client.Apply();
hooks::input.Set(g_IInput);
hooks::input.HookMethod((void*)GetUserCmd_hook, offsets::GetUserCmd());
@ -291,7 +292,7 @@ void hack::Initialize() {
hooks::modelrender.Set(g_IVModelRender);
hooks::modelrender.HookMethod((void*)DrawModelExecute_hook, offsets::DrawModelExecute());
hooks::modelrender.Apply();
#endif /* TEXTMODE */
#endif
hooks::steamfriends.Set(g_ISteamFriends);
hooks::steamfriends.HookMethod((void*)GetFriendPersonaName_hook, offsets::GetFriendPersonaName());
hooks::steamfriends.Apply();
@ -364,6 +365,7 @@ void hack::Initialize() {
hack::command_stack().push("exec cat_autoexec");
hack::command_stack().push("cat_killsay_reload");
hack::command_stack().push("cat_spam_reload");
hack::initialized = true;
}
void hack::Think() {
@ -374,7 +376,9 @@ 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...");

View File

@ -28,6 +28,7 @@ std::stack<std::string>& command_stack();
void ExecuteCommand(const std::string command);
extern bool shutdown;
extern bool initialized;
const std::string& GetVersion();
const std::string& GetType();

View File

@ -22,7 +22,7 @@ CatVar box_corner_size(CV_INT, "esp_box_corner_size", "10", "Corner Size");
CatEnum tracers_enum({ "OFF", "CENTER", "BOTTOM" });
CatVar tracers(tracers_enum, "esp_tracers", "0", "Tracers", "SDraws a line from the player to a position on your screen");
// Emoji Esp
#ifndef FEATURES_EMOJI_ESP_DISABLED
#ifndef FEATURE_EMOJI_ESP_DISABLED
CatEnum emoji_esp_enum({ "None", "Joy", "Thinking" });
CatVar emoji_esp(emoji_esp_enum, "esp_emoji", "0", "Emoji ESP", "Draw emoji on peopels head");
CatVar emoji_esp_size(CV_FLOAT, "esp_emoji_size", "32", "Emoji ESP Size");
@ -503,13 +503,13 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
draw_point = Vector(max_x + 2, min_y, 0);
} break;
case 1: { // BOTTOM RIGHT
draw_point = Vector(max_x + 2, max_y - data.at(ent->m_IDX).string_count * ((int)fonts::font_main->height), 0);
draw_point = Vector(max_x + 2, max_y - data.at(ent->m_IDX).string_count * /*((int)fonts::font_main->height)*/ 14, 0);
} break;
case 2: { // CENTER
origin_is_zero = true; // origin is still zero so we set to true
} break;
case 3: { // ABOVE
draw_point = Vector(min_x, min_y - data.at(ent->m_IDX).string_count * ((int)fonts::font_main->height), 0);
draw_point = Vector(min_x, min_y - data.at(ent->m_IDX).string_count * /*((int)fonts::font_main->height)*/ 14, 0);
} break;
case 4: { // BELOW
draw_point = Vector(min_x, max_y, 0);
@ -532,16 +532,16 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
if (transparent) color = colors::Transparent(color); // Apply transparency if needed
// If the origin is centered, we use one method. if not, the other
if (!origin_is_zero) {
FTGL_Draw(string.data, draw_point.x, draw_point.y, fonts::font_main, color);
} else {
if (!origin_is_zero || true) {
draw_api::draw_string(draw_point.x, draw_point.y, string.data.c_str(), color);
} else {/*
int size_x;
FTGL_StringLength(string.data, fonts::font_main, &size_x);
FTGL_Draw(string.data, draw_point.x - size_x / 2, draw_point.y, fonts::font_main, color);
}
*/}
// Add to the y due to their being text in that spot
draw_point.y += (int)fonts::font_main->height - 1;
draw_point.y += /*((int)fonts::font_main->height)*/ 14 - 1;
}
}

View File

@ -30,6 +30,7 @@ CatVar show_healthpacks(CV_SWITCH, "radar_healthpacks", "1", "Show Healthpacks")
CatVar show_ammopacks(CV_SWITCH, "radar_ammopacks", "1", "Show Ammopacks");
void Init() {
#if RENDERING_ENGINE_OPENGL
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
tx_classes[i][j].reset(new textures::AtlasTexture(64 * j, textures::atlas_height - 64 * (i + 1), 64, 64));
@ -40,6 +41,7 @@ void Init() {
tx_items[0].reset(new textures::AtlasTexture(10 * 64, textures::atlas_height - 64, 64, 64));
tx_items[1].reset(new textures::AtlasTexture(10 * 64, textures::atlas_height - 128, 64, 64));
#endif
}
std::pair<int, int> WorldToRadar(int x, int y) {

View File

@ -834,9 +834,9 @@ void DrawConnection(index_t a, connection_s& b) {
std::string flags;
if (b.flags & CF_LOW_AMMO) flags += "A";
if (b.flags & CF_LOW_HEALTH) flags += "H";
int size_x = 0, size_y = 0;
FTGL_StringLength(flags, fonts::font_main, &size_x, &size_y);
FTGL_Draw(flags, wts_cc.x - size_x / 2, wts_cc.y - size_y - 4, fonts::font_main);
//int size_x = 0, size_y = 0;
//FTGL_StringLength(flags, fonts::font_main, &size_x, &size_y);
draw_api::draw_string(wts_cc.x, wts_cc.y - 4, flags.c_str(), colors::white);
}
}
@ -880,7 +880,7 @@ void DrawNode(index_t node, bool draw_back) {
if (not draw::WorldToScreen(n.xyz(), wts))
return;
FTGL_Draw(std::to_string(node), wts.x, wts.y, fonts::font_main, *color);
draw_api::draw_string(wts.x, wts.y, std::to_string(node).c_str(), *color);
}
}

View File

@ -5,8 +5,8 @@
* Author: nullifiedcat
*/
#include "PaintTraverse.h"
#include "../common.h"
#include "PaintTraverse.h"
#include "../hack.h"
#include "hookedmethods.h"
#include "../segvcatch/segvcatch.h"
@ -25,7 +25,7 @@ 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");
void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
static const PaintTraverse_t original = (PaintTraverse_t)hooks::panel.GetMethod(offsets::PaintTraverse());
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;
@ -44,7 +44,7 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
#if ENABLE_VISUALS == 1
if (!textures_loaded) {
textures_loaded = true;
#ifndef FEATURES_RADAR_DISABLED
#ifndef FEATURE_RADAR_DISABLED
hacks::tf::radar::Init();
#endif
}
@ -91,7 +91,6 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
PROF_SECTION(PT_total);
if (vp == panel_top) draw_flag = true;
if (!cathook) return;
@ -132,6 +131,7 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
if (clean_screenshots && g_IEngine->IsTakingScreenshot()) return;
PROF_SECTION(PT_active);
#if RENDERING_ENGINE_OPENGL
#if ENABLE_VISUALS == 1
draw::UpdateWTS();
BeginCheatVisuals();
@ -142,8 +142,8 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
g_pGUI->Update();
#endif
EndCheatVisuals();
#endif
#endif
SEGV_END;
}

View File

@ -42,6 +42,8 @@ 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;
@ -55,6 +57,8 @@ void SDL_GL_SwapWindow_hook(SDL_Window* window);
void DoSDLHooking();
void DoSDLUnhooking();
#endif
#include "CreateMove.h"
#include "PaintTraverse.h"
#include "others.h"

View File

@ -5,8 +5,11 @@
* Author: nullifiedcat
*/
#include "hookedmethods.h"
#include "../common.h"
#ifdef RENDERING_ENGINE_OPENGL
#include "hookedmethods.h"
#include "../hack.h"
#include <link.h>
@ -46,7 +49,7 @@ void SDL_GL_SwapWindow_hook(SDL_Window* window) {
ctx_opengl = SDL_GL_CreateContext(window);
FTGL_Init();
textures::Init();
draw_api::intialize();
draw_api::initialize();
}
if (!cathook) {
@ -98,3 +101,5 @@ void DoSDLUnhooking() {
*SDL_GL_SwapWindow_loc = SDL_GL_SwapWindow_o;
*SDL_PollEvent_loc = SDL_PollEvent_o;
}
#endif

View File

@ -1,136 +0,0 @@
/*
* pipepacket.c
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#include "pipepacket.h"
#include <unistd.h>
#include <stdio.h>
int
pipe_packet_send(int fd, uint16_t type, uint32_t length, void *data)
{
int status;
unsigned total = 0;
unsigned size = 0;
struct pipe_packet_header_t header;
header.magic = PIPE_PACKET_MAGIC;
header.type = type;
header.length = length;
if (pipe_packet_write_manual(fd, sizeof(struct pipe_packet_header_t), &header) < 0)
return -1;
if (length != 0)
{
if (pipe_packet_write_manual(fd, length, data) < 0)
return -1;
uint16_t magic = PIPE_PACKET_MAGIC_DATA_END;
write(fd, &magic, sizeof(magic));
}
return 0;
}
int
pipe_packet_write_manual(int fd, uint32_t length, void *data)
{
uint32_t total = 0;
uint32_t size;
int status;
while (total < length)
{
size = length - total;
status = write(fd, data + total, size);
if (status < 0)
{
perror("pipe_packet write error");
return -1;
}
total += status;
}
return 0;
}
void*
pipe_packet_read(int fd, struct pipe_packet_header_t *header)
{
int capacity = 80;
uint8_t *data = malloc(capacity);
int status;
int total = 0;
int size = 0;
while (total < sizeof(struct pipe_packet_header_t))
{
status = read(fd, (void *)(header + total), sizeof(struct pipe_packet_header_t) - total);
if (status < 0)
{
perror("pipe_packet read error");
return NULL;
}
total += status;
}
if (header->magic != PIPE_PACKET_MAGIC)
{
fprintf(stderr, "pipe_packet read corrupted packet\n");
return NULL;
}
if (header->length != 0)
{
total = 0;
while (total < header->length)
{
if (capacity - total < 60)
{
capacity *= 2 + 14;
data = realloc(data, capacity);
}
size = header->length - total;
if (size > capacity)
size = capacity;
status = read(fd, data, size);
if (status < 0)
{
perror("pipe_packet read error");
return NULL;
}
total += status;
}
uint16_t magic;
read(fd, &magic, sizeof(magic));
if (magic != PIPE_PACKET_MAGIC_DATA_END)
{
fprintf(stderr, "pipe_packet read corrupted packet\n");
return NULL;
}
}
return (void *)data;
}
int
pipe_packet_read_manual(int fd, uint32_t length, void *data)
{
uint32_t total = 0;
uint32_t size;
int status;
while (total < length)
{
size = length - total;
status = read(fd, data + total, size);
if (status < 0)
{
perror("pipe_packet read error");
return -1;
}
total += status;
}
return 0;
}

View File

@ -1,54 +0,0 @@
/*
* pipepacket.h
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#pragma once
#include <stdint.h>
#define PIPE_PACKET_MAGIC (unsigned short)0xCA75
#define PIPE_PACKET_MAGIC_DATA_END (unsigned short)0x2710
struct pipe_packet_header_t
{
uint16_t magic;
uint16_t type;
uint32_t length;
};
/*
* Sends packet to pipe
* Returns 0 on success, -1 on failure
*/
int
pipe_packet_send(int fd, uint16_t type, uint32_t length, void *data);
/*
* DANGEROUS!
* Writes bytes of data to pipe.
* Returns 0 on success, -1 on failure
*/
int
pipe_packet_write_manual(int fd, uint32_t length, void *data);
/*
* Reads a packet from the pipe.
* Returns pointer to memory with packet data
* or NULL if read failed
* or valid pointer to undefined data if packet has 0 length
* Writes packet header data into *header
*/
void*
pipe_packet_read(int fd, struct pipe_packet_header_t *header);
/*
* DANGEROUS!
* Reads bytes of data from pipe.
* Returns 0 on success, -1 on failure
* Writes data into *data
*/
int
pipe_packet_read_manual(int fd, uint32_t length, void *data);

149
src/shmstream.c Normal file
View File

@ -0,0 +1,149 @@
/*
* shmstream.c
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#include "shmstream.h"
#include <unistd.h>
#include <stdio.h>
int
cat_shm_packet_send(cat_shm_render_context_t *ctx, uint16_t type, uint32_t length, void *data)
{
cat_shm_packet_header_t packet;
packet.magic = CAT_SHM_PACKET_MAGIC;
packet.type = type;
packet.length = length;
if (cat_shm_packet_write_manual(ctx, sizeof(packet), &packet) < 0)
return -1;
if (length != 0)
{
if (cat_shm_packet_write_manual(ctx, length, data) < 0)
return -1;
}
((struct cat_shm_header_s *)ctx->shm.data)->lastpacket++;
return 0;
}
int
cat_shm_packet_write_manual(cat_shm_render_context_t *ctx, uint32_t length, void *data)
{
uint32_t total = 0;
uint32_t size;
int status;
while (total < length)
{
size = length - total;
uint32_t size_avail = ctx->shm.size - ctx->curpos - sizeof(struct cat_shm_header_s);
if (size_avail < size)
{
size = size_avail;
}
memcpy(ctx->shm.data + sizeof(struct cat_shm_header_s) + ctx->curpos, data + total, size);
ctx->curpos += size;
if (ctx->curpos == ctx->shm.size - sizeof(struct cat_shm_header_s))
{
ctx->curpos = 0;
}
total += size;
}
return 0;
}
int
cat_shm_packet_read(cat_shm_render_context_t *ctx, cat_shm_packet_header_t *header, void *out, uint32_t out_length)
{
int status;
int total = 0;
int size = 0;
while (((struct cat_shm_header_s *)ctx->shm.data)->lastpacket == ctx->lastpacket) usleep(1);
xpcmutex_lock(ctx->mutex);
if (cat_shm_packet_read_manual(ctx, sizeof(cat_shm_packet_header_t), header) < 0)
{
fprintf(stderr, "cat_shm read packet error\n");
xpcmutex_unlock(ctx->mutex);
return -1;
}
if (header->magic != CAT_SHM_PACKET_MAGIC)
{
fprintf(stderr, "cat_shm read corrupted packet: %hx %hx %x\n", header->magic, header->type, header->length);
xpcmutex_unlock(ctx->mutex);
return -1;
}
if (header->length != 0)
{
if (out_length < header->length)
{
printf("not enough memory %x %x %hx %hx\n", out_length, header->length, header->type, header->magic);
return -1;
}
//printf("reading payload %u %hu\n", header->length, header->type);
cat_shm_packet_read_manual(ctx, header->length, out);
/*total = 0;
while (total < header->length)
{
size = header->length - total;
if (size > out_length)
{
printf("total %u length %u max %u\n", total, header->length, out_length);
return -1;
}
uint32_t size_avail = ctx->shm.size - ctx->curpos - sizeof(struct cat_shm_header_s);
if (size_avail < size)
{
size = size_avail;
}
printf("reading %x from %x\n", size, ctx->curpos + sizeof(struct cat_shm_header_s));
memcpy(out + total, ctx->shm.data + sizeof(struct cat_shm_header_s) + ctx->curpos, size);
ctx->curpos += size;
if (ctx->curpos + sizeof(struct cat_shm_header_s) == ctx->shm.size)
{
ctx->curpos = 0;
}
total += size;
}*/
}
ctx->lastpacket++;// ((struct cat_shm_header_s *)ctx->shm.data)->lastpacket;
xpcmutex_unlock(ctx->mutex);
return 0;
}
int
cat_shm_packet_read_manual(cat_shm_render_context_t *ctx, uint32_t length, void *data)
{
uint32_t total = 0;
uint32_t size;
while (total < length)
{
size = length - total;
uint32_t size_avail = ctx->shm.size - ctx->curpos - sizeof(struct cat_shm_header_s);
if (size_avail < size)
{
//printf("overflow\n");
size = size_avail;
}
//printf("s %x t %x l %x p %x\n", size, total, length, ctx->curpos);
memcpy(data + total, ctx->shm.data + sizeof(struct cat_shm_header_s) + ctx->curpos, size);
ctx->curpos += size;
if (ctx->curpos == ctx->shm.size - sizeof(struct cat_shm_header_s))
{
//printf("OVERFLOW %x\n", ctx->curpos);
ctx->curpos = 0;
}
total += size;
}
return 0;
}

47
src/shmstream.h Normal file
View File

@ -0,0 +1,47 @@
/*
* shmstream.h
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#pragma once
#include <stdint.h>
#include "xshm.h"
#include "xpcmutex.h"
#define CAT_SHM_PACKET_MAGIC (unsigned short)0xCA75
#define CAT_SHM_SIZE 1024 * 1024 * 8
typedef struct cat_shm_render_context_s
{
xshm_t shm;
xpcmutex_t mutex;
uint32_t curpos;
uint32_t lastpacket;
} cat_shm_render_context_t;
typedef struct cat_shm_packet_header_s
{
uint16_t magic;
uint16_t type;
uint32_t length;
} cat_shm_packet_header_t;
struct cat_shm_header_s
{
uint32_t lastpacket;
};
int
cat_shm_packet_send(cat_shm_render_context_t *ctx, uint16_t type, uint32_t length, void *data);
int
cat_shm_packet_write_manual(cat_shm_render_context_t *ctx, uint32_t length, void *data);
int
cat_shm_packet_read(cat_shm_render_context_t *ctx, cat_shm_packet_header_t *header, void *out, uint32_t out_length);
int
cat_shm_packet_read_manual(cat_shm_render_context_t *ctx, uint32_t length, void *data);

View File

@ -1,8 +0,0 @@
/*
* xoverlay.cpp
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/

75
src/xpcmutex.c Normal file
View File

@ -0,0 +1,75 @@
/*
* 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);
}
}

36
src/xpcmutex.h Normal file
View File

@ -0,0 +1,36 @@
/*
* 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);

95
src/xshm.c Normal file
View File

@ -0,0 +1,95 @@
/*
* 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);
}

30
src/xshm.h Normal file
View File

@ -0,0 +1,30 @@
/*
* 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);