feat(libSceSysmodule): implement sceSysmoduleUnloadModuleInternalWithArg #7889

Merged
ErenYeager1836 merged 2 commits from upstream-pr/7889 into main 2026-10-20 02:52:31 +00:00
ErenYeager1836 commented 2026-10-19 12:28:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T12:28:09Z.


What

Implements sceSysmoduleUnloadModuleInternalWithArg in core/libs/prx/libSceSysmodule/Export.cpp (NID aKa6YfBKZs4), the counterpart to sceSysmoduleLoadModuleInternalWithArg:

  1. Validates (id & 0x7fffffffu) == 0 -> returns SCE_SYSMODULE_ERROR_INVALID_VALUE.
  2. Validates findModuleName(id) -> throws std::runtime_error if unknown id, matching sceSysmoduleLoadModuleInternalWithArg and sceSysmoduleUnloadModuleInternal.
  3. Decrements module reference count in gLoadCount[id], returning SCE_SYSMODULE_ERROR_UNLOADED if not currently loaded.
  4. Stores 0 in ret when provided.

Tested

  • Unit test coverage in core/libs/tests/GuestSysmodule.cpp:
    • Unknown internal IDs throw runtime error with return variable unmodified in CheckUnknownIds().
    • Invalid value 0 returns SCE_SYSMODULE_ERROR_INVALID_VALUE.
    • Unloaded module returns SCE_SYSMODULE_ERROR_UNLOADED.
    • Balanced load and unload with arguments completes cleanly and reports module unloaded once count reaches 0.
  • python tools/check_conventions.py passes 100%.
  • Technical debt file updated.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA99000, PPSA99420
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4920927160 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-19T12:28:09Z. --- ### What Implements `sceSysmoduleUnloadModuleInternalWithArg` in `core/libs/prx/libSceSysmodule/Export.cpp` (NID `aKa6YfBKZs4`), the counterpart to `sceSysmoduleLoadModuleInternalWithArg`: 1. Validates `(id & 0x7fffffffu) == 0` -> returns `SCE_SYSMODULE_ERROR_INVALID_VALUE`. 2. Validates `findModuleName(id)` -> throws `std::runtime_error` if unknown id, matching `sceSysmoduleLoadModuleInternalWithArg` and `sceSysmoduleUnloadModuleInternal`. 3. Decrements module reference count in `gLoadCount[id]`, returning `SCE_SYSMODULE_ERROR_UNLOADED` if not currently loaded. 4. Stores `0` in `ret` when provided. ### Tested - Unit test coverage in `core/libs/tests/GuestSysmodule.cpp`: - Unknown internal IDs throw runtime error with return variable unmodified in `CheckUnknownIds()`. - Invalid value `0` returns `SCE_SYSMODULE_ERROR_INVALID_VALUE`. - Unloaded module returns `SCE_SYSMODULE_ERROR_UNLOADED`. - Balanced load and unload with arguments completes cleanly and reports module unloaded once count reaches 0. - `python tools/check_conventions.py` passes 100%. - Technical debt file updated. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [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: PPSA99000, PPSA99420 - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 12:28:54 +00:00 (Migrated from github.com)

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


Progress report (dbac9fa → 76c0882)

➖ System libraries: 79.81% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceSysmodule sceSysmoduleUnloadModuleInternalWithArg
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6267219973 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889#issuecomment-6267219973). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T12:28:54Z. --- <!-- progress-report --> ### Progress report (dbac9fa → 76c0882) ➖ **System libraries**: 79.81% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceSysmodule | `sceSysmoduleUnloadModuleInternalWithArg` | </details>
github-actions[bot] commented 2026-10-19 12:48:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T12:48:19Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libSceSysmodule/Export.cpp
PR 6044 core/libs/tests/GuestSysmodule.cpp
PR 8106 core/libs/prx/libSceSysmodule/Export.cpp
docs/dev/debt/libSceSysmodule.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6267578877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889#issuecomment-6267578877). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T12:48:19Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceSysmodule/Export.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSysmodule.cpp` | | [PR 8106](https://www.github.com/boykopovar/AnyPS5/pull/8106) | `core/libs/prx/libSceSysmodule/Export.cpp`<br>`docs/dev/debt/libSceSysmodule.md` |
MarcZX10 commented 2026-10-19 12:55:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T12:55:55Z.


The latest Conventions run still fails because the PR template’s Checklist section is missing. Please add the checklist from .github/pull_request_template.md and rerun the check.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6267720497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889#issuecomment-6267720497). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T12:55:55Z. --- The latest Conventions run still fails because the PR template’s `Checklist` section is missing. Please add the checklist from `.github/pull_request_template.md` and rerun the check.
ErenYeager1836 commented 2026-10-19 13:44:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T13:44:14Z.


Added the required ### Checklist section from .github/pull_request_template.md to the PR description. The Conventions CI workflow has re-run and passed successfully.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6268694394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889#issuecomment-6268694394). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-19T13:44:14Z. --- Added the required `### Checklist` section from `.github/pull_request_template.md` to the PR description. The Conventions CI workflow has re-run and passed successfully.
oneandonlydean commented 2026-10-19 16:25:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T16:25:30Z.


@ErenYeager1836 On f677163eec the full CI run (39274694989) fails to build the tests on both Linux and Windows:

core/libs/tests/GuestSysmodule.cpp:323:53: error: 'kAgcInternalId' was not declared in this scope

kAgcInternalId isn't defined anywhere on main or in this PR. The file has kAgcDriverModuleId (0x80000080) and kAgcModuleId (0x80000094). Could you switch lines 323 and 326 to the constant you meant, and make sure guest_sysmodule passes? The rest of the change looks good. Thanks!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271959334 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889#issuecomment-6271959334). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T16:25:30Z. --- @ErenYeager1836 On f677163eec the full CI run (39274694989) fails to build the tests on both Linux and Windows: ``` core/libs/tests/GuestSysmodule.cpp:323:53: error: 'kAgcInternalId' was not declared in this scope ``` `kAgcInternalId` isn't defined anywhere on `main` or in this PR. The file has `kAgcDriverModuleId` (0x80000080) and `kAgcModuleId` (0x80000094). Could you switch lines 323 and 326 to the constant you meant, and make sure `guest_sysmodule` passes? The rest of the change looks good. Thanks!
ErenYeager1836 commented 2026-10-19 16:37:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T16:37:05Z.


Thanks @oneandonlydean! Switched the module ID to kAgcDriverModuleId across lines 323–331. Built locally with GCC/Ninja and verified that guest_sysmodule passes 100% and tools/check_conventions.py passes cleanly.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272172703 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7889#issuecomment-6272172703). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-19T16:37:05Z. --- Thanks @oneandonlydean! Switched the module ID to `kAgcDriverModuleId` across lines 323–331. Built locally with GCC/Ninja and verified that `guest_sysmodule` passes 100% and `tools/check_conventions.py` passes cleanly.
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!7889
No description provided.