feat(libkernel_sys): answer sceKernelGetAppCategoryType from the app info record #14216

Merged
zaryabzip merged 4 commits from upstream-pr/14216 into main 2026-11-06 19:36:45 +00:00
zaryabzip commented 2026-11-01 00:24:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-11-01T00:24:47Z.


What

sceKernelGetAppCategoryType(int pid, uint32_t* category) in libkernel_sys now answers instead of throwing:

  • a null category returns EINVAL (0x80020016);
  • otherwise it writes the 32-bit field at offset 0x50 of the app-info record sceKernelGetAppInfo fills for pid, and returns that call's result.

This follows @BunnyFl's reading of firmware 13.42's libkernel, from disassembly. sceKernelGetAppCategoryType doesn't call sceKernelGetAppInfo, but both send the same request, sysctl({1, 0xe, 0x23, pid}), for the same 0x58-byte record. GetAppInfo returns the whole record; GetAppCategoryType returns only the uint32 at +0x50, or 0x80020016 for a null output.

Reading through sceKernelGetAppInfo keeps the two consistent:

  • the call answers for the same pids, the caller's own and 0;
  • other pids throw, as they already do there;
  • it reports the same 0xffffffff, which that record's debt entry says a payload process read on a PS5.

The camera module calls this on every sceCamera2* call, so it decides those answers. A follow-up PR uses the same field.

The debt entry says what wasn't read:

  • the category a real title gets;
  • whether the null check comes before the pid lookup.

libkernel_sys gains one implemented function.

The new GuestKernelSysAppCategory.cpp:

  • writes an app0/sce_sys/param.json into a temporary directory, as GuestAppContentLicense.cpp does, because sceKernelGetAppInfo for the caller's pid loads the title id;
  • for the caller's pid and for 0, compares the category with offset 0x50 of sceKernelGetAppInfo's record and checks that nothing past the four bytes is written;
  • checks the EINVAL for a null output.

It calls the export through a cast of its address, so it builds on main, where the export is parameterless.

Tested

Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 0b13ef8fd5 merged into main 8a4fc62318.

  • No warnings in the changed files. Every file that includes libkernel_sys/include/Api.hpp rebuilds with no warnings (26 on Windows, 27 on WSL2), and so does each header compiled on its own.
  • ctest -R "guest_kernel_sys|guest_offline_imports": 26 of 26 pass on Windows and 28 of 28 on WSL2. guest_kernel_sys_app_category passes 3 of 3 on --repeat until-fail:3.
  • Baseline: on that main with only the new test file and its CMakeLists.txt block, the test builds and aborts with sceKernelGetAppCategoryType not implemented (Windows exit 0xc0000409, Linux SIGABRT).
  • tools/check_conventions.py passes, and git merge-tree merges this cleanly with every open pull request that merges with main.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5102883493 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14216). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-11-01T00:24:47Z. --- ### What `sceKernelGetAppCategoryType(int pid, uint32_t* category)` in libkernel_sys now answers instead of throwing: - a null `category` returns `EINVAL` (`0x80020016`); - otherwise it writes the 32-bit field at offset 0x50 of the app-info record `sceKernelGetAppInfo` fills for `pid`, and returns that call's result. This follows @BunnyFl's [reading of firmware 13.42's libkernel](https://github.com/boykopovar/AnyPS5/pull/12943#issuecomment-6543803331), from disassembly. `sceKernelGetAppCategoryType` doesn't call `sceKernelGetAppInfo`, but both send the same request, `sysctl({1, 0xe, 0x23, pid})`, for the same 0x58-byte record. `GetAppInfo` returns the whole record; `GetAppCategoryType` returns only the `uint32` at `+0x50`, or `0x80020016` for a null output. Reading through `sceKernelGetAppInfo` keeps the two consistent: - the call answers for the same pids, the caller's own and 0; - other pids throw, as they already do there; - it reports the same 0xffffffff, which that record's debt entry says a payload process read on a PS5. The camera module calls this on every `sceCamera2*` call, so it decides those answers. A follow-up PR uses the same field. The debt entry says what wasn't read: - the category a real title gets; - whether the null check comes before the pid lookup. libkernel_sys gains one implemented function. The new `GuestKernelSysAppCategory.cpp`: - writes an `app0/sce_sys/param.json` into a temporary directory, as `GuestAppContentLicense.cpp` does, because `sceKernelGetAppInfo` for the caller's pid loads the title id; - for the caller's pid and for 0, compares the category with offset 0x50 of `sceKernelGetAppInfo`'s record and checks that nothing past the four bytes is written; - checks the `EINVAL` for a null output. It calls the export through a cast of its address, so it builds on `main`, where the export is parameterless. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 0b13ef8fd5 merged into `main` 8a4fc62318. - No warnings in the changed files. Every file that includes `libkernel_sys/include/Api.hpp` rebuilds with no warnings (26 on Windows, 27 on WSL2), and so does each header compiled on its own. - `ctest -R "guest_kernel_sys|guest_offline_imports"`: 26 of 26 pass on Windows and 28 of 28 on WSL2. `guest_kernel_sys_app_category` passes 3 of 3 on `--repeat until-fail:3`. - Baseline: on that `main` with only the new test file and its `CMakeLists.txt` block, the test builds and aborts with `sceKernelGetAppCategoryType not implemented` (Windows exit 0xc0000409, Linux SIGABRT). - `tools/check_conventions.py` passes, and `git merge-tree` merges this cleanly with every open pull request that merges with `main`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-11-01 01:25:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T01:25:47Z.

Review: APPROVED


Reviewed — looks good

The wrapper follows the firmware-derived query by delegating record lookup to sceKernelGetAppInfo and copying its category field.

What I ran

Reviewed head 0b13ef8fd52d13841fde1154b4848892142b3da4, based on PR base cbcb37b3140db682277a9c51d950b90ce75de784; the merge preview onto current main 666d9b10a5152919bb21cd47537ac5e408c4bca4 was clean. Environment: Debian Linux x86_64, Python 3.11.2, Git 2.39.5. I did not build locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14216
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base cbcb37b3140db682277a9c51d950b90ce75de784 --head 0b13ef8fd52d13841fde1154b4848892142b3da4 --json
git diff --check cbcb37b3140db682277a9c51d950b90ce75de784...0b13ef8fd52d13841fde1154b4848892142b3da4
python3 tools/pr_stack_check.py 14216 --repo boykopovar/AnyPS5

Results

Check Result
Conventions, PR template, diff check Passed.
Export declaration/definition audit Passed; the changed declaration and definition were found, with no audit findings. NID version mapping is not covered by this audit.
Current-main merge preview Clean; no declared dependencies.
Hosted CI for this exact head Windows job passed; Linux, write-watch, register-context, and relinker jobs were skipped.
Author-reported tests Windows and WSL2 test runs and repeat runs are described in the PR; I did not reproduce them.
Unedited conventions output
All conventions checks passed.

Findings

Blocking

None.

Non-blocking

The test compares the output with the same record API this wrapper delegates to, so it chiefly checks forwarding, the selected field, and write bounds. The firmware disassembly cited in the PR supplies the independent behavior evidence.

Sources

Not verified

No local build or C++ tests were run. Linux CI was skipped. The firmware-derived behavior and author-reported Windows/WSL2 tests were read but not independently reproduced.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725875818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14216#pullrequestreview-5725875818). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T01:25:47Z. **Review:** APPROVED --- # Reviewed — looks good The wrapper follows the firmware-derived query by delegating record lookup to `sceKernelGetAppInfo` and copying its category field. ## What I ran Reviewed head `0b13ef8fd52d13841fde1154b4848892142b3da4`, based on PR base `cbcb37b3140db682277a9c51d950b90ce75de784`; the merge preview onto current `main` `666d9b10a5152919bb21cd47537ac5e408c4bca4` was clean. Environment: Debian Linux x86_64, Python 3.11.2, Git 2.39.5. I did not build locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14216 python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base cbcb37b3140db682277a9c51d950b90ce75de784 --head 0b13ef8fd52d13841fde1154b4848892142b3da4 --json git diff --check cbcb37b3140db682277a9c51d950b90ce75de784...0b13ef8fd52d13841fde1154b4848892142b3da4 python3 tools/pr_stack_check.py 14216 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Conventions, PR template, diff check | Passed. | | Export declaration/definition audit | Passed; the changed declaration and definition were found, with no audit findings. NID version mapping is not covered by this audit. | | Current-main merge preview | Clean; no declared dependencies. | | Hosted CI for this exact head | Windows job passed; Linux, write-watch, register-context, and relinker jobs were skipped. | | Author-reported tests | Windows and WSL2 test runs and repeat runs are described in the PR; I did not reproduce them. | <details><summary>Unedited conventions output</summary> ```text All conventions checks passed. ``` </details> ## Findings ### Blocking None. ### Non-blocking The test compares the output with the same record API this wrapper delegates to, so it chiefly checks forwarding, the selected field, and write bounds. The firmware disassembly cited in the PR supplies the independent behavior evidence. ## Sources - [Firmware disassembly report: same sysctl request and category at offset 0x50](https://github.com/boykopovar/AnyPS5/pull/12943#issuecomment-6543803331) - [Wrapper implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/0b13ef8fd52d13841fde1154b4848892142b3da4/core/libs/prx/libkernel_sys/Export.Discovery.cpp#L678-L685) - [Existing app-info record behavior at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/0b13ef8fd52d13841fde1154b4848892142b3da4/core/libs/prx/libkernel/System/src/Process.cpp#L657-L677) ## Not verified No local build or C++ tests were run. Linux CI was skipped. The firmware-derived behavior and author-reported Windows/WSL2 tests were read but not independently reproduced.
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
boykopovar/AnyPS5!14216
No description provided.