feat(libSceSystemService): initialize the launcher utility and answer the app-message query #8651

Merged
nikowolf123 merged 2 commits from upstream-pr/8651 into main 2026-11-24 09:09:51 +00:00
nikowolf123 commented 2026-10-20 20:04:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T20:04:32Z.


What

sceLncUtilInitialize and sceAppMessagingTryReceiveMsg were pending exports that threw.

sceLncUtilInitialize now returns 0 on its first call in the process and SCE_LNC_UTIL_ERROR_ALREADY_INITIALIZED (0x80940018) on every later one, from any thread. On a PS4 a launch made before the call failed with NOT_INITIALIZED (LightningMods' daemon writeup), Orbis Suite's loader treats any result other than 0 as a failure, and a homebrew app takes 0x80940018 for a client still initialized when it returns from another game; PS5 homebrew (playden-ps5, ps5-mcp) accepts 0 and 0x80940018 alike. No other call reads this state, and sceLncUtilTerminate still throws, so it never resets.

sceAppMessagingTryReceiveMsg returns SCE_APP_MESSAGING_ERROR_NO_MESSAGE (0x80C50005) and writes nothing, since AnyPS5 has no shell or other application that sends the title messages and sceAppMessagingSendMsg throws; a null message returns SCE_APP_MESSAGING_ERROR_NULL_POINTER (0x80C50004). The signature and both values follow StubMaker, which credits the PS4 values to psdevwiki; the 8216-byte message layout matches etaHEN's PS5 declaration.

Not confirmed on a PS5 and recorded as technical debt: the error values, that a title starts with the client uninitialized, and the order of sceAppMessagingTryReceiveMsg's null check.

guest_system_service now checks that the first sceLncUtilInitialize returns 0 and the next two 0x80940018, and that sceAppMessagingTryReceiveMsg returns 0x80C50004 for null and 0x80C50005 twice for an 8216-byte buffer whose bytes all stay unchanged. On main the test aborts at its first new call, which throws "not implemented".

Rebased onto current main and adapted to the declarations, test layout and debt fragments it has now. #17144, opened later, also implements sceAppMessagingTryReceiveMsg.

Tested

Windows 11, WinLibs MinGW-w64 GCC 15.2.0 (ucrt, posix, seh), full build of this branch on current main. ctest passes for guest_system_service. Not run on a console or with a title.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4941738859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T20:04:32Z. --- ### What sceLncUtilInitialize and sceAppMessagingTryReceiveMsg were pending exports that threw. sceLncUtilInitialize now returns 0 on its first call in the process and SCE_LNC_UTIL_ERROR_ALREADY_INITIALIZED (0x80940018) on every later one, from any thread. On a PS4 a launch made before the call failed with NOT_INITIALIZED (LightningMods' daemon writeup), Orbis Suite's loader treats any result other than 0 as a failure, and a homebrew app takes 0x80940018 for a client still initialized when it returns from another game; PS5 homebrew (playden-ps5, ps5-mcp) accepts 0 and 0x80940018 alike. No other call reads this state, and sceLncUtilTerminate still throws, so it never resets. sceAppMessagingTryReceiveMsg returns SCE_APP_MESSAGING_ERROR_NO_MESSAGE (0x80C50005) and writes nothing, since AnyPS5 has no shell or other application that sends the title messages and sceAppMessagingSendMsg throws; a null message returns SCE_APP_MESSAGING_ERROR_NULL_POINTER (0x80C50004). The signature and both values follow StubMaker, which credits the PS4 values to psdevwiki; the 8216-byte message layout matches etaHEN's PS5 declaration. Not confirmed on a PS5 and recorded as technical debt: the error values, that a title starts with the client uninitialized, and the order of sceAppMessagingTryReceiveMsg's null check. guest_system_service now checks that the first sceLncUtilInitialize returns 0 and the next two 0x80940018, and that sceAppMessagingTryReceiveMsg returns 0x80C50004 for null and 0x80C50005 twice for an 8216-byte buffer whose bytes all stay unchanged. On main the test aborts at its first new call, which throws "not implemented". Rebased onto current `main` and adapted to the declarations, test layout and debt fragments it has now. #17144, opened later, also implements `sceAppMessagingTryReceiveMsg`. ### 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, posix, seh), full build of this branch on current `main`. `ctest` passes for guest_system_service. Not run on a console or with a title. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-21 01:05:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:05:41Z.

Review: APPROVED


Reviewed the implementation, tests, and debt notes. The three former stubs now have explicit behavior and regression coverage; the unconfirmed PS5 details are clearly recorded as unknown rather than asserted as measured. I found no code defect in this diff. The hosted Linux/Windows and specialized build jobs are skipped on this PR, and the PR reports Linux test evidence, so this approval does not claim platform-matrix or console verification.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5593717902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651#pullrequestreview-5593717902). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T01:05:41Z. **Review:** APPROVED --- Reviewed the implementation, tests, and debt notes. The three former stubs now have explicit behavior and regression coverage; the unconfirmed PS5 details are clearly recorded as unknown rather than asserted as measured. I found no code defect in this diff. The hosted Linux/Windows and specialized build jobs are skipped on this PR, and the PR reports Linux test evidence, so this approval does not claim platform-matrix or console verification.
frankea commented 2026-10-21 03:07:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-21T03:07:11Z.


One console datapoint on the value this PR mirrors. sceLncUtilGetAppIdOfRunningBigApp returns 1 here because sceSystemServiceGetAppIdOfRunningBigApp already does on main. On a PS5 (firmware 13.40, 2026-10-19), sceSystemServiceGetAppIdOfRunningBigApp() called inside a running retail title, Gran Turismo 7 (PPSA01317), returned 0x8094000F, not an app ID. The call was a ptrace remote call from an elfldr payload, which borrows a stopped game thread, calls the export the game itself resolved and restores the thread.

So in that process the SystemService call answered with an error in the launcher range (0x8094xxxx) rather than 1. I did not call sceLncUtilInitialize or sceLncUtilGetAppIdOfRunningBigApp there, so I can't say whether the LncUtil export answers the same way, or whether initializing the launcher client first would change it. Since this PR makes the new export equal the existing one, the existing "Running application ID" answer of 1 may be the part worth checking. I can measure sceLncUtilInitialize, sceLncUtilGetAppIdOfRunningBigApp and the SystemService call in the same game process, in both orders, if that would help.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307024107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651#issuecomment-6307024107). Originally posted by [frankea](https://github.com/frankea) on 2026-10-21T03:07:11Z. --- One console datapoint on the value this PR mirrors. `sceLncUtilGetAppIdOfRunningBigApp` returns 1 here because `sceSystemServiceGetAppIdOfRunningBigApp` already does on `main`. On a PS5 (firmware 13.40, 2026-10-19), `sceSystemServiceGetAppIdOfRunningBigApp()` called inside a running retail title, Gran Turismo 7 (PPSA01317), returned **0x8094000F**, not an app ID. The call was a ptrace remote call from an elfldr payload, which borrows a stopped game thread, calls the export the game itself resolved and restores the thread. So in that process the SystemService call answered with an error in the launcher range (0x8094xxxx) rather than 1. I did not call `sceLncUtilInitialize` or `sceLncUtilGetAppIdOfRunningBigApp` there, so I can't say whether the LncUtil export answers the same way, or whether initializing the launcher client first would change it. Since this PR makes the new export equal the existing one, the existing "Running application ID" answer of 1 may be the part worth checking. I can measure `sceLncUtilInitialize`, `sceLncUtilGetAppIdOfRunningBigApp` and the SystemService call in the same game process, in both orders, if that would help. AI-assisted: yes (Claude Code).
nikowolf123 commented 2026-10-21 03:17:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-21T03:17:33Z.


Thanks, that contradicts the value this PR copied. I took sceLncUtilGetAppIdOfRunningBigApp out, so it throws again as on main. The PR now covers only sceLncUtilInitialize and sceAppMessagingTryReceiveMsg, rebased onto current main (a819544273, guest_system_service passes).

Yes, that measurement would settle it. The most useful readings in one game process:

  • sceLncUtilGetAppIdOfRunningBigApp and sceSystemServiceGetAppIdOfRunningBigApp, each before and after sceLncUtilInitialize;
  • what sceLncUtilInitialize itself returns there, on the first and on a second call.

With that, the LncUtil export can return what the console does. The SystemService call on main, which returns 1 (the "Running application ID" entry), can then be corrected in a separate PR. 0x8094000F is not in the public LncUtil error list (Lnc_errors.h), so its name would stay unknown.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307159295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651#issuecomment-6307159295). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-21T03:17:33Z. --- Thanks, that contradicts the value this PR copied. I took `sceLncUtilGetAppIdOfRunningBigApp` out, so it throws again as on `main`. The PR now covers only `sceLncUtilInitialize` and `sceAppMessagingTryReceiveMsg`, rebased onto current `main` (a819544273, `guest_system_service` passes). Yes, that measurement would settle it. The most useful readings in one game process: - `sceLncUtilGetAppIdOfRunningBigApp` and `sceSystemServiceGetAppIdOfRunningBigApp`, each before and after `sceLncUtilInitialize`; - what `sceLncUtilInitialize` itself returns there, on the first and on a second call. With that, the LncUtil export can return what the console does. The SystemService call on `main`, which returns 1 (the "Running application ID" entry), can then be corrected in a separate PR. `0x8094000F` is not in the public LncUtil error list ([`Lnc_errors.h`](https://github.com/LightningMods/PS4-daemon-writeup/blob/dc404caac0cc0c8063f577a40996e929b3738552/Lnc_errors.h)), so its name would stay unknown.
xXPBSXx commented 2026-10-21 05:17:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T05:17:24Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only guest_system_service_tests; ctest -N -R guest_system_service lists exactly one test.

Results (3 runs each):

  • PR head: guest_system_service passes 3/3.
  • Baseline: I kept the PR's test and replaced only these production files: core/libs/prx/libSceSystemService/Export.cpp, core/libs/prx/libSceSystemService/PendingExports.cpp, core/libs/prx/libSceSystemService/SystemService.hpp with the version from the PR's merge base (9f4ddf7cf9), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308657566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651#issuecomment-6308657566). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T05:17:24Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` is clean. I built only `guest_system_service_tests`; `ctest -N -R guest_system_service` lists exactly one test. **Results (3 runs each):** - PR head: `guest_system_service` passes 3/3. - Baseline: I kept the PR's test and replaced only these production files: `core/libs/prx/libSceSystemService/Export.cpp`, `core/libs/prx/libSceSystemService/PendingExports.cpp`, `core/libs/prx/libSceSystemService/SystemService.hpp` with the version from the PR's merge base (`9f4ddf7cf9`), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards. **Not run:** other platforms, the other tests in the same family, the full repository CTest, and any title or console run. AI-assisted (Claude Code).
frankea commented 2026-10-21 23:34:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-21T23:34:43Z.


@nikowolf123 here are the readings, all from one game process: Gran Turismo 7 (PPSA01317) on a PS5 with firmware 13.40, measured 2026-10-21. The calls are ptrace remote calls from an elfldr payload, which borrows a stopped game thread and calls the exports as the game's own libSceSystemService resolves them, in this order:

call returns
sceSystemServiceGetAppIdOfRunningBigApp() 0x8094000F
sceLncUtilGetAppIdOfRunningBigApp() 0x8094000F
sceLncUtilInitialize() 0
sceLncUtilInitialize() again 0
sceSystemServiceGetAppIdOfRunningBigApp() 0x8094000F
sceLncUtilGetAppIdOfRunningBigApp() 0x8094000F
  • Both getters return 0x8094000F, before and after sceLncUtilInitialize, so initializing doesn't change the answer, and the LncUtil and SystemService calls answer the same in this process.
  • sceLncUtilInitialize returns 0 on both calls. These are the probe's first and second calls; whether the game had called it earlier isn't known.
  • Each call got a pointer to 16 bytes of 0xAA as its first argument, and none of them wrote to it.
  • All three exports resolve in the game's libSceSystemService module.

So the LncUtil export can return 0x8094000F like the SystemService one, and sceLncUtilInitialize 0 on every call. That's one process of one title; a title launched another way, or the shell, might get an app id.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328944645 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651#issuecomment-6328944645). Originally posted by [frankea](https://github.com/frankea) on 2026-10-21T23:34:43Z. --- @nikowolf123 here are the readings, all from one game process: Gran Turismo 7 (PPSA01317) on a PS5 with firmware 13.40, measured 2026-10-21. The calls are ptrace remote calls from an elfldr payload, which borrows a stopped game thread and calls the exports as the game's own libSceSystemService resolves them, in this order: | call | returns | |---|---| | `sceSystemServiceGetAppIdOfRunningBigApp()` | 0x8094000F | | `sceLncUtilGetAppIdOfRunningBigApp()` | 0x8094000F | | `sceLncUtilInitialize()` | 0 | | `sceLncUtilInitialize()` again | 0 | | `sceSystemServiceGetAppIdOfRunningBigApp()` | 0x8094000F | | `sceLncUtilGetAppIdOfRunningBigApp()` | 0x8094000F | - Both getters return 0x8094000F, before and after `sceLncUtilInitialize`, so initializing doesn't change the answer, and the LncUtil and SystemService calls answer the same in this process. - `sceLncUtilInitialize` returns 0 on both calls. These are the probe's first and second calls; whether the game had called it earlier isn't known. - Each call got a pointer to 16 bytes of 0xAA as its first argument, and none of them wrote to it. - All three exports resolve in the game's libSceSystemService module. So the LncUtil export can return 0x8094000F like the SystemService one, and `sceLncUtilInitialize` 0 on every call. That's one process of one title; a title launched another way, or the shell, might get an app id. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-22 12:08:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:08:47Z.

Review: COMMENTED


Reviewed — no blocking findings

The change implements the two requested exports and records the unconfirmed console behavior as technical debt; no verified blocking defect was found in the inspected code.

What I ran

Reviewed head ae779ab4b1bfeac20a85a3d773dfe876e73059ba. I read the prepared description, commits, manifest, diff, and all five changed files’ relevant changed sections. Repository files were read through repo_read.py; no commands or tests were run in this review.

Results

Check Result Note
Diff and changed code passed Changed behavior and tests inspected
Build and tests not run Only author-reported results were available
Console behavior not run Description records this as unconfirmed

Findings

Blocking

None.

Non-blocking

  • sceLncUtilInitialize returns success on every call, while the description’s opening claim says later calls return SCE_LNC_UTIL_ERROR_ALREADY_INITIALIZED; the implementation, test, and debt entry instead consistently specify success on every call (core/libs/prx/libSceSystemService/Export.cpp:745). Align the description with the implemented behavior.

Not verified

  • No build, ctest, console, or title run was performed. The Windows build and test results in the PR description are author-reported.
  • The manifest lists five changed files, all included. The relevant changed sections were read; unrelated portions of the larger source files were not reviewed. No files were excluded.

To get this to a good state

Nothing is required. Optional: correct the inconsistent description of repeated sceLncUtilInitialize calls.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012122393 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8651#pullrequestreview-6012122393). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T12:08:47Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The change implements the two requested exports and records the unconfirmed console behavior as technical debt; no verified blocking defect was found in the inspected code. ## What I ran Reviewed head `ae779ab4b1bfeac20a85a3d773dfe876e73059ba`. I read the prepared description, commits, manifest, diff, and all five changed files’ relevant changed sections. Repository files were read through `repo_read.py`; no commands or tests were run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Changed behavior and tests inspected | | Build and tests | not run | Only author-reported results were available | | Console behavior | not run | Description records this as unconfirmed | ## Findings ### Blocking None. ### Non-blocking - `sceLncUtilInitialize` returns success on every call, while the description’s opening claim says later calls return `SCE_LNC_UTIL_ERROR_ALREADY_INITIALIZED`; the implementation, test, and debt entry instead consistently specify success on every call (`core/libs/prx/libSceSystemService/Export.cpp:745`). Align the description with the implemented behavior. ## Not verified - No build, `ctest`, console, or title run was performed. The Windows build and test results in the PR description are author-reported. - The manifest lists five changed files, all included. The relevant changed sections were read; unrelated portions of the larger source files were not reviewed. No files were excluded. ## To get this to a good state Nothing is required. Optional: correct the inconsistent description of repeated `sceLncUtilInitialize` calls.
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!8651
No description provided.