runtime: test ACP HAL create, shape-context and heap sequence #1040

Merged
rasptum merged 1 commit from upstream-pr/1047 into main 2026-11-23 23:18:47 +00:00
rasptum commented 2026-11-23 23:01:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T23:01:23Z.


Adds a source-built caller (tests/cpu/acphal_hal_caller.asm) and a test-only recording provider (tests/cpu/acphal_hal_provider.cpp) for the remaining acphal.dll imports in #870:

  • acphal.dll!ApuCreateHeap
  • acphal.dll!AcpHalCreate
  • acphal.dll!AcpHalAllocateShapeContexts
  • acphal.dll!AcpHalReleaseShapeContexts

The caller also imports ApuAlloc and ApuFree (the DirectXTK12 call shape used in #1000), so that heap creation has an observable effect. Same conventions as #1000: exe_startup.asm, finish_exe, Windows loader and pe_map, a faulty-provider build, and withheld-export controls. Test-only: no production acphal.dll export.

Public evidence and what is not public

  • No public signature for any of the four. The Microsoft reference pages are behind the NDA program.
  • The MIT GDK Learn index at f8c3438 lists AcpHal and ShapeContexts member pages, plus per-type pages (ShapeDmaContext, ShapeEqCompContext, ShapeFiltVolContext, ShapePcmContext, ShapeSrcContext, ShapeXmaContext, ShapeFlowGraph). These are names only.
  • MIT DirectXTK12 at f3555e3 names ApuCreateHeap only in an ApuAlloc failure diagnostic, as the heap ApuAlloc draws from. It has no call site.
  • Fixture contract (proposed, not console evidence): HRESULT ApuCreateHeap(UINT32 size), HRESULT AcpHalCreate(void** hal), HRESULT AcpHalAllocateShapeContexts(void* hal, UINT32 count, void** contexts), HRESULT AcpHalReleaseShapeContexts(void* hal, void* contexts). The 64 KiB heap bound (4 KiB granularity), the single HAL instance, the 16-slot pool of 64-byte contexts, first-fit reuse and every refusal code are desktop policy for this fixture.
  • No unaffiliated reimplementation was consulted.

Verified cases (identical under the Windows loader and pe_map, exit 0x8AC)

  1. ApuAlloc before any heap returns HRESULT_FROM_WIN32(ERROR_INVALID_STATE) and leaves the output.
  2. ApuCreateHeap(0) returns E_INVALIDARG. ApuCreateHeap(0x2000) succeeds. A second heap returns ERROR_ALREADY_EXISTS.
  3. The heap bounds ApuAlloc: 4 KiB succeeds, a further 8 KiB returns E_OUTOFMEMORY with the output and the first block intact.
  4. Shape-context allocation with a null handle before create returns E_HANDLE. The checker also replays the provider's real handle address before create, which only the created-state check can refuse. The same call succeeds after create.
  5. AcpHalCreate(nullptr) returns E_POINTER. One HAL is created. A second create returns ERROR_ALREADY_EXISTS with its output untouched.
  6. Count 0, count 17 and a null output are refused with the output untouched.
  7. Two allocations of 4 contexts are cleared, 64-byte aligned and disjoint. The first keeps the caller's writes.
  8. A release succeeds. A double release returns E_INVALIDARG and is counted. A wrong handle returns E_HANDLE.
  9. Released slots are reused: 8 contexts come back cleared from the first slot.
  10. Provider records after the pe_map run match the expected call counts exactly (3 heap, 3 ApuAlloc, 3 create, 7 allocate with 3 successes, 5 release, 1 double-release refusal, 2 handle refusals, 0 live).

Controls: a provider that skips clearing the contexts (ACPHAL_TEST_FAULTY) stops at Step 7 (0xF07) under both loaders. Withholding any of the four exports stops pe_map before entry with unresolved import acphal.dll!<name> and no provider calls. With no acphal.dll at all, pe_map stops before entry and the Windows loader exits 0xC0000135 (STATUS_DLL_NOT_FOUND).

Mutation check (local, not committed): each mutation was built into the provider and the test rerun. All six failed at the expected point: double release accepted -> 0xF08, ApuAlloc before heap allowed -> 0xF01, heap bound ignored -> 0xF03, second create allowed -> 0xF05, created-state check removed -> replayed-handle control, release keeps slots -> 0xF09.

Environment

Windows 10 Pro 22H2 (10.0.19045.6466), MSVC 19.44.35207.1 x64, CMake/Ninja, Python 3.13.13 (out/pe-env). Tested commit 8e9393a5 (rebased on origin/main at 62b55f9).

Commands and results

cmake --preset dev
cmake --build --preset dev --target pe_map cpu_exe_io cpu_acphal_hal_provider cpu_acphal_hal_provider_faulty cpu_acphal_hal_caller cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller cpu_apu_alloc_provider cpu_apu_alloc_provider_lenient cpu_apu_alloc_caller
ctest --preset dev --no-tests=error -R '^cpu_native_(acphal_hal|apu_address|apu_alloc_caller)$' -V
caller imports: {'acphal.dll': ['AcpHalAllocateShapeContexts', 'AcpHalCreate', 'AcpHalReleaseShapeContexts', 'ApuAlloc', 'ApuCreateHeap', 'ApuFree', 'get_acphal_double_release_refusals'], 'cpu_exe_io.dll': ['finish_exe']}
native and mapped exit 0x8ac; provider records {'get_acphal_heap_create_calls': 3, 'get_acphal_heap_limit': 8192, 'get_acphal_alloc_calls': 3, 'get_acphal_free_calls': 1, 'get_acphal_hal_create_calls': 3, 'get_acphal_shape_alloc_calls': 7, 'get_acphal_shape_alloc_successes': 3, 'get_acphal_shape_release_calls': 5, 'get_acphal_double_release_refusals': 1, 'get_acphal_handle_refusals': 2, 'get_acphal_live_shape_allocations': 0}
before create: replayed handle refused with E_HANDLE; same call succeeds after create
faulty provider: native and mapped exit 0xf07 at Step 7
before entry: unresolved import acphal.dll!AcpHalAllocateShapeContexts
before entry: unresolved import acphal.dll!AcpHalCreate
before entry: unresolved import acphal.dll!AcpHalReleaseShapeContexts
before entry: unresolved import acphal.dll!ApuCreateHeap
missing provider, before entry: unresolved import acphal.dll!ApuCreateHeap
missing provider, Windows loader: exit 0xc0000135 (STATUS_DLL_NOT_FOUND)
1/3 Test #339: cpu_native_apu_alloc_caller ......   Passed
2/3 Test #340: cpu_native_apu_address ...........   Passed
3/3 Test #341: cpu_native_acphal_hal ............   Passed
100% tests passed, 0 tests failed out of 3

The same build and ctest with --preset release: 100% tests passed, 0 tests failed out of 3. No capability skips.

.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py

All passed. docs/experiments.md gains an "ACP HAL, shape-context and heap caller and recorder" section, and the four inventory rows now point at it. Their status stays "needs evidence".

This does not establish the console signatures, the shape-context layout, the startup call order, or whether startup calls ApuCreateHeap before ApuAlloc.

Refs #870. Related: #947, #1000.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6570614412 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1047). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T23:01:23Z. --- Adds a source-built caller (`tests/cpu/acphal_hal_caller.asm`) and a test-only recording provider (`tests/cpu/acphal_hal_provider.cpp`) for the remaining `acphal.dll` imports in #870: - `acphal.dll!ApuCreateHeap` - `acphal.dll!AcpHalCreate` - `acphal.dll!AcpHalAllocateShapeContexts` - `acphal.dll!AcpHalReleaseShapeContexts` The caller also imports `ApuAlloc` and `ApuFree` (the DirectXTK12 call shape used in #1000), so that heap creation has an observable effect. Same conventions as #1000: `exe_startup.asm`, `finish_exe`, Windows loader and `pe_map`, a faulty-provider build, and withheld-export controls. Test-only: no production `acphal.dll` export. ### Public evidence and what is not public - **No public signature for any of the four.** The Microsoft reference pages are behind the NDA program. - The MIT [GDK Learn index at `f8c3438`](https://github.com/microsoft/XBOX-GDK-dotnet/blob/f8c3438aa366fbbb662d8a5e724021a9d0b65f5d/eng/gdk-learn-index.json) lists `AcpHal` and `ShapeContexts` member pages, plus per-type pages (`ShapeDmaContext`, `ShapeEqCompContext`, `ShapeFiltVolContext`, `ShapePcmContext`, `ShapeSrcContext`, `ShapeXmaContext`, `ShapeFlowGraph`). These are names only. - MIT [DirectXTK12 at `f3555e3`](https://github.com/microsoft/DirectXTK12/blob/f3555e3014a53c81a6202b786dc4d6509b95a936/Audio/SoundEffect.cpp#L249) names `ApuCreateHeap` only in an `ApuAlloc` failure diagnostic, as the heap `ApuAlloc` draws from. It has no call site. - **Fixture contract (proposed, not console evidence):** `HRESULT ApuCreateHeap(UINT32 size)`, `HRESULT AcpHalCreate(void** hal)`, `HRESULT AcpHalAllocateShapeContexts(void* hal, UINT32 count, void** contexts)`, `HRESULT AcpHalReleaseShapeContexts(void* hal, void* contexts)`. The 64 KiB heap bound (4 KiB granularity), the single HAL instance, the 16-slot pool of 64-byte contexts, first-fit reuse and every refusal code are desktop policy for this fixture. - No unaffiliated reimplementation was consulted. ### Verified cases (identical under the Windows loader and `pe_map`, exit `0x8AC`) 1. `ApuAlloc` before any heap returns `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)` and leaves the output. 2. `ApuCreateHeap(0)` returns `E_INVALIDARG`. `ApuCreateHeap(0x2000)` succeeds. A second heap returns `ERROR_ALREADY_EXISTS`. 3. The heap bounds `ApuAlloc`: 4 KiB succeeds, a further 8 KiB returns `E_OUTOFMEMORY` with the output and the first block intact. 4. Shape-context allocation with a null handle before create returns `E_HANDLE`. The checker also replays the provider's real handle address before create, which only the created-state check can refuse. The same call succeeds after create. 5. `AcpHalCreate(nullptr)` returns `E_POINTER`. One HAL is created. A second create returns `ERROR_ALREADY_EXISTS` with its output untouched. 6. Count 0, count 17 and a null output are refused with the output untouched. 7. Two allocations of 4 contexts are cleared, 64-byte aligned and disjoint. The first keeps the caller's writes. 8. A release succeeds. A double release returns `E_INVALIDARG` and is counted. A wrong handle returns `E_HANDLE`. 9. Released slots are reused: 8 contexts come back cleared from the first slot. 10. Provider records after the `pe_map` run match the expected call counts exactly (3 heap, 3 `ApuAlloc`, 3 create, 7 allocate with 3 successes, 5 release, 1 double-release refusal, 2 handle refusals, 0 live). **Controls:** a provider that skips clearing the contexts (`ACPHAL_TEST_FAULTY`) stops at Step 7 (`0xF07`) under both loaders. Withholding any of the four exports stops `pe_map` before entry with `unresolved import acphal.dll!<name>` and no provider calls. With no `acphal.dll` at all, `pe_map` stops before entry and the Windows loader exits `0xC0000135` (`STATUS_DLL_NOT_FOUND`). **Mutation check (local, not committed):** each mutation was built into the provider and the test rerun. All six failed at the expected point: double release accepted -> `0xF08`, `ApuAlloc` before heap allowed -> `0xF01`, heap bound ignored -> `0xF03`, second create allowed -> `0xF05`, created-state check removed -> replayed-handle control, release keeps slots -> `0xF09`. ### Environment Windows 10 Pro 22H2 (`10.0.19045.6466`), MSVC 19.44.35207.1 x64, CMake/Ninja, Python 3.13.13 (`out/pe-env`). Tested commit `8e9393a5` (rebased on `origin/main` at `62b55f9`). ### Commands and results ```powershell cmake --preset dev cmake --build --preset dev --target pe_map cpu_exe_io cpu_acphal_hal_provider cpu_acphal_hal_provider_faulty cpu_acphal_hal_caller cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller cpu_apu_alloc_provider cpu_apu_alloc_provider_lenient cpu_apu_alloc_caller ctest --preset dev --no-tests=error -R '^cpu_native_(acphal_hal|apu_address|apu_alloc_caller)$' -V ``` ``` caller imports: {'acphal.dll': ['AcpHalAllocateShapeContexts', 'AcpHalCreate', 'AcpHalReleaseShapeContexts', 'ApuAlloc', 'ApuCreateHeap', 'ApuFree', 'get_acphal_double_release_refusals'], 'cpu_exe_io.dll': ['finish_exe']} native and mapped exit 0x8ac; provider records {'get_acphal_heap_create_calls': 3, 'get_acphal_heap_limit': 8192, 'get_acphal_alloc_calls': 3, 'get_acphal_free_calls': 1, 'get_acphal_hal_create_calls': 3, 'get_acphal_shape_alloc_calls': 7, 'get_acphal_shape_alloc_successes': 3, 'get_acphal_shape_release_calls': 5, 'get_acphal_double_release_refusals': 1, 'get_acphal_handle_refusals': 2, 'get_acphal_live_shape_allocations': 0} before create: replayed handle refused with E_HANDLE; same call succeeds after create faulty provider: native and mapped exit 0xf07 at Step 7 before entry: unresolved import acphal.dll!AcpHalAllocateShapeContexts before entry: unresolved import acphal.dll!AcpHalCreate before entry: unresolved import acphal.dll!AcpHalReleaseShapeContexts before entry: unresolved import acphal.dll!ApuCreateHeap missing provider, before entry: unresolved import acphal.dll!ApuCreateHeap missing provider, Windows loader: exit 0xc0000135 (STATUS_DLL_NOT_FOUND) 1/3 Test #339: cpu_native_apu_alloc_caller ...... Passed 2/3 Test #340: cpu_native_apu_address ........... Passed 3/3 Test #341: cpu_native_acphal_hal ............ Passed 100% tests passed, 0 tests failed out of 3 ``` The same build and `ctest` with `--preset release`: `100% tests passed, 0 tests failed out of 3`. No capability skips. ```powershell .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py ``` All passed. `docs/experiments.md` gains an "ACP HAL, shape-context and heap caller and recorder" section, and the four inventory rows now point at it. Their status stays "needs evidence". This does not establish the console signatures, the shape-context layout, the startup call order, or whether startup calls `ApuCreateHeap` before `ApuAlloc`. Refs #870. Related: #947, #1000. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:46:01 +00:00
R0Y00 commented 2026-11-24 06:49:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T23:06:52Z.


Independent Windows Release at 8e9393a5 passed the ACP HAL fixture and the existing ApuAlloc/address fixtures (3/3). Native and mapped runs returned 0x8ac, the uncleared-context provider failed at 0xf07, and each withheld export stopped mapping before entry. Keep the ACP heap, HAL and context arguments labeled as test-provider policy until independent ABI evidence is available. This result can be tracked separately from the XApu/XDsp queue work in #870.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116566842 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1047#issuecomment-7116566842). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T23:06:52Z. --- Independent Windows Release at 8e9393a5 passed the ACP HAL fixture and the existing ApuAlloc/address fixtures (3/3). Native and mapped runs returned 0x8ac, the uncleared-context provider failed at 0xf07, and each withheld export stopped mapping before entry. Keep the ACP heap, HAL and context arguments labeled as test-provider policy until independent ABI evidence is available. This result can be tracked separately from the XApu/XDsp queue work in #870.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1040
No description provided.