runtime: rewrite bound delay QueryApiImpl and always log it #2341
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2349"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-25T13:13:22Z.
Change
Account-picker TRACE_API on tip-of-main still shows zero
QueryApiImpl/provider … proxiedafter the scoped package GPA patch (#2166). Y reaches GameInput (0x20); #2201 never gets a chance. Do not treat this as FakeUser slot-7 evidence.Delay-imported
xgameruntime.dll!QueryApiImplbinds through the CRT delay helper (its own unhookedGetProcAddress), so the title keeps calling the real export while the proxy only remembered it. This change:QueryApiImplIAT slot only when it already equals the remembered real export (delay_query_slot_is_bound); unbound thunks stay untouchedGetProcAddress("QueryApiImpl")past the generic 40-line GPA capQueryApiImpl remembered via {gpa|iat|export}and a one-shotQueryApiImpl statuswhenxgameruntimeis loadedSynthetic PE control + Windows
startup_runtime_proxy_scopecover the bound rewrite; unbound delay and a pre-attach cached pointer are negative controls (the cache still calls the real export — claimable follow-up).Refs #870.
AI-assisted.
Verification
On Windows after configure:
Evidence and follow-up
Source-built / synthetic only; no game files.
docs/startup-runtime.mdX2W_RUNTIME_PROXYrow updated.User re-test: rebuild from this branch with
$env:X2W_TRACE_API='1', press Y. Look forQueryApiImpl remembered via, always-on GPA for that name,bound delay QueryApiImpl import(s) rewritten, and anyprovider … proxied.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:20:54Z.
Review: COMMENTED
Review of head
95f0f67562aaff1610d639b55dd0a603928ec4f5(comment only).Scope read:
runtime_gpa_patch.h(newdelay_query_slot_is_bound),runtime_proxy.cpp(delay-slot rewrite, always-log QueryApiImpl GPA, periodic quiet rescan),CMakeLists.txt(helper now delay-loads the fake xgameruntime), the gpa-patch check and the proxy-scope host/helper.Commands executed locally (Linux):
git diff --stat origin/main...HEAD-> 8 files, +212/-53git diff --check origin/main...HEAD-> cleanpython3 tests/docs_links_check.py-> self-test passed, 19 files / 453 links okpython3 tests/bidi_controls_check.py-> 1630 files, no bidi controlsg++ -std=c++17 -Isrc tests/startup_runtime_gpa_patch_check.cpp+ run ->startup_runtime_gpa_patch: ok;--mutate name-only->FAIL: name-only accepts QueryApiImpl from other.dll(control fails as intended)&& slot_value == real_queryfromdelay_query_slot_is_bound->synthetic delay QueryApiImpl still unbound: MISMATCH,startup_runtime_gpa_patch: FAIL (2). The new test kills it. Reverted withgit checkout -- ..startup_runtime_proxy_scope) is covered by the passing CI Windows job.Findings
runtime_proxy.cpp, delay branch ofpatch_module):remember_real_query_from_export()runs on every delay hit on every quiet scan (every ~250 ms per module). It is cheap oncereal_queryis set, but an earlyif (load_real_query())skip would avoid a repeatedGetModuleHandleW+GetProcAddress.slot == real exportto detect the bind. A package helper that caches the export elsewhere before the first scan is covered by the negative control (pre-attach cached pointer), so behavior is as documented; worth keeping that control.log_query_status_once) is a useful diagnostic.Semantics check: unbound delay thunks are never touched (value != real export). Only an exact match to the remembered real export is rewritten, with
VirtualProtectaround the 8-byte aligned store. The delay-GetProcAddress path stays unhooked, as before. Clean-room and title are neutral. PR is mergeable.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T14:07:10Z.
Review: CHANGES_REQUESTED
The independent Windows run passed the three GPA and loader-scope tests on
95f0f675. The background delay-slot rewrite still needs to preserve a value changed by the delay loader after the eligibility check. It reads the real export, calls VirtualProtect, and then writes the proxy for any value other than the proxy. If the slot was restored to its delay thunk in that interval, the fallback can overwrite the restored state.Please make the replacement conditional on the slot still holding the exact real export at the write, and count only successful replacements. A source-built check can exercise both transitions deterministically: a real export that remains installed is replaced, and a slot changed back to the thunk before the replacement stays untouched. Keep the existing unbound, same-name decoy and pre-attach pointer controls.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-25T16:06:43Z.
APPROVED. Rewrites bound delay QueryApiImpl with logging.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T12:30:53Z.
Addressed the review in
f8b51edb(after merging currentmainin6adfba14). The delay-slot store now compare-exchanges against the remembered real export, so a slot that still holds that export is replaced and counted, while a slot restored to its delay thunk before the exchange is left untouched and not counted.startup_runtime_gpa_patchcovers both transitions, and a mutant helper that stores the proxy for any other value fails both checks. The unbound-thunk, same-name decoy and pre-attach pointer controls remain instartup_runtime_proxy_scope. Quiet scans reuse an already-remembered export and still log only when a store succeeds.Verification (Windows 11 25H2 26200, MSVC 19.42, dev preset):
ctest --preset dev --no-tests=error -R '^(startup_runtime_gpa_patch(_name_only_control)?|startup_runtime_proxy_scope)$'returned 3/3 passed, exit 0. On Linux, thepython-linuxcheck list returned 208/208 passed.AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:21:30Z.
Review: CHANGES_REQUESTED
Independently reviewed
f8b51edbintegrated overmaine582a9a4(tree3784ee7e). The merge is clean (CMakeLists.txtanddocs/startup-runtime.mdauto-merged) andgit diff --cached --check origin/mainis clean.Earlier finding (R0Y00, changes requested on
95f0f675): the code is addressed, the end-to-end evidence is not.replace_bound_delay_querynow stores the proxy withInterlockedCompareExchange64against the remembered real export, andpatch_modulecounts only a successful exchange. Because the store compares at the moment it writes, a thunk the delay loader puts back after the eligibility read stays as it is.startup_runtime_gpa_patchcovers both transitions with a fake exchange. Restoring the old unconditional store fails it atslot restored to the thunk stays the thunk: MISMATCHandrestored thunk not counted: MISMATCH.What I ran.
devand inrelease/O2, with no skips.startup_runtime_proxy_scopepasses 10 of 10 repeats in each preset.startup_stub_gameinputandstartup_stub_consumer, which also compileruntime_proxy.cpp, build in both presets.Finding:
startup_runtime_proxy_scopedoes not exercise the new delay-slot rewrite, and its unbound-thunk control does not hold. Each mutant below was applied alone tosrc/startup_stubs/runtime_proxy.cpp,startup_runtime_proxy_scope(with the carrier) rebuilt indev, the test rerun, and the file restored from its raw bytes.git diff --quietwas clean afterwards.startup_runtime_proxy_scopemain)real_bits = *slot(any non-proxy delay slot counts as bound, so the unbound thunk is rewritten)GetProcAddressimport being patched:x2w-runtime proxy: 1 import(s) patched in package module startup_runtime_proxy_helper.dll. Yetbound delay slot rewritten to proxystill passes. The CRT delay helper resolvesQueryApiImplthrough the helper's ownGetProcAddressimport, which the scan has already hooked. So the bind itself stores the proxy, and the slot never holds the real export for the new code to replace. That is also whydelay bind wrote real export or proxyaccepts either value.2 import(s) patched in package module startup_runtime_proxy_helper.dll. The thunk is replaced in the same scan that hooks the helper'sGetProcAddress.wait_for_helper_hookwaits for that scan, sobefore_bindalready reads the proxy.delay_query_slot_is_bound(proxy, real, proxy)is then false and the slot never changes after that, so bothdelay slot unbound before first useandunbound delay slot not rewrittenpass.The device-free check stays sound. But the one test that runs the real loader, which the body and
docs/startup-runtime.mdgive as coverage for the rewrite, passes for this PR, formain's handling and for the unsafe rewrite R0Y00 asked to rule out.Suggested direction (unconfirmed):
call_delay_querybefore the proxy carrier attaches. The bind then goes through the unhookedGetProcAddress. Check that the slot equalsxgr_query, then load the carrier and wait for the slot to become the proxy.SizeOfImage), not just to equal an earlier read of itself. A second helper that is never called would give a clean unbound slot for this.Other mutants (same procedure;
startup_runtime_gpa_patchfor the header):slot restored to the thunk stays the thunk: MISMATCHrestored thunk not counted: MISMATCHunbound thunk refused: MISMATCHreal_queryis already remembered through the hookedGetProcAddressQueryApiImpllookups capped with the generic 40-line logNon-blocking, a hypothesis I did not reproduce. In a module built with
/guard:cf, the delay IAT can be protected. The MSVC delay-load helper then keeps that section read-only and unprotects it under its own lock only while it writes a slot. The background pass callsVirtualProtecton the slot's page, compare-exchanges, then restores the protection it saw, without that lock. Suppose another thread's first call to a different delay import in the same module takes the helper through its unprotect/write/reprotect at the same time. This pass could then restore read-only between the helper's unprotect and its write, and the helper's write would fault. In the other order, it could leave the section writable. Nothing in this repository builds with/guard:cf, so the fixtures cannot show it. Leaving delay slots alone in an image whose load config setsIMAGE_GUARD_PROTECT_DELAYLOAD_IATwould avoid the question.Verdict: changes requested on
f8b51edb, for the loader fixture above. The compare-exchange itself looks right to me.Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass onf8b51edb.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-27T22:49:13Z.
The loader test was calling the delay import after GetProcAddress was already hooked, so the bind wrote the proxy and the rewrite never got a real export to replace. The helper now calls it before the proxy attaches. The test checks the slot is the real export, then waits for that slot to become the proxy. A second helper is never called, and after the scan its thunk has to still sit inside its own image.
I built the source-built check, then ran it again with the exchange removed.
bound delay slot rewritten to proxywas MISMATCH and the check failed (8). The loader test waits for that same change, so dropping the rewrite leaves the real export in the slot and the wait fails.The check printed
startup_runtime_gpa_patch: ok, the name-only control exited 1, and the Python run was 245 passed.Windows test PC: the three tests passed twice, ctest exit 0.
AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T23:04:11Z.
Review: CHANGES_REQUESTED
Retested
eafec814integrated overmain2e12dd8e(tree987cb1c4). The merge is clean (CMakeLists.txtanddocs/startup-runtime.mdauto-merged) andgit diff --cached --check origin/mainis clean.My earlier finding on
f8b51edb(the loader fixture did not exercise the rewrite): addressed. The helper now binds its delay slot before the proxy attaches, and the test checks that the slot is the real export first. A second, never-called helper must keep its thunk inside its own image. My two earlier survivors are now killed:f8b51edbeafec814main's handling)bound delay slot rewritten to proxy: MISMATCHunbound delay thunk stays inside its image: MISMATCHWhat I ran. I built
startup_runtime_gpa_patch,startup_runtime_proxy_scope,startup_stub_gameinput,startup_stub_consumer,startup_runtime_local,startup_console_modeandstartup_console_mode_decoyindevandrelease, then ran:8 of 8 pass in Debug and Release
/O2, with no skips.startup_runtime_proxy_scopepasses 10 of 10 repeats in each preset.New finding: the loader test no longer loads anything after the proxy attaches, so the late-load path that
maintests is now uncovered. Onmain,host.cpploads the carrier first and then the helper ("late-load package helper"). It then waits for the helper'sGetProcAddressimport to be hooked by the worker. At this head both helpers, the decoy and the fakexgameruntime.dllall load before the carrier, so the initial scan finds everything. This came from my suggested direction, and I didn't flag the cost at the time.The mutant: the worker runs only its first
patch_package_modulesand never rescans.main2e12dd8e(if (rescan_package_modules.exchange(...)) patch_package_modules();changed to run once):startup_runtime_proxy_scopefails athelper sees proxied xgameruntime QueryApiImpl: MISMATCH.eafec814(if (tick == 0) patch_package_modules(true);): the test passes. Two narrower mutants also pass:dll_loadedignoring the load notification, and the new periodic quiet pass removed.AGENTS.mdasks not to weaken existing tests. The load-notification path is also the onedocs/startup-runtime.mdand theCMakeLists.txtcomment still describe ("Notification only enqueues; rewrite runs after link").Suggested direction (unconfirmed): load
startup_runtime_proxy_helper_unbound.dllafter the carrier, instead of before it. Keep the bound helper where it is. The unbound helper then needs the worker's load-driven scan to get itsGetProcAddresshooked, which aresolve_querywait likewait_for_helper_hookwould check. Its delay thunk is still never called, so the in-image check stays the negative control. The scan-once mutant should then fail again.The periodic quiet pass is new in this PR. With the bind moved before attach, no test now needs it. A slot bound after the load-driven scan through an unhooked lookup would need it, but I don't see a cheap way to build that through the real loader. I'm not asking for it.
Verdict: changes requested on
eafec814, for the lost late-load coverage only. The compare-exchange and the new bound and unbound controls look right to me. R0Y00's changes-requested review on95f0f675also still stands. This supersedes my changes-requested review onf8b51edb.Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass oneafec814.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:14:21Z.
Thanks for the compare-exchange and the bound and unbound helpers. I reviewed head
eafec814against currentmain(1f07b2c1). R0Y00's request is met in code. A g++ 17-Wall -Wextra -Werrorbuild ofstartup_runtime_gpa_patch_check.cppprintsstartup_runtime_gpa_patch: ok, and five header mutants all fail it. A plain store instead of the CAS givesslot restored to the thunk stays the thunk: MISMATCH, counting every attempt givesrestored thunk not counted: MISMATCH, and the other three (the bound test ignoring the real export,address_in_imagewithout its upper bound, the pre-check dropped) fail too. R0Y00 will still need to re-review, because that changes request stands. Two things block the merge:main,host.cpploads the carrier first and the helper after it (check("late-load package helper", ...)). Ateafec814both helpers load before the carrier. Noload_beside(call follows the carrier, andgrep -c late-loadonhost.cpp→0. The worker's first scan therefore sees every module, and thedll_loadedrescan never runs. pigalot's scan-once mutant (if (tick == 0) ...) and their notification-ignored mutant both pass at this head. pigalot's suggestion would fix this: loadstartup_runtime_proxy_helper_unbound.dllafter the carrier and wait for itsGetProcAddresshook withwait_for_helper_hook. The CMake comment "Notification only enqueues; rewrite runs after link" would then be true again.main.git merge-tree --write-tree 1f07b2c1 eafec814exits 1 withCONFLICT (content): Merge conflict in docs/startup-runtime.md. Only one table row conflicts. Keep #2107'sX2W_AUDIO_ACTIVITY=1row frommain, with your updatedX2W_RUNTIME_PROXY=1row below it. Main's proxy row is byte-identical to the base row (cmpprints nothing), so there is nothing else to reconcile. Please merge rather than rebase.Also worth fixing:
else if (tick % 10 == 0) patch_package_modules(false);) has no test: pigalot's mutant that removes it passes. It also never stops. On the regular-import path,patch_modulecallsVirtualProtect(slot, 8, PAGE_READWRITE, &old)beforeif (*slot != ...hooked_get_proc_address). Every regularGetProcAddressandQueryApiImplslot in the EXE and package helpers therefore gets a protect/restore pair four times a second. Onmainthat happened only on module loads (grep -c 'tick % 10'→0). The new delay path already compares first. Moving the comparison beforeVirtualProtect, limiting the quiet pass to delayQueryApiImplslots, or dropping the pass would fix this.ctest --preset pr(100% tests passed out of 69), andgrep -cforstartup_runtime_proxy_scopeandstartup_runtime_gpa_patchon its log gives0and0. Please post a Windowsstartup_runtime_proxy_scoperun on the fixed head.Environment: Linux. I reviewed the git objects statically, ran
git merge-tree, built the device-free check with g++ (plus the five mutants) and read the CI job logs. I did no Windows or loader run, so the loader mutant results above are pigalot's.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T10:42:24Z.
Review: APPROVED
Retested
3ceef4a4integrated overmainec71c290(treebb3f0da7). The merge is clean andgit diff --cached --check origin/mainis clean. The author's merge ofmain(9d2d0700) resolves the one conflicting table row indocs/startup-runtime.mdby keepingmain'sX2W_AUDIO_ACTIVITY=1row and the PR'sX2W_RUNTIME_PROXY=1row.My earlier finding on
eafec814(late-load coverage lost): addressed.host.cppnow loadsstartup_runtime_proxy_helper_unbound.dllafter the carrier and waits for itsGetProcAddresshook (late-load helper sees proxied xgameruntime QueryApiImpl). The bound helper still binds before the carrier loads, and the unbound thunk must still lie inside its own image after the scan. The scan-once mutant that passed ateafec814now fails.What I ran. I built
startup_runtime_gpa_patch,startup_runtime_proxy_scope,startup_stub_gameinput,startup_stub_consumer,startup_runtime_local,startup_console_modeandstartup_console_mode_decoyindevandrelease, then ran:8 of 8 pass in Debug and Release
/O2, with no skips.startup_runtime_proxy_scopepasses 10 of 10 repeats in each preset.Mutants. Each was applied alone to
src/startup_stubs/runtime_proxy.cpp(the last one toruntime_gpa_patch.h), the two tests rebuilt indevand run with--repeat until-fail:5, and the file restored from its raw bytes.git diff --quietwas clean afterwards.Killed:
late-load helper sees proxied xgameruntime QueryApiImpl: MISMATCHlate-load helper sees proxied xgameruntime QueryApiImpl: MISMATCHmain's handling)bound delay slot rewritten to proxy: MISMATCHunbound delay thunk stays inside its image: MISMATCHGetProcAddressslotshost GetProcAddress(xgameruntime) is proxied: MISMATCHslot restored to the thunk stays the thunk: MISMATCH,restored thunk not counted: MISMATCHSurviving:
QueryApiImplslotsxgameruntime.dll!QueryApiImplimport;mainhas the same gap for that branchEquivalent:
GetProcAddressslotsVirtualProtectpair differs, which no test observesThe first two survivors are the two rescan paths covering for each other: either one alone gets the late helper hooked, and removing both fails. I'm not asking for a test that tells them apart.
Other notes, none blocking.
VirtualProtecton regular slots means a quiet pass no longer changes page protection on slots that are already patched. I read it; no test observes it (see the equivalent mutant)./guard:cfprotected delay IAT hypothesis from my review onf8b51edbis unchanged. I still have not reproduced it and nothing in this repository builds that way.ctest --preset prdoes not runstartup_runtime_proxy_scopeorstartup_runtime_gpa_patch, so the results above are from my local runs.Verdict: approved on
3ceef4a4. This supersedes my changes-requested review oneafec814. R0Y00's changes-requested review on95f0f675still stands on the PR; the compare-exchange it asked for is in the code and covered bystartup_runtime_gpa_patch. I am not merging this.Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on3ceef4a4.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-28T10:51:55Z.
The second helper loads after the carrier again, with the late-load package helper check, and the test waits for that helper's GetProcAddress hook. The first helper still binds the delay slot to the real export before the proxy attaches. Current main is merged, with the audio-activity switch row kept above the runtime-proxy row. Regular import slots are compared before VirtualProtect, so the quiet pass leaves an already patched slot's protection unchanged.
g++ -std=c++17 -Wall -Wextra -Werror -Isrc tests/startup_runtime_gpa_patch_check.cppis ok.--mutate name-onlyexits 1 withFAIL: name-only accepts QueryApiImpl from other.dll. The five header mutants (plain store, count every attempt, bound test ignoring the real export, image check without the upper bound, pre-check dropped) each fail that binary. The Linux Python suite reported all 254 checks passed.Windows test PC, head
3ceef4a448(upstream main3926a289merged):passed 3/3 twice, exit 0.
startup_runtime_gpa_patch_name_only_controlprintedFAIL: name-only accepts QueryApiImpl from other.dlland ctest still passed it, as expected.passed 6/6 once, exit 0.
AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:11:02Z.
Thanks for restoring the late-load helper and moving the comparison ahead of
VirtualProtect. I re-reviewed3ceef4a4against currentmain(c04e0dd6). Nothing blocking from me. Both things I raised oneafec814are fixed:host.cpploadsstartup_runtime_proxy_helper_unbound.dllafter the carrier again (check("late-load package helper", ...)). It then waits for that helper's hook withwait_for_helper_hook(unbound_resolve, xgr, host_xgr, 2000)(late-load helper sees proxied xgameruntime QueryApiImpl). The CMake comment "Notification only enqueues; rewrite runs after link" is true again.patch_modulenow returns beforeVirtualProtectwhen aGetProcAddressslot already holdshooked_get_proc_address, or aQueryApiImplslot already holds the proxy. The registry path (patch_registry_imports) already compared first. So the 250 ms pass no longer flips protections on already patched slots.What I ran
git merge-tree --write-tree c04e0dd6 3ceef4a4gives rc=0. On the merged tree,docs_links_check.pyreportsChecked 171 Markdown files and 708 links.(rc=0), andbidi_controls_check.pygives rc=0.runtime_gpa_patch.handstartup_runtime_gpa_patch_check.cppare unchanged sinceeafec814(git diff --quietrc=0). I rebuilt the check from the head withg++ -std=c++17 -Wall -Wextra -Werror. It printsstartup_runtime_gpa_patch: ok(rc=0), and--mutate name-onlygivesFAIL: name-only accepts QueryApiImpl from other.dll(rc=1). The five header mutants still fail it: plain store (slot restored to the thunk stays the thunk: MISMATCH), count every attempt (restored thunk not counted), bound test ignoring the real export (unbound thunk refused),address_in_imagewithout its upper bound (real export lies outside the helper image) and the pre-check dropped (unbound thunk is left alone).Non-blocking
run.shandrun.ps1setX2W_RUNTIME_PROXY=1, so the uncappedGetProcAddress(..., "QueryApiImpl")line is on the default launcher path. Onmainthe generic 40-line cap already fills during a normal run (a recent one logs 40 of these lines, 1 of themQueryApiImpl). So how often a title looks the name up later is unmeasured. A per-module cap, or logging only lookups that return a different pointer, would bound it if that rate turns out to be high.R0Y00's changes request on
95f0f675(conditional store, count only successes) is met in code sincef8b51edb, but it still blocks the merge. This needs their re-review.Environment: Linux only: git objects,
git merge-tree, the device-free check with its mutants, and two pure-Python checks on the merged tree. I did no Windows or loader run. The loader results are yours and pigalot's.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T12:18:34Z.
Review: APPROVED
The delayed-slot race I raised on
95f0f675is addressed. The replacement compares the slot to the real export at the write and counts a successful exchange only. Pigalot's independent review on3ceef4a4verifies the bound, untouched thunk, and late-load controls through the loader fixture. I confirmed a clean trial merge and successful required Windows CI.