mirror of
https://github.com/sp00nznet/xboxrecomp.git
synced 2026-12-06 02:22:30 +00:00
fix/dpc-queue-lock
3 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d7774d5088 |
kernel: "an xbox_* exists so the wrapper is mechanical" is false
Rebuilt Halo with the kernel fixes and it held: exit=3, still reaching render_cameras.c:458, and PsCreateSystemThreadEx now genuinely spawns a worker instead of running it inline -- the <stdlib.h> malloc truncation fix taking effect. Then wrote the 23 bridge wrappers for the ordinals Halo's thunk table binds but the bridge did not route. Every one had a working xbox_* behind it, so this looked like transcription. It crashed the title EARLIER than the stubs it replaced, twice, with two different faults, and both times presented as "0 assert sites" -- the trap run.sh warns about. Bisected (11 -> 5 -> 3 -> 1) to a memory-model mismatch, not to argument arithmetic: xbox_IoCreateDevice HeapAllocs from GetProcessHeap() and writes that NATIVE pointer through its out-parameter. The bridge hands it the native address of a 4-BYTE GUEST slot, so a 64-bit pointer goes into 4 bytes -- clobbering the adjacent guest dword and leaving the title a truncated pointer it dereferences. The crash was a write to 0x90909090. xbox_ExFreePool calls HeapFree(GetProcessHeap(), P) on guest pool memory that was never on the host heap. These functions were written for a native caller: host pointers, host allocations. The bridge is a different world -- guest VAs, memory in the mapped guest space. XBOX_TO_NATIVE converts an address; it cannot convert an allocator. So the wrappers are left in place and NOT routed, with the reasoning at the call site, and tools.kernel_audit.coverage no longer calls category A "mechanical". Routing one now requires checking which side owns the allocation and whether any out-pointer must carry a guest VA. The Xc* crypto group and RtlTimeToTimeFields only read/write bytes at a caller-supplied address and should be fine; anything that allocates, frees, or returns a pointer is not. Halo is back at its best known state, verified: exit=3, milestones held, render_cameras.c:458 reached. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
cd8151d336 |
kernel: data-export table had a shifted block, handing functions data addrs
Went to fix Halo's 29 unsized imports and found something worse in the
same file. kernel_data_va_for_ordinal is consulted BEFORE function
routing when thunks are built, so an ordinal listed there wrongly does
not merely mis-read a variable -- the title gets a data address for a
real kernel function and calls it, jumping into kernel data.
A whole block had drifted:
17 -> ExEventObjectType slot, but 17 is ExFreePool (function)
65 -> IoCompletionObjectType, but 65 is IoCreateDevice (function)
327 -> AlternateSignatureKeys, but 327 is XeLoadSection (function)
328 -> XeImageFileName, but 328 is XeUnloadSection (function)
71 -> IoDeviceObjectType, but 71 is IoFileObjectType
326 -> XboxLANKey, but 326 is XeImageFileName
355 -> XboxLANKey again, but 355 is XePublicKeyData
356 -> AlternateSignatureKeys, but 356 is HalBootSMCVideoMode
357 -> XePublicKeyData, but 357 is IdexChannelObject
Crimson Skies imports all four of those functions. In the other
direction the genuine exports at 16, 353, 354, 356 and 357 got no thunk
at all, so a title reading XboxLANKey or KeTimeIncrement read whatever
the function fallback happened to leave.
Fixes the table, adds the eight slots that had nowhere to live
(ExMutant/ExSemaphore/ExTimer/IoFile object types, KeTimeIncrement,
HalBootSMCVideoMode, IdexChannelObject, HalDiskCachePartitionCount), and
adds the 25 missing argument sizes Halo needed -- 7 verified against a
local xbox_* prototype, 18 from published signatures. Under-popping only
leaks, over-popping corrupts a live frame, so nothing uncertain was
guessed high.
Object types were all initialised to 0. That is wrong twice: a title
null-checking one sees "no such type", and ObReferenceObjectByHandle
compares an expected type against the object's, so with every type equal
to 0 a mutant handle passes a check meant for events. Each now gets a
distinct non-zero value.
Also: kernel_bridge.c was missing <stdlib.h>, so C89 implicit declaration
made malloc return `int` and bridge_spawn_thread TRUNCATED its heap
pointer to 32 bits before storing it as a struct pointer. Every field
write then landed somewhere unrelated to the allocation. That is the
PsCreateSystemThreadEx path, which is the one Halo currently papers over
by running workers synchronously. MSVC reported it as C4013 + C4047 and
this file builds /W4 /WX-.
Two new audit tests, because the existing ones covered the routing and
arg-size tables but not this one:
data_exports_match_their_ordinal -- every entry vs the export table
no_data_export_ordinal_is_also_a_function_route -- the tables must not overlap
The runner is now discovery-based; the tests I appended were defined
after the hand-written call list and silently never ran.
unsized imports Halo 29 -> 0 Crimson Skies 20 -> 0 SB retail 3 -> 0
SB debug 32 -> 5 (KdDebuggerEnabled, IoQueryVolumeInformation,
IoDismountVolumeByName, RtlWalkFrameChain, RtlAssert)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
||
|
|
0eb45c14cf |
kernel: make every unhandled import stack-safe, and audit coverage per title
Standing up the Crimson Skies kernel layer. The headline "86 of 147 imports missing" turned out to be three very different problems wearing one number, so this adds tools.kernel_audit.coverage to split them: handled (bridge or thunk) what already works needs a bridge_ wrapper an xbox_* exists; mechanical data export needs a value, not a function no implementation real work For Crimson Skies that is 79 / 65 / 0 / 3, not 61 / 86. The number that actually mattered was none of those. kernel_bridge.c keeps an argument-size table separate from its dispatch table, so an unrouted ordinal is normally harmless -- the generic stub cleans the right number of bytes off the simulated stack and returns 0. Twenty of Crimson Skies' imports had NO size entry, so calling any of them would have popped the wrong amount and corrupted the stack for everything upstream. That is a silent, far-from-the-cause failure, and it is not visible as "missing kernel function". Adds those 20 sizes, taken from the xbox_* prototypes in src/kernel rather than guessed. Two are __fastcall (IofCallDriver, IofCompleteRequest) and therefore take ZERO stack bytes -- sizing them by argument count would have been worse than leaving them out. Crimson Skies now has 0 unsafe imports, up from 20. Also fixes two comments in kernel_bridge.c that were off by one against the export table -- "case 17: DATA export - ExEventObjectType" (17 is ExFreePool; 16 is ExEventObjectType) and "case 65: DATA export - IoCompletionObjectType" (65 is IoCreateDevice; 64 is the data export). Stale-but-plausible commentary in this file is exactly what test_bridge_ordinals.py was written after. And fixes a false gap the tool itself introduced: data exports resolve in kernel_thunks.c, not the bridge, so checking only the bridge reported all 18 of Crimson Skies' as missing when every one was already handled. Cross-checked against the other titles, which are NOT yet safe: Crimson Skies 147 imports 79 handled 0 unsafe SB LOC retail 144 imports 80 handled 3 unsafe Halo 2276 166 imports 76 handled 29 unsafe SB LOC debug 188 imports 82 handled 32 unsafe Halo's 29 are worth attention: that project is being actively debugged, and a wrong-sized stub is the kind of fault that shows up as corrupted callee-saved registers a long way from the call. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |