Skip to content

Commit 28fa8ba

Browse files
committed
fix(scanner): correct offset semantics docs and harden find_pattern
- Hoist empty/all-wildcard validation out of internal primitive so warnings log once per public call, not per region or per occurrence. - Use unsigned modular arithmetic in resolve_rip_relative to avoid signed pointer overflow UB. - Correct docs/misc/aob-signatures.md: find_pattern applies pattern.offset internally; remove misleading manual-add guidance. - Add regression tests for offset-at-end, all-wildcard Nth occurrence, zero/empty/null guards, and RIP-relative wraparound contract.
1 parent cbaf38b commit 28fa8ba

6 files changed

Lines changed: 1226 additions & 138 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ dispatcher.emit_safe(PlayerStateChanged{.health = player->health});
226226
- **Concurrency tests:** Use `std::atomic<bool> stop` flag pattern with multiple threads. See `AsyncMode_ConcurrentLogAndDisable` in `test_logger.cpp` for the reference pattern.
227227
- **Build flag:** Tests are enabled with `DMK_BUILD_TESTS=ON` (on by default in debug presets).
228228
229-
For detailed coverage analysis, see [docs/tests/README.md](docs/tests/README.md). For hot-reload testing patterns, see [docs/hot-reload/README.md](docs/hot-reload/README.md).
229+
For detailed coverage analysis, see [docs/tests/README.md](docs/tests/README.md). For hot-reload testing patterns, see [docs/hot-reload/README.md](docs/hot-reload/README.md). For AOB signature construction, the Scanner API, and RIP-relative resolution, see [docs/misc/aob-signatures.md](docs/misc/aob-signatures.md).
230230
231231
After any code change, build and run the full test suite before committing:
232232

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ DetourModKit is a lightweight C++ toolkit designed to simplify common tasks in g
3535
- `|` offset markers for targeting a specific instruction within a wider pattern (e.g., `"48 8B 88 B8 00 00 00 | 48 89 4C 24 68"` sets the offset to byte 7)
3636
- Nth-occurrence matching (1-based) for patterns that hit multiple locations
3737
- RIP-relative instruction resolution for extracting absolute addresses from x86-64 code (returns `std::expected` with typed `RipResolveError` for actionable diagnostics)
38-
- `scan_executable_regions()` for scanning all committed executable pages in the process - useful for games with packed or protected binaries that unpack code into anonymous memory outside any loaded module
38+
- `scan_executable_regions()` for scanning all committed executable pages in the process - useful for games with packed or protected binaries that unpack code into anonymous memory outside any loaded module (pure-execute pages without a read bit are skipped to avoid access violations)
3939

4040
</details>
4141

@@ -187,6 +187,7 @@ For detailed coverage analysis and test architecture, see the [Test Coverage Gui
187187

188188
## Guides
189189

190+
* [AOB Signature Scanning Guide](docs/misc/aob-signatures.md) - Pattern syntax, RIP-relative resolution, and patch-proof signature practices
190191
* [Hot-Reload Development Guide](docs/hot-reload/README.md) - Development workflow for iterating on hooks with live reload
191192
* [Test Coverage Guide](docs/tests/README.md) - Coverage analysis, test architecture, and module-level breakdown
192193

@@ -865,6 +866,7 @@ For practical reference and real-world usage examples:
865866
* **KCD1-TPVToggle**: [https://github.com/tkhquang/KCD1Tools/tree/main/TPVToggle](https://github.com/tkhquang/KCD1Tools/tree/main/TPVToggle)
866867
* **KCD2-TPVToggle**: [https://github.com/tkhquang/KCD2Tools/tree/main/TPVToggle](https://github.com/tkhquang/KCD2Tools/tree/main/TPVToggle)
867868
* **CrimsonDesert-EquipHide**: [https://github.com/tkhquang/CrimsonDesertTools/tree/main/CrimsonDesertEquipHide](https://github.com/tkhquang/CrimsonDesertTools/tree/main/CrimsonDesertEquipHide)
869+
* **CrimsonDesert-LiveTransmog**: [https://github.com/tkhquang/CrimsonDesertTools/tree/main/CrimsonDesertLiveTransmog](https://github.com/tkhquang/CrimsonDesertTools/tree/main/CrimsonDesertLiveTransmog)
868870
869871
## Acknowledgements
870872

0 commit comments

Comments
 (0)