Files
sp00nz 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>
2026-07-23 02:52:43 -07:00

0 lines
0 B
Python