feat(libkernel): implement sceKernelGetAppInfo #3056

Merged
TheAggie merged 3 commits from upstream-pr/3056 into main 2026-10-11 07:12:55 +00:00
TheAggie commented 2026-10-10 21:28:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T21:28:33Z.


What

sceKernelGetAppInfo (G-MYv5erXaU) isn't exported. XPSemu (PPSA97358) stops on it at start-up on main:

FAIL: unresolved ELF import G-MYv5erXaU from libkernel.prx

XPSemu calls it with its own pid to read its title ID (ui/xui/dashboard.cc, OwnTitleId). It declares the structure as { uint32_t app_id; uint64_t unknown1; char title_id[14]; char unknown2[0x3c]; }, so the title ID is at offset 0x10. That matches shadPS4's OrbisKernelAppInfo (cusa_name[10] after four 32-bit fields).

sceKernelGetAppInfo(pid, info):

  • For the calling process: writes app_id 1 (the running title's id in libSceSystemService) and the titleId from /app0/sce_sys/param.json at offset 0x10, up to 9 characters plus a terminator. Only these two fields are written, because callers declare the structure with different sizes.
  • Any other pid: returns ESRCH.
  • Null info: returns EFAULT.

Test (guest_app_info):

  • It creates a temporary directory holding app0/sce_sys/param.json and switches into it.
  • It checks the app ID and title ID, that bytes past the written fields are left untouched, and the ESRCH and EFAULT cases.
  • With the title-ID parsing removed, it fails.

Tested

  • XPSemu: on main b8a083b2 it stops at G-MYv5erXaU. With this PR it moves on to 0Ma-LQjv6So (cpuset_setaffinity), which no open PR implements.
  • Suite: guest|kernel|process tests: 238 passed, 1 skipped, 1 failed. The failure is guest_memory, which fails the same way on main here (CheckGuestModuleImageProtection's dlopen).
  • Conventions: tools/check_conventions.py passes.
  • Setup: Windows 11, MinGW-w64 GCC 15.2.0, Release. Not tested on Linux or macOS.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4814560984 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T21:28:33Z. --- ### What `sceKernelGetAppInfo` (`G-MYv5erXaU`) isn't exported. XPSemu (PPSA97358) stops on it at start-up on `main`: ``` FAIL: unresolved ELF import G-MYv5erXaU from libkernel.prx ``` XPSemu calls it with its own pid to read its title ID ([`ui/xui/dashboard.cc`](https://github.com/ZiZc3/XPSemu/blob/master/ui/xui/dashboard.cc), `OwnTitleId`). It declares the structure as `{ uint32_t app_id; uint64_t unknown1; char title_id[14]; char unknown2[0x3c]; }`, so the title ID is at offset 0x10. That matches shadPS4's `OrbisKernelAppInfo` (`cusa_name[10]` after four 32-bit fields). `sceKernelGetAppInfo(pid, info)`: - **For the calling process:** writes `app_id` 1 (the running title's id in `libSceSystemService`) and the `titleId` from `/app0/sce_sys/param.json` at offset 0x10, up to 9 characters plus a terminator. Only these two fields are written, because callers declare the structure with different sizes. - **Any other pid:** returns `ESRCH`. - **Null `info`:** returns `EFAULT`. **Test (`guest_app_info`):** - It creates a temporary directory holding `app0/sce_sys/param.json` and switches into it. - It checks the app ID and title ID, that bytes past the written fields are left untouched, and the `ESRCH` and `EFAULT` cases. - With the title-ID parsing removed, it fails. ### Tested - **XPSemu:** on `main` b8a083b2 it stops at `G-MYv5erXaU`. With this PR it moves on to `0Ma-LQjv6So` (`cpuset_setaffinity`), which no open PR implements. - **Suite:** `guest|kernel|process` tests: 238 passed, 1 skipped, 1 failed. The failure is `guest_memory`, which fails the same way on `main` here (`CheckGuestModuleImageProtection`'s `dlopen`). - **Conventions:** `tools/check_conventions.py` passes. - **Setup:** Windows 11, MinGW-w64 GCC 15.2.0, Release. Not tested on Linux or macOS. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: none - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-10 21:28:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T21:28:56Z.


Progress report (bae9962 → 3974857)

📈 System libraries: 85.81% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetAppInfo
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102369034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056#issuecomment-6102369034). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T21:28:56Z. --- <!-- progress-report --> ### Progress report (bae9962 → 3974857) 📈 **System libraries**: 85.81% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetAppInfo` | </details>
adriadam10 commented 2026-10-10 22:04:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:04:58Z.

Review: CHANGES_REQUESTED


Thanks, the layout (title ID at +0x10) matches SharpProspero's SceKernelAppInfo and shadPS4's OrbisKernelAppInfo, and guest_app_info fails without the change. A few things to fix:

  • core/libs/prx/libkernel/System/src/Process.cpp:210-218: param.json is parsed by hand with find. libkernel/AppMetadata already parses it (ParamJsonParser, GetAppTitleId_nid_postfix); please reuse it so there is one rule for it (and its validation, e.g. a missing or empty titleId throws there).
  • Process.cpp:205-206: EFAULT for a null info and ESRCH for another pid have no source. shadPS4 returns EPERM for a pid other than its own and ORBIS_OK for a null info. Either follow a reference or keep unverified cases throwing.
  • Process.cpp:220: app_id = 1 is not sourced. If it is inferred, say so.
  • docs/dev/TechnicalDebt.md: no line. Add one under "Unknown function info" for the app ID value, the error codes, and that only app_id and the title ID are written.
  • core/libs/tests/GuestAppInfo.cpp: add the case without param.json.
  • Process.cpp:30: <string> is out of alphabetical order.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5480967067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056#pullrequestreview-5480967067). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T22:04:58Z. **Review:** CHANGES_REQUESTED --- Thanks, the layout (title ID at +0x10) matches SharpProspero's `SceKernelAppInfo` and shadPS4's `OrbisKernelAppInfo`, and `guest_app_info` fails without the change. A few things to fix: - `core/libs/prx/libkernel/System/src/Process.cpp:210-218`: `param.json` is parsed by hand with `find`. `libkernel/AppMetadata` already parses it (`ParamJsonParser`, `GetAppTitleId_nid_postfix`); please reuse it so there is one rule for it (and its validation, e.g. a missing or empty `titleId` throws there). - `Process.cpp:205-206`: `EFAULT` for a null `info` and `ESRCH` for another pid have no source. shadPS4 returns `EPERM` for a pid other than its own and `ORBIS_OK` for a null `info`. Either follow a reference or keep unverified cases throwing. - `Process.cpp:220`: `app_id` = 1 is not sourced. If it is inferred, say so. - `docs/dev/TechnicalDebt.md`: no line. Add one under "Unknown function info" for the app ID value, the error codes, and that only `app_id` and the title ID are written. - `core/libs/tests/GuestAppInfo.cpp`: add the case without `param.json`. - `Process.cpp:30`: `<string>` is out of alphabetical order.
babyhuey commented 2026-10-10 22:16:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T22:16:15Z.


Linux check, since the description says it wasn't run there: 431f8044 merged onto main ecafb64f (clean), Ubuntu 24.04, GCC 13, Release.

  • guest_app_info passes 5/5 (--repeat until-fail:5).
  • XPSemu (PPSA97358), catalog build with sce_module/libc.prx unwrapped (#2605): main stops at undefined symbol: G-MYv5erXaU; with this PR it goes on to undefined symbol: 0Ma-LQjv6So (cpuset_setaffinity), the same as your Windows run.

cpuset_setaffinity for the calling thread is ready on babyhuey:feat/libkernel-cpuset-setaffinity; I'll open it once this is in and it is XPSemu's stop on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102758753 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056#issuecomment-6102758753). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T22:16:15Z. --- Linux check, since the description says it wasn't run there: 431f8044 merged onto `main` ecafb64f (clean), Ubuntu 24.04, GCC 13, Release. - `guest_app_info` passes 5/5 (`--repeat until-fail:5`). - XPSemu (PPSA97358), catalog build with `sce_module/libc.prx` unwrapped (#2605): `main` stops at `undefined symbol: G-MYv5erXaU`; with this PR it goes on to `undefined symbol: 0Ma-LQjv6So` (`cpuset_setaffinity`), the same as your Windows run. `cpuset_setaffinity` for the calling thread is ready on babyhuey:feat/libkernel-cpuset-setaffinity; I'll open it once this is in and it is XPSemu's stop on `main`.
Dextroid17 commented 2026-10-10 22:43:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T22:43:36Z.

Review: COMMENTED


This one answers the question this tree always asks before anyone has to: a named title (XPSemu, PPSA97358), the exact failing line, the caller's own structure quoted from its source, and a second reference in shadPS4's OrbisKernelAppInfo to confirm the layout. That is the shape a bring-up fix should have.

The partial write is the right decision, and the test pins part of it rather than describing it. Writing only app_id and the title id and leaving the rest of the caller's structure alone is correct precisely because callers declare that structure at different sizes. guest_app_info does check that a byte past the written fields (unknown2[0]) is unchanged — though unknown1, sitting between the two written fields, goes unchecked, so the property the reasoning rests on is only half-pinned.

The details line up with the tree and with the reference. Nine characters plus a terminator is ten bytes, matching shadPS4's cusa_name[10] exactly; the running title's app id is 1 on the console side (SYSTEM_SERVICE_RUNNING_APP_ID, which lives in libSceSystemService rather than libkernel — likely why the value appears here as a literal); and the test failing when the title-id parsing is removed is the evidence bar this tree asks for.

On the title-id read, the maintainer's point stands, and the evidence makes it firmer than a preference. AppMetadata exposes GetAppTitleId and ParamJsonParser exposes parseParamJson returning a titleId; both are in the same libkernel target and already consumed by sibling directories (Apr, File) and by other libraries, so System/ reaching AppMetadata is not a layering problem here. The read as written is an ifstream plus a find on "titleId", which also means a missing or malformed param.json yields an empty title id instead of surfacing as one — where the existing parser is the path with validation and tests already in it. adriadam10 has asked for this reuse in review already, so treating it as the one thing to settle before this lands seems right. Everything else here is in good shape.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5481073619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056#pullrequestreview-5481073619). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-10T22:43:36Z. **Review:** COMMENTED --- This one answers the question this tree always asks before anyone has to: a named title (XPSemu, PPSA97358), the exact failing line, the caller's own structure quoted from its source, and a second reference in shadPS4's `OrbisKernelAppInfo` to confirm the layout. That is the shape a bring-up fix should have. **The partial write is the right decision, and the test pins part of it rather than describing it.** Writing only `app_id` and the title id and leaving the rest of the caller's structure alone is correct precisely because callers declare that structure at different sizes. `guest_app_info` does check that a byte past the written fields (`unknown2[0]`) is unchanged — though `unknown1`, sitting between the two written fields, goes unchecked, so the property the reasoning rests on is only half-pinned. **The details line up with the tree and with the reference.** Nine characters plus a terminator is ten bytes, matching shadPS4's `cusa_name[10]` exactly; the running title's app id is `1` on the console side (`SYSTEM_SERVICE_RUNNING_APP_ID`, which lives in `libSceSystemService` rather than libkernel — likely why the value appears here as a literal); and the test failing when the title-id parsing is removed is the evidence bar this tree asks for. **On the title-id read, the maintainer's point stands, and the evidence makes it firmer than a preference.** `AppMetadata` exposes `GetAppTitleId` and `ParamJsonParser` exposes `parseParamJson` returning a `titleId`; both are in the same `libkernel` target and already consumed by sibling directories (`Apr`, `File`) and by other libraries, so `System/` reaching `AppMetadata` is not a layering problem here. The read as written is an `ifstream` plus a `find` on `"titleId"`, which also means a missing or malformed `param.json` yields an empty title id instead of surfacing as one — where the existing parser is the path with validation and tests already in it. adriadam10 has asked for this reuse in review already, so treating it as the one thing to settle before this lands seems right. Everything else here is in good shape. Written with AI assistance.
TheAggie commented 2026-10-10 23:28:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T23:28:02Z.


Thanks @adriadam10, @babyhuey and @Dextroid17. Addressed in e7a06d00:

  • Title ID: now read through GetAppTitleId_nid_postfix, so param.json goes through ParamJsonParser and its validation. A missing file, or a missing or empty titleId, throws there. The hand-written find is gone.

  • Error codes: these now follow shadPS4 (sceKernelGetAppInfo in src/core/libraries/kernel/kernel.cpp). Another pid returns EPERM, and a null info returns 0 without writing anything.

  • app_id = 1: this is inferred, not measured. It's the running title's id in libSceSystemService (SYSTEM_SERVICE_RUNNING_APP_ID). shadPS4 zero-fills its whole structure and leaves app_id at 0. I kept writing only app_id and the title ID, because callers declare the structure at different sizes. Zeroing shadPS4's larger layout could write past XPSemu's.

  • guest_app_info:

    • The param.json it writes now has localizedParameters, as the parser requires.
    • It checks that unknown1, between the two written fields, is left alone.
    • It runs the call without param.json in a child process and expects that process to fail. The throw comes from inside libkernel.prx, and on Windows the test executable can't catch that one itself.
  • Includes: the stray <string>, <algorithm> and <iterator> are gone.

  • TechnicalDebt (d09b3372): a line under "Unknown function info" for the guessed app_id, the shadPS4 error codes, and the partial write.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103314276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056#issuecomment-6103314276). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T23:28:02Z. --- Thanks @adriadam10, @babyhuey and @Dextroid17. Addressed in e7a06d00: - **Title ID:** now read through `GetAppTitleId_nid_postfix`, so `param.json` goes through `ParamJsonParser` and its validation. A missing file, or a missing or empty `titleId`, throws there. The hand-written `find` is gone. - **Error codes:** these now follow shadPS4 (`sceKernelGetAppInfo` in `src/core/libraries/kernel/kernel.cpp`). Another pid returns `EPERM`, and a null `info` returns 0 without writing anything. - **`app_id` = 1:** this is inferred, not measured. It's the running title's id in `libSceSystemService` (`SYSTEM_SERVICE_RUNNING_APP_ID`). shadPS4 zero-fills its whole structure and leaves `app_id` at 0. I kept writing only `app_id` and the title ID, because callers declare the structure at different sizes. Zeroing shadPS4's larger layout could write past XPSemu's. - **`guest_app_info`:** - The `param.json` it writes now has `localizedParameters`, as the parser requires. - It checks that `unknown1`, between the two written fields, is left alone. - It runs the call without `param.json` in a child process and expects that process to fail. The throw comes from inside `libkernel.prx`, and on Windows the test executable can't catch that one itself. - **Includes:** the stray `<string>`, `<algorithm>` and `<iterator>` are gone. - **TechnicalDebt (d09b3372):** a line under "Unknown function info" for the guessed `app_id`, the shadPS4 error codes, and the partial write. AI-assisted (Claude Code).
adriadam10 commented 2026-10-11 07:08:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:08:01Z.

Review: APPROVED


Rebased onto current main (only conflict: adjacent TechnicalDebt line, kept both).

Checked: guest_app_info passes on the rebased tree and fails to link without the change; the title ID goes through GetAppTitleId_nid_postfix; error codes and the partial write are recorded in TechnicalDebt under "Unknown function info"; Linux run by @babyhuey confirms XPSemu moves on to cpuset_setaffinity. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482280370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3056#pullrequestreview-5482280370). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:08:01Z. **Review:** APPROVED --- Rebased onto current `main` (only conflict: adjacent TechnicalDebt line, kept both). Checked: `guest_app_info` passes on the rebased tree and fails to link without the change; the title ID goes through `GetAppTitleId_nid_postfix`; error codes and the partial write are recorded in TechnicalDebt under "Unknown function info"; Linux run by @babyhuey confirms XPSemu moves on to `cpuset_setaffinity`. Merging.
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!3056
No description provided.