runtime: emulate console LSA and package-family policy state in-process #32

Closed
github-bot wants to merge 1 commit from gh-pr/32/head into gh-pr/32/base
Owner

@⁠figmasigma122343-bot on GitHub · 2026-11-21 18:29 UTC · original
figmasigma122343-bot:runtime/console-policy-state → main · +339 −71 · 17 files · 1 commits · closed without merging

Tasks

  • Port LsaEnablePasswordLessCurrentUser and LsaDisablePasswordLessCurrentUser
  • Export both through advapi32 PE forwarders and cover the real-name load
  • Port AddPackageToFamilyXref and RemovePackageFromFamilyXref
  • Wire GetPackageInstallTime to the in-process package repository
  • Add round-trip, error-path and NULL/empty-name tests
  • Refresh the generated library map, badges and milestones
  • Port the two gamecoreclient COM classes (tracked by #8)

What changed

Passwordless LSA policy

The console advapi32 / advapi32legacy exports are no-argument lsarpc NdrClientCall3 wrappers (opnums 0x7e and 0x7f). Calling the host LSA opnum would change the signed-in PC user's real sign-in options, so both calls now update process-local advapi32legacy::policy state and return STATUS_SUCCESS. advapi32 exports them as PE forwarders to advapi32legacy, matching the console API-set resolution through ext-ms-win-advapi32-lsa-l1-1-3.

KernelBase package-family xref

The console deployment internals write/delete ACL-protected keys under HKEY_USERS\<sid>\...\AppModel\Repository\Families\<family>\<fullname>. The port keeps the same InstallTime qword, flags dword and reserved dword in an in-process repository, never in the signed-in user's real hive.

  • AddPackageToFamilyXref(family, full, {InstallTime, flags, reserved})
  • RemovePackageFromFamilyXref(family, full)
  • GetPackageInstallTime reads the in-process repository first and only then falls back to the host HKCU

The ABI follows the x86 _AddPackageToFamilyXref@24 decoration and the x64 3-parameter symbol: two string pointers plus a 16-byte record. A missing remove returns ERROR_FILE_NOT_FOUND (2); invalid or empty names return ERROR_INVALID_PARAMETER (0x57).

Before / after

The three changed library blocks, with the cells whose status changed boxed in red:

Library diff: advapi32legacy, advapi32, KernelBase

Full updated map:

Xbox console libraries: 97.24% (2082/2141)

Verification

cargo build -p kernelbase -p advapi32legacy -p advapi32
cargo test -p kernelbase -p advapi32legacy -p advapi32
python tools/progress/gen.py

Observed:

  • kernelbase: 7 unit tests and 3 export/forwarder tests passed.
  • advapi32legacy: 9 unit tests and 4 export/forwarder tests passed.
  • advapi32: 4 export/forwarder tests and 1 real-name test passed.
  • Console exports: 2082/2141 (97.24%), from 2076/2141.
  • advapi32legacy is 207/207, advapi32 is 13/13, KernelBase is 3/3.

Scope and limits

  • The package repository is process-local. The console registry survives process exit; the emulator serves one title process at a time, so this matches the current runtime model.
  • The xref ABI is recovered from the console's x86 decoration and the public x64 symbol. If a console call site shows a different record layout, the struct is isolated in kernelbase::repository and easy to adjust.
  • The host LSA database, registry hive and user account are never touched by either policy path.
  • gamecoreclient!DllGetClassObject is already ported and tested in src/lib.rs, but its two COM class objects are still unported. It is intentionally not flipped to implemented in this PR because #8 requires the objects to be able to reach their peer; a class factory returning E_NOTIMPL would be a stub, not coverage.

Refs #7

**@⁠figmasigma122343-bot** on GitHub · 2026-11-21 18:29 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/32) `figmasigma122343-bot:runtime/console-policy-state` → `main` · +339 −71 · 17 files · 1 commits · closed without merging ## Tasks - [x] Port `LsaEnablePasswordLessCurrentUser` and `LsaDisablePasswordLessCurrentUser` - [x] Export both through `advapi32` PE forwarders and cover the real-name load - [x] Port `AddPackageToFamilyXref` and `RemovePackageFromFamilyXref` - [x] Wire `GetPackageInstallTime` to the in-process package repository - [x] Add round-trip, error-path and NULL/empty-name tests - [x] Refresh the generated library map, badges and milestones - [ ] Port the two `gamecoreclient` COM classes (tracked by #8) ## What changed ### Passwordless LSA policy The console `advapi32` / `advapi32legacy` exports are no-argument `lsarpc` `NdrClientCall3` wrappers (opnums 0x7e and 0x7f). Calling the host LSA opnum would change the signed-in PC user's real sign-in options, so both calls now update process-local `advapi32legacy::policy` state and return `STATUS_SUCCESS`. `advapi32` exports them as PE forwarders to `advapi32legacy`, matching the console API-set resolution through `ext-ms-win-advapi32-lsa-l1-1-3`. ### KernelBase package-family xref The console deployment internals write/delete ACL-protected keys under `HKEY_USERS\<sid>\...\AppModel\Repository\Families\<family>\<fullname>`. The port keeps the same `InstallTime` qword, flags dword and reserved dword in an in-process repository, never in the signed-in user's real hive. - `AddPackageToFamilyXref(family, full, {InstallTime, flags, reserved})` - `RemovePackageFromFamilyXref(family, full)` - `GetPackageInstallTime` reads the in-process repository first and only then falls back to the host `HKCU` The ABI follows the x86 `_AddPackageToFamilyXref@24` decoration and the x64 3-parameter symbol: two string pointers plus a 16-byte record. A missing remove returns `ERROR_FILE_NOT_FOUND` (2); invalid or empty names return `ERROR_INVALID_PARAMETER` (0x57). ## Before / after The three changed library blocks, with the cells whose status changed boxed in red: ![Library diff: advapi32legacy, advapi32, KernelBase](https://raw.githubusercontent.com/figmasigma122343-bot/xbox-emulator/assets/progress-2080/progress-diff-2082.png) Full updated map: ![Xbox console libraries: 97.24% (2082/2141)](https://raw.githubusercontent.com/figmasigma122343-bot/xbox-emulator/assets/progress-2080/progress-2082.png) ## Verification ```powershell cargo build -p kernelbase -p advapi32legacy -p advapi32 cargo test -p kernelbase -p advapi32legacy -p advapi32 python tools/progress/gen.py ``` Observed: - `kernelbase`: 7 unit tests and 3 export/forwarder tests passed. - `advapi32legacy`: 9 unit tests and 4 export/forwarder tests passed. - `advapi32`: 4 export/forwarder tests and 1 real-name test passed. - Console exports: **2082/2141 (97.24%)**, from 2076/2141. - `advapi32legacy` is 207/207, `advapi32` is 13/13, `KernelBase` is 3/3. ## Scope and limits - The package repository is process-local. The console registry survives process exit; the emulator serves one title process at a time, so this matches the current runtime model. - The xref ABI is recovered from the console's x86 decoration and the public x64 symbol. If a console call site shows a different record layout, the struct is isolated in `kernelbase::repository` and easy to adjust. - The host LSA database, registry hive and user account are never touched by either policy path. - `gamecoreclient!DllGetClassObject` is already ported and tested in `src/lib.rs`, but its two COM class objects are still unported. It is intentionally not flipped to `implemented` in this PR because #8 requires the objects to be able to reach their peer; a class factory returning `E_NOTIMPL` would be a stub, not coverage. Refs #7
advapi32/advapi32legacy: LsaEnablePasswordLessCurrentUser and LsaDisablePasswordLessCurrentUser are no-argument lsarpc NdrClientCall3 wrappers in the console image. The port applies both to process-local policy state, returns STATUS_SUCCESS, and exports them from advapi32 as PE forwarders to advapi32legacy. The host LSA database and the signed-in user's sign-in options are untouched.

KernelBase: AddPackageToFamilyXref and RemovePackageFromFamilyXref now use an in-process Families<family><fullname> repository holding the InstallTime qword, flags dword and reserved dword. GetPackageInstallTime reads it first and only then falls back to the host HKCU; no ACL-protected HKEY_USERS key is created or deleted. The ABI follows the x86 @24 decoration and the x64 3-parameter symbol.

Tests: cargo build -p kernelbase -p advapi32legacy -p advapi32; cargo test -p kernelbase -p advapi32legacy -p advapi32 (7+3, 9+4 and 4+1 tests passed); python tools/progress/gen.py (console 2082/2141, 97.24%).

Refs #7
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:07:52 +00:00
github-bot closed this pull request 2026-11-26 06:07:52 +00:00
Author
Owner

@⁠figmasigma122343-bot on GitHub · 2026-11-22 07:56 UTC · original

Closing: current main already implements both halves with the console-verified signatures. KernelBase AddPackageToFamilyXref is (PSID, PCWSTR, PCWSTR, DWORD, ULONGLONG), and advapi32legacy has src/passwordless.rs. My earlier PR used an inferred xref layout and is superseded; keeping it open would be misleading.

**@⁠figmasigma122343-bot** on GitHub · 2026-11-22 07:56 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/32#issuecomment-7076213913) Closing: current main already implements both halves with the console-verified signatures. KernelBase AddPackageToFamilyXref is (PSID, PCWSTR, PCWSTR, DWORD, ULONGLONG), and advapi32legacy has src/passwordless.rs. My earlier PR used an inferred xref layout and is superseded; keeping it open would be misleading.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.