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
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:
- 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.
**Use only on authorized systems.** The web server runs plain HTTP — protect with a password before exposing beyond localhost.
## Features
- External DMA-backed memory access through VolkDMA.
- Runtime signature scanning and static offsets for DayZ structures.
- Automatic reconnect behavior when the process/session drops.
- High-frequency camera reads decoupled from entity scans.
- Player, infected, animal, vehicle, loot, corpse, and bullet snapshots.
- Player skeleton rendering with cached bone pointer chains and gap filling.
- Health, held weapon, worn items, names, boxes, head circles, and configurable draw distances.
- Ballistic aim dot using local weapon ammo velocity and drag values.
- Bullet trail visualization for active, completed, and phantom bullet tracks.
- Configurable item category filters from `config/item_filters.json`.
- DirectX 11 transparent overlay with a Lumin/ImGui menu.
- Built-in HTTP server with:
- `GET /` static radar UI
- `GET /api/bootstrap`
- `GET /api/state`
- `GET /events` server-sent events
- `GET /tile`
- `GET /map-image`
- `GET /api/debug`
- CORS support for serving the web UI from a different origin.
- Optional `Caddyfile` for static webroot hosting and API proxying.
- Embedded map support for known maps, with runtime disk PNG overrides.
- DMA throughput stats shown in the overlay info panel.
**Memory & Reading:**
- DMA-backed memory access (VolkDMA)
- Runtime signature scanning + static offsets
- Auto-reconnect on process/session drop
- High-frequency camera reads
- Efficient batched entity scanning
**Overlay (DirectX 11 + ImGui):**
- Player/zombie/animal/vehicle/loot ESP
- Player skeletons with interpolation
- Health bars, held weapons, worn items
- Configurable draw distances
- Ballistic aim dot (weapon velocity + drag)
- Bullet trail visualization
- Lumin menu with live config save
**Web Radar (HTTP + SSE):**
- Real-time map with pan/zoom
- Entity filters + player list
- Bullet path visualization
- Server-sent events for live updates
- Map tiles (512x512 PNG cache)
- Optional Caddy proxy for static hosting
- CORS support
## 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.
- Visual Studio 2022 Build Tools or full Visual Studio with the MSVC x64 toolchain.
- Windows SDK with DirectX 11 headers/libraries.
- CMake 3.20 or newer.
- 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
**VolkDMA:**
Must be at this location (or update `VOLKDMA_ROOT` in CMakeLists.txt):
```
../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`
- `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`.
Vendored in `external/lumin/`: ImGui, Lumin framework, FreeType
## Repository Layout
@@ -142,27 +118,23 @@ Running from the repository root can work for some files, but the executable als
## Runtime Controls
- `INSERT`: toggle the overlay menu.
- `Config -> Save Config`: writes overlay settings to `config/overlay.json`.
- `Config -> Exit`: closes the overlay and stops the process.
- `Ctrl+C` in the console: requests shutdown.
**Keys:**
- `INSERT` — toggle menu
- `Ctrl+C` in console — shutdown
Menu tabs:
- `Aim`: ballistic dot and bullet trail toggles.
- `Visuals`: player/world ESP toggles and draw distances.
- `Loot`: item category filters sourced from `config/item_filters.json`.
- `Info`: connection status, entity counts, local position, DMA stats, web radar info.
- `Config`: monitor/render resolution overrides, save, and exit.
**Menu Tabs:**
- `Aim` — ballistics, bullet trails
- `Visuals` — ESP toggles, draw distances
- `Loot` — item filters (from `config/item_filters.json`)
- `Info` — status, entity counts, DMA throughput, web radar URLs
- `Config` — resolution/render overrides, save settings, exit
## 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/overlay.json`: JSON overlay/web settings, created or updated by the 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`** — INI format, runtime reader settings (refresh intervals, batch sizes)
- **`config/overlay.json`** — JSON, overlay/web UI settings (auto-created/updated by menu)
### `config/config.cfg`
@@ -377,84 +349,50 @@ The tile server cuts maps into 512x512 PNG tiles and caches encoded tile bytes i
## 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/`.
2. Initializes spdlog.
3. Loads `config/config.cfg` into `RuntimeConfig`.
4. Loads `config/overlay.json` into `OverlayConfig`.
5. Starts `WebRadarServer`.
6. Starts `DayZRuntimeService`.
7. Creates the overlay and enters the DirectX/ImGui render loop.
**Runtime Service** (`DayZRuntimeService`):
- Main loop: wait for process, resolve base objects
- Refresh entity lists at configured intervals
- Read players, bullets, items, bones
- Publish `RuntimeUpdate` snapshot to overlay + web
### 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.
- Finds and attaches to `DayZ_x64.exe`.
- Applies `fix_cr3`.
- Performs typed reads, raw reads, string reads, and scatter reads.
- Tracks total bytes and scatter calls for DMA stats.
- Re-applies CR3 after `ForceRefresh()`.
**Overlay** (DirectX 11 + ImGui):
- `OverlayWindow` — Win32 window, DX device, font atlas
- `GameOverlay` — ESP rendering, projection, trails, ballistics
- `MenuBridge``external/lumin/framework/gui.cpp` (menu layout)
### Runtime Service
`src/Runtime/DayZRuntimeService.*` owns the background reader threads.
The main live loop:
- 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.
**Web Radar:**
- `WebRadarServer` — HTTP routes, SSE, auth, CORS
- `WebSnapshotService` `RuntimeUpdate` → JSON
- `BulletTrackCache` — bullet history
- `MapTileService` — tile generation + PNG cache
- `webroot/` — browser UI
## Logs
@@ -487,129 +425,83 @@ Useful messages to look for:
## 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
../dayz-dma/dma-dayz-cpp-master/VolkDMA
```
**Exit code `0xC0000135`** (DLL missing)
- 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`
- `leechcore.dll`
- `FTD3XX.dll`
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.
**Attach OK but data wrong**
- DayZ offsets/signatures may be stale post-update
- Check: `Offsets.h`, `SigScanner.cpp`, `logs/dayz-memory.log`
## 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.
2. Read the value in the appropriate resolver/reader.
3. Add fields to `src/Core/Models.h` or `RuntimeUpdate` if the value must cross module boundaries.
4. Publish the field to overlay or web code.
5. Add diagnostics around pointer-chain failures if the chain is fragile.
**Add overlay option:**
1. `OverlayConfig` struct + `Config.cpp` load/save
2. Add to `GameOverlay` class
3. Sync in `GameOverlay::SyncConfig()`
4. Expose via `MenuBridge`
5. Add control in `external/lumin/framework/gui.cpp`
6. Use in draw path
### Add an overlay option
1. Add the value to `OverlayConfig` if it should be configurable.
2. Load/save it in `src/Config.cpp`.
3. Add a member in `GameOverlay`.
4. Sync it in `GameOverlay::SyncConfig()`.
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.
**Add web radar field:**
1. Add to runtime model
2. Serialize in `WebSnapshotService`
3. Consume in `webroot/app.js`
4. Style in `webroot/style.css`
5. Update bootstrap data if needed
## Known Limitations
- Windows-only.
- Offsets/signatures must match the current DayZ build.
- Built-in web server is HTTP only; use Caddy, a tunnel, or another reverse proxy for TLS.
- Web auth is a simple query-parameter password, not a full user/session system.
- Map recognition depends on server map metadata and the known map alias table.
- Browser map images require correctly named PNGs unless embedded at build time.
- Overlay projection depends on correct monitor/render resolution configuration.
- Windows-only
- Offsets/signatures must match current DayZ build
- Web server is HTTP only (use Caddy/proxy for TLS)
- Web auth is query-param password, not full session system
- Map recognition depends on server metadata + alias table
- Browser map images need correctly named PNGs (or embed at build)
- 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:
- Dear ImGui under `external/lumin/thirdparty/imgui`.
- FreeType under `external/lumin/thirdparty/freetype`.
- 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.
Vendored/fetched components — check licenses before redistribution:
- ImGui, FreeType (under `external/lumin/`)
- Lumin framework, nlohmann/json, spdlog, cpp-httplib, stb
- VolkDMA + VMM/LeechCore (sibling checkout)