external drawing (does not work)

This commit is contained in:
nullifiedcat 2017-11-12 12:59:13 +03:00
parent f9ef9498fe
commit 918b23fc92
23 changed files with 596 additions and 96 deletions

View File

@ -35,7 +35,7 @@
<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="" 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"/>
<builder arguments="build-debug-tf2" buildPath="${workspace_loc:/cathook}" command="bash" 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

@ -12,6 +12,7 @@
# NO_TF2_RENDERING - disable in-game rendering (does not work yet)
# TEXTMODE_STDIN - allows using console with textmode tf2
# TEXTMODE_VAC - allows joining VAC-secured servers in textmode
# EXTERNAL_RENDERING - enabled Xoverlay rendering, disables ImGui
#
GAME=tf2
@ -22,6 +23,7 @@ ENABLE_IPC=1
ENABLE_NULL_GRAPHICS=0
TEXTMODE_STDIN=0
TEXTMODE_VAC=0
EXTERNAL_RENDERING=0
DATA_PATH="/opt/cathook/data"
NO_LTO=0
ifdef CLANG
@ -68,8 +70,14 @@ LD=ld.lld
LDFLAGS+=-melf_i386
endif
DEFINES:=_GLIBCXX_USE_CXX11_ABI=0 _POSIX=1 FREETYPE_GL_USE_VAO=1 RAD_TELEMETRY_DISABLED=1 LINUX=1 USE_SDL=1 _LINUX=1 POSIX=1 GNUC=1 NO_MALLOC_OVERRIDE=1
DEFINES+=ENABLE_VISUALS=$(ENABLE_VISUALS) ENABLE_GUI=$(ENABLE_GUI) ENABLE_IPC=$(ENABLE_IPC) BUILD_GAME=$(GAME) ENABLE_NULL_GRAPHICS=$(ENABLE_NULL_GRAPHICS) TEXTMODE_STDIN=$(TEXTMODE_STDIN) TEXTMODE_VAC=$(TEXTMODE_VAC) DATA_PATH="\"$(DATA_PATH)\""
DEFINES=
ifeq ($(EXTERNAL_RENDERING), 1)
ENABLE_GUI=0
endif
DEFINES+=_GLIBCXX_USE_CXX11_ABI=0 _POSIX=1 FREETYPE_GL_USE_VAO=1 RAD_TELEMETRY_DISABLED=1 LINUX=1 USE_SDL=1 _LINUX=1 POSIX=1 GNUC=1 NO_MALLOC_OVERRIDE=1
DEFINES+=XOVERLAY=$(EXTERNAL_RENDERING) ENABLE_VISUALS=$(ENABLE_VISUALS) ENABLE_GUI=$(ENABLE_GUI) ENABLE_IPC=$(ENABLE_IPC) BUILD_GAME=$(GAME) ENABLE_NULL_GRAPHICS=$(ENABLE_NULL_GRAPHICS) TEXTMODE_STDIN=$(TEXTMODE_STDIN) TEXTMODE_VAC=$(TEXTMODE_VAC) DATA_PATH="\"$(DATA_PATH)\""
WARNING_FLAGS=-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef
COMMON_FLAGS=-fpermissive -O3 -shared -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC -march=native -mtune=native
@ -98,12 +106,15 @@ CXXFLAGS+=$(WARNING_FLAGS)
endif
ifeq ($(ENABLE_VISUALS),1)
ifeq ($(EXTERNAL_RENDERING), 1)
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)
CFLAGS+=$(shell sdl2-config --cflags)
else
EXCL_SOURCES:=hacks/ESP.cpp hacks/SkinChanger.cpp hacks/SpyAlert.cpp hacks/Radar.cpp fidgetspinner.cpp ftrender.cpp hooks/sdl.cpp drawing.cpp drawmgr.cpp drawgl.cpp hooks/PaintTraverse.cpp EffectChams.cpp EffectGlow.cpp atlas.cpp
EXCL_SOURCES:=xoverlay.cpp catpclient.c pipepacket.c hacks/ESP.cpp hacks/SkinChanger.cpp hacks/SpyAlert.cpp hacks/Radar.cpp fidgetspinner.cpp ftrender.cpp hooks/sdl.cpp drawing.cpp drawmgr.cpp drawgl.cpp hooks/PaintTraverse.cpp EffectChams.cpp EffectGlow.cpp atlas.cpp
EXCL_SOURCES:=$(addprefix $(SRC_DIR)/,$(EXCL_SOURCES))
SOURCES:=$(filter-out $(shell find $(SRC_DIR)/gui -name "*.cpp" -print),$(SOURCES))

View File

@ -21,7 +21,7 @@ AtlasTexture::AtlasTexture(float x, float y, float sx, float sy) {
}
void AtlasTexture::Draw(float x, float y, float sx, float sy) {
drawgl::TexturedRect(x, y, sx, sy, tex_coords[0].x, tex_coords[0].y, tex_coords[1].x, tex_coords[1].y);
drawgl::draw_rect_textured(x, y, sx, sy, tex_coords[0].x, tex_coords[0].y, tex_coords[1].x, tex_coords[1].y);
}
GLuint texture;

86
src/catpackets.h Normal file
View File

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

87
src/catpclient.c Normal file
View File

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

29
src/catpclient.h Normal file
View File

@ -0,0 +1,29 @@
/*
* catpclient.h
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#pragma once
void
cat_send_render_packet_begin(int fd, 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);

65
src/drawex.cpp Normal file
View File

@ -0,0 +1,65 @@
/*
* drawex.cpp
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#include "drawex.hpp"
#include "catpclient.h"
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
const char *drawex_pipe_name = "/tmp/cathook-rendering-pipe";
namespace drawex
{
int pipe_fd;
namespace api
{
void intialize()
{
pipe_fd = open(drawex_pipe_name, O_WRONLY);
}
void draw_rect(float x, float y, float w, float h, const float* rgba = colors::white)
{
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 = colors::white, float thickness)
{
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 = colors::white, float thickness)
{
cat_send_render_packet_line(pipe_fd, x, y, dx, dy, rgba, thickness);
}
void draw_rect_textured(float x, float y, float w, float h, const float* rgba = colors::white, float u, float v, float s, float t)
{
static_assert(0, "draw_rect_textured is not implemented");
}
void draw_begin()
{
cat_send_render_packet_begin(pipe_fd, draw::wts.Base());
}
void draw_end()
{
cat_send_render_packet_end(pipe_fd);
}
}}

32
src/drawex.hpp Normal file
View File

@ -0,0 +1,32 @@
/*
* drawex.hpp
*
* Created on: Nov 12, 2017
* Author: nullifiedcat
*/
#pragma once
#define draw_api drawex::api
namespace drawex
{
extern int pipe_fd;
namespace api
{
void intialize();
void draw_rect(float x, float y, float w, float h, const float* rgba = colors::white);
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba = colors::white, float thickness);
void draw_line(float x, float y, float dx, float dy, const float* rgba = colors::white, float thickness);
void draw_rect_textured(float x, float y, float w, float h, const float* rgba = colors::white, float u, float v, float s, float t);
void draw_begin();
void draw_end();
}
}

View File

@ -32,7 +32,7 @@ mat4 model, view, projection;
bool ready_state = false;
void Initialize() {
void intialize() {
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");
@ -65,14 +65,14 @@ void Initialize() {
textures::Init();
// Do not fucking ask. Without this, it crashes.
drawgl::Rect(0, 0, 0, 0);
drawgl::FilledRect(0, 0, 0, 0);
drawgl::TexturedRect(0, 0, 0, 0, 0, 0, 0, 0);
drawgl::draw_rect_outlined(0, 0, 0, 0);
drawgl::draw_rect(0, 0, 0, 0);
drawgl::draw_rect_textured(0, 0, 0, 0, 0, 0, 0, 0);
ready_state = true;
Render();
draw_end();
}
void FilledRect(float x, float y, float w, float h, const float* rgba) {
void draw_rect(float x, float y, float w, float h, const float* rgba) {
GLuint idx = buffer_triangles_plain->vertices->size;
//
// 3 - 2
@ -90,7 +90,7 @@ void FilledRect(float x, float y, float w, float h, const float* rgba) {
vertex_buffer_push_back_vertices(buffer_triangles_plain, vertices, 4);
}
void Line(float x, float y, float dx, float dy, const float* rgba) {
void draw_line(float x, float y, float dx, float dy, const float* rgba) {
GLuint idx = buffer_lines->vertices->size;
GLuint indices[] = { idx, idx + 1 };
vertex_v2c4_t vertices[] = {
@ -101,7 +101,7 @@ void Line(float x, float y, float dx, float dy, const float* rgba) {
vertex_buffer_push_back_vertices(buffer_lines, vertices, 2);
}
void 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) {
GLuint idx = buffer_lines->vertices->size;
GLuint indices[] = { idx, idx + 1, idx + 1, idx + 2, idx + 2, idx + 3, idx + 3, idx };
vertex_v2c4_t vertices[] = {
@ -114,7 +114,7 @@ void Rect(float x, float y, float w, float h, const float* rgba) {
vertex_buffer_push_back_vertices(buffer_lines, vertices, 4);
}
void TexturedRect(float x, float y, float w, float h, float u, float v, float u2, float v2, const float* rgba) {
void draw_rect_textured(float x, float y, float w, float h, float u, float v, float u2, float v2, const float* rgba) {
GLuint idx = buffer_triangles_textured->vertices->size;
GLuint indices[] = { idx, idx + 1, idx + 2, idx, idx + 2, idx + 3 };
vertex_v2t2c4_t vertices[] = {
@ -127,13 +127,13 @@ void TexturedRect(float x, float y, float w, float h, float u, float v, float u2
vertex_buffer_push_back_vertices(buffer_triangles_textured, vertices, 4);
}
void Refresh() {
void draw_begin() {
vertex_buffer_clear(buffer_triangles_plain);
vertex_buffer_clear(buffer_triangles_textured);
vertex_buffer_clear(buffer_lines);
}
void PreRender() {
void render_begin() {
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND);
@ -158,20 +158,21 @@ void PreRender() {
glEnableClientState(GL_INDEX_ARRAY);
}
void PostRender() {
glUseProgram(0);
glBindTexture(GL_TEXTURE_2D, 0);
glPopClientAttrib();
glPopAttrib();
}
void render() {
PROF_SECTION(DRAW_rendering_gl);
void Render() {
glUseProgram(shader_v2fc4f);
vertex_buffer_render(buffer_triangles_plain, GL_TRIANGLES);
vertex_buffer_render(buffer_lines, GL_LINES);
glUseProgram(shader_v2ft2fc4f);
glBindTexture(GL_TEXTURE_2D, textures::texture);
vertex_buffer_render(buffer_triangles_textured, GL_TRIANGLES);
}
glUseProgram(shader_v2fc4f);
vertex_buffer_render(buffer_triangles_plain, GL_TRIANGLES);
vertex_buffer_render(buffer_lines, GL_LINES);
glUseProgram(shader_v2ft2fc4f);
glBindTexture(GL_TEXTURE_2D, textures::texture);
vertex_buffer_render(buffer_triangles_textured, GL_TRIANGLES);
FTGL_Render();
glUseProgram(0);
glBindTexture(GL_TEXTURE_2D, 0);
glPopClientAttrib();
glPopAttrib();
}
}

View File

@ -10,6 +10,8 @@
#include "drawing.h"
#define draw_api drawgl::api
extern "C" {
#include "freetype-gl/vec234.h"
#include "freetype-gl/vertex-buffer.h"
@ -28,25 +30,23 @@ struct vertex_v2t2c4_t {
ftgl::vec4 rgba;
};
extern ftgl::vertex_buffer_t* buffer_lines;
extern ftgl::vertex_buffer_t* buffer_triangles_plain;
extern ftgl::vertex_buffer_t* buffer_triangles_textured;
extern const float white[4];
void Initialize();
void intialize();
void FilledRect(float x, float y, float w, float h, const float* rgba = white);
void Line(float x, float y, float dx, float dy, const float* rgba = white);
void Rect(float x, float y, float w, float h, const float* rgba = white);
void TexturedRect(float x, float y, float w, float h, float u, float v, float u2, float v2, const float* rgba = white);
void draw_rect(float x, float y, float w, float h, const float* rgba = white);
void draw_line(float x, float y, float dx, float dy, const float* rgba = white);
void draw_rect_outlined(float x, float y, float w, float h, const float* rgba = white);
void draw_rect_textured(float x, float y, float w, float h, float u, float v, float u2, float v2, const float* rgba = white);
void Refresh();
void Render();
void draw_begin();
void draw_end();
void PreRender();
void PostRender();
void render();
extern bool ready_state;

View File

@ -34,6 +34,8 @@ void DrawStrings();
namespace draw {
extern VMatrix wts;
extern int width;
extern int height;
extern float fov;

View File

@ -12,7 +12,7 @@ void BeginCheatVisuals() {
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
if (drawgl::ready_state) {
FTGL_NewFrame();
drawgl::Refresh();
drawgl::draw_begin();
ResetStrings();
}
}

View File

@ -838,7 +838,7 @@ void DrawText() {
px = width / 2 + radius * cos(ang);
py = height / 2 + radius * sin(ang);
}
drawgl::Line(px, py, x - px, y - py, color);
drawgl::draw_line(px, py, x - px, y - py, color);
px = x;
py = y;
}
@ -853,8 +853,8 @@ void DrawText() {
Vector screen;
Vector oscreen;
if (draw::WorldToScreen(calculated_data_array[i].aim_position, screen) && draw::WorldToScreen(ent->m_vecOrigin, oscreen)) {
drawgl::FilledRect(screen.x - 2, screen.y - 2, 4, 4);
drawgl::Line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y);
drawgl::draw_rect(screen.x - 2, screen.y - 2, 4, 4);
drawgl::draw_line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y);
}
}
}

View File

@ -146,7 +146,7 @@ struct bonelist_s {
return;
}
if (i > 0) {
drawgl::Line(last_screen.x, last_screen.y, current_screen.x - last_screen.x, current_screen.y - last_screen.y, color);
drawgl::draw_line(last_screen.x, last_screen.y, current_screen.x - last_screen.x, current_screen.y - last_screen.y, color);
}
last_screen = current_screen;
}
@ -300,7 +300,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
draw::WorldToScreen(ent->m_vecOrigin, scn);
// Draw a line
drawgl::Line(scn.x, scn.y, width - scn.x, height - scn.y, fg);
drawgl::draw_line(scn.x, scn.y, width - scn.x, height - scn.y, fg);
}
// Sightline esp
@ -379,7 +379,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
}
// We have both vectors, draw
if (found_scn1) {
drawgl::Line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg);
drawgl::draw_line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg);
}
}
}
@ -466,8 +466,8 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) {
int hbh = (max_y - min_y - 2) * min((float)health / (float)healthmax, 1.0f);
// Draw
drawgl::Rect(min_x - 7, min_y, 7, max_y - min_y, border);
drawgl::FilledRect(min_x - 6, max_y - hbh - 1, 5, hbh, hp);
drawgl::draw_rect_outlined(min_x - 7, min_y, 7, max_y - min_y, border);
drawgl::draw_rect(min_x - 6, max_y - hbh - 1, 5, hbh, hp);
}
}
}
@ -905,9 +905,9 @@ void _FASTCALL DrawBox(CachedEntity* ent, const rgba_t& clr) {
BoxCorners(min_x, min_y, max_x, max_y, clr, (clr.a != 1.0f));
// Otherwise, we just do simple draw funcs
else {
drawgl::Rect(min_x, min_y, max_x - min_x, max_y - min_y, border);
drawgl::Rect(min_x + 1, min_y + 1, max_x - min_x - 2, max_y - min_y - 2, clr);
drawgl::Rect(min_x + 2, min_y + 2, max_x - min_x - 4, max_y - min_y - 4, border);
drawgl::draw_rect_outlined(min_x, min_y, max_x - min_x, max_y - min_y, border);
drawgl::draw_rect_outlined(min_x + 1, min_y + 1, max_x - min_x - 2, max_y - min_y - 2, clr);
drawgl::draw_rect_outlined(min_x + 2, min_y + 2, max_x - min_x - 4, max_y - min_y - 4, border);
}
}
@ -918,31 +918,31 @@ void BoxCorners(int minx, int miny, int maxx, int maxy, const rgba_t& color, boo
// Black corners
// Top Left
drawgl::FilledRect(minx, miny, size, 3, black);
drawgl::FilledRect(minx, miny + 3, 3, size - 3, black);
drawgl::draw_rect(minx, miny, size, 3, black);
drawgl::draw_rect(minx, miny + 3, 3, size - 3, black);
// Top Right
drawgl::FilledRect(maxx - size + 1, miny, size, 3, black);
drawgl::FilledRect(maxx - 3 + 1, miny + 3, 3, size - 3, black);
drawgl::draw_rect(maxx - size + 1, miny, size, 3, black);
drawgl::draw_rect(maxx - 3 + 1, miny + 3, 3, size - 3, black);
// Bottom Left
drawgl::FilledRect(minx, maxy - 3, size, 3, black);
drawgl::FilledRect(minx, maxy - size, 3, size - 3, black);
drawgl::draw_rect(minx, maxy - 3, size, 3, black);
drawgl::draw_rect(minx, maxy - size, 3, size - 3, black);
// Bottom Right
drawgl::FilledRect(maxx - size + 1, maxy - 3, size, 3, black);
drawgl::FilledRect(maxx - 2, maxy - size, 3, size - 3, black);
drawgl::draw_rect(maxx - size + 1, maxy - 3, size, 3, black);
drawgl::draw_rect(maxx - 2, maxy - size, 3, size - 3, black);
// Colored corners
// Top Left
drawgl::Line(minx + 1, miny + 1, size - 2, 0, color);
drawgl::Line(minx + 1, miny + 1, 0, size - 2, color);
drawgl::draw_line(minx + 1, miny + 1, size - 2, 0, color);
drawgl::draw_line(minx + 1, miny + 1, 0, size - 2, color);
// Top Right
drawgl::Line(maxx - 1, miny + 1, -(size - 2), 0, color);
drawgl::Line(maxx - 1, miny + 1, 0, size - 2, color);
drawgl::draw_line(maxx - 1, miny + 1, -(size - 2), 0, color);
drawgl::draw_line(maxx - 1, miny + 1, 0, size - 2, color);
// Bottom Left
drawgl::Line(minx + 1, maxy - 2, size - 2, 0, color);
drawgl::Line(minx + 1, maxy - 2, 0, -(size - 2), color);
drawgl::draw_line(minx + 1, maxy - 2, size - 2, 0, color);
drawgl::draw_line(minx + 1, maxy - 2, 0, -(size - 2), color);
// Bottom Right
drawgl::Line(maxx - 1, maxy - 2, -(size - 2), 0, color);
drawgl::Line(maxx - 1, maxy - 2, 0, -(size - 2), color);
drawgl::draw_line(maxx - 1, maxy - 2, -(size - 2), 0, color);
drawgl::draw_line(maxx - 1, maxy - 2, 0, -(size - 2), color);
}
// Used for caching collidable bounds

View File

@ -790,7 +790,7 @@ void DrawFollowbot() {
// Get the entity vector to screen and draw a rect on it
Vector scn;
draw::WorldToScreen(breadcrumbs[crumbBottom], scn);
drawgl::FilledRect(scn.x - 3, scn.y - 3, 6, 6);
drawgl::draw_rect(scn.x - 3, scn.y - 3, 6, 6);
}
// Return as we have nothing else to do
@ -819,11 +819,11 @@ void DrawFollowbot() {
draw::WorldToScreen(breadcrumbs[tmpCrumb2], scnEnd);
// Draw a line from one crumb to the other
drawgl::Line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - scnSrt.y, colors::white);
drawgl::draw_line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - scnSrt.y, colors::white);
// If this is our first iteration, draw a box on 1
if (i == 0)
drawgl::FilledRect(scnSrt.x - 3, scnSrt.y - 3, 6, 6);
drawgl::draw_rect(scnSrt.x - 3, scnSrt.y - 3, 6, 6);
}
return;
}

View File

@ -90,15 +90,15 @@ void DrawEntity(int x, int y, CachedEntity* ent) {
tx_classes[2][clazz - 1].get()->Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
} else {
tx_classes[idx][clazz - 1].get()->Draw(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size);
drawgl::Rect(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v);
drawgl::draw_rect_outlined(x + wtr.first, y + wtr.second, (int)icon_size, (int)icon_size, idx ? colors::blu_v : colors::red_v);
}
if (ent->m_iMaxHealth && healthbar) {
healthp = (float)ent->m_iHealth / (float)ent->m_iMaxHealth;
clr = colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
if (healthp > 1.0f) healthp = 1.0f;
drawgl::Rect(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black);
drawgl::FilledRect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
drawgl::draw_rect_outlined(x + wtr.first, y + wtr.second + (int)icon_size, (int)icon_size, 4, colors::black);
drawgl::draw_rect(x + wtr.first + 1, y + wtr.second + (int)icon_size + 1, ((float)icon_size - 2.0f) * healthp, 2, clr);
}
} else if (ent->m_Type == ENTITY_BUILDING) {
/*if (ent->m_iClassID == CL_CLASS(CObjectDispenser)) {
@ -147,8 +147,8 @@ void Draw() {
outlineclr = (hacks::shared::aimbot::foundTarget ? colors::pink : GUIColor());
drawgl::FilledRect(x, y, radar_size, radar_size, colors::Transparent(colors::black, 0.4f));
drawgl::Rect(x, y, radar_size, radar_size, outlineclr);
drawgl::draw_rect(x, y, radar_size, radar_size, colors::Transparent(colors::black, 0.4f));
drawgl::draw_rect_outlined(x, y, radar_size, radar_size, outlineclr);
if (enemies_over_teammates) enemies.clear();
for (int i = 1; i < HIGHEST_ENTITY; i++) {
@ -173,11 +173,11 @@ void Draw() {
DrawEntity(x, y, LOCAL_E);
const auto& wtr = WorldToRadar(g_pLocalPlayer->v_Origin.x, g_pLocalPlayer->v_Origin.y);
if (!use_icons)
drawgl::Rect(x + wtr.first, y + wtr.second, int(icon_size), int(icon_size), GUIColor());
drawgl::draw_rect_outlined(x + wtr.first, y + wtr.second, int(icon_size), int(icon_size), GUIColor());
}
drawgl::Line(x + half_size, y + half_size / 2, 0, half_size, colors::Transparent(GUIColor(), 0.4f));
drawgl::Line(x + half_size / 2, y + half_size, half_size, 0, colors::Transparent(GUIColor(), 0.4f));
drawgl::draw_line(x + half_size, y + half_size / 2, 0, half_size, colors::Transparent(GUIColor(), 0.4f));
drawgl::draw_line(x + half_size / 2, y + half_size, half_size, 0, colors::Transparent(GUIColor(), 0.4f));
}
}}}

View File

@ -828,7 +828,7 @@ void DrawConnection(index_t a, connection_s& b) {
if ((a_.flags & b_.flags) & NF_JUMP) color = &colors::yellow;
else if ((a_.flags & b_.flags) & NF_DUCK) color = &colors::green;
drawgl::Line(wts_a.x, wts_a.y, wts_c.x - wts_a.x, wts_c.y - wts_a.y, color->rgba);
drawgl::draw_line(wts_a.x, wts_a.y, wts_c.x - wts_a.x, wts_c.y - wts_a.y, color->rgba);
if (draw_connection_flags && b.flags != CF_GOOD) {
std::string flags;
@ -868,7 +868,7 @@ void DrawNode(index_t node, bool draw_back) {
if (node == state::active_node)
color = &colors::red;
drawgl::FilledRect(wts.x - node_size, wts.y - node_size, 2 * node_size, 2 * node_size, color->rgba);
drawgl::draw_rect(wts.x - node_size, wts.y - node_size, 2 * node_size, 2 * node_size, color->rgba);
}
if (draw_indices) {

View File

@ -46,7 +46,7 @@ void SDL_GL_SwapWindow_hook(SDL_Window* window) {
ctx_text = SDL_GL_CreateContext(window);
FTGL_Init();
textures::Init();
drawgl::Initialize();
drawgl::intialize();
}
if (!cathook) {
@ -58,18 +58,7 @@ void SDL_GL_SwapWindow_hook(SDL_Window* window) {
SDL_GL_MakeCurrent(window, ctx_text);
{
std::lock_guard<std::mutex> draw_lock(drawing_mutex);
drawgl::PreRender();
{
PROF_SECTION(DRAW_gl);
drawgl::Render();
}
{
PROF_SECTION(DRAW_freetype);
FTGL_Render();
}
drawgl::PostRender();
drawgl::render();
}
SDL_GL_MakeCurrent(window, ctx_imgui);
{

View File

@ -8,5 +8,5 @@
#pragma once
#ifndef DATA_PATH
# define DATA_PATH "/opt/cathook-data"
# define DATA_PATH "/opt/cathook"
#endif

136
src/pipepacket.c Normal file
View File

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

54
src/pipepacket.h Normal file
View File

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

View File

@ -93,7 +93,7 @@ void Prediction_PaintTraverse() {
for (int j = 0; j < predicted_players[i].size(); j++) {
Vector screen;
if (draw::WorldToScreen(predicted_players[i][j], screen)) {
drawgl::Line(screen.x, screen.y, previous_screen.x - screen.x, previous_screen.y - screen.y, color);
drawgl::draw_line(screen.x, screen.y, previous_screen.x - screen.x, previous_screen.y - screen.y, color);
previous_screen = screen;
} else {
break;

8
src/xoverlay.cpp Normal file
View File

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