summaryrefslogtreecommitdiffstats
path: root/src/hl2h.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/hl2h.h50
1 files changed, 45 insertions, 5 deletions
diff --git a/src/hl2h.h b/src/hl2h.h
index 86573d8..f1a1ea0 100644
--- a/src/hl2h.h
+++ b/src/hl2h.h
@@ -11,6 +11,8 @@
11#include <pthread.h> 11#include <pthread.h>
12#include <unistd.h> 12#include <unistd.h>
13 13
14#include "overlay.h"
15
14// Shared float-precision constant. More digits than a float can hold are 16// Shared float-precision constant. More digits than a float can hold are
15// rounded at compile time and have no runtime cost; a coarse value would only 17// rounded at compile time and have no runtime cost; a coarse value would only
16// hurt angular accuracy, never performance. 18// hurt angular accuracy, never performance.
@@ -24,6 +26,31 @@ void logf(const char *fmt, ...);
24void logd(const char *fmt, ...); // debug-only (HL2H_DEBUG=1) 26void logd(const char *fmt, ...); // debug-only (HL2H_DEBUG=1)
25 27
26// --------------------------------------------------------------------------- 28// ---------------------------------------------------------------------------
29// init readiness
30// ---------------------------------------------------------------------------
31//
32// setup_thread runs detached while the game threads are already live, and some
33// hooks are installed lazily from the game thread. Hooks therefore always stay
34// installed but pass straight through to the original until setup reaches
35// INIT_LIVE, so the game can never observe half-initialised state. INIT_FAILED
36// is terminal: the cheat stays inert instead of half-working.
37enum {
38 INIT_FAILED = -1,
39 INIT_NONE = 0,
40 INIT_INTERFACES = 1, // modules + interfaces + netvars resolved
41 INIT_READY = 2, // config loaded, ISurface/fonts resolved
42 INIT_LIVE = 3 // hooks may run their bodies
43};
44void init_set_stage(int stage);
45int init_stage(); // acquire load
46inline bool init_live() { return init_stage() == INIT_LIVE; }
47
48// Clone a vtable into a new array, preserving the Itanium ABI header at
49// [-2]/[-1] (offset-to-top and typeinfo) so RTTI on the hooked object still
50// works. Returns the slot-0 pointer to install (i.e. the clone + 2).
51void **vtable_clone(void *iface, size_t slots);
52
53// ---------------------------------------------------------------------------
27// on-screen toasts 54// on-screen toasts
28// --------------------------------------------------------------------------- 55// ---------------------------------------------------------------------------
29 56
@@ -51,7 +78,17 @@ struct Module {
51 return false; 78 return false;
52 } 79 }
53}; 80};
54extern Module g_client, g_engine, g_server; 81// Immutable module snapshots. A reader gets a reference that stays valid for
82// the whole process: find_modules() publishes a new snapshot instead of
83// mutating the old one, and retired snapshots are intentionally never freed, so
84// a concurrent refresh can never invalidate a reference already in use.
85const Module &mod_client();
86const Module &mod_engine();
87const Module &mod_server();
88
89// True only when the whole byte range [p, p+n) lies inside one known module
90// range. Use before dereferencing pointers read out of engine memory.
91bool module_range(uintptr_t p, size_t n);
55 92
56// --------------------------------------------------------------------------- 93// ---------------------------------------------------------------------------
57// game interfaces 94// game interfaces
@@ -308,6 +345,9 @@ void skybox_invalidate();
308void skybox_reload_image(); 345void skybox_reload_image();
309bool resolve_server_netvars(); 346bool resolve_server_netvars();
310int server_entity_health(int idx, int *maxhealth, int *lifestate, void **base_out); 347int server_entity_health(int idx, int *maxhealth, int *lifestate, void **base_out);
348// Authoritative server velocity; client-side m_vecVelocity is not networked for
349// NPCs. Returns false when the server interface or datamap field is missing.
350bool server_entity_velocity(int idx, Vector *out);
311bool server_set_velocity_z(int idx, float vz); 351bool server_set_velocity_z(int idx, float vz);
312int server_active_weapon(int idx); 352int server_active_weapon(int idx);
313int server_npc_relation(int idx, int local_idx); 353int server_npc_relation(int idx, int local_idx);
@@ -332,7 +372,8 @@ void find_modules();
332bool module_jump_slot(const char *path, const char *name, uintptr_t *vaddr, 372bool module_jump_slot(const char *path, const char *name, uintptr_t *vaddr,
333 uintptr_t *bias); 373 uintptr_t *bias);
334void init_conmsg(); 374void init_conmsg();
335bool feature_active(int feature); 375bool feature_active(int feature); // enabled AND bind held (or unbound)
376bool feature_enabled(int feature); // enabled, regardless of bind
336bool feature_has_bind(int feature); 377bool feature_has_bind(int feature);
337bool feature_bind_held(int feature); 378bool feature_bind_held(int feature);
338bool esp_option(int opt); 379bool esp_option(int opt);
@@ -359,6 +400,8 @@ int engine_get_local_player();
359void draw_text_col(int x, int y, const char *s, int r, int g, int b); 400void draw_text_col(int x, int y, const char *s, int r, int g, int b);
360void draw_text_small_col(int x, int y, const char *s, int r, int g, int b); 401void draw_text_small_col(int x, int y, const char *s, int r, int g, int b);
361void esp_draw(); 402void esp_draw();
403void esp_draw_fov_circle(); // aimbot cone, independent of the ESP toggle
404void esp_reset_session(); // map change / respawn: clear per-map latches
362void esp_draw_items(); 405void esp_draw_items();
363void esp_draw_projectiles(); 406void esp_draw_projectiles();
364void prop_tint_update(); 407void prop_tint_update();
@@ -395,7 +438,4 @@ bool gui_bind_capture_active();
395QAngle gui_frozen_view(); 438QAngle gui_frozen_view();
396void gui_config_init(); 439void gui_config_init();
397void gui_config_write(FILE *f); 440void gui_config_write(FILE *f);
398// ISurface pointer (defined in menu.cpp, used for drawing tests)
399struct ISurface;
400extern ISurface *g_surface;
401#endif 441#endif