commit and push

This commit is contained in:
67
2026-06-22 16:33:58 +08:00
parent 4f5df4d1c9
commit 7f9a6620f9
+155 -263
View File
@@ -1,83 +1,59 @@
# DayZ Memory C++ Overlay # DayZ Memory C++ Overlay
Windows C++20 DayZ DMA reader with an ImGui/DirectX 11 overlay and a browser-based web radar. A Windows C++20 DMA reader for DayZ using VolkDMA backend. Reads game memory in real-time and streams data to two frontends: an overlay ESP (DirectX 11 + ImGui) and a web radar (HTTP + SSE).
The application attaches to `DayZ_x64.exe` through VolkDMA, resolves the current DayZ runtime structures, reads entities in the background, and publishes the same live snapshot to two frontends: **Use only on authorized systems.** The web server runs plain HTTP — protect with a password before exposing beyond localhost.
- A transparent desktop overlay for ESP, skeletons, loot, bullet trails, and aim-assist visualizations.
- A local HTTP/SSE web radar with map tiles, filters, player lists, bullet paths, and remote browser support.
Use this only on systems and servers where you are allowed to inspect the target process. The built-in web server is plain HTTP; set a password before exposing it outside localhost or your trusted LAN.
## Features ## Features
- External DMA-backed memory access through VolkDMA. **Memory & Reading:**
- Runtime signature scanning and static offsets for DayZ structures. - DMA-backed memory access (VolkDMA)
- Automatic reconnect behavior when the process/session drops. - Runtime signature scanning + static offsets
- High-frequency camera reads decoupled from entity scans. - Auto-reconnect on process/session drop
- Player, infected, animal, vehicle, loot, corpse, and bullet snapshots. - High-frequency camera reads
- Player skeleton rendering with cached bone pointer chains and gap filling. - Efficient batched entity scanning
- Health, held weapon, worn items, names, boxes, head circles, and configurable draw distances.
- Ballistic aim dot using local weapon ammo velocity and drag values. **Overlay (DirectX 11 + ImGui):**
- Bullet trail visualization for active, completed, and phantom bullet tracks. - Player/zombie/animal/vehicle/loot ESP
- Configurable item category filters from `config/item_filters.json`. - Player skeletons with interpolation
- DirectX 11 transparent overlay with a Lumin/ImGui menu. - Health bars, held weapons, worn items
- Built-in HTTP server with: - Configurable draw distances
- `GET /` static radar UI - Ballistic aim dot (weapon velocity + drag)
- `GET /api/bootstrap` - Bullet trail visualization
- `GET /api/state` - Lumin menu with live config save
- `GET /events` server-sent events
- `GET /tile` **Web Radar (HTTP + SSE):**
- `GET /map-image` - Real-time map with pan/zoom
- `GET /api/debug` - Entity filters + player list
- CORS support for serving the web UI from a different origin. - Bullet path visualization
- Optional `Caddyfile` for static webroot hosting and API proxying. - Server-sent events for live updates
- Embedded map support for known maps, with runtime disk PNG overrides. - Map tiles (512x512 PNG cache)
- DMA throughput stats shown in the overlay info panel. - Optional Caddy proxy for static hosting
- CORS support
## Requirements ## Requirements
### Platform **Build:**
- Windows x64
- Visual Studio 2022 (MSVC toolchain)
- Windows SDK (DirectX 11)
- CMake 3.20+
- Git
- Internet (first configure only, to fetch dependencies)
- Windows x64. **VolkDMA:**
- Visual Studio 2022 Build Tools or full Visual Studio with the MSVC x64 toolchain. Must be at this location (or update `VOLKDMA_ROOT` in CMakeLists.txt):
- Windows SDK with DirectX 11 headers/libraries. ```
- CMake 3.20 or newer. ../dayz-dma/dma-dayz-cpp-master/VolkDMA/
- Git.
- Internet access during the first CMake configure, unless dependencies are already cached.
### External dependency: VolkDMA
`CMakeLists.txt` expects VolkDMA at this sibling path:
```text
../dayz-dma/dma-dayz-cpp-master/VolkDMA
``` ```
That directory must contain: **Auto-fetched:**
- nlohmann/json 3.11.3
- spdlog 1.14.1
- cpp-httplib 0.18.1
- stb
- `src/dma.cpp` Vendored in `external/lumin/`: ImGui, Lumin framework, FreeType
- `src/process.cpp`
- `src/inputstate.cpp`
- `include/VolkDMA/...`
- `external/vmm`
- `external/leechcore`
- `dlls/vmm.dll`
- `dlls/leechcore.dll`
- `dlls/FTD3XX.dll`
If your VolkDMA checkout lives somewhere else, update `VOLKDMA_ROOT` near the top of `CMakeLists.txt`.
### Fetched dependencies
CMake downloads these with `FetchContent`:
- `nlohmann/json` v3.11.3
- `spdlog` v1.14.1
- `cpp-httplib` v0.18.1
- `stb` from upstream master
The ImGui/Lumin/FreeType pieces are vendored under `external/lumin`.
## Repository Layout ## Repository Layout
@@ -142,27 +118,23 @@ Running from the repository root can work for some files, but the executable als
## Runtime Controls ## Runtime Controls
- `INSERT`: toggle the overlay menu. **Keys:**
- `Config -> Save Config`: writes overlay settings to `config/overlay.json`. - `INSERT` — toggle menu
- `Config -> Exit`: closes the overlay and stops the process. - `Ctrl+C` in console — shutdown
- `Ctrl+C` in the console: requests shutdown.
Menu tabs: **Menu Tabs:**
- `Aim` — ballistics, bullet trails
- `Aim`: ballistic dot and bullet trail toggles. - `Visuals` — ESP toggles, draw distances
- `Visuals`: player/world ESP toggles and draw distances. - `Loot` — item filters (from `config/item_filters.json`)
- `Loot`: item category filters sourced from `config/item_filters.json`. - `Info` — status, entity counts, DMA throughput, web radar URLs
- `Info`: connection status, entity counts, local position, DMA stats, web radar info. - `Config` — resolution/render overrides, save settings, exit
- `Config`: monitor/render resolution overrides, save, and exit.
## Configuration ## Configuration
There are two config files: Two config files (both in working directory, copied at build):
- `config/config.cfg`: INI-style runtime reader settings. - **`config/config.cfg`** — INI format, runtime reader settings (refresh intervals, batch sizes)
- `config/overlay.json`: JSON overlay/web settings, created or updated by the menu. - **`config/overlay.json`** — JSON, overlay/web UI settings (auto-created/updated by menu)
Both paths are resolved relative to the process working directory. Post-build copies the repository `config/` directory next to the executable.
### `config/config.cfg` ### `config/config.cfg`
@@ -377,84 +349,50 @@ The tile server cuts maps into 512x512 PNG tiles and caches encoded tile bytes i
## Architecture ## Architecture
### Startup **Startup** (`main.cpp`):
1. Create logs, init spdlog
2. Load `config/config.cfg``RuntimeConfig`
3. Load `config/overlay.json``OverlayConfig`
4. Start `WebRadarServer`, `DayZRuntimeService`
5. Create overlay, enter DX11 render loop
`src/main.cpp` performs startup: **Memory** (`VmmAccessor`):
- Wraps VolkDMA/VMM access
- Finds + attaches to `DayZ_x64.exe`
- Typed/raw/string/scatter reads
- Tracks DMA throughput
1. Creates `logs/`. **Runtime Service** (`DayZRuntimeService`):
2. Initializes spdlog. - Main loop: wait for process, resolve base objects
3. Loads `config/config.cfg` into `RuntimeConfig`. - Refresh entity lists at configured intervals
4. Loads `config/overlay.json` into `OverlayConfig`. - Read players, bullets, items, bones
5. Starts `WebRadarServer`. - Publish `RuntimeUpdate` snapshot to overlay + web
6. Starts `DayZRuntimeService`.
7. Creates the overlay and enters the DirectX/ImGui render loop.
### Memory Layer **Readers/Resolvers:**
- `BaseObjectResolver` — world/network ptrs
- `LocalPlayerResolver`, `NetworkMetadataReader`
- `NearEntityListReader`, `FarEntityListReader`, `SlowEntityListReader`
- `ItemListReader`, `BulletTableReader`, `ClientScoreboardReader`
- `EntityCategoryProjector` — raw ents → typed lists
- `ItemFilterCatalog` — loot categorization
`src/Memory/VmmAccessor.*` wraps VolkDMA process access: **Offsets & Signatures:**
- `Offsets.h` — static known offsets
- `RuntimeOffsets.h` — runtime-resolved addresses
- `SigScanner.cpp` — module pattern scanning
- *After DayZ updates: check these first if data is wrong*
- Initializes DMA/VMM. **Overlay** (DirectX 11 + ImGui):
- Finds and attaches to `DayZ_x64.exe`. - `OverlayWindow` — Win32 window, DX device, font atlas
- Applies `fix_cr3`. - `GameOverlay` — ESP rendering, projection, trails, ballistics
- Performs typed reads, raw reads, string reads, and scatter reads. - `MenuBridge``external/lumin/framework/gui.cpp` (menu layout)
- Tracks total bytes and scatter calls for DMA stats.
- Re-applies CR3 after `ForceRefresh()`.
### Runtime Service **Web Radar:**
- `WebRadarServer` — HTTP routes, SSE, auth, CORS
`src/Runtime/DayZRuntimeService.*` owns the background reader threads. - `WebSnapshotService` `RuntimeUpdate` → JSON
- `BulletTrackCache` — bullet history
The main live loop: - `MapTileService` — tile generation + PNG cache
- `webroot/` — browser UI
- Waits for a valid process/session.
- Resolves base objects and runtime offsets.
- Refreshes near/far/slow entity lists at configured intervals.
- Refreshes scoreboard and network metadata.
- Reads local player and camera data.
- Reads bullets and items.
- Projects raw entities into typed player/animal/zombie/vehicle/loot snapshots.
- Refreshes bones using scatter reads.
- Publishes a `RuntimeUpdate` snapshot to overlay and web server consumers.
A separate camera loop keeps projection data fresher than the heavier entity scans.
### Readers and Resolvers
- `Resolvers/BaseObjectResolver.*`: resolves core world/network pointers.
- `Resolvers/LocalPlayerResolver.*`: resolves local player data.
- `Resolvers/NetworkMetadataReader.*`: reads server metadata.
- `Readers/NearEntityListReader.*`: near entity list.
- `Readers/FarEntityListReader.*`: far entity list.
- `Readers/SlowEntityListReader.*`: slow entity list.
- `Readers/ItemListReader.*`: loot/item extraction.
- `Readers/BulletTableReader.*`: active bullet reads and direction inference.
- `Readers/ClientScoreboardReader.*`: scoreboard player entries.
- `Readers/EntityCategoryProjector.*`: classifies raw entities into typed output lists.
- `Readers/ItemFilterCatalog.*`: loads and applies loot filter rules.
### Signature and Offset Handling
- `src/SigScanner/SigScanner.*` scans the module with page-sized scatter reads.
- `src/Offsets.h` contains known static offsets.
- `src/RuntimeOffsets.h` stores runtime-resolved addresses/offsets used by readers.
After a DayZ update, signature patterns and offsets are the first places to check if attach succeeds but data is wrong.
### Overlay
- `src/Overlay/OverlayWindow.*`: Win32 window, DirectX 11 device, swap chain, ImGui backend, font setup.
- `src/Overlay/GameOverlay.*`: ESP rendering, projection, menu state, smoothing, bullet trails, ballistic dot.
- `src/Overlay/MenuBridge.h`: pointer bridge between project state and the vendored Lumin menu.
- `external/lumin/framework/gui.cpp`: actual menu layout.
### Web Radar
- `src/Web/WebRadarServer.*`: HTTP routes, SSE broadcast, auth, CORS.
- `src/Web/WebSnapshotService.*`: converts `RuntimeUpdate` into JSON.
- `src/Web/BulletTrackCache.*`: keeps bullet path history for web and overlay visualizations.
- `src/Web/MapRegistry.*`: known maps, aliases, world-to-map coordinate transforms.
- `src/Web/MapTileService.*`: map image loading, tile generation, PNG caching.
- `webroot/`: static browser UI.
## Logs ## Logs
@@ -487,129 +425,83 @@ Useful messages to look for:
## Troubleshooting ## Troubleshooting
### CMake cannot find VolkDMA files **CMake can't find VolkDMA**
- Check: `../dayz-dma/dma-dayz-cpp-master/VolkDMA/` exists
- If elsewhere, set `VOLKDMA_ROOT` in CMakeLists.txt
Confirm this path exists: **Dependency fetch fails**
- First configure needs internet (GitHub FetchContent)
- Check network/proxy; use pre-cached deps if offline
```text **Exit code `0xC0000135`** (DLL missing)
../dayz-dma/dma-dayz-cpp-master/VolkDMA - Verify these exist next to exe: `vmm.dll`, `leechcore.dll`, `FTD3XX.dll`
``` - Rebuild or copy from `${VOLKDMA_ROOT}/dlls`
If your checkout is elsewhere, edit `VOLKDMA_ROOT` in `CMakeLists.txt`. **Overlay ESP misaligned**
- Open `Config` tab, set:
- `overlayWidth` / `overlayHeight` = monitor resolution
- `renderWidth` / `renderHeight` = game render resolution (if different)
- `stretchToFill` = match your GPU scaling
### Dependency download fails during configure **Web radar blank**
- Check `Info` tab: attached + connected?
- Browser URL correct (host/port)?
- `webPassword` matches `?password=` param?
- `webBindAddress` not `127.0.0.1` for remote?
- Firewall allows port?
The first configure fetches dependencies from GitHub. Check network/proxy access or use a CMake dependency cache with the packages already populated. **Map background missing**
- Place PNG: `maps/<map-id>.png` (e.g., `maps/chernarusplus.png`)
- To embed: add to repo `maps/`, re-run CMake, rebuild
### Executable exits immediately with `0xC0000135` **Caddy serves 404s**
- Run `caddy run` from repo root, or fix `root` path in Caddyfile
That status usually means a DLL is missing. Confirm these files are next to `dayz-memory-cpp.exe`: **Port in use**
- Change `webPort` in `config/overlay.json`, restart
- If using Caddy, also update upstream port
- `vmm.dll` **Attach OK but data wrong**
- `leechcore.dll` - DayZ offsets/signatures may be stale post-update
- `FTD3XX.dll` - Check: `Offsets.h`, `SigScanner.cpp`, `logs/dayz-memory.log`
Rebuild the target or manually verify `${VOLKDMA_ROOT}/dlls` contains those DLLs.
### Overlay opens but ESP alignment is wrong
Open `Config` and set:
- Monitor resolution in `overlayWidth` / `overlayHeight`.
- Game render resolution in `renderWidth` / `renderHeight` if DayZ renders at a different resolution.
- `stretchToFill` according to your GPU/display scaling mode.
Save config and restart if needed.
### Web radar is blank
Check:
- The app is attached and `Info` shows connected.
- The browser URL points to the correct host/port.
- `webPassword` matches the `?password=` parameter for remote clients.
- `webBindAddress` is not restricted to `127.0.0.1` when using another device.
- Firewall allows the configured port.
### Map background is missing
Place a supported PNG at:
```text
maps/<map-id>.png
```
Example:
```text
maps/chernarusplus.png
```
If you added the PNG to the repository `maps/` folder and want it embedded, re-run CMake configure and rebuild.
### Caddy serves 404s
Run `caddy run` from the repository root so `root * ./webroot` resolves correctly, or adjust the `root` path in `Caddyfile`.
### Port is already in use
Change `webPort` in `config/overlay.json`, then restart. If using Caddy, also update the upstream port in `Caddyfile`.
### Attach succeeds but entity data is wrong
DayZ offsets or signatures may be stale. Check:
- `src/Offsets.h`
- `src/RuntimeOffsets.h`
- `src/SigScanner/SigScanner.cpp`
- `logs/dayz-memory.log`
Runtime structures can change after a DayZ update even when the process name and module still resolve.
## Development Workflow ## Development Workflow
### Add a new memory field **Add a memory field:**
1. Add offset to `Offsets.h` or scanner logic
2. Read in appropriate resolver/reader
3. Add to `Models.h` / `RuntimeUpdate` if cross-module
4. Publish to overlay or web
5. Add diagnostics for fragile chains
1. Add or update the offset in `src/Offsets.h` or runtime scanner logic. **Add overlay option:**
2. Read the value in the appropriate resolver/reader. 1. `OverlayConfig` struct + `Config.cpp` load/save
3. Add fields to `src/Core/Models.h` or `RuntimeUpdate` if the value must cross module boundaries. 2. Add to `GameOverlay` class
4. Publish the field to overlay or web code. 3. Sync in `GameOverlay::SyncConfig()`
5. Add diagnostics around pointer-chain failures if the chain is fragile. 4. Expose via `MenuBridge`
5. Add control in `external/lumin/framework/gui.cpp`
6. Use in draw path
### Add an overlay option **Add web radar field:**
1. Add to runtime model
1. Add the value to `OverlayConfig` if it should be configurable. 2. Serialize in `WebSnapshotService`
2. Load/save it in `src/Config.cpp`. 3. Consume in `webroot/app.js`
3. Add a member in `GameOverlay`. 4. Style in `webroot/style.css`
4. Sync it in `GameOverlay::SyncConfig()`. 5. Update bootstrap data if needed
5. Expose it through `MenuBridge`.
6. Add the control in `external/lumin/framework/gui.cpp`.
7. Use the toggle in the draw path.
### Add a web radar field
1. Add it to the relevant runtime model.
2. Serialize it in `WebSnapshotService`.
3. Consume it in `webroot/app.js`.
4. Style it in `webroot/style.css` when needed.
5. Update bootstrap data if the frontend needs metadata or filter definitions.
## Known Limitations ## Known Limitations
- Windows-only. - Windows-only
- Offsets/signatures must match the current DayZ build. - Offsets/signatures must match current DayZ build
- Built-in web server is HTTP only; use Caddy, a tunnel, or another reverse proxy for TLS. - Web server is HTTP only (use Caddy/proxy for TLS)
- Web auth is a simple query-parameter password, not a full user/session system. - Web auth is query-param password, not full session system
- Map recognition depends on server map metadata and the known map alias table. - Map recognition depends on server metadata + alias table
- Browser map images require correctly named PNGs unless embedded at build time. - Browser map images need correctly named PNGs (or embed at build)
- Overlay projection depends on correct monitor/render resolution configuration. - Overlay accuracy depends on monitor/render resolution config
## License and Third-Party Code ## Third-Party Code
This repository vendors or fetches third-party components. Check their upstream licenses before redistributing binaries: Vendored/fetched components — check licenses before redistribution:
- ImGui, FreeType (under `external/lumin/`)
- Dear ImGui under `external/lumin/thirdparty/imgui`. - Lumin framework, nlohmann/json, spdlog, cpp-httplib, stb
- FreeType under `external/lumin/thirdparty/freetype`. - VolkDMA + VMM/LeechCore (sibling checkout)
- Lumin framework under `external/lumin/framework`.
- nlohmann/json, spdlog, cpp-httplib, and stb through CMake `FetchContent`.
- VolkDMA and its bundled VMM/LeechCore dependencies from the sibling checkout.