Stable ESP

This commit is contained in:
nullifiedcat 2017-11-12 22:07:40 +03:00
parent 8cc5db22dc
commit 429bb71138
8 changed files with 40 additions and 19 deletions

View File

@ -32,8 +32,8 @@ 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)
{
xpcmutex_unlock(ctx->mutex);
cat_shm_packet_send(ctx, CATP_DRAW_END, 0, 0);
xpcmutex_unlock(ctx->mutex);
}
void

View File

@ -11,7 +11,7 @@
#include "hack.h"
extern "C"
{
#include "catpclient.h"
#include "catsmclient.h"
}
#include <stdio.h>
@ -27,17 +27,18 @@ const char *drawex_pipe_name = "/tmp/cathook-rendering-pipe";
namespace drawex
{
int pipe_fd;
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)
if (hack::initialized && api::ready_state)
{
draw::UpdateWTS();
BeginCheatVisuals();
DrawCheatVisuals();
@ -47,10 +48,19 @@ void rendering_routine()
EndCheatVisuals();
}
std::this_thread::sleep_for(std::chrono::microseconds(100));
xpcmutex_unlock(server_throttle_mutex);
usleep(1000000 / 100);
//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
{
@ -59,28 +69,26 @@ bool ready_state = false;
void initialize()
{
rendering_thread = std::thread(rendering_routine);
pipe_fd = open(drawex_pipe_name, O_WRONLY);
ctx = cat_shm_connect("cathook-rendering");
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);
cat_shm_render_rect(&ctx, 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);
cat_shm_render_rect_outline(&ctx, 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);
cat_shm_render_line(&ctx, x, y, dx, dy, 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)
@ -91,25 +99,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);
cat_shm_render_circle(&ctx, 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);
cat_shm_render_string(&ctx, x, y, string, rgba);
}
void draw_begin()
{
PROF_SECTION(DRAWEX_draw_begin);
cat_send_render_packet_begin(pipe_fd, draw::wts.Base());
cat_shm_render_begin(&ctx, draw::wts.Base());
}
void draw_end()
{
PROF_SECTION(DRAWEX_draw_end);
cat_send_render_packet_end(pipe_fd);
cat_shm_render_end(&ctx);
}
}}

View File

@ -9,12 +9,17 @@
#include <thread>
extern "C"
{
#include "catsmclient.h"
}
#define draw_api drawex::api
namespace drawex
{
extern int pipe_fd;
extern cat_shm_render_context_t ctx;
extern std::thread rendering_thread;
void rendering_routine();

View File

@ -62,6 +62,7 @@ void AddCenterString(const std::string& string, const rgba_t& color) {
int draw::width = 0;
int draw::height = 0;
float draw::fov = 90.0f;
std::mutex draw::draw_mutex;
namespace fonts {

View File

@ -41,6 +41,7 @@ void DrawStrings();
namespace draw {
extern std::mutex draw_mutex;
extern VMatrix wts;
extern int width;

View File

@ -288,10 +288,12 @@ void hack::Initialize() {
hooks::input.Set(g_IInput);
hooks::input.HookMethod((void*)GetUserCmd_hook, offsets::GetUserCmd());
hooks::input.Apply();
#ifndef HOOK_DME_DISABLED
#if ENABLE_VISUALS == 1
hooks::modelrender.Set(g_IVModelRender);
hooks::modelrender.HookMethod((void*)DrawModelExecute_hook, offsets::DrawModelExecute());
hooks::modelrender.Apply();
#endif
#endif
hooks::steamfriends.Set(g_ISteamFriends);
hooks::steamfriends.HookMethod((void*)GetFriendPersonaName_hook, offsets::GetFriendPersonaName());
@ -321,6 +323,7 @@ void hack::Initialize() {
// cat_reloadscheme to load imgui
hack::command_stack().push("cat_reloadscheme");
#endif
#ifndef FEATURE_EFFECTS_DISABLED
if (g_ppScreenSpaceRegistrationHead && g_pScreenSpaceEffects) {
effect_chams::g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &effect_chams::g_EffectChams);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams");
@ -328,7 +331,8 @@ void hack::Initialize() {
effect_glow::g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &effect_glow::g_EffectGlow);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
}
logging::Info("SSE enabled..");
logging::Info("SSE enabled..");
#endif
#if RENDERING_ENGINE_OPENGL
DoSDLHooking();
logging::Info("SDL hooking done");

View File

@ -131,9 +131,9 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
if (clean_screenshots && g_IEngine->IsTakingScreenshot()) return;
PROF_SECTION(PT_active);
draw::UpdateWTS();
#if RENDERING_ENGINE_OPENGL
#if ENABLE_VISUALS == 1
draw::UpdateWTS();
BeginCheatVisuals();
DrawCheatVisuals();

View File

@ -30,5 +30,7 @@ constexpr int c_strcmp( char const* lhs, char const* rhs ) {
#define FEATURE_EMOJI_ESP_DISABLED
#define FEATURE_RADAR_DISABLED
#define FEATURE_FIDGET_SPINNER_DISABLED
#define FEATURE_EFFECTS_DISABLED
#define HOOK_DME_DISABLED
#endif