Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/libs/prx/libkernel/SysExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ int APS5_VABI sceKernelGetAppCategoryType(int pid, std::uint32_t* categoryType)
*__error_nid_postfix() = 3;
return SCE_KERNEL_ERROR_ESRCH;
}
if (pid != 0 && pid != getpid_nid_postfix()) NotImplemented_nid_no_patch(__func__);
if (pid != 0 && pid != getpid_nid_postfix()) {
*__error_nid_postfix() = 3;
return SCE_KERNEL_ERROR_ESRCH;
}
std::uint32_t value = 0;
if (!GetAppCategoryType_nid_no_patch(&value)) NotImplemented_nid_no_patch(__func__);
if (!GuestCopyOut_nid_no_patch(categoryType, &value, sizeof(value))) return SCE_KERNEL_ERROR_EFAULT;
Expand Down
6 changes: 6 additions & 0 deletions core/libs/tests/GuestKernelSysAppCategory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ int main() {
Require(*__error_nid_postfix() == 3 && output[0] == 0x5a5a5a5au, "a negative pid set the wrong errno or wrote the output");
Require(getAppCategoryType(pid, nullptr) == static_cast<int>(0x80020016), "the null check does not come first");
}
{
output[0] = 0x5a5a5a5au;
*__error_nid_postfix() = 0;
Require(getAppCategoryType(999999, output.data()) == static_cast<int>(0x80020003), "an unused pid is not ESRCH");
Require(*__error_nid_postfix() == 3 && output[0] == 0x5a5a5a5au, "an unused pid set the wrong errno or wrote the output");
}
Require(getAppCategoryType(getpid_nid_postfix(), reinterpret_cast<std::uint32_t*>(0x10)) == static_cast<int>(0x8002000e),
"an unwritable output is not EFAULT");

Expand Down
6 changes: 2 additions & 4 deletions core/libs/tests/GuestKernelSysNeoMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,8 @@ int main(int argc, char** argv) {
std::uint32_t categoryType = 0;
Require(sceKernelGetAppCategoryType(getpid_nid_postfix(), &categoryType) == 0, "current-process category lookup failed");
Require(categoryType == ApplicationCategoryType, "current-process category type was not read from param.json");
bool unsupportedPid = false;
try { static_cast<void>(sceKernelGetAppCategoryType(getpid_nid_postfix() + 1, &categoryType)); }
catch (const std::runtime_error&) { unsupportedPid = true; }
Require(unsupportedPid, "a different process id was accepted");
Require(sceKernelGetAppCategoryType(getpid_nid_postfix() + 1, &categoryType) == static_cast<int>(0x80020003), "a different process id is not ESRCH");
Require(categoryType == ApplicationCategoryType, "an unused pid wrote the output");
return 0;
}
if (mode == "--category-unavailable") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# libkernel

## change [sceKernelGetAppCategoryType]

Check warning on line 3 in docs/dev/debt/changes/fix-libkernel-app-category-unknown-pid-esrch.md

View workflow job for this annotation

GitHub Actions / conventions

debt-length

Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1224 characters

- [sceKernelGetAppCategoryType](../../../core/libs/prx/libkernel/SysExports.cpp) (libkernel; also exported by libkernel_sys through the shared compilation unit) - `(int pid, uint32_t* category)` returns `EINVAL` (0x80020016) for a null `category` before it looks at the pid. Pid 0 and the current process return the `applicationCategoryType` field of the title's `param.json`, and 0; a PS5 Pro payload process (13.60) answered `0xffffffff` where a 13.590.001 session reported 0, so the answer for a process without category data is not firmware-stable. Other pids, negative or unused, return `ESRCH` (0x80020003) with `errno` 3 without writing the output: measured on a PS5 Pro (-1, `INT_MIN` and an unused pid all answered ESRCH); the console answered values for its own other live processes, which AnyPS5 does not have, so every non-self pid here is an unused one. A real title's stored value is unmeasured, and the offset-0x50 field of the `sceKernelGetAppInfo` record is a fixed `0xffffffff` marker here, not category data. GoY (PPSA26344) and Marvel's Wolverine call it from bundled `libSceAgc` and skip a RegMgr GPU-transcoding check (key `0x34ae6c7a451600db`) only when it is `0x10000` (Ghidra, not console-measured).
Loading