added a SHIT ton of modules

This commit is contained in:
st committed 2026-10-14 00:10:39 -05:00
1 parent b1634d195c
commit 361892bf0b
64 files changed
+5346 -482

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
# Client profiles
Open the client menu with Right Shift. The profile bar above the module panels
shows the active profile and whether changes are saving or saved.
- Pick a profile from the dropdown to load it. Pending changes in the previous
profile are saved before switching.
- **Manage profiles** lets you create a copy of your current setup, rename the
active profile, or delete it with confirmation. Default is protected.
- **Save now** saves immediately. Autosaving is always on: changes save after
roughly 0.75 seconds without edits, or every five seconds during continuous
editing. Unloading saves pending changes before disabling modules.
- The last active profile loads automatically the next time you load the DLL.
Profiles include module enabled states, toggle keys, every configurable setting
(including RGBA colors and individual action keys), and HUD positions. Mode names
are stored so reordering options doesn't change the selected behavior. Buttons,
key-capture state, animations, notification history, trade runs, and countdowns
are not saved. Switching/creating profiles cancels trade activity and releases
injected inputs before applying settings; loading an enabled Macro only arms it.
Files live in **profiles** beside the loaded DLL, with one `.profile` file per
profile and `active.txt` remembering the selection. Names allow 1–48 ASCII letters,
numbers, spaces, underscores, and hyphens; reserved Windows names are rejected.
Each save writes and flushes a temporary file, then replaces the previous file.
A failed write preserves the previous save and shows an error notification.
Damaged or unsupported files are preserved. A damaged startup profile pauses
autosaving until you choose another profile or create a recovery profile. **Save
now** explicitly replaces it with your current settings. Damaged files selected
from the dropdown leave the current setup intact. Unknown modules/settings are
ignored; missing settings use initial defaults and numeric values are clamped to
their permitted ranges.
Existing `villager-trade.ini` or Desktop `papertrade.ini` calibration is used for
the initial setup. Once profiles are active, macro captures and its **save
settings** button save into the active profile.
The integration suite verifies all setting types, keybinds, HUD positions,
defaults, named modes, limits, cancellation, debounce and continuous autosave,
remembered profiles, missing-profile fallback, rename/delete, damaged-file
preservation, failed atomic writes, and unload saving enabled states.
+141
View File
@@ -0,0 +1,141 @@
# FOV Changer verification
## World modules and HUD style
See [WORLD_MODULES.md](WORLD_MODULES.md) for the new modules, verified interfaces,
controls, tests, current rendering limits and in-game checks.
## Profiles and autosaving
See [PROFILES.md](PROFILES.md) for profile controls, file storage, migration and
failure handling. The integration executable also tests profile serialization,
switching, cancellation, autosaving, rename/delete and recovery behavior.
## New quality-of-life modules
All new modules start disabled. Right-click their rows to expand settings, and use
the normal **bind** control to assign a module toggle key.
- **VISUAL / viewmodel:** separate **main** and **offhand** position X/Y/Z and
pitch/yaw/roll sliders. Zero is neutral. **Separate offhand** is on by default;
turn it off to make both hands inherit the main settings. Offhand controls cover
shields and other held offhand items, and substitute the offhand pose before the
game's item-specific transforms so animations remain relative to that pose.
Position offsets use each pose's local basis; rotation keeps its translation
pivot. Check shield raised/lowered, offhand items, empty hands, tools, blocks,
view bobbing both on/off, and third person in-game.
- **UTILITY / toggle sprint:** enable once to hold your sprint key while moving
forward. Defaults are W and Left Ctrl; both are rebindable in its settings.
Shift (sneak), S (backwards), visible menus/cursor, focus loss, and disabling
release the module's injected key. Its optional status HUD is draggable. This
uses normal keyboard input and preserves Minecraft's normal sprint restrictions.
- **HUD / cps counter:** separate left/right click totals over the previous second.
Clicks in the client menu are excluded; opening it or leaving the game clears
the rolling count. Mouse messages capture clicks between rendered frames.
- **HUD / clock:** local computer time, optional seconds and 12/24-hour format.
The expanded integration suite also checks actual viewmodel hook/trampoline calls,
independent main/offhand translation and all rotation axes, preservation of an
item-animation transform, linked mode, matrix restoration, and repeated toggles; plus Sprint's
key ownership, repeated updates, rebinding, failed-release retry, physical-input
handoff, injected-event filtering, and focus cleanup. Both x64 DLL builds pass.
The tests use controlled executable fixtures and do not establish visual behavior
inside Minecraft; the in-game checks above remain useful.
Cursor-hook installation now enables only those cursor hooks, so initializing
the menu does not enable unrelated game hooks. Module panels scroll when expanded
settings exceed the available screen height.
The viewmodel renderer, shared item renderer, and offhand call-site signatures
each matched exactly once in the captured 26.52 executable, at RVAs `0x47ca240`,
`0x47b5ba0`, and `0x47ceed3`. The call-site target is checked against the hooked
function. The offhand hook also requires that return address and the active
first-person render context, so other item-renderer calls are forwarded unchanged.
Temporary world matrices are restored after each draw scope. The isolated
executable fixtures use these exact prologues/call-site instructions and controlled
callbacks; shield rendering itself still needs the in-game check above.
### Viewmodel regression coverage
The working `hand_bob` hook is again the primary main-hand transform. The optional
hand-draw hook also passes an adjusted **copy** of its R8 source matrix: the real
26.52 renderer copies that matrix to its own storage at `+0x388`, so changing only
the shared matrix is insufficient. First-person checks accept the flags bit rather
than requiring an exact `0x21` value. Previous-frame bob snapshots expire at frame
end, avoiding duplicate main-hand offsets and stale offhand corrections.
Tests cover the direct hand hook and simulate the renderer copying a distinct input
matrix, including `0x23` flags and preservation of the caller's input. Earlier
fixtures consumed only the shared matrix and missed this rendering behavior.
### Custom crosshair
The existing crosshair module is now **custom crosshair** (F8). It includes length,
width, gap, dynamic gap/length toggles, independent speed and easing controls, base
color, gradient toggle/color, spin toggle/speed/easing, and the optional center dot.
Each dynamic channel has its own **pulse** or **movement / clicks** mode and amount.
Reactive mode responds to WASD/Space and left/right clicks; client-menu input is
excluded. Pulse speed is cycles per second; reactive speed sets transition rate;
spin speed is degrees per second. Easing options are linear, smooth, ease in,
ease out, and ease in/out. Gradient runs from the base color at the inner ends to
the second color at the outer ends. Spin and gradients work together.
Tests exercise animation timing at 60/144 Hz, easing bounds, reactive return to
rest, toggle reset, and actual ImGui draw vertices/indices, gradient colors, and
rotated geometry. Client Debug/Release builds pass. In-game rendering should be
checked after reloading the new DLL.
### Outline and native crosshair replacement
**Black outline** adds a black border behind each arm and the center dot; **outline
width** controls its thickness. The border uses the same animated gap, length, and
angle as the colored arms, and draws before the fill so gradient/spin combinations
remain intact.
Enabling Custom Crosshair suppresses the native CursorRenderer draw; disabling
restores it. The 26.52 CursorRenderer was identified through the `cursor_renderer`
factory/vtable and its `ui_crosshair` material. Its four-pointer render entry at
RVA `0x8db97b0` matches the signature exactly once in the captured executable.
The hook affects this renderer only. A missing/ambiguous signature leaves native
hiding unavailable and the module tooltip reports that limitation.
Integration tests use the verified native prologue and a controlled draw callback,
checking suppression, argument forwarding, restoration, and repeated toggles.
ImGui tests check black outline vertices with rotating arms and a center dot.
Visual behavior inside Minecraft remains an in-game check after reloading.
## FOV signature and original integration test
The FOV signature was checked against executable sections read from the running
Minecraft Windows **1.26.5203.0 (26.52)** process. It matched exactly once, at
RVA `0x46bd250`. Disassembly identified the `video.fov` option (`0x2f`), a float
return in degrees, a default of 70 degrees, and the game's 130-degree upper clamp.
Call sites pass `(renderer, frame_alpha, bool)` using the Windows x64 ABI.
`fov_changer_test.vcxproj` is a standalone x64 integration test. Its executable
fixture uses the verified function prologue with a controlled 70-degree return;
it is **not** an in-game rendering test. It exercises the production signature
scanner, MinHook, and FOV module, including:
- Missing and ambiguous signatures refuse to enable the module.
- Default off, slider updates, finite bounds, and NaN fallback.
- Forwarding calls with the projection flag false.
- Zoom composition with vanilla/overridden FOV and unchanged hand projection.
- Repeated enable/disable cycles restore the original getter.
Build the test project with Visual Studio/MSBuild in `Debug|x64`, then run
`client/build/tests/fov_changer_test.exe`. Assertions remain enabled in this project.
## In-game check
Load the updated client DLL using your existing workflow. Under **VISUAL**, enable
**fov changer** and expand its **fov** slider. The default is 90 degrees; the range
is 30–130. Check 30, 90, and 130 degrees in a world, then disable the module and
confirm the game's normal FOV returns. This sets a fixed world FOV, including
during sprinting. The zoom module magnifies this FOV when active. Neither module
writes Minecraft's saved FOV setting.
The Debug and Release client DLLs build successfully, and the isolated integration
test passes. Visual behavior inside Minecraft still requires the in-game check.
Future game updates may require a new signature; a missing or ambiguous match
leaves the module unavailable.
+74
View File
@@ -0,0 +1,74 @@
# Villager Macro
Macro replaces the old generic recorder with the supplied `trade.ahk` workflow.
The AutoHotkey source and its Desktop INI are read only; the client stores its own
configuration in the active client profile under `profiles` beside the DLL.
An existing `villager-trade.ini` is still read for initial migration.
## Use
1. Enable **Macro** in **UTILITY**, then close the client menu and open a villager.
2. Hover the trade row and press **F7**, then the trade button and press **F8**.
3. With a villager out of stock, hover the red X and press **F9** to sample the
strongest red pixel in a 17×17 area, matching the script's default calibration.
4. To recalibrate the material detector, hover an **empty** material slot and press
**F10**. The client saves the position, moves away, waits for the hover highlight
to disappear, and reads the empty-slot color. Alternatively edit the coordinates
and RGB color directly in the GUI.
5. Press **F6** to start or stop. **End** or **Escape** also stops immediately.
Ctrl+Escape stops this macro; it does not unload the DLL.
All keys are rebindable. While Macro is enabled, its assigned keys take priority
over other module toggles, including the existing F6/F7/F8 HUD/crosshair bindings.
Disable Macro to return those keys to their normal module controls.
The GUI also provides capture/start/stop buttons. Capture buttons wait for you to
close the client menu, then show a countdown before sampling the cursor position.
Start from the GUI waits for the same countdown after you return to the trade UI.
## Settings and persistence
The GUI exposes delay, click hold duration, maximum attempts, all calibration
coordinates and RGB colors, stock search radius/tolerance, red calibration radius
and minimum dominance, material tolerance, detector toggles, visible-cursor guard,
notification enable/duration, and live progress. A run takes a snapshot of timing,
coordinates, and detection settings when it starts.
The first load imports `Desktop/papertrade.ini` if there is no client profile.
**Import papertrade.ini** imports it again. Row/button/red X entries are supported,
as are optional `[slot] sx/sy/color` entries. **Save settings**, captures, starts,
and disabling Macro save the active client profile. GUI edits also autosave.
Switching profiles stops the run and countdown; enabling Macro from a saved
profile arms it without starting trades. The original INI is never written.
The click order follows the script: preliminary row click and material check;
move to the button before stock detection; select the row; check materials with
the cursor off the slot; click the trade button; repeat up to the attempt limit.
The configurable delays are minimum waits; frame rate can lengthen them. Nothing
sleeps in the rendering callback. Counts reflect trade-button attempts, not server
confirmation that each trade succeeded.
## Stops and notifications
Trading stops on stock exhaustion, the empty-material color, manual stop, module
disable/unload, Escape, focus loss, client menu opening, trading menu closure when
the visible-cursor guard is enabled, window resizing, pixel-read failure, or mouse
input failure. A held left mouse button is released on cancellation; failed releases
retain ownership for retry and prevent another run from starting.
Notifications appear at the upper right, with sliding/fading cards, reflow, shadows,
colored status icons, a spinner while running, and progress/lifetime bars. Trading
updates one persistent card rather than creating a toast for every attempt. The
renderer remains active after Macro is disabled so final stop messages can finish.
## Verification
The isolated trading-engine tests exercise the exact precheck/repeat click order,
three-attempt completion, stock/material stops, read failures, mid-click cancellation,
release retry, disabled checks, and RGB tolerance/red dominance. ImGui tests exercise
notification deduplication, progress updates, rendered finite vertices, dismissal,
and expiry. Debug/Release client builds and the existing integration suite pass.
Villager interaction and screen-pixel matching still require an in-game check with
your resolution/UI scale, resource pack, and trading screen. Recalibrate if those
change; the macro does not identify trades semantically or bypass game trade rules.
+334
View File
@@ -0,0 +1,334 @@
# World and player modules (26.52)
All new modules start disabled. Expand a module with right click. Settings,
text names, keybinds, enabled states, and HUD positions autosave in your profile.
| Module | Controls and behavior |
| --- | --- |
| Block outlines | Color, black outline toggle, width. Outlines the selected block cell using the game's actual hit result. |
| Atmosphere | Custom fog toggle/color, world color, night mode and darkness. Color alpha controls blend strength. Night mode darkens the rendered image without changing time. |
| Armor HUD | Equipped head/chest/legs/feet item names, compact display and hiding empty slots. |
| Name changer | Editable display name. The name getter substitutes it for local player display calls; the original entity string is never changed. |
| Better nametags | Player name, optional health/distance, maximum distance, scale, color and background. Native player names are suppressed during relevant display calls. |
| Target HUD | Aim at a player while holding a sword, axe, bow/crossbow, trident, mace or spear. Shows name, client-reported health, distance and equipped items. Optional weapon requirement, equipment and health bar; default linger is two seconds. |
| Time changer | Custom ticks (0–23999), sunrise/day/sunset/night presets. Changes the visual celestial calculation on the rendering thread; never writes the world's tick/time state. |
| Freelook | Enable the module, then hold Left Alt (rebindable). Mouse movement rotates only the render camera. Releasing returns to the normal view. Sensitivity and status HUD controls are provided. Works with the game's chosen first/third-person perspective. |
| Coordinates | Feet position and optional horizontal speed in blocks per second. |
| Zoom | Hold C by default, rebindable, with optional toggle activation. Magnification 1.25–12x, smooth zoom toggle, transition speed and smooth/linear easing. Composes with FOV changer; restores immediately on menus, focus loss, stale world data or disable. |
| Glint changer | RGBA color picker for the native named enchantment glint uniform. Other shader parameters and input color buffers are unchanged; disabling returns future draws to vanilla values. |
| Music mini player | Track/artist, playing/paused status, progress and previous/play/pause/next buttons. Background, scale, color, width, progress, controls and hide-when-idle settings. Blank player follows Windows' current session; next-player action cycles available source IDs and automatic mode. |
| Inventory tools | Steal transfers chest items into your inventory; dump transfers inventory items into the open chest. Middle-click sorts the hovered chest or inventory panel by item name. Three buttons appear over container screens; the sort button becomes stop while working. Hotbar dumping defaults off. Action delay and button X/Y positions are configurable. |
| Anti AFK | After 30 seconds idle by default, briefly jumps and alternates left/right movement. Jump-only and strafe-only modes, idle interval (10–300 seconds), hold time (50–1000ms), action keys and FPS-style status HUD. Settings/enabled state autosave. |
Anti AFK requires a fresh world snapshot, Minecraft focus and a hidden menu
cursor. Real keyboard/raw mouse activity and held physical keys reset the timer.
Client/game menus, focus loss, stale world data, world changes and disabling
release owned inputs. A focus-loss callback releases keys immediately even if
rendering pauses while minimized. Returning starts a fresh idle countdown. Its
tagged synthetic input does not count as user activity or trigger module hotkeys.
Tests cover interval/hold timing, alternating directions, activity interruption,
pause/resume, physical key ownership, rebinding and failed release retries.
Verify in your Realm by enabling the utility module while Minecraft stays
focused, observing movement/countdown, and then checking that menus, manual play,
Alt-Tab and disabling release keys. Realm idle-kick behavior itself has not been
verified in the automated test.
Inventory tools use native container transactions on the container tick thread,
not guessed slot coordinates or raw inventory writes. Same-name stacks are kept
separate; count/NBT remain owned by the game's stack operations. Armor, crafting
and hotbar sorting are excluded. They stop on focus/menu/controller changes,
cursor-held items, manual clicks elsewhere, and transfer acknowledgement timeout.
Unknown cursor state refuses operations. The verified interfaces are container
tick `0x4df8350`, group size `0x33e7550`, group item `0x33e6f80`, take-all
`0x4dfac60`, place-all `0x4dfae00`, and auto-place `0x4df9f60`. Each signature
matches uniquely in the captured 26.52 executable. Hovered group is at `+0x1098`,
distinct from selected group at `+0x1048`; container model is at `+0x12c0`.
Simulation tests cover sorting, transfers, separate stacks, empty slots and
cancellation. Actual server transactions still require an in-game check with
ordinary test items in a chest, then a full chest, closed screen and focus switch.
Outlines hide when the client menu/game cursor is visible or Minecraft loses
focus. Edges crossing the camera near plane are clipped rather than discarded;
a 75ms selection grace handles intermittent missed block-hit updates and resets
on menus, targets or world changes. This reduces selection/near-plane flicker.
The music card now includes an album-art toggle and a placeholder when no cover
is available. It reads the session thumbnail, limits encoded size to 4MB and
decoded dimensions, scales to at most 256px, decodes RGBA with Windows Imaging
Component, and uploads an immutable D3D11 texture on the rendering thread. Cover
data is cached by player/track/artist/album; player/track changes clear stale art.
Tests check decoded pixel colors, invalid images and real D3D11 texture upload.
Music controls are clickable while the client menu is open; drag the upper part
of the card to move it. The player field can also select an exact Windows source
ID, and module settings provide the same playback actions. Metadata is polled on
a cancellable worker, never synchronously on the rendering thread. Turning the
module off/unloading stops and joins that worker. Missing sessions and denied API
access show an explicit idle/error message. Players must expose a Windows media
session; this does not play local files or guarantee integration with every app.
The API is documented by [Microsoft](https://learn.microsoft.com/en-us/uwp/api/windows.media.control.globalsystemmediatransportcontrolssession).
Glint uses the uniquely verified float4 uniform setter at `0x52f2250`, matches
the FNV-1a hash of `GlintColor` (`0x71ac3c48991afd1e`), checks native slot bounds,
and passes a temporary replacement buffer to the original setter. Standard draws
using that uniform are affected; render paths/resource packs which bypass it may
retain their own color. Verify held enchanted items, armor, and inventory glint
in game, including disable/restoration.
The integration suite tests matching versus unrelated glint uniforms, rejected
slot/count cases, unchanged source buffers, music HUD geometry, and live media
API startup/cancellation/shutdown. Outside the sandbox the read-only Windows API
check found an active media session. No test sends playback commands. Minecraft
rendering and playback actions still need an in-game check.
Target HUD now has a compact head/name/health percentage/bar layout. Its head is
a neutral placeholder because snapshots do not contain player skins. Health and
distance remain beneath the bar. Equipment expands into five additional rows;
it defaults off for new profiles, while saved profile preferences are retained.
Unknown health shows `--%` and an empty track. Zero/invalid maximum health never
produces a fabricated percentage. The original two-second linger is retained.
FPS, watermark, CPS, clock, sprint status, freelook status, coordinates, armor and
target HUDs share the FPS card's fill, border, padding, rounded corners, muted
labels, semibold values, background toggle, scale and color settings. Keystrokes
uses the same surrounding card with its key grid inside. Crosshair geometry keeps
its existing visual controls.
The armor HUD uses readable item names rather than item textures and does not show
durability. Block outlines currently show a block cell (including for non-cube
blocks). World color/night mode filter the rendered game image before client HUD
cards, so vanilla HUD pixels also receive that filter. The filter pauses when the
game shows a menu cursor; fog uses the game's actual dimension fog calculation.
Health is what the client has received; unavailable values are shown as unknown.
Target information expires when leaving/changing worlds, and rendering stops
using snapshots older than half a second.
## Verified game interfaces
The new signatures each match exactly once in the captured executable sections
of Minecraft Windows 1.26.5203.0:
| Interface | RVA |
| --- | --- |
| ClientInstance update | `0x5da7c00` |
| LevelRenderer renderLevel call / target | `0x4be899` / `0x47f8570` |
| Render camera matrices | `0x46cff30` |
| Active render camera helper | `0x9ed0a0` (unique tag anchor at `0x9ed1f1`, resolved through native unwind data) |
| Visual celestial time | `0x2312080` |
| Actor name getter | `0x1a14ac0` |
| Dimension brightness-dependent fog color | `0x2308050` |
Read-only live inspection confirmed local entity registry and versions, the
player's position/rotation, camera origin/projection, armor item names, inventory
selected-slot getter, and paired entity/block hit results. The implementation
uses the native component storage's read-only `get_at` method after checking
sparse versions and packed membership. This avoids constructing/mutating a
registry or assuming an external EnTT build matches Bedrock's custom page sizes.
Immutable snapshots carry copied data to the HUD; entity pointers are not kept
by modules. Freelook saves/restores the camera quaternion around matrix generation.
The isolated integration suite tests sparse versions/membership and the native
storage ABI, projection and quaternion math, time/fog/name display isolation,
profile text round trips, and actual HUD geometry. A real D3D11 WARP device checks
the color/darkness shader's output pixels and renderer state restoration. Existing
FOV, viewmodel, sprint, crosshair, trading, notification and profile tests still
pass. These checks do not replace in-game visual verification after loading.
Zoom tests exercise the actual shared FOV hook both with and without the FOV
override, unchanged hand projection, restoration, menu cancellation and invalid
factor handling. Target HUD geometry covers compact/expanded equipment and
unknown/zero-maximum health. In game, check holding/releasing C, toggle mode,
transition controls, changing FOV while zooming, opening menus and switching focus.
SDK layouts were compared with the MIT-licensed
[26.52 ModBase](https://github.com/b01dev/MCBE_DX12_ModBase) and primary
[LeviLamina headers](https://github.com/LiteLDev/LeviLamina); signatures, offsets
and storage behavior above were verified directly against this game's binary and
read-only process data. No external SDK implementation is linked into the client.
## In-game checks
Enable modules individually after reloading. Check outline width/color on a cube;
fog in the distance; tint/night toggles and restoration; every armor slot;
name changes in a third-person display; other players' tags; target HUD with/without
a weapon and its linger; sunrise/night presets; and freelook while standing still
and moving. Releasing Alt, opening either menu, losing focus, disabling the module,
switching profiles and unloading should return normal camera/input behavior.
## Inventory buttons, tab list and XP HUD (26.52)
Read-only inspection of an open double chest confirmed that the model at
controller +0x12c0 owns the inventory/hotbar/container group views. The old
slot-count function used virtual slot 17, which returns zero for sparse UI views.
The fix verifies the slot-4 capacity getter and reads the ItemStack vector at
+0x100/+0x108 (152-byte stride). The live chest contained 54 slots and inventory
27. A fresh container tick establishes screen availability; an OS cursor flag
is not required. Transfers remain blocked while unfocused or in the client menu.
The server player roster comes from the singleton LevelComponent, rather than
nearby ActorOwner components. Level +0x4e0 points to the roster map; map head/size
are +8/+16 and the node player name is +56. Copied names are sorted and validated
before publication. No player, skin, or server data is modified. Unknown or stale
rosters are not replaced with a nearby-player approximation.
XP uses local AttributesComponent IDs 4 (level) and 5 (experience fraction),
136-byte entries, current value +0x70. Live inspection found level 28 and fraction
0.2983785. XP-to-next-level uses the three vanilla level ranges; remaining XP is
rounded up from the bar fraction. These layouts are specific to the verified build.
Tests cover sparse-view getter validation/capacity, malformed roster chains,
empty rosters, XP range boundaries and invalid attribute values, multi-column
roster geometry, menu previews and clearing collection on disable. In game,
enable inventory tools and check chest buttons; enable tab list and hold Tab;
enable XP progress and compare level/percentage to the vanilla bar. Verify tab
contents with a player farther away than entity rendering range. Notification
cards use the clickgui palette and simple fade/slide, with explicit task progress
only. In-game verification of the rebuilt DLL still requires loading it.
## HUD editor grid snapping
The clickgui's top bar has a `hud editor` popup with snap/grid toggles and a
4-64 pixel grid size (default 10). Hold Shift while dragging to bypass snapping.
Only dragged HUD elements snap; opening the editor leaves existing layouts alone.
Mouse displacement is measured from the original grab point, rather than rounding
each frame's delta, so slow dragging does not get stuck between grid cells.
Screen edges take priority over grid alignment, including HUD cards larger than
the screen. Editor preferences use a reserved profile entry and participate in
normal autosaving, profile switching and defaults for older profiles.
Tests cover accumulated movement, free movement, screen edges/oversized cards,
preference serialization, clamping and restoration when absent from old profiles.
## Inventory action correction
The old function at RVA 0x4df9f60 was auto-take into the cursor, not quick move.
It invokes model virtual slot 9 and therefore left the first stack on the cursor,
triggering the module's cursor cancellation. Steal/dump now bind the actual
controller quick-move action at RVA 0x4dfb4d0 (same four-argument ABI), which
resolves destination routes and invokes model virtual slot 15. Its 112-byte
signature was verified unique in the captured 1.26.5203.0 executable.
Sorting now uses the native model slot-to-slot swap at RVA 0x33e9880, with a
verified unique 96-byte signature. Slot descriptors explicitly use the game's
32-byte string plus slot-index layout, independent of debug STL layout. The
native swap queues one complete transaction and never borrows the cursor.
Sorting waits for the source change before scheduling the next swap, respecting
server update delays and preserving complete native stack data. Tests include
delayed acknowledgement and inventory/hotbar quick-move routing. In-game checks
still require reloading the rebuilt DLL and checking steal, dump and sort.
## Menu cursor ownership
ImGui's Win32 cursor updates are disabled with NoMouseCursorChange. Previously,
MouseDrawCursor caused its WM_SETCURSOR handler to call SetCursor(nullptr) on
Minecraft's window thread, leaving an invisible native cursor after close.
The menu now draws a software pointer only when the OS cursor is already hidden;
otherwise the native inventory pointer remains visible. Closing restores clipping
and posts WM_SETCURSOR to let the native window procedure choose its cursor on
its own thread. No ShowCursor counter manipulation or forced gameplay pointer.
Check opening/closing with Right Shift and Escape, both in gameplay and with a
chest/trade screen open, then moving the pointer without leaving Minecraft.
## Sorter compatibility correction
The live open chest used the legacy model path (model +0xa0 was null), and its
slots were correctly populated with unsorted item names/counts. The direct
slot-to-slot model swap was rejected on this path. This supersedes the direct
swap implementation described above. Sorting now uses native controller actions:
take-all 0x4dfac60, cursor swap 0x4dfa820, and place-all 0x4dfae00. Each signature
was checked unique against the captured executable. The controller actions also
perform native selection/UI bookkeeping that direct model calls bypass.
A staged state machine waits for the picked-up stack and empty source slot,
then the destination and displaced cursor stack, then cursor clearance and
place-back confirmation. It honors the configured action delay, accepts only
the expected held stack during its own operation, and does not continue on
controller/focus changes. A declined swap attempts to return the original stack
to its still-empty source. Timeouts provide a concise notification. Tests cover
multi-step sorting, delayed confirmation, rejected-swap recovery, empty slots
and separate same-name stacks. Reload and check sorting in a chest and inventory;
in-game success has not been verified by these isolated tests.
## Whole-stack pickup correction
The recorded failed sort had `sort_taken = arrow x10`, matching the reported
pickup of only five arrows. Binary inspection confirmed controller 0x4dfac60
calls model slot 12 (0x33e9c20), whose legacy request is subtype 1 and computes
half the stack. The previous name `take_all` was incorrect. Sorting now binds
only the controller left-click/swap action at 0x4dfa820 for pickup, replacement,
place-back and recovery; no half-stack action is called. The model slot-10 legacy
request uses subtype 0 (whole stack). This supersedes the pickup binding in the
previous section. Tests now explicitly observe an entire arrow x10 stack on the
cursor during sorting, along with odd-count x7 stacks and final count conservation.
## Recorded sort stop and directional placement
Live verification showed full pickup succeeded (charcoal x8 held, source slot 53
empty). The recorded stop reason was timeout, and the chest remained unchanged
after recovery. Binary analysis distinguished full take (controller 0x4dfa820,
model slot 10, source -> cursor) from full place (controller 0x4dfae00, model slot
11, cursor -> destination). The prior use of the take action on an occupied
cursor was incorrect. Sorting now takes once, places into the destination, then
places the displaced stack back into the source. The test take action rejects an
occupied cursor, rather than incorrectly modeling every call as a symmetric swap.
Additional controller ticks cannot overwrite an active owner's fresh snapshot;
phase timeouts govern transactions instead of display freshness. Recorded stop
reasons distinguish timeout, focus, controller, cursor, native action failure and
explicit stop. These changes supersede the same-action sequence above.
## Third-person orbit freelook
Freelook now temporarily overrides the native view-perspective getter to back
third person (1) while the hold key is active. Getter RVA 0xfb7430 is matched by a
unique signature against the captured 26.52 binary; the caller's native perspective
is returned unchanged outside freelook. CameraComponent orientation +0x30 and
position +0x40 are substituted only around matrix generation, then restored.
The camera position moves around the current local-player eye pivot according to
the look quaternion and adjustable radius (default 4, range 1-8 blocks). Input
continues to suppress camera/player mouse-turn packets during the hold. Release,
menus, loss of focus, disabling, profile switches and unloading remove the override.
No game perspective setting is saved/rewritten. Math tests cover side/front/full
rotation, fixed pivot and radius at steep pitch. Check in game that the local body
is visible, the camera orbits, aim stays fixed, and releasing Alt restores the prior
view. The orbit currently does not shorten its radius for walls/obstacles.
## Freelook player-angle lock
Read-only inspection verified ActorRotationComponent (16 bytes), head/body yaw
components (8 bytes each), and RenderRotationComponent (8 bytes). While holding
freelook, the local entity's current/previous pitch/yaw and head/body/render angles
are held at the entry values before/after client update and before rendering.
This supplements raw-input suppression, which does not cover all Bedrock input
paths. Position/velocity and movement keys are not modified. No component pointers
are retained across updates; registry/entity identity changes start a new lock.
Release/menu/focus loss/disable removes the angle lock, allowing normal turning.
Tests verify angle preservation despite attempted changes, continued translation,
independent orbit rotation, release/re-entry and changed player identity.
## Native freelook input verification
A live held-Alt trace showed `was_looking=1`, camera yaw/pitch staying zero,
`frozen_look.held=0`, and changing player angles. Thus Win32 raw-input deltas were
not delivered and the angle-lock lookup failed. ActorRotation's verified native
16-byte `get_at` starts with `mov rax,rdx` before loading its payload pages, unlike
the 8-byte getter previously accepted. The protected ECS accessor now validates
that specific alternate prefix as well. A test executes the actual leaf layout
against controlled sparse/payload storage to cover the missing ABI variant.
Freelook no longer relies on WM_INPUT for orbit movement. Native pitch/yaw changes
are measured against the held player angle, accumulated as camera-only deltas,
and the player/head/body/render angles are restored. Normal movement messages are
forwarded; WASD/jump remain active. Camera sensitivity scales the native angular
deltas. Tests cover angular wraparound, fixed player angles and the native getter.
The rebuilt native-input version was then monitored live during a held-Alt mouse
movement test (20 samples). `frozen_look.held` stayed true; player current/previous
pitch and yaw remained 16.716339 / -120.978310 throughout, while camera orbit yaw
and pitch changed across the samples. This verifies the angle lock and camera
input routing in the running game, rather than only in isolated math fixtures.
The native look target is now consumed by changes relative to the last observed
native target. Reapplying a cached absolute target no longer produces repeated
orbit deltas; reads of the restored player baseline do not reset that reference.
A regression checks that a repeated target contributes zero camera movement,
then a new target contributes only its incremental pitch/yaw change. This fixes
the observed continuous orbit after stopping the mouse.
+46
View File
@@ -0,0 +1,46 @@
#pragma once
#include "../src/modules/anti_afk_engine.h"
inline void test_anti_afk() {
using namespace anti_afk_logic;
anti_afk_logic::config settings;settings.interval=1000;settings.hold=150;
bool physical_keys[256]{};bool success=true;
std::vector<std::pair<int,bool>> events;
const auto physical=[&](int key){return physical_keys[key];};
const auto send=[&](int key,bool down){if(success)events.emplace_back(key,down);return success;};
engine timer;
timer.update(0,true,0,false,settings,physical,send);
timer.update(999,true,0,false,settings,physical,send);assert(events.empty());
timer.update(1000,true,0,false,settings,physical,send);
assert(events.size()==2 && events[0]==std::make_pair(VK_SPACE,true) && events[1]==std::make_pair(int('A'),true));
timer.update(1149,true,0,false,settings,physical,send);assert(events.size()==2);
timer.update(1150,true,0,false,settings,physical,send);assert(events.size()==4 && !timer.active());
timer.update(2000,true,0,false,settings,physical,send);assert(events.size()==6 && events.back()==std::make_pair(int('D'),true));
timer.update(2010,true,1,false,settings,physical,send);assert(events.size()==8 && !timer.active());
timer.update(2900,true,1,false,settings,physical,send);assert(events.size()==8);
timer.update(3010,true,1,false,settings,physical,send);assert(timer.active());
physical_keys[VK_SPACE]=true;const auto before=events.size();
timer.update(3020,true,2,true,settings,physical,send);
assert(!timer.active() && events.size()==before+1 && events.back()==std::make_pair(int('A'),false));
physical_keys[VK_SPACE]=false;
timer.update(8000,false,2,false,settings,physical,send);const auto paused=events.size();
timer.update(9000,false,2,false,settings,physical,send);assert(events.size()==paused);
timer.update(9100,true,2,false,settings,physical,send);assert(events.size()==paused);
timer.update(10100,true,2,false,settings,physical,send);assert(timer.active());
success=false;timer.stop(physical,send);assert(timer.active());
success=true;timer.stop(physical,send);assert(!timer.active());
settings.mode=0;settings.jump='J';timer.update(11000,true,2,false,settings,physical,send);
const auto rebound=events.size();timer.update(12000,true,2,false,settings,physical,send);
assert(events.size()==rebound+1 && events.back()==std::make_pair(int('J'),true));
timer.stop(physical,send);
const auto sequence=input::activity_sequence.load();
const auto previous=SetMessageExtraInfo(static_cast<LPARAM>(input::sprint_input_tag));
input::observe_message(nullptr,WM_KEYDOWN,VK_SPACE,0);assert(input::activity_sequence==sequence);
SetMessageExtraInfo(previous);input::observe_message(nullptr,WM_KEYDOWN,VK_SPACE,0);
assert(input::activity_sequence==sequence+1);input::observe_message(nullptr,WM_KILLFOCUS,0,0);
input::observe_message(nullptr,WM_LBUTTONDBLCLK,0,0);assert(input::physical_keys[VK_LBUTTON]);
input::observe_message(nullptr,WM_LBUTTONUP,0,0);assert(!input::physical_keys[VK_LBUTTON]);
input::observe_message(nullptr,WM_XBUTTONDOWN,WPARAM(XBUTTON1)<<16,0);assert(input::physical_keys[VK_XBUTTON1]);
input::observe_message(nullptr,WM_XBUTTONUP,WPARAM(XBUTTON1)<<16,0);assert(!input::physical_keys[VK_XBUTTON1]);
std::cout<<"PASS: anti-AFK timing, alternating pulses, activity/menu cancellation, physical key ownership, rebinding and release retry\n";
}
+444
View File
@@ -0,0 +1,444 @@
// Integration test: the verified FOV prologue with a controlled 70-degree return.
// Exercises the real signature scanner, MinHook trampoline, and module lifecycle.
#include <cassert>
#include <iostream>
#include <limits>
#include "../src/modules/fov_changer.h"
#include "../src/modules/viewmodel.h"
#include "../src/modules/sprint_latch.h"
#include "../src/modules/crosshair_animation.h"
#include "../src/modules/crosshair.h"
#include "../src/modules/villager_trade.h"
#include "../src/modules/trade_profile.h"
#include "../src/gui/notifications.h"
#include "../src/input.h"
#pragma section(".fvtest", read, execute)
#pragma comment(linker, "/SECTION:.fvtest,ER")
__declspec(allocate(".fvtest")) unsigned char fixture[] = {0x56, 0x57, 0x53, 0x48, 0x83, 0xec, 0x60, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x50, 0x0f, 0x29, 0x7c, 0x24, 0x40, 0x0f, 0x29, 0x74, 0x24, 0x30, 0x44, 0x89, 0xc3, 0x0f, 0x28, 0xf1, 0x48, 0x89, 0xce, 0x45, 0x84, 0xc0, 0x0f, 0x84, 0x23, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x86, 0x88, 0x11, 0x00, 0x00, 0x48, 0x8b, 0x88, 0xf8, 0x03, 0x00, 0x00, 0x48, 0x8b, 0x01, 0x48, 0x8b, 0x80, 0xd8, 0x00, 0x00, 0x00, 0x48, 0x8d, 0x54, 0x24, 0x28, 0x41, 0xb8, 0x2f, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x10, 0x05, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x28, 0x74, 0x24, 0x30, 0x0f, 0x28, 0x7c, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x50, 0x48, 0x83, 0xc4, 0x60, 0x5b, 0x5f, 0x5e, 0xc3, 0x00, 0x00, 0x8c, 0x42};
__declspec(allocate(".fvtest")) unsigned char duplicate[sizeof(fixture)] = {};
#include "separate_hand_fixture.h"
#include "viewmodel_fixture.h"
#include "native_crosshair_fixture.h"
static void write_code(unsigned char* target, const unsigned char* bytes, size_t size);
static void identity(float* m) {
memset(m, 0, sizeof(float) * 16);
m[0] = m[5] = m[10] = m[15] = 1.f;
}
static bool close_float(float a, float b) { return std::fabs(a - b) < 0.00001f; }
static float main_seen[16], offhand_seen[16], after_offhand[16];
static unsigned char test_item[0x30]{};
static void __fastcall offhand_callback(void*, void* context, void*, void*) {
std::memcpy(offhand_seen, game::viewmodel_world_matrix(context), sizeof(offhand_seen));
}
static void __fastcall hands_callback(void*, void* context, void* source, unsigned char) {
float* matrix = game::viewmodel_world_matrix(context);
// Reproduce the real renderer consuming its distinct input matrix.
if (source) std::memcpy(matrix,source,16*sizeof(float));
std::memcpy(main_seen, matrix, sizeof(main_seen));
// An item/blocking animation applied after the shared hand transform.
const float animation[] = {0, 2, 0}, rotation[] = {0, 0, 0};
game::transform_viewmodel(matrix, animation, rotation);
using call_fn = void(__fastcall*)(void*, void*, void*, void*);
reinterpret_cast<call_fn>(static_cast<void*>(offhand_call_fixture))(nullptr, context, nullptr, test_item);
std::memcpy(after_offhand, matrix, sizeof(after_offhand));
}
static void test_viewmodel() {
uintptr_t callback = reinterpret_cast<uintptr_t>(&hands_callback);
write_code(hands_fixture + hands_callback_offset, reinterpret_cast<unsigned char*>(&callback), sizeof(callback));
callback = reinterpret_cast<uintptr_t>(&offhand_callback);
write_code(offhand_fixture + offhand_callback_offset, reinterpret_cast<unsigned char*>(&callback), sizeof(callback));
const int32_t displacement = static_cast<int32_t>(offhand_fixture - (offhand_call_fixture + offhand_call_offset + 18));
write_code(offhand_call_fixture + offhand_call_offset + 14,
reinterpret_cast<const unsigned char*>(&displacement), sizeof(displacement));
assert(sigscan::find(sigs::render_hands,true)==hands_fixture);
assert(sigscan::find(sigs::render_offhand_item,true)==offhand_fixture);
test_item[0x23]=1;
unsigned char renderer[0x178]{}, context[0x30]{}, render[0x20]{}, screen[0xc0]{};
float matrix[16]; identity(matrix);
float* map[]={matrix};
*reinterpret_cast<void**>(context+0x28)=render;
*reinterpret_cast<void**>(render+0x18)=screen;
*reinterpret_cast<void**>(screen+0x88)=map;
*reinterpret_cast<size_t*>(screen+0x90)=1;
*reinterpret_cast<size_t*>(screen+0xa0)=1;
void* vtable[0x100]{}; void* client=vtable;
*reinterpret_cast<void**>(renderer+0x170)=&client;
viewmodel module;
using draw_fn=void(__fastcall*)(void*,void*,void*,unsigned char);
auto draw=reinterpret_cast<draw_fn>(static_cast<void*>(hands_fixture));
module.set_enabled(true); assert(module.enabled());
module.settings()[0].float_value=0.5f;
module.settings()[1].float_value=-0.25f;
module.settings()[6].float_value=-0.75f;
module.settings()[7].float_value=0.4f;
// The earlier working direct hand hook must continue to apply sliders.
using bob_fn=void(__fastcall*)(void*,float*,float);
unsigned char bob_renderer[0x1200]{};
float bob_matrix[16];identity(bob_matrix);
module.on_render();
reinterpret_cast<bob_fn>(static_cast<void*>(hand_fixture))(bob_renderer,bob_matrix,0.5f);
assert(close_float(bob_matrix[12],1.5f) && close_float(bob_matrix[13],-0.25f));
module.on_frame_end(); // Invalidate previous-frame bob snapshots.
module.on_render(); draw(renderer,context,nullptr,0x21);
assert(close_float(main_seen[12],0.5f) && close_float(main_seen[13],-0.25f));
assert(close_float(offhand_seen[12],-0.75f) && close_float(offhand_seen[13],2.4f));
assert(close_float(after_offhand[12],0.5f) && close_float(after_offhand[13],1.75f));
assert(matrix[12]==0 && matrix[13]==0 && matrix[0]==1); // Scope restores shared matrix.
float distinct_source[16];identity(distinct_source);
draw(renderer,context,distinct_source,0x23);
assert(close_float(main_seen[12],0.5f));
assert(close_float(offhand_seen[12],-0.75f));
assert(distinct_source[12]==0); // Never alter the caller's input matrix.
for(int axis=0;axis<3;++axis) {
for(int i=0;i<12;++i) module.settings()[i].float_value=0;
module.settings()[3+axis].float_value=90.f;
module.on_render();draw(renderer,context,nullptr,0x21);
// Offhand remains neutral with its own original animation, independent of main rotation.
assert(close_float(offhand_seen[0],1) && close_float(offhand_seen[5],1) && close_float(offhand_seen[10],1));
if(axis==0) assert(close_float(main_seen[6],1) && close_float(main_seen[9],-1));
if(axis==1) assert(close_float(main_seen[2],-1) && close_float(main_seen[8],1));
if(axis==2) assert(close_float(main_seen[1],1) && close_float(main_seen[4],-1));
module.settings()[3+axis].float_value=0;
module.settings()[9+axis].float_value=90;
module.on_render();draw(renderer,context,nullptr,0x21);
assert(main_seen[0]==1 && main_seen[5]==1 && main_seen[10]==1);
if(axis==0) assert(close_float(offhand_seen[6],1) && close_float(offhand_seen[9],-1));
if(axis==1) assert(close_float(offhand_seen[2],-1) && close_float(offhand_seen[8],1));
if(axis==2) assert(close_float(offhand_seen[1],1) && close_float(offhand_seen[4],-1));
}
module.settings()[12].bool_value=false;
module.settings()[0].float_value=1;
module.on_render();draw(renderer,context,nullptr,0x21);
assert(close_float(main_seen[12],1) && close_float(offhand_seen[12],1));
for(int i=0;i<10;++i) {
module.set_enabled(false);identity(matrix);draw(renderer,context,nullptr,0x21);
assert(main_seen[12]==0 && offhand_seen[12]==0);
module.set_enabled(true);identity(matrix);draw(renderer,context,nullptr,0x21);
assert(close_float(main_seen[12],1));
}
module.set_enabled(false);
}
static void test_crosshair_animation() {
using namespace crosshair_animation;
for(int easing=0;easing<5;++easing) {
assert(ease(0,easing)==0 && ease(1,easing)==1);
float previous=0;
for(int i=0;i<=100;++i) { const float value=ease(i/100.f,easing);assert(value>=previous && value<=1);previous=value; }
channel slow,fast;
for(int i=0;i<60;++i) slow.update(1.f/60,true,0,false,0.75f,easing);
for(int i=0;i<144;++i) fast.update(1.f/144,true,0,false,0.75f,easing);
assert(std::fabs(slow.current-fast.current)<0.0001f);
channel reactive;
for(int i=0;i<60;++i) reactive.update(1.f/60,true,1,true,2,easing);
assert(reactive.current==1);
for(int i=0;i<60;++i) reactive.update(1.f/60,true,1,false,2,easing);
assert(reactive.current==0);
assert(reactive.update(0.1f,false,1,true,2,easing)==0);
double phase=0;
for(int i=0;i<60;++i) spin(phase,1.f/60,true,90,easing);
assert(std::fabs(phase-0.25)<0.0001);
assert(spin(phase,0.1f,false,90,easing)==0 && phase==0);
}
}
struct fake_trade_io : villager_trade::io {
std::vector<std::pair<char,villager_trade::point>> events;
int downs=0,ups=0,reads=0,stock_reads=0;
bool held=false,exhausted=false,stock_empty=false,read_ok=true,release_ok=true;
bool move(villager_trade::point p) override {events.push_back({'m',p});return true;}
bool button(bool down) override {
if(!down && !release_ok) return false;
if(down) {++downs;held=true;}else {++ups;held=false;}return true;
}
bool pixel(villager_trade::point,uint32_t& color) override {
++reads;color=exhausted ? 0x993434 : 0x111111;return read_ok;
}
bool stock(const villager_trade::config&,bool& found) override {++stock_reads;found=stock_empty;return read_ok;}
};
static void test_villager_trade() {
using namespace villager_trade;
assert(color_near(0xBA370F,0xBA370F,0));
assert(color_near(0xBC390F,0xBA370F,2));
assert(!color_near(0xBD390F,0xBA370F,2));
assert(red_score(0xBA370F)==131);
config settings;settings.row={10,20};settings.button={30,40};settings.stock={50,60};settings.stock_check=true;settings.max_trades=3;
auto run=[](engine& trading,fake_trade_io& input) {for(int i=0;i<1000 && trading.running();++i) trading.tick(i*0.01,input);assert(!trading.running());};
fake_trade_io input;engine trading;
assert(trading.start(settings,0));run(trading,input);
assert(trading.result()==reason::completed && trading.count()==3);
assert(input.downs==7 && input.ups==7 && !input.held && input.stock_reads==3 && input.reads==4);
assert(input.events[0].second.x==10 && input.events[1].second.x==30 && input.events[2].second.x==10);
fake_trade_io empty;empty.exhausted=true;
trading.start(settings,0);run(trading,empty);
assert(trading.result()==reason::out_of_materials && trading.count()==0 && empty.downs==1 && !empty.held);
fake_trade_io sold_out;sold_out.stock_empty=true;
trading.start(settings,0);run(trading,sold_out);
assert(trading.result()==reason::out_of_stock && sold_out.downs==1 && sold_out.ups==1);
fake_trade_io failed;failed.read_ok=false;
trading.start(settings,0);run(trading,failed);
assert(trading.result()==reason::read_failed && !failed.held);
fake_trade_io cancel;
trading.start(settings,0);trading.tick(0,cancel);trading.tick(0.01,cancel);
assert(cancel.held);
cancel.release_ok=false;trading.stop(cancel);
assert(!trading.running() && !trading.start(settings,0));
cancel.release_ok=true;trading.release_pending(cancel);
assert(!cancel.held && cancel.ups==1 && trading.start(settings,0));
trading.stop(cancel);
fake_trade_io disabled_checks;disabled_checks.read_ok=false;
settings.stock_check=false;settings.material_check=false;
trading.start(settings,0);run(trading,disabled_checks);
assert(trading.result()==reason::completed && disabled_checks.reads==0 && disabled_checks.stock_reads==0);
}
static int native_crosshair_draws=0;
static void __fastcall native_crosshair_callback(void* a,void* b,void* c,void* d) {
assert(a==reinterpret_cast<void*>(1) && b==reinterpret_cast<void*>(2) &&
c==reinterpret_cast<void*>(3) && d==reinterpret_cast<void*>(4));
++native_crosshair_draws;
}
static void test_crosshair_render() {
const uintptr_t callback=reinterpret_cast<uintptr_t>(&native_crosshair_callback);
write_code(native_crosshair_fixture+native_crosshair_callback_offset,
reinterpret_cast<const unsigned char*>(&callback),sizeof(callback));
using native_draw_fn=void(__fastcall*)(void*,void*,void*,void*);
auto native_draw=reinterpret_cast<native_draw_fn>(static_cast<void*>(native_crosshair_fixture));
auto draw_native=[&] { native_draw(reinterpret_cast<void*>(1),reinterpret_cast<void*>(2),
reinterpret_cast<void*>(3),reinterpret_cast<void*>(4)); };
ImGui::CreateContext();
ImGuiIO& io=ImGui::GetIO();
io.IniFilename=nullptr;
io.DisplaySize=ImVec2(800,600);
io.DeltaTime=1.f/60;
unsigned char* pixels;int width,height;
io.Fonts->GetTexDataAsRGBA32(&pixels,&width,&height);
crosshair cross;
draw_native();assert(native_crosshair_draws==1);
auto setting_named=[&](const char* name)->setting& {
for(auto& value:cross.settings()) if(value.name==name) return value;
assert(false);return cross.settings().front();
};
cross.set_enabled(true);
draw_native();assert(native_crosshair_draws==1); // Native drawing suppressed only while enabled.
for(int frame=0;frame<4;++frame) {
if(frame==1) {
setting_named("gradient").bool_value=true;
setting_named("gradient color").color[0]=0;
setting_named("spin").bool_value=true;
setting_named("dynamic gap").bool_value=true;
setting_named("dynamic length").bool_value=true;
}
if(frame==2) {
setting_named("gradient").bool_value=false;
setting_named("spin").bool_value=false;
setting_named("dynamic gap").bool_value=false;
setting_named("dynamic length").bool_value=false;
}
if(frame==3) {
setting_named("black outline").bool_value=true;
setting_named("outline width").float_value=2;
setting_named("center dot").bool_value=true;
setting_named("spin").bool_value=true;
}
ImGui::NewFrame();cross.on_render();
ImDrawList* draw=ImGui::GetBackgroundDrawList();
if(frame<3) assert(draw->VtxBuffer.Size==16 && draw->IdxBuffer.Size==24);
else {
assert(draw->VtxBuffer.Size>32 && draw->IdxBuffer.Size>48);
bool black=false;
for(const auto& vertex:draw->VtxBuffer)
if(vertex.col==IM_COL32(0,0,0,255)) black=true;
assert(black);
}
for(const auto& vertex:draw->VtxBuffer) assert(std::isfinite(vertex.pos.x) && std::isfinite(vertex.pos.y));
for(auto index:draw->IdxBuffer) assert(index<draw->VtxBuffer.Size);
if(frame==1) {
assert(draw->VtxBuffer[0].col!=draw->VtxBuffer[1].col);
assert(std::fabs(draw->VtxBuffer[0].pos.y-draw->VtxBuffer[1].pos.y)>0.1f);
} else if(frame<3) {
assert(draw->VtxBuffer[0].col==draw->VtxBuffer[1].col);
assert(close_float(draw->VtxBuffer[0].pos.x,404) && close_float(draw->VtxBuffer[1].pos.x,412));
}
ImGui::Render();
}
cross.set_enabled(false);
draw_native();assert(native_crosshair_draws==2);
for(int i=0;i<5;++i) {
cross.set_enabled(true);draw_native();assert(native_crosshair_draws==2+i);
cross.set_enabled(false);draw_native();assert(native_crosshair_draws==3+i);
}
notifications::items.clear();
notifications::push("Trading","1 / 500 trade attempts",notifications::kind::info,0,"trade",0.1f);
notifications::push("Trading","2 / 500 trade attempts",notifications::kind::info,0,"trade",0.2f);
assert(notifications::items.size()==1 && notifications::items[0].progress==0.2f);
notifications::push("Trade row saved","Client position: 814, 425",notifications::kind::success,3);
notifications::push("Out of stock","Trading stopped and mouse released.",notifications::kind::warning,3);
for(auto& item:notifications::items) item.born-=0.4;
ImGui::NewFrame();notifications::draw();
assert(ImGui::GetForegroundDrawList()->VtxBuffer.Size>0);
for(const auto& vertex:ImGui::GetForegroundDrawList()->VtxBuffer) assert(std::isfinite(vertex.pos.x) && std::isfinite(vertex.pos.y));
ImGui::Render();
notifications::dismiss("trade");assert(notifications::items[0].duration>0);
for(auto& item:notifications::items) item.born-=20;
ImGui::NewFrame();notifications::draw();assert(notifications::items.empty());ImGui::Render();
ImGui::DestroyContext();
}
static void test_sprint() {
sprint_latch latch;
bool physically_down[256]{};
std::vector<std::pair<int,bool>> events;
bool success = true;
auto physical = [&](int key) { return physically_down[key]; };
auto send = [&](int key, bool down) { if (success) events.emplace_back(key,down); return success; };
latch.update(true,VK_LCONTROL,physical,send);
latch.update(true,VK_LCONTROL,physical,send);
assert(events.size()==1 && latch.held_key()==VK_LCONTROL);
latch.update(false,0,physical,send);
assert(events.size()==2 && !events.back().second && latch.held_key()==0);
physically_down[VK_LCONTROL]=true;
latch.update(true,VK_LCONTROL,physical,send);
assert(events.size()==2 && latch.held_key()==0);
physically_down[VK_LCONTROL]=false;
latch.update(true,VK_LCONTROL,physical,send);
latch.update(true,VK_RCONTROL,physical,send);
assert(events[3]==std::make_pair(VK_LCONTROL,false) && events[4]==std::make_pair(VK_RCONTROL,true));
success=false;
latch.update(false,0,physical,send);
assert(latch.held_key()==VK_RCONTROL); // Retry a failed key-up rather than losing ownership.
success=true;
latch.update(false,0,physical,send);
assert(latch.held_key()==0);
latch.update(true,VK_LCONTROL,physical,send);
physically_down[VK_LCONTROL]=true;
const auto before=events.size();
latch.update(false,0,physical,send);
assert(latch.held_key()==0 && events.size()==before); // No release of a physical key.
const LPARAM previous=SetMessageExtraInfo(static_cast<LPARAM>(input::sprint_input_tag));
input::observe_message(nullptr,WM_KEYDOWN,VK_CONTROL,0);
assert(!input::physical_keys[VK_LCONTROL]);
SetMessageExtraInfo(previous);
input::observe_message(nullptr,WM_KEYDOWN,VK_CONTROL,0);
assert(input::physical_keys[VK_LCONTROL]);
input::observe_message(nullptr,WM_KILLFOCUS,0,0);
assert(!input::physical_keys[VK_LCONTROL]);
}
static void write_code(unsigned char* target, const unsigned char* bytes, size_t size) {
DWORD old;
assert(VirtualProtect(target, size, PAGE_EXECUTE_READWRITE, &old));
memcpy(target, bytes, size);
DWORD ignored;
assert(VirtualProtect(target, size, old, &ignored));
FlushInstructionCache(GetCurrentProcess(), target, size);
}
#include "profile_tests.h"
#include "world_tests.h"
#include "media_glint_tests.h"
#include "inventory_tests.h"
#include "anti_afk_tests.h"
#include "server_hud_tests.h"
#include "hud_grid_tests.h"
int main() {
test_profiles();
test_world_math_and_hooks();
test_world_filter();
test_world_huds();
test_media_and_glint();
test_inventory_tools();
test_anti_afk();
test_server_hud();
test_hud_grid();
// Fail closed on zero or multiple executable matches.
assert(sigscan::find(sigs::get_fov, true) == fixture);
write_code(duplicate, fixture, sizeof(fixture));
assert(sigscan::find(sigs::get_fov, true) == nullptr);
unsigned char zero = 0;
write_code(duplicate, &zero, 1);
write_code(fixture, &zero, 1);
assert(sigscan::find(sigs::get_fov, true) == nullptr);
unsigned char push_rsi = 0x56;
write_code(fixture, &push_rsi, 1);
assert(MH_Initialize() == MH_OK);
test_viewmodel();
test_sprint();
test_crosshair_animation();
test_villager_trade();
test_crosshair_render();
write_code(duplicate, fixture, sizeof(fixture));
{
fov_changer unavailable;
unavailable.set_enabled(true);
assert(!unavailable.enabled());
}
write_code(duplicate, &zero, 1);
write_code(fixture, &zero, 1);
{
fov_changer unavailable;
unavailable.set_enabled(true);
assert(!unavailable.enabled());
}
write_code(fixture, &push_rsi, 1);
{
fov_changer module;
using getter = float(__fastcall*)(void*, float, bool);
auto get_fov = reinterpret_cast<getter>(static_cast<void*>(fixture));
// Match the pointer reads in the verified game's function entry.
alignas(16) unsigned char renderer[0x1200] = {};
alignas(16) unsigned char context[0x400] = {};
void* options_vtable[0x100] = {};
void* options = options_vtable;
*reinterpret_cast<void**>(renderer + 0x1188) = context;
*reinterpret_cast<void**>(context + 0x3f8) = &options;
assert(!module.enabled());
assert(get_fov(renderer, 0.5f, true) == 70.f);
module.set_enabled(true);
assert(module.enabled());
assert(get_fov(renderer, 0.5f, true) == 90.f);
assert(get_fov(renderer, 0.5f, false) == 70.f);
module.settings()[0].float_value = 110.f;
module.on_render();
assert(get_fov(renderer, 0.5f, true) == 110.f);
module.settings()[0].float_value = 200.f;
module.on_render();
assert(get_fov(renderer, 0.5f, true) == 130.f);
module.settings()[0].float_value = 1.f;
module.on_render();
assert(get_fov(renderer, 0.5f, true) == 30.f);
module.settings()[0].float_value = std::numeric_limits<float>::quiet_NaN();
module.on_render();
assert(get_fov(renderer, 0.5f, true) == 90.f);
for (int i = 0; i < 10; ++i) {
module.set_enabled(false);
assert(get_fov(renderer, 0.5f, true) == 70.f);
module.set_enabled(true);
assert(get_fov(renderer, 0.5f, true) == 90.f);
}
module.set_enabled(false);
assert(get_fov(renderer, 0.5f, true) == 70.f);
// Zoom shares the verified hook and must work with FOV changer disabled,
// compose with its override, and leave hand projection untouched.
zoom_effect::magnification=4.f;
const float zoomed=get_fov(renderer,0.5f,true);
assert(zoomed>0 && zoomed<30 && std::abs(zoomed-zoom_effect::apply(70,4))<.001f);
assert(get_fov(renderer,0.5f,false)==70.f);
module.set_enabled(true);
assert(std::abs(get_fov(renderer,0.5f,true)-zoom_effect::apply(90,4))<.001f);
module.set_enabled(false);
zoom_effect::magnification=1;
assert(get_fov(renderer,0.5f,true)==70.f);
assert(zoom_effect::apply(70,std::numeric_limits<float>::quiet_NaN())==70);
assert(MH_Uninitialize() == MH_OK);
}
std::cout << "PASS: unique/missing/ambiguous signatures, actual hook/trampoline, "
"FOV and independent main/offhand transforms/restoration, sprint ownership/release/rebinding, "
"physical versus injected input, crosshair rendering/native suppression, villager trading stops/cancellation, animated notifications\n";
}
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64"><Configuration>Debug</Configuration><Platform>x64</Platform></ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals"><WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion></PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration"><ConfigurationType>Application</ConfigurationType><PlatformToolset>v143</PlatformToolset></PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup><OutDir>$(ProjectDir)..\build\tests\</OutDir><IntDir>$(OutDir)obj\</IntDir></PropertyGroup>
<ItemDefinitionGroup>
<ClCompile><LanguageStandard>stdcpp17</LanguageStandard><WarningLevel>Level3</WarningLevel><UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions><AdditionalIncludeDirectories>$(ProjectDir)..\vendor\minhook\include;$(ProjectDir)..\vendor\imgui;$(ProjectDir)..\vendor\imgui\backends</AdditionalIncludeDirectories></ClCompile>
<Link><AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies></Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="fov_changer_test.cc" />
<ClCompile Include="..\vendor\imgui\imgui.cpp" />
<ClCompile Include="..\vendor\imgui\imgui_draw.cpp" />
<ClCompile Include="..\vendor\imgui\imgui_tables.cpp" />
<ClCompile Include="..\vendor\imgui\imgui_widgets.cpp" />
<ClCompile Include="..\vendor\minhook\src\buffer.c" />
<ClCompile Include="..\vendor\minhook\src\hook.c" />
<ClCompile Include="..\vendor\minhook\src\trampoline.c" />
<ClCompile Include="..\vendor\minhook\src\hde\hde64.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include "../src/config/profiles.h"
inline void test_hud_grid() {
using namespace hud_editor;
drag gesture;gesture.begin({23,37},{100,100});
auto p=gesture.move({101,101},{100,30},{800,600},true,10);assert(p.x==20 && p.y==40);
// Repeated sub-grid mouse movements must eventually move the snapped card.
for(int i=1;i<=12;++i)p=gesture.move({100.f+i,100.f+i},{100,30},{800,600},true,10);
assert(p.x==40 && p.y==50);
p=gesture.move({112,112},{100,30},{800,600},false,10);assert(p.x==35 && p.y==49);
p=gesture.move({2000,2000},{107,37},{800,600},true,10);assert(p.x==693 && p.y==563);
p=gesture.move({-2000,-2000},{100,30},{800,600},true,10);assert(p.x==0 && p.y==0);
p=gesture.move({110,110},{900,700},{800,600},true,10);assert(p.x==0 && p.y==0);
const auto original=options;options={};module_manager manager;const auto defaults=config::capture(manager);
options={false,false,24};auto custom=config::capture(manager);config::snapshot decoded;
assert(config::decode(config::encode(custom),decoded));options={};config::apply(manager,defaults,decoded);
assert(!options.snap && !options.show_grid && options.grid_size==24);
decoded["[hud editor]"].settings["grid size"].numbers[0]=500;
config::apply(manager,defaults,decoded);assert(options.grid_size==64);
config::apply(manager,defaults,{});assert(options.snap && options.show_grid && options.grid_size==10);
options=original;
std::cout<<"PASS: HUD grid accumulated dragging, free movement, screen bounds and profile preferences\n";
}
+100
View File
@@ -0,0 +1,100 @@
#pragma once
#include "../src/game/inventory_tools.h"
namespace inventory_test {
inline std::vector<world::item> stock;
inline world::item cursor;
inline int transfers=0,swaps=0;
inline bool defer_swap=false;inline int pending_source=-1,pending_destination=-1;
inline std::vector<std::string> transferred_groups;
struct type {unsigned char padding[0xd8]{};std::string name;};
inline type native_type;
inline uintptr_t counter=reinterpret_cast<uintptr_t>(&native_type);
inline unsigned char stack[48]{};
inline uintptr_t __fastcall item(uintptr_t,const std::string* group,int index) {
const auto value=*group=="cursor_items" ? cursor : index>=0 && index<int(stock.size()) ? stock[index] : world::item{};
native_type.name=value.name;*reinterpret_cast<uintptr_t*>(stack+8)=reinterpret_cast<uintptr_t>(&counter);
stack[0x22]=static_cast<unsigned char>(value.count);return reinterpret_cast<uintptr_t>(stack);
}
inline void __fastcall swap(uintptr_t,const std::string*,int index) {
// Native full-take refuses to replace a different held item.
assert(!cursor.count);++swaps;std::swap(cursor,stock.at(index));
}
inline void __fastcall place(uintptr_t,const std::string*,int index) {
assert(cursor.count);++swaps;
if(defer_swap && stock.at(index).count){pending_destination=index;return;}
std::swap(cursor,stock.at(index));
}
inline void refresh(inventory_tools::snapshot& state) {
state.panels[0].items=stock;state.held=cursor;state.cursor=cursor.count>0;
}
inline void __fastcall transfer(uintptr_t,int amount,const std::string* group,int index){assert(amount==stock.at(index).count && cursor.count==0);transferred_groups.push_back(*group);stock[index]={};++transfers;}
inline uint32_t __fastcall tick(uintptr_t){return 7;}
inline void __fastcall decline(uintptr_t,int,const std::string*,int){++transfers;}
}
inline void test_inventory_tools() {
using namespace inventory_tools;using namespace inventory_test;
auto old_item=get_item;auto old_swap=swap_cursor;auto old_place=place_all;auto old_auto=auto_place;
get_item=&item;swap_cursor=&swap;place_all=&place;auto_place=&transfer;
alignas(8) unsigned char controller[0x12d0]{};*reinterpret_cast<uintptr_t*>(controller+0x12c0)=1;
const auto owner=reinterpret_cast<uintptr_t>(controller);
stock={{"stone",64},{"apple",12},{"dirt",8},{"apple",3},{}};cursor={};
snapshot state;state.controller=owner;state.panels={{"container_items",stock},{"inventory_items",stock}};
engine worker;worker.start({owner,action::sort,"container_items"});
for(int i=0;i<40 && worker.active();++i){refresh(state);worker.step(state,1000+i*100,true);}
assert(!worker.active() && cursor.count==0 && stock[0].name=="apple" && stock[1].name=="apple" && stock[2].name=="dirt" && stock[3].name=="stone" && stock[4].name.empty());
assert(stock[0].count==12 && stock[1].count==3 && stock[3].count==64);
worker.start({owner,action::sort,"container_items"});state.cursor=true;worker.step(state,5000,true);assert(!worker.active());state.cursor=false;
worker.start({owner,action::sort,"container_items"});worker.step(state,5000,false);assert(!worker.active());
worker.start({owner+8,action::sort,"container_items"});worker.step(state,5000,true);assert(!worker.active());
transfers=0;worker.start({owner,action::steal,""});
for(int i=0;i<10 && worker.active();++i){state.panels[0].items=stock;worker.step(state,6000+i*100,true);}
assert(transfers==4 && !worker.active());
stock={{"stone",64}};state.panels[0].items=stock;auto_place=&decline;transfers=0;
worker.start({owner,action::steal,""});worker.step(state,8000,true);worker.step(state,8200,true);worker.step(state,8800,true);
assert(transfers==1 && !worker.active() && stock[0].count==64);
// Real UI sequencing: pickup, cursor swap, place-back, each acknowledged on later ticks.
stock={{"stone",64},{"apple",12}};cursor={};refresh(state);defer_swap=true;swaps=0;
worker.start({owner,action::sort,"container_items"});worker.step(state,10000,true);
refresh(state);worker.step(state,10100,true);assert(swaps==2 && cursor.name=="apple");
refresh(state);worker.step(state,10200,true);assert(swaps==2 && worker.active());
std::swap(cursor,stock[pending_destination]);refresh(state);worker.step(state,10300,true);
assert(cursor.count==0);refresh(state);worker.step(state,10400,true);worker.step(state,10500,true);
assert(!worker.active() && stock[0].name=="apple" && stock[1].name=="stone");
// Rejected swaps return the picked-up stack instead of abandoning it.
stock={{"stone",64},{"apple",12}};cursor={};refresh(state);worker.start({owner,action::sort,"container_items"});
worker.step(state,12000,true);refresh(state);worker.step(state,12100,true);
refresh(state);worker.step(state,13700,true);assert(cursor.count==0);refresh(state);worker.step(state,13800,true);
assert(!worker.active() && stock[0].name=="stone" && stock[1].name=="apple");defer_swap=false;
// The reported failure: sorting must move all 10 arrows, not a half-stack of 5.
stock={{"stone",64},{"apple",7},{"arrow",10}};cursor={};refresh(state);swaps=0;
worker.start({owner,action::sort,"container_items"});worker.step(state,14000,true);
assert(cursor.name=="apple" && cursor.count==7 && stock[1].count==0);
bool whole_arrows_seen=false;
for(int i=1;i<20 && worker.active();++i) {
refresh(state);worker.step(state,14000+i*100,true);
if(cursor.name=="arrow"){assert(cursor.count==10);whole_arrows_seen=true;}
}
assert(whole_arrows_seen);
assert(!worker.active() && !cursor.count && stock[0].name=="apple" && stock[0].count==7 && stock[1].name=="arrow" && stock[1].count==10 && stock[2].count==64);
// Dump routes inventory and optional hotbar stacks through quick move.
stock={{"stone",64}};state.panels={{"container_items",{}},{"inventory_items",stock},{"hotbar_items",stock}};
auto_place=&transfer;transferred_groups.clear();include_hotbar=true;
worker.start({owner,action::dump,""});worker.step(state,11000,true);
state.panels[1].items=stock;worker.step(state,11100,true);
stock={{"apple",3}};state.panels[2].items=stock;worker.step(state,11200,true);
state.panels[2].items=stock;worker.step(state,11300,true);
assert(!worker.active() && cursor.count==0 && transferred_groups==std::vector<std::string>({"inventory_items","hotbar_items"}));include_hotbar=false;
assert(next_minimum({},0)==-1);
// Additional controllers must not cancel an operation owned by a fresh chest.
auto old_tick=original_tick;auto old_current=current;auto old_published=latest();const bool old_enabled=enabled;
original_tick=&inventory_test::tick;enabled=true;state.controller=owner;state.stamp=GetTickCount64();
{std::lock_guard lock(mutex);published=state;}
current.start({owner,action::sort,"container_items"});
assert(tick_detour(owner+1)==7 && current.active() && latest().controller==owner);
current.cancel(engine::stop_reason::requested);assert(current.last_stop==engine::stop_reason::requested);
current=old_current;original_tick=old_tick;enabled=old_enabled;
{std::lock_guard lock(mutex);published=old_published;}
get_item=old_item;swap_cursor=old_swap;place_all=old_place;auto_place=old_auto;
std::cout<<"PASS: inventory transfer/sort scheduling, separate same-name stacks, empty slots, cursor/focus/controller cancellation\n";
}
+60
View File
@@ -0,0 +1,60 @@
#pragma once
#include "../src/modules/glint_changer.h"
#include "../src/modules/music_player.h"
inline float glint_received[4]{};
inline const glint_effect::values* glint_forwarded=nullptr;
inline void __fastcall glint_test_setter(uintptr_t,uintptr_t,const glint_effect::values* values) {
glint_forwarded=values;memcpy(glint_received,values->data,sizeof(glint_received));
}
inline void test_media_and_glint() {
const HRESULT apartment=CoInitializeEx(nullptr,COINIT_MULTITHREADED);assert(SUCCEEDED(apartment));
std::vector<unsigned char> bmp(58);
const auto dword=[&](int offset,uint32_t value){memcpy(bmp.data()+offset,&value,4);};
bmp[0]='B';bmp[1]='M';dword(2,58);dword(10,54);dword(14,40);dword(18,1);dword(22,1);
bmp[26]=1;bmp[28]=24;dword(34,4);bmp[54]=7;bmp[55]=23;bmp[56]=200;
auto cover=media::decode_art(bmp);assert(cover && cover->width==1 && cover->height==1 && cover->rgba[0]==200 && cover->rgba[1]==23 && cover->rgba[2]==7 && cover->rgba[3]==255);
std::vector<unsigned char> bad={1,2,3};assert(!media::decode_art(bad));CoUninitialize();
alignas(8) unsigned char context[0x80]{},entries[32]{},definition[0x40]{};
const auto ctx=reinterpret_cast<uintptr_t>(context);
*reinterpret_cast<uintptr_t*>(context+0x30)=reinterpret_cast<uintptr_t>(entries);
*reinterpret_cast<uint16_t*>(context+0x3a)=2;
*reinterpret_cast<uintptr_t*>(entries+16)=reinterpret_cast<uintptr_t>(definition);
*reinterpret_cast<uint64_t*>(definition+0x28)=glint_effect::color_name;
uint16_t index=1;float original_values[]={.2f,.3f,.4f,.8f};glint_effect::values source{1,original_values};
const auto old=glint_effect::original;glint_effect::original=&glint_test_setter;
glint_effect::enabled=true;glint_effect::tint=IM_COL32(255,64,128,200);
glint_effect::detour(ctx,reinterpret_cast<uintptr_t>(&index),&source);
assert(glint_received[0]==1 && std::abs(glint_received[1]-64.f/255)<1e-6 && glint_received[3]==200.f/255);
assert(original_values[0]==.2f && original_values[3]==.8f && source.data==original_values);
*reinterpret_cast<uint64_t*>(definition+0x28)=123;
glint_effect::detour(ctx,reinterpret_cast<uintptr_t>(&index),&source);assert(glint_forwarded==&source && glint_received[0]==.2f);
*reinterpret_cast<uint64_t*>(definition+0x28)=glint_effect::color_name;
index=2;assert(!glint_effect::is_color(ctx,reinterpret_cast<uintptr_t>(&index),reinterpret_cast<uintptr_t>(&source)));
index=1;source.count=2;assert(!glint_effect::is_color(ctx,reinterpret_cast<uintptr_t>(&index),reinterpret_cast<uintptr_t>(&source)));
source.count=1;glint_effect::enabled=false;glint_effect::detour(ctx,reinterpret_cast<uintptr_t>(&index),&source);assert(glint_forwarded==&source);
assert(!glint_effect::is_color(0,0,0));glint_effect::original=old;
ImGui::CreateContext();auto& io=ImGui::GetIO();io.DisplaySize={1280,720};io.DeltaTime=.016f;
io.Fonts->AddFontDefault();unsigned char* pixels;int width,height;io.Fonts->GetTexDataAsRGBA32(&pixels,&width,&height);
ImGui::NewFrame();music_player player;media::snapshot state;
player.draw(state);state.available=true;state.playing=true;state.title="Track title";state.artist="Artist";state.app="test player";
state.duration=240;state.position=60;state.stamp=GetTickCount64();player.draw(state);
Microsoft::WRL::ComPtr<ID3D11Device> art_device;Microsoft::WRL::ComPtr<ID3D11DeviceContext> art_context;D3D_FEATURE_LEVEL art_level;
assert(SUCCEEDED(D3D11CreateDevice(nullptr,D3D_DRIVER_TYPE_WARP,nullptr,0,nullptr,0,D3D11_SDK_VERSION,&art_device,&art_level,&art_context)));
media_art::device=art_device.Get();state.art=cover;player.draw(state);media_art::device=nullptr;
g_menu_open=true;player.draw(state);g_menu_open=false;
assert(player.hud_drag_size().y<player.hud_size().y);
ImGui::Render();assert(ImGui::GetDrawData()->TotalVtxCount>100);
for(int i=0;i<ImGui::GetDrawData()->CmdListsCount;++i)for(const auto& v:ImGui::GetDrawData()->CmdLists[i]->VtxBuffer)assert(std::isfinite(v.pos.x) && std::isfinite(v.pos.y));
ImGui::DestroyContext();
// Read-only live Windows API smoke test: no playback commands are sent.
media::reader reader;reader.start();const auto deadline=GetTickCount64()+4500;
while(reader.latest().message=="Looking for a media player..." && GetTickCount64()<deadline)Sleep(20);
const auto live=reader.latest();assert(live.available || live.message!="Looking for a media player...");
const auto stopped=GetTickCount64();reader.stop();assert(GetTickCount64()-stopped<1500);
assert(!reader.latest().available);reader.start();reader.stop();
media::system().start();media::shutdown();assert(media::instance==nullptr);
std::cout<<"PASS: isolated glint uniform replacement/forwarding, music HUD geometry and live Windows media API shutdown ("<<(live.available ? "session available" : live.message)<<")\n";
}
+3
View File
@@ -0,0 +1,3 @@
// Verified CursorRenderer render prologue with a controlled draw callback.
__declspec(allocate(".fvtest")) unsigned char native_crosshair_fixture[] = {0x55, 0x41, 0x57, 0x41, 0x56, 0x41, 0x55, 0x41, 0x54, 0x56, 0x57, 0x53, 0x48, 0x81, 0xec, 0x18, 0x05, 0x00, 0x00, 0x48, 0x8d, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x0f, 0x29, 0xbd, 0x80, 0x04, 0x00, 0x00, 0x0f, 0x29, 0xb5, 0x70, 0x04, 0x00, 0x00, 0x48, 0xc7, 0x85, 0x68, 0x04, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x4d, 0x89, 0xce, 0x4c, 0x89, 0xc6, 0x48, 0x89, 0xd3, 0x48, 0x89, 0xcf, 0x48, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0xb5, 0x70, 0x04, 0x00, 0x00, 0x0f, 0x28, 0xbd, 0x80, 0x04, 0x00, 0x00, 0x48, 0x81, 0xc4, 0x18, 0x05, 0x00, 0x00, 0x5b, 0x5f, 0x5e, 0x41, 0x5c, 0x41, 0x5d, 0x41, 0x5e, 0x41, 0x5f, 0x5d, 0xc3};
constexpr size_t native_crosshair_callback_offset=66;
+131
View File
@@ -0,0 +1,131 @@
#pragma once
#include "../src/config/profiles.h"
class profile_test_module : public module {
public:
int enables = 0, disables = 0, actions = 0;
bool running = false;
profile_test_module() : module("Test \"module\"", "", category::hud, VK_F2) {
add_toggle("switch", true);
add_float("float", 1.5f, -5, 5);
add_int("integer", 4, -10, 10);
add_mode("mode", {"first", "second"});
add_color("color", .1f, .2f, .3f, .4f);
add_key("key", VK_F6);
add_action("action", [this] { ++actions; });
add_text("name", "Player", 48);
}
void on_enable() override { ++enables; }
void on_disable() override { ++disables; running = false; if (config_save::request) config_save::request(); }
};
inline void test_profiles() {
using namespace config;
assert(valid_name("Survival build_2"));
for (const auto& name : {"", "../escape", "x/y", "x\\y", "CON", "Lpt1", "NUL", "trailing ", " leading", "foo.bar", "x:y"}) assert(!valid_name(name));
module_manager manager;
auto* m = manager.add<profile_test_module>(); m->set_enabled(true);
const auto defaults = capture(manager);
m->settings()[0].bool_value = false;
m->settings()[1].float_value = -3.25f;
m->settings()[2].int_value = 9;
m->settings()[3].int_value = 1;
m->settings()[4].color[3] = .75f;
m->settings()[5].int_value = VK_END;
m->settings()[7].text_value = "Local \"name\"";
m->set_toggle_key(VK_F12); m->hud_pos = ImVec2(333, 444);
const auto customized = capture(manager);
snapshot decoded;
const auto serialized = encode(customized);
assert(decode(serialized, decoded)); assert(encode(decoded) == serialized);
assert(decoded.begin()->second.settings.size() == 7); // actions never serialize
m->running = true;
apply(manager, defaults, decoded);
assert(!m->running && m->enabled() && m->actions == 0);
assert(m->toggle_key() == VK_F12 && m->hud_pos.x == 333 && m->hud_pos.y == 444);
assert(!m->settings()[0].bool_value && m->settings()[1].float_value == -3.25f);
assert(m->settings()[2].int_value == 9 && m->settings()[3].int_value == 1);
assert(m->settings()[4].color[3] == .75f && m->settings()[5].int_value == VK_END);
assert(m->settings()[7].text_value == "Local \"name\"");
// Missing options use defaults, unknown settings/modules are ignored, changed
// mode order resolves by name, and edited numeric values stay in GUI bounds.
snapshot partial;
auto& state = partial[m->name()]; state.enabled = false;
state.settings["float"] = customized.at(m->name()).settings.at("float"); state.settings["float"].numbers[0] = 999;
state.settings["integer"] = customized.at(m->name()).settings.at("integer"); state.settings["integer"].numbers[0] = -999;
state.settings["mode"] = customized.at(m->name()).settings.at("mode");
state.settings["unknown"] = {};
partial["Removed module"] = {};
std::swap(m->settings()[3].modes[0], m->settings()[3].modes[1]);
apply(manager, defaults, partial);
assert(!m->enabled() && m->settings()[0].bool_value);
assert(m->settings()[1].float_value == 5 && m->settings()[2].int_value == -10);
assert(m->settings()[3].int_value == 0); // second option is now index 0
std::swap(m->settings()[3].modes[0], m->settings()[3].modes[1]);
for (const auto& bad : {std::string("garbage"), serialized.substr(0, serialized.size() - 4), serialized + "junk\n",
std::string("AMNESIA_PROFILE 2\nend\n"), std::string("AMNESIA_PROFILE 1\nmodule \"bad\" 3 0 0 0\nend\n"),
std::string("AMNESIA_PROFILE 1\nmodule \"bad\" 1 0 nan 0\nend\n")}) {
snapshot preserved = customized; assert(!decode(bad, preserved)); assert(encode(preserved) == serialized);
}
apply(manager, defaults, customized);
const auto root = directory() / ("profile-test-" + std::to_string(GetCurrentProcessId()) + "-" + std::to_string(GetTickCount64()));
profile_manager service; service.initialize(manager, root);
assert(service.active() == "Default" && !service.dirty());
assert(fs::exists(root / "Default.profile"));
m->settings()[1].float_value = 2.75f;
service.tick(100); service.tick(100.5); assert(service.dirty());
service.tick(100.8); assert(!service.dirty());
assert(read(root / "Default.profile", decoded));
assert(decoded.at(m->name()).settings.at("float").numbers[0] == 2.75);
assert(service.create("Trading")); assert(!service.create("trading"));
m->settings()[1].float_value = -2;
m->running = true;
assert(service.switch_to("Default")); assert(!m->running);
assert(m->settings()[1].float_value == 2.75f);
assert(service.switch_to("Trading")); assert(m->settings()[1].float_value == -2);
assert(service.rename("Villager trades")); assert(!fs::exists(root / "Trading.profile"));
assert(service.active() == "Villager trades");
assert(atomic_write(root / "active.txt", "Missing profile\n"));
{
module_manager restarted; auto* restored = restarted.add<profile_test_module>();
profile_manager fallback; fallback.initialize(restarted, root, false);
assert(fallback.active() == "Default" && restored->settings()[1].float_value == 2.75f);
}
assert(atomic_write(root / "active.txt", "Villager trades\n"));
// Reinitializing restores the active profile, toggles, keys and settings.
{
module_manager restarted; auto* restored = restarted.add<profile_test_module>();
profile_manager second; second.initialize(restarted, root, false);
assert(second.active() == "Villager trades" && restored->enabled());
assert(restored->settings()[1].float_value == -2 && restored->toggle_key() == VK_F12);
}
// A temporary-file collision cannot truncate the existing saved profile.
const auto saved = encode(capture(manager));
assert(fs::create_directory(root / "Villager trades.profile.tmp"));
m->settings()[1].float_value = 4;
assert(!service.save(false)); assert(service.dirty());
assert(read(root / "Villager trades.profile", decoded)); assert(encode(decoded) == saved);
assert(fs::remove(root / "Villager trades.profile.tmp"));
assert(service.remove_active()); assert(service.active() == "Default");
assert(!service.remove_active()); assert(!service.rename("Renamed Default"));
assert(atomic_write(root / "Broken.profile", "damaged file\n"));
const auto before = encode(capture(manager));
assert(!service.switch_to("Broken")); assert(encode(capture(manager)) == before);
assert(atomic_write(root / "active.txt", "Broken\n"));
{
profile_manager damaged; damaged.initialize(manager, root, false);
assert(damaged.blocked()); damaged.tick(500); damaged.tick(510);
std::ifstream original(root / "Broken.profile"); std::string line; std::getline(original, line); assert(line == "damaged file");
assert(damaged.create("Recovery")); // fresh file preserves damaged one
damaged.shutdown();
}
// Debounce still saves during continuous edits after five seconds, then
// shutdown saves the enabled state before module destruction disables it.
assert(service.switch_to("Default"));
for (int i = 0; i < 7; ++i) { m->hud_pos.x = float(i + 20); service.tick(600 + i); }
assert(read(root / "Default.profile", decoded)); assert(decoded.at(m->name()).x == 25);
m->set_enabled(true); m->hud_pos.x = 900; service.shutdown();
m->set_enabled(false);
assert(read(root / "Default.profile", decoded)); assert(decoded.at(m->name()).enabled && decoded.at(m->name()).x == 900);
std::cout << "PASS: profile round-trip, defaults/modes/clamps, autosave, switching/cancellation, remembered profile, rename/delete, atomic failure and damaged-file preservation\n";
}
+5
View File
@@ -0,0 +1,5 @@
// Verified 26.52 entries and offhand call site with controlled callbacks.
__declspec(allocate(".fvtest")) unsigned char hands_fixture[] = {0x55, 0x41, 0x57, 0x41, 0x56, 0x41, 0x55, 0x41, 0x54, 0x56, 0x57, 0x53, 0x48, 0x81, 0xec, 0x18, 0x02, 0x00, 0x00, 0x48, 0x8d, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbd, 0x80, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xb5, 0x70, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xad, 0x60, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xa5, 0x50, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x9d, 0x40, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x95, 0x30, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x8d, 0x20, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x85, 0x10, 0x01, 0x00, 0x00, 0x0f, 0x29, 0xbd, 0x00, 0x01, 0x00, 0x00, 0x0f, 0x29, 0xb5, 0xf0, 0x00, 0x00, 0x00, 0x48, 0xc7, 0x85, 0xe8, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x44, 0x88, 0x4d, 0x7f, 0x4d, 0x89, 0xc7, 0x48, 0x89, 0xd3, 0x48, 0x89, 0xce, 0x48, 0x8b, 0x89, 0x70, 0x01, 0x00, 0x00, 0x48, 0x8b, 0x01, 0x48, 0x8b, 0x80, 0xf8, 0x00, 0x00, 0x00, 0x48, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0xb5, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0x28, 0xbd, 0x00, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x85, 0x10, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbd, 0x80, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xb5, 0x70, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xad, 0x60, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xa5, 0x50, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x9d, 0x40, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x95, 0x30, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x8d, 0x20, 0x01, 0x00, 0x00, 0x48, 0x81, 0xc4, 0x18, 0x02, 0x00, 0x00, 0x5b, 0x5f, 0x5e, 0x41, 0x5c, 0x41, 0x5d, 0x41, 0x5e, 0x41, 0x5f, 0x5d, 0xc3};
__declspec(allocate(".fvtest")) unsigned char offhand_fixture[] = {0x55, 0x41, 0x57, 0x41, 0x56, 0x41, 0x55, 0x41, 0x54, 0x56, 0x57, 0x53, 0x48, 0x81, 0xec, 0xd8, 0x03, 0x00, 0x00, 0x48, 0x8d, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x8d, 0x40, 0x03, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x85, 0x30, 0x03, 0x00, 0x00, 0x0f, 0x29, 0xbd, 0x20, 0x03, 0x00, 0x00, 0x0f, 0x29, 0xb5, 0x10, 0x03, 0x00, 0x00, 0x48, 0xc7, 0x85, 0x08, 0x03, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x41, 0x80, 0x79, 0x23, 0x01, 0x48, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x44, 0x0f, 0x28, 0x8d, 0x40, 0x03, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x85, 0x30, 0x03, 0x00, 0x00, 0x0f, 0x28, 0xbd, 0x20, 0x03, 0x00, 0x00, 0x0f, 0x28, 0xb5, 0x10, 0x03, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xd8, 0x03, 0x00, 0x00, 0x5b, 0x5f, 0x5e, 0x41, 0x5c, 0x41, 0x5d, 0x41, 0x5e, 0x41, 0x5f, 0x5d, 0xc3};
__declspec(allocate(".fvtest")) unsigned char offhand_call_fixture[] = {0x55, 0x57, 0x56, 0x41, 0x56, 0x48, 0x81, 0xec, 0x28, 0x02, 0x00, 0x00, 0x48, 0x8d, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x48, 0x89, 0xcf, 0x48, 0x89, 0x55, 0xf8, 0x4c, 0x89, 0xc6, 0x4d, 0x89, 0xce, 0x48, 0x89, 0xf9, 0x48, 0x8b, 0x55, 0xf8, 0x49, 0x89, 0xf0, 0x4d, 0x89, 0xf1, 0xe8, 0xbb, 0x6c, 0xfe, 0xff, 0xc6, 0x85, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x85, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0x28, 0x02, 0x00, 0x00, 0x41, 0x5e, 0x5e, 0x5f, 0x5d, 0xc3};
constexpr size_t hands_callback_offset=148, offhand_callback_offset=75, offhand_call_offset=33;
+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include "../src/modules/server_hud.h"
inline void test_server_hud() {
assert(xp_math::next(0)==7 && xp_math::next(15)==37 && xp_math::next(16)==42);
assert(xp_math::next(30)==112 && xp_math::next(31)==121 && xp_math::remaining(28,.5f)==51);
assert(xp_math::remaining(0,1)==0 && xp_math::remaining(0,0)==7);
alignas(8) unsigned char attrs[80]{},values[272]{};uint32_t keys[]{4,5};
auto put=[](unsigned char* p,size_t off,auto value){memcpy(p+off,&value,sizeof(value));};
put(attrs,0,uintptr_t(keys));put(attrs,8,uintptr_t(keys+2));put(attrs,24,uintptr_t(values));put(attrs,32,uintptr_t(values+272));
put(values,0x70,28.f);put(values,136+0x70,.3f);put(values,0x7c,0.f);
int level;float progress;assert(world::read_xp_values(uintptr_t(attrs),level,progress) && level==28 && progress==.3f);
put(values,136+0x70,std::numeric_limits<float>::quiet_NaN());assert(!world::read_xp_values(uintptr_t(attrs),level,progress));
put(values,136+0x70,1.1f);assert(!world::read_xp_values(uintptr_t(attrs),level,progress));
struct node {uintptr_t next=0,previous=0;unsigned char uuid_and_entry[40]{};std::string name;};
static_assert(offsetof(node,name)==56);node head,a,b;a.name="Zoe";b.name="Alex";
head.next=uintptr_t(&a);a.next=uintptr_t(&b);b.next=uintptr_t(&head);
uintptr_t map[]{0,uintptr_t(&head),2};std::vector<std::string> names;
assert(world::read_roster_map(uintptr_t(map),names) && names==std::vector<std::string>({"Alex","Zoe"}));
b.next=uintptr_t(&a);assert(!world::read_roster_map(uintptr_t(map),names));b.next=uintptr_t(&head);
map[2]=1025;assert(!world::read_roster_map(uintptr_t(map),names));map[2]=0;head.next=uintptr_t(&head);
assert(world::read_roster_map(uintptr_t(map),names) && names.empty());
// Sparse UI views report capacity from their actual ItemStack vector.
alignas(8) unsigned char view[0x110]{},getter[]{0x48,0x8b,0x81,0x08,0x01,0,0};uintptr_t vt[5]{};vt[4]=uintptr_t(getter);
put(view,0,uintptr_t(vt));put(view,0x100,uintptr_t(0x100000));put(view,0x108,uintptr_t(0x100000+54*152));
assert(inventory_tools::view_count(uintptr_t(view))==54);
put(view,0x108,uintptr_t(0x100000+27*152));assert(inventory_tools::view_count(uintptr_t(view))==27);
put(view,0x108,uintptr_t(0x100001));assert(inventory_tools::view_count(uintptr_t(view))==-1);
getter[0]=0;assert(inventory_tools::view_count(uintptr_t(view))==-1);
ImGui::CreateContext();auto& io=ImGui::GetIO();io.DisplaySize={1280,720};io.DeltaTime=.016f;
io.Fonts->AddFontDefault();unsigned char* pixels;int w,h;io.Fonts->GetTexDataAsRGBA32(&pixels,&w,&h);
ImGui::NewFrame();g_menu_open=true;
world::frame frame;frame.valid=true;frame.stamp=GetTickCount64();frame.xp_known=true;frame.xp_level=28;frame.xp_progress=.3f;frame.roster_known=true;
for(int i=0;i<25;++i)frame.online_players.push_back("player "+std::to_string(i));world::publish(frame);
tab_list list;xp_progress_hud xp;list.on_render();xp.on_render();assert(list.hud_size().x==360 && xp.hud_size().y==54);
world::publish({});list.on_render();xp.on_render();list.on_disable();xp.on_disable();
assert(!world::collect_roster && !world::collect_xp);
ImGui::Render();auto* data=ImGui::GetDrawData();assert(data->TotalVtxCount>100);
for(int i=0;i<data->CmdListsCount;++i)for(auto& v:data->CmdLists[i]->VtxBuffer)assert(std::isfinite(v.pos.x) && std::isfinite(v.pos.y));
g_menu_open=false;ImGui::DestroyContext();
std::cout<<"PASS: sparse container capacity, online roster integrity, XP attributes/boundaries and HUD geometry\n";
}
+2
View File
@@ -0,0 +1,2 @@
// Verified hand-bob prologue with a controlled original transform.
__declspec(allocate(".fvtest")) unsigned char hand_fixture[] = {0x55, 0x56, 0x57, 0x53, 0x48, 0x81, 0xec, 0x28, 0x01, 0x00, 0x00, 0x48, 0x8d, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbd, 0x90, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xb5, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x6d, 0x70, 0x44, 0x0f, 0x29, 0x65, 0x60, 0x44, 0x0f, 0x29, 0x5d, 0x50, 0x44, 0x0f, 0x29, 0x55, 0x40, 0x44, 0x0f, 0x29, 0x4d, 0x30, 0x44, 0x0f, 0x29, 0x45, 0x20, 0x0f, 0x29, 0x7d, 0x10, 0x0f, 0x29, 0x75, 0x00, 0x48, 0xc7, 0x45, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x28, 0xfa, 0x48, 0x89, 0xd6, 0x48, 0x8b, 0x89, 0x68, 0x11, 0x00, 0x00, 0xf3, 0x0f, 0x10, 0x46, 0x30, 0xf3, 0x0f, 0x58, 0x05, 0x47, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x11, 0x46, 0x30, 0x0f, 0x28, 0x75, 0x00, 0x0f, 0x28, 0x7d, 0x10, 0x44, 0x0f, 0x28, 0x45, 0x20, 0x44, 0x0f, 0x28, 0x4d, 0x30, 0x44, 0x0f, 0x28, 0x55, 0x40, 0x44, 0x0f, 0x28, 0x5d, 0x50, 0x44, 0x0f, 0x28, 0x65, 0x60, 0x44, 0x0f, 0x28, 0x6d, 0x70, 0x44, 0x0f, 0x28, 0xb5, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbd, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0x28, 0x01, 0x00, 0x00, 0x5b, 0x5f, 0x5e, 0x5d, 0xc3, 0x00, 0x00, 0x80, 0x3f};
+145
View File
@@ -0,0 +1,145 @@
#pragma once
#include "../src/modules/world_modules.h"
#include "../src/modules/fps_counter.h"
#include "../src/modules/keystrokes.h"
#include "../src/modules/watermark.h"
#include "../src/modules/cps_counter.h"
#include "../src/modules/clock.h"
#include "../src/modules/zoom.h"
#include "../src/modules/anti_afk.h"
inline float world_test_time(void*,int ticks,float alpha){return float(ticks)+alpha;}
inline world::color* world_test_fog(void*,world::color* output,const world::color* base,float brightness){*output=*base;output->r*=brightness;return output;}
inline const std::string* world_test_name(uintptr_t){static const std::string real="Original";return &real;}
inline void test_world_math_and_hooks() {
using namespace world;
float matrix[16]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};ImVec2 screen;
assert(project(matrix,{0,0,0},{0,0,-5},1,1,{800,600},screen));assert(screen.x==400 && screen.y==300);
assert(!project(matrix,{0,0,0},{0,0,5},1,1,{800,600},screen));
assert(!project(matrix,{0,0,0},{0,0,0},1,1,{800,600},screen));
ImVec2 end;assert(project_edge(matrix,{0,0,0},{0,0,1},{0,0,-5},1,1,{800,600},screen,end));
assert(!project_edge(matrix,{0,0,0},{0,0,1},{0,0,2},1,1,{800,600},screen,end));
const auto q=turn({},90,20);assert(std::abs(q.x*q.x+q.y*q.y+q.z*q.z+q.w*q.w-1)<1e-5f);
const auto original=quaternion{};const auto restored=turn(turn(original,90,0),-90,0);assert(std::abs(restored.w-1)<1e-5f);
// Orbit position follows camera orientation around a fixed player pivot.
const vec3 pivot{12,65,-8};const auto back=orbit_position(pivot,{},4);
assert(distance(back,pivot)==4 && back.z==-4 && back.x==12);
const auto side=orbit_position(pivot,turn({},90,0),4);
assert(std::abs(distance(side,pivot)-4)<1e-5f && std::abs(side.x-8)<1e-5f);
const auto front=orbit_position(pivot,turn({},180,0),4);
assert(std::abs(front.z+12)<1e-5f && std::abs(front.x-12)<1e-5f);
const auto full=orbit_position(pivot,turn({},360,0),4);assert(distance(full,back)<1e-5f);
const auto overhead=orbit_position(pivot,turn({},90,85),6);assert(std::abs(distance(overhead,pivot)-6)<1e-5f);
assert(pivot.x==12 && pivot.y==65 && pivot.z==-8);
// Player angle locking is independent of movement and camera orbit rotation.
player_look_lock angle_lock;std::array<float,4> player_rotation{15,70,14,69};
std::array<float,2> head_angle{70,69},body_angle{65,64},render_angle{15,70};vec3 moving_player{2,3,4};
auto apply_lock=[&](bool active,uintptr_t owner=1){return angle_lock.apply(owner,7,uintptr_t(&player_rotation),uintptr_t(&head_angle),uintptr_t(&body_angle),uintptr_t(&render_angle),active);};
assert(apply_lock(true));
player_rotation={80,-120,79,-119};head_angle={-120,-119};body_angle={-100,-99};render_angle={80,-120};moving_player.x+=5;
assert(apply_lock(true) && player_rotation[0]==15 && player_rotation[1]==70 && head_angle[0]==70 && body_angle[0]==65 && render_angle[1]==70);
assert(angle_lock.delta[0]==65 && angle_lock.delta[1]==170);
assert(apply_lock(true) && angle_lock.delta[0]==0 && angle_lock.delta[1]==0);
player_rotation={80,-120,79,-119};assert(apply_lock(true));
assert(angle_lock.delta[0]==0 && angle_lock.delta[1]==0); // cached target, mouse stopped
player_rotation={85,-110,84,-111};assert(apply_lock(true));
assert(angle_lock.delta[0]==5 && angle_lock.delta[1]==10); // new mouse movement only
assert(moving_player.x==7 && moving_player.y==3 && moving_player.z==4);
const auto camera_side=orbit_position(moving_player,turn({},120,0),4);assert(std::abs(distance(camera_side,moving_player)-4)<1e-5f);
assert(!apply_lock(false));player_rotation={20,90,20,90};assert(!apply_lock(false) && player_rotation[1]==90);
assert(apply_lock(true) && angle_lock.rotation[1]==90);
player_rotation={25,100,25,100};assert(apply_lock(true,2) && angle_lock.rotation[1]==100);
assert(weapon("diamond_sword") && weapon("crossbow") && weapon("netherite_axe") && !weapon("diamond_pickaxe") && !weapon("bread"));
assert(clean_name("\xc2\xa7" "aPlayer\n")=="Player");
assert(item_label("minecraft:diamond_helmet")=="diamond helmet");
auto old_time=original_time;original_time=&world_test_time;render_thread=GetCurrentThreadId();time_override=6000;
assert(time_detour(nullptr,18000,.5f)==6000.5f);time_override=-1;assert(time_detour(nullptr,18000,.5f)==18000.5f);
time_override=6000;render_thread=0;assert(time_detour(nullptr,18000,.5f)==18000.5f);time_override=-1;original_time=old_time;
auto old_fog=original_fog;original_fog=&world_test_fog;render_thread=GetCurrentThreadId();fog_enabled=true;fog_color=IM_COL32(255,0,0,255);
color input{.25f,.5f,.75f,1},result{};fog_detour(nullptr,&result,&input,1);assert(result.r==1 && result.g==0 && result.b==0 && result.a==1);
fog_enabled=false;fog_detour(nullptr,&result,&input,1);assert(result.r==input.r && result.g==input.g);original_fog=old_fog;
auto old_name=original_name;original_name=&world_test_name;local_actor=123;alias_enabled=true;set_alias("My local name");rendering=true;
assert(*name_detour(123)=="My local name");rendering=false;assert(*name_detour(123)=="Original");assert(*world_test_name(123)=="Original");
alias_enabled=false;original_name=old_name;local_actor=0;
// Real native get_at ABI using a controlled executable leaf with the
// verified payload-load prefix, sparse versions and packed membership.
const unsigned char bytes[]={0x48,0x8b,0x49,0x50,0x49,0x89,0xd0,0x49,0xc1,0xe8,0x07,0x83,0xe2,0x7f,0x8d,0x04,0xd5,0,0,0,0,0x4a,0x03,0x04,0xc1,0xc3};
auto* code=VirtualAlloc(nullptr,4096,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);assert(code);memcpy(code,bytes,sizeof(bytes));DWORD old;
assert(VirtualProtect(code,4096,PAGE_EXECUTE_READ,&old));FlushInstructionCache(GetCurrentProcess(),code,sizeof(bytes));
uintptr_t vt[]={reinterpret_cast<uintptr_t>(code)};uint32_t sparse[2048];std::fill(sparse,sparse+2048,0xffffffffu);
uint32_t packed[]={0x40003};sparse[3]=0x40000;uintptr_t pages[]={reinterpret_cast<uintptr_t>(sparse)};
uintptr_t payload[128]{};payload[0]=0x12345678;uintptr_t payload_pages[]={reinterpret_cast<uintptr_t>(payload)};
uintptr_t storage[16]{};storage[0]=reinterpret_cast<uintptr_t>(vt);storage[1]=reinterpret_cast<uintptr_t>(pages);storage[2]=storage[1]+8;
storage[4]=reinterpret_cast<uintptr_t>(packed);storage[5]=storage[4]+4;storage[10]=reinterpret_cast<uintptr_t>(payload_pages);
assert(component_at(reinterpret_cast<uintptr_t>(storage),0x40003)==reinterpret_cast<uintptr_t>(payload));
assert(!component_at(reinterpret_cast<uintptr_t>(storage),3));assert(!component_at(reinterpret_cast<uintptr_t>(storage),0x40004));
assert(!component_at(0,0x40003));assert(!component_at(1,0x40003));
// ActorRotation's real 16-byte getter has an index-copy prefix.
const unsigned char rotation_bytes[]={0x48,0x89,0xd0,0x48,0x8b,0x49,0x50,0x48,0xc1,0xea,0x07,0x83,0xe0,0x7f,0xc1,0xe0,0x04,0x48,0x03,0x04,0xd1,0xc3};
assert(VirtualProtect(code,4096,PAGE_READWRITE,&old));memcpy(code,rotation_bytes,sizeof(rotation_bytes));
assert(VirtualProtect(code,4096,PAGE_EXECUTE_READ,&old));FlushInstructionCache(GetCurrentProcess(),code,sizeof(rotation_bytes));
assert(component_at(reinterpret_cast<uintptr_t>(storage),0x40003)==reinterpret_cast<uintptr_t>(payload));
assert(!component_at(reinterpret_cast<uintptr_t>(storage),0x80003));
assert(VirtualFree(code,0,MEM_RELEASE));
std::cout<<"PASS: projection, freelook quaternion, weapon filtering, visual time/fog/name isolation and native ECS read-only access\n";
}
inline void test_world_filter() {
using namespace world_filter;
ComPtr<ID3D11Device> device;ComPtr<ID3D11DeviceContext> context;D3D_FEATURE_LEVEL level;
assert(SUCCEEDED(D3D11CreateDevice(nullptr,D3D_DRIVER_TYPE_WARP,nullptr,0,nullptr,0,D3D11_SDK_VERSION,&device,&level,&context)));
D3D11_TEXTURE2D_DESC desc{};desc.Width=32;desc.Height=32;desc.MipLevels=1;desc.ArraySize=1;desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count=1;desc.Usage=D3D11_USAGE_DEFAULT;desc.BindFlags=D3D11_BIND_RENDER_TARGET;
ComPtr<ID3D11Texture2D> output;ComPtr<ID3D11RenderTargetView> target;
assert(SUCCEEDED(device->CreateTexture2D(&desc,nullptr,&output)));assert(SUCCEEDED(device->CreateRenderTargetView(output.Get(),nullptr,&target)));
ID3D11RenderTargetView* rt=target.Get();context->OMSetRenderTargets(1,&rt,nullptr);
const float white[4]={1,1,1,1};context->ClearRenderTargetView(rt,white);
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
D3D11_VIEWPORT viewport{2,3,20,18,0,1};context->RSSetViewports(1,&viewport);
enabled=true;tint=IM_COL32(255,128,64,255);brightness=.5f;
assert(apply(device.Get(),context.Get(),rt));
D3D11_PRIMITIVE_TOPOLOGY topology;context->IAGetPrimitiveTopology(&topology);assert(topology==D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
UINT count=1;D3D11_VIEWPORT restored{};context->RSGetViewports(&count,&restored);assert(restored.TopLeftX==2 && restored.Height==18);
desc.Usage=D3D11_USAGE_STAGING;desc.BindFlags=0;desc.CPUAccessFlags=D3D11_CPU_ACCESS_READ;ComPtr<ID3D11Texture2D> staging;
assert(SUCCEEDED(device->CreateTexture2D(&desc,nullptr,&staging)));context->CopyResource(staging.Get(),output.Get());
D3D11_MAPPED_SUBRESOURCE mapped{};assert(SUCCEEDED(context->Map(staging.Get(),0,D3D11_MAP_READ,0,&mapped)));
auto* pixel=static_cast<unsigned char*>(mapped.pData)+16*mapped.RowPitch+16*4;
assert(std::abs(int(pixel[0])-128)<=1 && std::abs(int(pixel[1])-64)<=1 && std::abs(int(pixel[2])-32)<=1 && pixel[3]==255);
context->Unmap(staging.Get(),0);enabled=false;assert(!apply(device.Get(),context.Get(),rt));shutdown();
std::cout<<"PASS: actual D3D11 color/darkness shader and render-state restoration (WARP)\n";
}
inline void test_world_huds() {
ImGui::CreateContext();auto& io=ImGui::GetIO();io.DisplaySize={1280,720};io.DeltaTime=.016f;
io.Fonts->AddFontDefault();unsigned char* pixels;int width,height;io.Fonts->GetTexDataAsRGBA32(&pixels,&width,&height);
ImGui::NewFrame();
world::frame frame;frame.valid=true;frame.stamp=GetTickCount64();frame.world_id=1;frame.has_block=true;frame.block={-1,-1,-5};
frame.matrix[0]=frame.matrix[5]=frame.matrix[10]=frame.matrix[15]=1;
frame.local.position={0,1.62f,0};frame.local.held.name="diamond_sword";
for(int i=0;i<4;++i)frame.local.armor[i].name="diamond_helmet";
frame.has_target=true;frame.target.name="Actual player";frame.target.position={0,0,-5};frame.target.head={0,1,-5};
frame.target.health=12;frame.target.max_health=20;frame.target.health_known=true;frame.players.push_back(frame.target);
world::publish(frame);
fps_counter fps;watermark logo;keystrokes keys;cps_counter cps;clock_hud clock;
armor_hud armor;target_hud target;coordinates_hud coordinates;block_outlines outline;better_nametags tags;
module* hud_modules[]={&fps,&logo,&keys,&cps,&clock,&armor,&target,&coordinates,&outline,&tags};
for(auto* m:hud_modules)m->on_render();
anti_afk afk;afk.on_render();assert(afk.hud_size().x>0);afk.on_disable();
block_outlines::draw_selection(frame,frame.block,IM_COL32_WHITE,2,true);
assert(armor.hud_size().y>0 && target.hud_size().y>0);
const float compact_height=target.hud_size().y;
for(auto& setting:target.settings()) if(setting.name=="equipment")setting.bool_value=true;
target.on_render();assert(target.hud_size().y>compact_height);
// Unknown/zero maximum health must never produce invalid geometry.
frame.target.max_health=0;world::publish(frame);target.on_render();
frame.target.health_known=false;world::publish(frame);target.on_render();
zoom magnifier;zoom_effect::magnification=4;
g_menu_open=true;magnifier.on_render();assert(zoom_effect::magnification==1);
g_menu_open=false;zoom_effect::magnification=4;
magnifier.on_disable();assert(zoom_effect::magnification==1);
ImGui::Render();auto* data=ImGui::GetDrawData();assert(data->TotalVtxCount>100);
for(int i=0;i<data->CmdListsCount;++i)for(const auto& v:data->CmdLists[i]->VtxBuffer)assert(std::isfinite(v.pos.x) && std::isfinite(v.pos.y));
world::publish({});ImGui::DestroyContext();
std::cout<<"PASS: actual HUD/card, armor, target, coordinates, nametag and outlined-block geometry\n";
}