cpu: reproduce load-config callback dispatch during EXE startup #903
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#903
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@R0Y00 on GitHub · 2026-11-23 16:36 UTC · original
Refs #870 and #317. Available to claim. Please post the test environment and any overlapping PR when claiming.
Build a source-only x64 Windows fixture that calls a typed startup callback through a load-config dispatch slot. Put both an absent callback and a callback from a relocated, read-only slot in the fixture. Keep the input image and provider identical when comparing Windows and
pe_map.Acceptance:
pe_mapsupports and report any refusal. Keep the CFG-enabled path subject to its original checks.The first contribution can be the fixture and results. The shared AOT binding and loader policy can be reviewed against it separately. Use source-built inputs and share the commands, commit and Windows build.
@triggered02 on GitHub · 2026-11-23 16:47 UTC · original
Claiming this.
Environment: Windows 11 Pro 26200, AMD Ryzen 5 5500, MSVC 19.52 (VS 2026 Build Tools), Windows SDK 10.0.26100 (DXC 1.9.2602.17), CMake/Ninja, Python 3.12,
devandreleasepresets.First pass is the source-built fixture and results, not a production loader or shim change. I plan to build a MASM caller that invokes a typed startup callback through a load-config dispatch slot, with:
pe_map;pe_mapdoes.I will record the load-config fields, relocation and slot permissions from the fixture's own PE, and use the existing
exe_startup/finish_exewrapper and live-worker control. Refs #870 and #317. Overlaps: #165 (source-built startup), #896 (tools-memory fixture), #902 (mapping); none changes the load-config dispatch path. If the fixture exposes a loader gap, I will report it separately rather than fold it into this slice.AI-assisted.
@denn0x on GitHub · 2026-11-23 16:47 UTC · original
Claiming this.
devpreset.__guard_dispatch_icall_fptror CFG. #899 is the closest landed work. It seeds the/GScookie from the same directory, and I'd reuse its CRT-freeexe_startup.asmpattern._load_config_usedwhoseGuardCFDispatchFunctionPointernames a read-only, relocated slot holding ajmp raxdispatcher.(int, int, int, void*)returning an int, through that slot for two read-only, relocated pointers. One pointer is null and is tested and skipped. The other names a callback that records its arguments and the number of calls.pe_map_runof the same image and provider, on exit code, recorded arguments and call count. It also records the relocation entries covering both slots, their section permissions and the load-config fields, read from the fixture's own PE./guard:cflink of the same source. I'll report what Windows writes into the check and dispatch slots, whether a valid target runs, and what an invalid target does natively. Forpe_mapI'll record what it currently does with that image, without relaxing any check. Any refusal or divergence is reported rather than worked around, so the loader policy can be reviewed separately.AI-assisted (Claude Code).
@R0Y00 on GitHub · 2026-11-23 16:49 UTC · original
Thanks to both of you for claiming this. @triggered02, please take the first source-built caller and trace, since you posted first. @denn0x, if willing, please review that candidate on your separate Windows environment and independently check the PE fields, observed call count and the negative control. Keep the CFG-enabled build separate and record observed behavior or a refusal using the original validation rules. This keeps the two contributions on one fixture.
@denn0x on GitHub · 2026-11-23 16:58 UTC · original
Understood. @triggered02 has the caller and trace, and I won't open a competing PR. I'll review the candidate on this machine (Windows 11 build 26300.9974, Ryzen 7 7700, MSVC 19.50.35720) and check the PE fields, call count and negative control independently.
I had already built a local source-only prototype before the assignment, so here are its results as independent data points for the review and for the separate CFG build. Setup: a C++ caller compiled with
/guard:cfcalls through__guard_dispatch_icall_fptr, using a hand-written_load_config_used(size0x138). The callback table and both guard slots are in.rdata, each with a DIR64 relocation. Every function starts on a 16-byte boundary. Results are the same on thedevandreleasepresets.pe_map_run/guard:cf(GuardFlags0x100, noGUARD_CF)jmp rax, one call, expected args, absent entry zero calls/guard:cf(GuardFlags0x17500,GUARD_CFset), valid callback/guard:cf, target inside a function (absent from the function table)0xC0000409, before any outputThe GuardFlags values are as measured on link 14.50 and may differ on other MSVC versions. A target inside a function also runs under both loaders when the image is linked without
/guard:cf.Two things that may help the review:
IMAGE_GUARD_CF_INSTRUMENTED. Even with/guard:cfat link time, Windows then left both slots untouched here, so a CFG build needs at least one object compiled with/guard:cfbefore the loader applies the guard slots.AI-assisted (Claude Code).
@triggered02 on GitHub · 2026-11-23 16:59 UTC · original
Fixture is in #914. Present/absent/alternate native and pe_map both return
0xb111/0xb211/0xb151; the PE check records the 0x138 load config, slot at directory+0x78, read-only.rdataand the DIR64 relocation. CFG: Windows refuses the hand-builtGuardFlags=0x100config before entry withSTATUS_DATA_ERROR(0xc000003e), while pe_map ignores GuardFlags and returns0xb111. That is recorded as a refusal/gap, not a pass; a linker-emitted valid CFG config is an open follow-up. No productionpe_mapchange.AI-assisted.
@triggered02 on GitHub · 2026-11-23 16:59 UTC · original
Thanks @denn0x - #914 is up. The absent/present/alternate cases are the native-vs-
pe_mapmatches; the CFG variant is the hand-builtGuardFlags=0x100config, which Windows refuses before entry withSTATUS_DATA_ERROR(0xc000003e) whilepe_mapignoresGuardFlagsand returns0xb111. A PE-field/call-count review is exactly what I want, especially if you think the CFG case should use a linker-emitted config instead of this hand-built one.@R0Y00 on GitHub · 2026-11-23 18:23 UTC · original
Completed by #914. The merged source-built fixtures cover absent, present, and alternate callbacks, verify the read-only relocated slot, and compare the same inputs under Windows and pe_map. The separate linker-generated CFG build records the observed boundary: Windows rejects the invalid target, while pe_map currently executes it. Thanks @triggered02 and @denn0x for the fixture and independent evidence. Loader enforcement remains separate from this fixture.