fix(hook): harden detour install, unload, and delta reconnection

Initialize every detour before enabling any, so a hook body that calls
another detour's trampoline can never hit an uninitialized detour and abort
the process. Pin the module on load so unloading can no longer leave
kernel32/ntdll patched to jump into freed memory. On a failed FILETIME
conversion, fall through to the real time instead of returning an
uninitialized SYSTEMTIME. Reconnect the shared delta mapping lazily so
setting a delta after injection takes effect instead of being disabled
forever. Add host-agnostic tick-conversion tests.
This commit is contained in:
tiennm99 committed 2026-09-21 16:13:17 +07:00
1 parent a2e34060e0
commit f4bd35ae5b
17 files changed
+385 -70

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
# time-mocker-target
Java test target for [time-mocker](https://github.com/tiennm99/time-mocker) — validates injected fake time behavior.
## Quick start
```bash
./gradlew run
```
Run alongside `time-mocker` to verify that system time injection works correctly.
## Expected behavior
**Without time-mocker** — prints actual current time, ticking every second:
```
2025-01-15T08:30:01
2025-01-15T08:30:02
2025-01-15T08:30:03
```
**With time-mocker injecting a fake date** (e.g. 2000-06-15T12:00:00) — the same binary prints the mocked time instead:
```
2000-06-15T12:00:01
2000-06-15T12:00:02
2000-06-15T12:00:03
```
If the output reflects the injected date rather than real system time, the injection is working correctly.
## License
Apache-2.0 — see [LICENSE](LICENSE).