pe: start the pe_run_package entry as the main image #1078
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1085"
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 mumba17 on 2026-11-24T00:32:57Z.
Change
tools/pe_run_package.pystarted the entry EXE withpe_map_run. An EXE built with/GAreads its thread-locals through TLS slot 0 without loading_tls_index, so under the runner it read and wrote whatever block the host Python process keeps in slot 0. #988 addedpe_map_run_mainfor this case, but nothing intools/called it.pe_map_run_main. Per #988, an image without a TLS template simply starts, so other entries behave as before.CreateThreadimports (kernel32.dll,kernelbase.dllor anapi-ms-win-core-processthreads-*contract) are bound tope_map_main_create_thread, so the threads it starts are enrolled. Bundled DLLs keep their own imports, the same scope #988 documents for other thread routes.pe_map_run_mainis refused withthe entry EXE requires a mapper with pe_map_run_main.plan(), provider resolution or release order.Test
tests/cpu/package_main_image_check.py, registered ascpu_package_main_image, reuses #988's/GAEXEcpu_exe_tls_slot0and its expected strings:kernel32!CreateThread.LOG:m1=yy m:yyyy a2=yy a:yyyy a3=y- b2=yy b:yyyy b3=y- X=0, exit 0.--system kernel32.dll: refused before mapping, with no guest log.--system kernel32.dll: the same guest log, exit code 0 and{"image_order": ["cpu_exe_tls_slot0.exe"], "entry_executed": true, "exit_code": 0}.Negative controls (local mutations, not committed):
pe_map_run(currentmain)m1=n- m:n--- a2=n- a:n--- a3=n- b2=n- b:n--- b3=n- X=8, which is #988'sPLAIN; the check failspe_map_run_main, do not bindCreateThreadm1=yy m:yyyy a:n--- b:n--- X=2: the main thread passes and both workers fail; the check failsVerification
Environment: Windows 11 Pro build 26300, MSVC 19.44.35207.1 x64, Python 3.13.1 (
out/pe-env), branch on110e186.devand 11/11 inrelease, including every existingpe_run_package.pyuser and the three slot-0 tests from #988.pe_package_preflight_check.py,pe_package_ordinal_plan_check.py,docs_links_check.py,bidi_controls_check.pyandgit diff --checkare clean.Local observation (no image or log attached): I ran the main executable from the #870 checkpoints through the runner with the two shims and System32 providers. With the previous start, it crashed right after its memory setup on a write whose index register held ASCII text, where the Windows loader carried on. With this change it reaches the same next boundary as the Windows loader: the executable's runtime services initialize and the first call into a missing module follows. That made the gap visible. The fixture above is the evidence.
docs/experiments.mdrecords the start mode next to the other runner options.Refs #870, #988.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:45:07Z.
I pushed a narrow provider-precedence fix. The ordinary System32 route still enrolls both workers and matches the native /GA fixture. The prior candidate silently replaced CreateThread even when the caller supplied that DLL through --shim. The new control sets both options and verifies the explicitly selected provider stays in effect. The main thread owns slot 0 and both unwrapped workers give their expected refusal markers. Windows Release cpu_package_main_image passed, including refusal before mapping with neither provider configured.
Candidate:
0cfb44ceb9