Contrib/import telemetry #4

Open
github-bot wants to merge 6 commits from github-bot/gh-4 into main AGit
Owner

@⁠opal-26 on GitHub · 2026-11-23 00:33 UTC · original
opal-26:contrib/import-telemetry → main · +1436 −49 · 14 files · 6 commits · open

Summary

Adds an opt-in, zero-dependency import & auto-stub telemetry ledger (SCARLETT_TRACE_OUT) to scarlett_hook.dll, extending AutoStubEngine with caller-RVA capture and crash-safe Vectored Exception Handler (VEH) flushing.

  • Off by default / zero hot-path overhead: Inactive unless SCARLETT_TRACE_OUT=<path> is set (single relaxed atomic check when disabled).
  • Caller-PC forwarding in auto_stub.hpp: Adds mov rdx, [rsp + 0x28] inside the existing 48-byte W^X trampoline and an atomic call observer hook to capture the caller's return address without changing thunk stride or ABI.
  • Unified JSON report (src/loader/import_telemetry.hpp): Records LoadLibrary* shim redirects, GetProcAddress outcomes (resolved / auto_stubbed / unresolved, named and ordinal), runtime stub hit counts + first caller RVA, and a lock-free 128-slot chronological recent_calls ring buffer.
  • Crash-safe & loader-lock safe flush: Uses TryAcquireSRWLockShared and a stack-buffered Win32 CreateFileW / WriteFile JSON writer so hardware exceptions (EXCEPTION_ACCESS_VIOLATION, etc.) dump the fault RVA, access address, and trailing stub calls before process teardown (toggleable via SCARLETT_TRACE_VEH=0).
  • Tier 1 E2E test (ImportTelemetryAndVehFlushE2E): Exercises disabled no-op, dynamic redirects, resolved/stubbed/unresolved lookups, 4-thread ring-buffer wrap (160 calls), and a recoverable SEH-guarded access violation verifying the VEH JSON output.

Verification

  • python tools/generate_status.py --check — synced docs/STATUS.md, README.md, docs/ROADMAP.md, CONTRIBUTING.md, and AGENTS.md to 79/79 (43 cpu, 36 gpu).
  • Windows CI (MSVC x64 /W4 /permissive-, 43 CPU CTests + 36 GPU WARP CTests): [link your green workflow run here]

Scope & Hygiene

  • Clean-room C++23 implementation, zero third-party dependencies, Apache-2.0 compatible.
  • No changes to encrypted XVD rejection policy or existing shim behavior when SCARLETT_TRACE_OUT is unset.
**@⁠opal-26** on GitHub · 2026-11-23 00:33 UTC · [original](https://github.com/jadeowaowa/scarlett-layer/pull/4) `opal-26:contrib/import-telemetry` → `main` · +1436 −49 · 14 files · 6 commits · open ## Summary Adds an opt-in, zero-dependency import & auto-stub telemetry ledger (`SCARLETT_TRACE_OUT`) to `scarlett_hook.dll`, extending `AutoStubEngine` with caller-RVA capture and crash-safe Vectored Exception Handler (VEH) flushing. - **Off by default / zero hot-path overhead:** Inactive unless `SCARLETT_TRACE_OUT=<path>` is set (single relaxed atomic check when disabled). - **Caller-PC forwarding in `auto_stub.hpp`:** Adds `mov rdx, [rsp + 0x28]` inside the existing 48-byte W^X trampoline and an atomic call observer hook to capture the caller's return address without changing thunk stride or ABI. - **Unified JSON report (`src/loader/import_telemetry.hpp`):** Records `LoadLibrary*` shim redirects, `GetProcAddress` outcomes (`resolved` / `auto_stubbed` / `unresolved`, named and ordinal), runtime stub hit counts + first caller RVA, and a lock-free 128-slot chronological `recent_calls` ring buffer. - **Crash-safe & loader-lock safe flush:** Uses `TryAcquireSRWLockShared` and a stack-buffered Win32 `CreateFileW` / `WriteFile` JSON writer so hardware exceptions (`EXCEPTION_ACCESS_VIOLATION`, etc.) dump the fault RVA, access address, and trailing stub calls before process teardown (toggleable via `SCARLETT_TRACE_VEH=0`). - **Tier 1 E2E test (`ImportTelemetryAndVehFlushE2E`):** Exercises disabled no-op, dynamic redirects, resolved/stubbed/unresolved lookups, 4-thread ring-buffer wrap (160 calls), and a recoverable SEH-guarded access violation verifying the VEH JSON output. ## Verification - `python tools/generate_status.py --check` — synced `docs/STATUS.md`, `README.md`, `docs/ROADMAP.md`, `CONTRIBUTING.md`, and `AGENTS.md` to `79/79` (`43 cpu`, `36 gpu`). - Windows CI (`MSVC x64 /W4 /permissive-`, 43 CPU CTests + 36 GPU WARP CTests): _[link your green workflow run here]_ ## Scope & Hygiene - Clean-room C++23 implementation, zero third-party dependencies, Apache-2.0 compatible. - No changes to encrypted XVD rejection policy or existing shim behavior when `SCARLETT_TRACE_OUT` is unset.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:42:41 +00:00
This pull request has changes conflicting with the target branch.
  • docs/ROADMAP.md
  • docs/STATUS.md
  • src/loader/scarlett_hook.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4/head:github-bot/gh-4'
git switch 'github-bot/gh-4'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4'
git switch 'github-bot/gh-4'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4'
git switch 'github-bot/gh-4'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4'
git switch 'main'
git merge --squash 'github-bot/gh-4'
git switch 'main'
git merge --ff-only 'github-bot/gh-4'
git switch 'main'
git merge 'github-bot/gh-4'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.