diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-06 16:09:55 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-06 16:09:55 +0100 |
| commit | 33f5ed9ef58f26c6b3b52cf605dd4311d658a60d (patch) | |
| tree | a97254872e465c9107b7ef19695ab56bb076d7e2 /src/overlay.h | |
| parent | Items: log the usable ammo table once (diff) | |
| download | hl2h-33f5ed9ef58f26c6b3b52cf605dd4311d658a60d.tar.gz hl2h-33f5ed9ef58f26c6b3b52cf605dd4311d658a60d.zip | |
Fix audit findings: crash safety, correctness, rendering, performance
Crash/UB:
- gate every hook behind an init-stage flag until config/surface/input are ready
- publish module maps as immutable atomic snapshots instead of reallocating
shared vectors under unlocked readers
- validate the %ebp walk in the RandomSeed/RandomFloat hooks against the stack
- bounds-check every RecvTable/RecvProp/string dereference with module_range()
- preserve the Itanium vtable header when cloning (client, CInput, model render,
studio render)
- reject negative usercmd sequence numbers; guard config_load against a null
section target; cap the bone parent walk; check mprotect; drop PROT_EXEC on
the GOT patch; absorb server.so .bss tail
Correctness:
- filter dormant entities across ESP, aimbot, triggerbot, melee, items and
projectiles (slot self-tested against the local player)
- reset the server-health latch per map and only latch on valid model indices
- bone cache sized for the 128-target scan; set valid=false on every failure;
head_position keeps searching past an invalid bone
- vischeck steps past glass by probing until clear, and ignores entities owned
by the target (held weapons, bone followers)
- aimbot: maxs no longer disables it, AABB-aware FOV prefilter, lock hysteresis,
lead point re-checked for FOV and visibility
- spread: seed hook arms on the no-spread toggle alone; engine toggle only
controls the RandomFloat zeroing
- resolve m_hOwnerEntity/m_hOwner; NPC lead velocity from the server entity
- vector_angles pitch range, point_ground normal test, underwater jump+duck no
longer skips combat, semi-auto press/release edge for synthetic fire
- item/projectile markers and blast rings refresh origin per frame while
discovery stays at 10 Hz; trajectory uses the real m_DmgRadius and honours
the blast-radius toggle
Rendering/GUI:
- one overlay draw per engine frame (FRAME_RENDER_START boundary), fixing
alpha stacking and the speed-graph flicker
- clipped lines/outlines and ellipsised text instead of drawing past the
content pane or shifting over neighbours
- dropdown dismissal consumes the click; hover ignores hidden controls
- chams: reset AlphaModulate, reference shared materials once, restore prop
tint colour; fonts created once per handle
- projection uses Source's 4:3 aspect scaling and roll; screen size refreshed
each frame; FOV circle gated on the aim toggles, not the bind
Performance:
- TTL caches for NPC relation, friendly/neutral and damage class
- model names memoised per model index
- entity pointer -> index cache for the triggerbot (was a 4096-slot walk/tick)
Build:
- real Makefile with -MMD dependency tracking, debug/release objects and an
always-relink rule; build.sh kept as a thin wrapper
Diffstat (limited to 'src/overlay.h')
| -rw-r--r-- | src/overlay.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/overlay.h b/src/overlay.h new file mode 100644 index 0000000..6cf86c9 --- /dev/null +++ b/src/overlay.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #ifndef HL2H_OVERLAY_H | ||
| 2 | #define HL2H_OVERLAY_H | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | |||
| 6 | // VGUI_Surface030 vtable slots, confirmed against the shipped | ||
| 7 | // vguimatsurface.so. This header is the only place that knows them; every | ||
| 8 | // consumer goes through the functions below. | ||
| 9 | enum SurfaceSlot { | ||
| 10 | SURF_GetEmbeddedPanel = 6, | ||
| 11 | SURF_PushMakeCurrent = 8, | ||
| 12 | SURF_PopMakeCurrent = 9, | ||
| 13 | SURF_DrawSetColor = 10, | ||
| 14 | SURF_DrawFilledRect = 12, | ||
| 15 | SURF_DrawOutlinedRect = 14, | ||
| 16 | SURF_DrawLine = 15, | ||
| 17 | SURF_DrawSetTextFont = 17, | ||
| 18 | SURF_DrawSetTextColor = 18, | ||
| 19 | SURF_DrawSetTextPos = 20, | ||
| 20 | SURF_DrawPrintText = 22, | ||
| 21 | SURF_GetScreenSize = 38, | ||
| 22 | SURF_CreateFont = 66, | ||
| 23 | SURF_AddGlyphSetToFont = 67, | ||
| 24 | SURF_GetTextSize = 75 | ||
| 25 | }; | ||
| 26 | |||
| 27 | using HFont = unsigned long; | ||
| 28 | |||
| 29 | struct ISurface; | ||
| 30 | |||
| 31 | // Set once by install_menu(); every wrapper below is a no-op while it is null. | ||
| 32 | extern ISurface *g_surface; | ||
| 33 | |||
| 34 | void overlay_color(int r, int g, int b, int a); | ||
| 35 | void overlay_fill(int x0, int y0, int x1, int y1); | ||
| 36 | void overlay_outline_rect(int x0, int y0, int x1, int y1); | ||
| 37 | void overlay_line(int x0, int y0, int x1, int y1); | ||
| 38 | void overlay_text_font(HFont f); | ||
| 39 | void overlay_text_color(int r, int g, int b, int a); | ||
| 40 | void overlay_text_pos(int x, int y); | ||
| 41 | void overlay_print_text(const wchar_t *text, int count, int draw_type = 0); | ||
| 42 | HFont overlay_create_font(); | ||
| 43 | bool overlay_add_glyph_set(HFont f, const char *name, int tall, int weight, | ||
| 44 | int blur, int scanlines, int flags, int range_min, | ||
| 45 | int range_max); | ||
| 46 | void overlay_screen_size(int &w, int &h); | ||
| 47 | void overlay_text_size(HFont f, const wchar_t *text, int &w, int &h); | ||
| 48 | int overlay_embedded_panel(); | ||
| 49 | void overlay_push_make_current(int panel, bool use_insets); | ||
| 50 | void overlay_pop_make_current(int panel); | ||
| 51 | |||
| 52 | // Per-frame draw budget. The engine calls PaintTraverseEx for every panel, and | ||
| 53 | // DrawPrintText for every text draw, so the overlay must be collapsed to one | ||
| 54 | // draw per frame. A timer cannot do that: panels spaced a few ms apart in the | ||
| 55 | // same frame would draw twice and double the alpha of translucent elements. | ||
| 56 | // overlay_frame_mark() is called from FRAME_RENDER_START, which is the real | ||
| 57 | // frame boundary; if that stops arriving (menu/pause) a 10 ms fallback keeps | ||
| 58 | // the GUI repainting. | ||
| 59 | void overlay_frame_mark(); | ||
| 60 | bool overlay_should_draw(); | ||
| 61 | |||
| 62 | #endif | ||
