Repository navigation
docs(libSceNgs2): record the measured parse and enumerate results on firmware 11.60 - #23413
Merged
oneandonlydean merged 1 commit intoNov 19, 2026
Conversation
…firmware 11.60 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Probe source (built with ps5-payload-sdk; probe.c/* Probe cd2_ngs2_parse_v2 (Debt libSceNgs2.md:6): sceNgs2ParseWaveformUser und die Enumerierer
sceNgs2SystemEnumHandles / sceNgs2SystemEnumRackHandles in libSceNgs2.sprx. Payload-Prozess, Firmware 11.60. KEIN
sceNgs2SystemCreate. ABBRUCH ERWARTET moeglich: die Zeigerfaelle (NULL-Handler, NULL-Ausgabe, EnumHandles(NULL,4))
stehen zuletzt und einzeln; ein SIGSEGV/SIGBUS wird als FAULT-Zeile mit END gemeldet. Aenderung gegen die erste Fassung:
(1) Zeigerfaelle nach den Enum-Faellen, (2) Signal-Handler, (3) der Handler liefert jetzt ein echtes RIFF/WAVE
(36 Byte, fmt-Chunk, PCM 16 Bit mono 48000) je nach offset/size statt Nullbytes - die erste Fassung gab bei
Rueckgabe 0 ein ungueltiges RIFF und der Fall 3 war deshalb nicht aussagekraeftig. Signaturen NICHT gemessen:
angenommen ParseWaveformUser(handler, user_data, out_info), SystemEnumHandles(array, max),
SystemEnumRackHandles(system, array, max); Handler int handler(user, offset, data, size). */
#include <dlfcn.h>
#include <errno.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h> /* nur fuer kernel_get_fw_version() */
#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif
static int cases = 0;
static const char* g_cur_id = "-";
static void probe_alarm(int sig) {
static const char msg[] = "TIMEOUT\tprobe self limit\n";
(void)sig;
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
}
static void sig_handler(int s) {
printf("CASE\t%s\tsignal during call\t%d\t0\tFAULT\n", g_cur_id, s);
printf("END\t%d\n", cases + 1);
fflush(stdout);
_exit(0);
}
static void probe_header(void) {
char utc[32];
time_t now = time(0);
struct tm tmv;
gmtime_r(&now, &tmv);
strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
getpid(), utc);
fflush(stdout);
}
static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
fflush(stdout);
cases++;
}
static void probe_note(const char* text) {
printf("NOTE\t%s\n", text);
fflush(stdout);
}
static void probe_end(void) {
printf("END\t%d\n", cases);
fflush(stdout);
}
static void hex(const unsigned char* p, int n, char* out) {
static const char d[] = "0123456789abcdef";
for (int i = 0; i < n; i++) {
out[2 * i] = d[p[i] >> 4];
out[2 * i + 1] = d[p[i] & 15];
}
out[2 * n] = 0;
}
typedef int (*handler_t)(uintptr_t, uint32_t, void*, size_t);
typedef int (*parse_t)(handler_t, uintptr_t, void*);
typedef int (*enum_sys_t)(void*, uint32_t);
typedef int (*enum_rack_t)(uintptr_t, void*, uint32_t);
static const unsigned char riff[36] = {'R', 'I', 'F', 'F', 0x1c, 0, 0, 0, 'W', 'A', 'V', 'E', 'f', 'm', 't', ' ', 16, 0, 0,
0, 1, 0, 1, 0, 0x80, 0xbb, 0, 0, 0, 0x77, 1, 0, 2, 0, 16, 0};
static int hcalls = 0;
static int hret = 0;
static int hmode = 0;
static unsigned long hlast_off = 0, hlast_size = 0;
static int handler(uintptr_t user, uint32_t offset, void* data, size_t size) {
(void)user;
hcalls++;
hlast_off = offset;
hlast_size = size;
if (hmode == 1 && data) {
memset(data, 0, size);
if (offset < sizeof riff) {
size_t n = sizeof riff - offset;
memcpy(data, riff + offset, n < size ? n : size);
}
return 0;
}
return hret;
}
static unsigned char info[512];
static void run_parse(const char* id, const char* call, parse_t f, handler_t h, void* out, int handler_ret, int mode) {
char extra[700], hx[2 * 64 + 1];
memset(info, 0xAA, sizeof info);
hcalls = 0;
hret = handler_ret;
hmode = mode;
hlast_off = hlast_size = 0;
g_cur_id = id;
errno = 0;
int r = f(h, 0x1234, out);
int er = errno;
hex(info, 64, hx);
snprintf(extra, sizeof extra, "ret32=0x%08x;handler_calls=%d;last_off=%lu;last_size=%lu;info64=%s", (unsigned)r,
hcalls, hlast_off, hlast_size, hx);
probe_case(id, call, r, er, extra);
}
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
void* lib = dlopen("libSceNgs2.sprx", RTLD_LAZY);
probe_case("0.dlopen", "dlopen(libSceNgs2.sprx)", lib != 0, 0, "-");
if (!lib) { probe_end(); return 0; }
parse_t parse = (parse_t)dlsym(lib, "sceNgs2ParseWaveformUser");
enum_sys_t enum_sys = (enum_sys_t)dlsym(lib, "sceNgs2SystemEnumHandles");
enum_rack_t enum_rack = (enum_rack_t)dlsym(lib, "sceNgs2SystemEnumRackHandles");
void* ctrl_neg = dlsym(lib, "sceNgs2NoSuchFunctionControl");
probe_case("1.name", "dlsym(sceNgs2ParseWaveformUser)", parse != 0, 0, "1 = name resolves");
probe_case("1.name", "dlsym(sceNgs2SystemEnumHandles)", enum_sys != 0, 0, "-");
probe_case("1.name", "dlsym(sceNgs2SystemEnumRackHandles)", enum_rack != 0, 0, "-");
probe_case("1.ctrl", "dlsym(sceNgs2NoSuchFunctionControl) expect 0", ctrl_neg != 0, 0, "negative control");
struct sigaction sa;
memset(&sa, 0, sizeof sa);
sa.sa_handler = sig_handler;
sigaction(SIGSEGV, &sa, 0);
sigaction(SIGBUS, &sa, 0);
if (parse) {
run_parse("2.parse", "ParseWaveformUser(handler ret -1, user, info)", parse, handler, info, -1, 0);
run_parse("3.parse", "ParseWaveformUser(handler serves RIFF36, user, info)", parse, handler, info, 0, 1);
}
if (enum_sys) {
unsigned long arr[4];
memset(arr, 0xAA, sizeof arr);
g_cur_id = "6.enum";
errno = 0;
int r = enum_sys(arr, 4);
int er = errno;
char extra[96], hx[2 * 32 + 1];
hex((unsigned char*)arr, 32, hx);
snprintf(extra, sizeof extra, "ret32=0x%08x;arr=%s", (unsigned)r, hx);
probe_case("6.enum", "SystemEnumHandles(arr4,4)", r, er, extra);
}
if (enum_rack) {
unsigned long arr[4];
memset(arr, 0xAA, sizeof arr);
g_cur_id = "8.rack";
errno = 0;
int r = enum_rack(0, arr, 4);
probe_case("8.rack", "SystemEnumRackHandles(0,arr4,4)", r, errno, "-");
}
/* Zeigerfaelle zuletzt, jeweils einzeln; ein Signal beendet die Probe mit FAULT + END. */
if (parse) {
probe_note("next: ParseWaveformUser(NULL handler); a fault ends the run here");
run_parse("4.parse", "ParseWaveformUser(NULL handler, user, info)", parse, 0, info, 0, 0);
probe_note("next: ParseWaveformUser(handler, user, NULL out); a fault ends the run here");
run_parse("5.parse", "ParseWaveformUser(handler serves RIFF36, user, NULL out)", parse, handler, 0, 0, 1);
}
if (enum_sys) {
probe_note("last: SystemEnumHandles(NULL,4); a fault ends the run here");
g_cur_id = "9.enum";
errno = 0;
int r = enum_sys(0, 4);
probe_case("9.enum", "SystemEnumHandles(NULL,4)", r, errno, "-");
}
probe_end();
return 0;
}raw output (stdout) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
sceNgs2ParseWaveformUser,sceNgs2SystemEnumHandlesandsceNgs2SystemEnumRackHandlesentry indocs/dev/debt/libSceNgs2.md(line 6) states what the firmware 11.00 module does: a negative handler return and a null handler become0x804A0408, a null output0x804A0053, the enumerators return the count of live systems, a null array with a nonzero count returns0x804A0053and an unknown system0x804A0230. A probe on a PS5 with firmware 11.60, from a payload process and withoutsceNgs2SystemCreate, measured these cases: a handler returning -1 gave0x804A0408after one call of the handler (offset 0, size 4; case 2.parse, line 7 of the raw output); a null handler gave0x804A0408without a call (case 4.parse, line 12); a null output gave0x804A0053without a call (case 5.parse, line 14);sceNgs2SystemEnumHandleswith an array of 4 and a count of 4 and no system returned 0 and left the array unchanged (case 6.enum, line 9);sceNgs2SystemEnumRackHandleswith the system 0 returned0x804A0230(case 8.rack, line 10);sceNgs2SystemEnumHandleswith a null array and a count of 4 returned0x804A0053(case 9.enum, line 16). Nothing faulted and the run ended with itsENDline (line 17). The entry now says that, and that a handler that succeeds was not measured. Only this one entry changes, as a new fragment indocs/dev/debt/changes/; no code does.The handler that serves a 36-byte RIFF header with a
fmtchunk and nodatachunk was called 10 times (the last call at offset 12, size 8) andsceNgs2ParseWaveformUserstill returned0x804A0408(case 3.parse, line 8). That is not recorded in the entry: the probe's waveform has nodatachunk, so the result does not show what a successful parse returns, and a waveform withfmtanddatawas not measured.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005, line 1 of the raw output), from a homebrew payload process, on 2026-11-18 at 22:06 UTC (the console's own clock in thePROBEline reads 23:48:33Z, 1 h 42 min ahead of the runner's clock). A title process may differ. The cases are 0.dlopen to 9.enum, lines 2 to 16 of the raw output in the first comment. The signatures are not measured: the probe assumesParseWaveformUser(handler, user_data, out_info),SystemEnumHandles(array, max)andSystemEnumRackHandles(system, array, max)(probe.cheader comment), and presets its output buffers to 0xAA so that an unchanged output shows (info64andarrin the raw output).dlsymof a name that does not exist returned 0 (case 1.ctrl, line 6).0x804A0408, 1 call (line 7)0x804A04080x804A0408, no call (line 12)0x804A0053, no call (line 14)0x804A0053sceNgs2SystemEnumHandles(arr, 4), no systemsceNgs2SystemEnumHandles(NULL, 4)0x804A0053(line 16)0x804A0053sceNgs2SystemEnumRackHandles(0, arr, 4)0x804A0230(line 10)0x804A0230The right-hand statements are the entry's text, which describes
libSceNgs2.native/src/System.cpp; that source was not read or run for this change.tools/check_conventions.pyreports no error with this fragment added tomainanddebt_fold --checkreturns 0; the changed entry is 1512 characters without the list marker. This is a documentation change, so no test was added or run. Not tested: Linux, macOS, the CI runner, a title process, a created system, a handler that succeeds and firmware other than 11.60.Overlap: counted on 2026-11-19 at 00:09 UTC from the 2024 open pull requests (file lists from the GitHub API; the ten with 100 or more files were read in full through the files API) against
mainat 973026d. This pull request adds one file,docs/dev/debt/changes/docs-libscengs2-parse-enum-measured.md, and no code; no open pull request has a file of that name. No open pull request changesdocs/dev/debt/libSceNgs2.md, and the diffs of the Ngs2 pull requests that changelibSceNgs2.nativeor add a Ngs2 fragment (#23227, #22860, #22536, #21141, #18501, #12315) do not namesceNgs2ParseWaveformUser,sceNgs2SystemEnumHandlesorsceNgs2SystemEnumRackHandles; #22860 changeslibSceNgs2.native/src/System.cppin thesceNgs2SystemRenderarea only, and the entry cites that file without line numbers. A search of the open pull requests for the three function names finds nothing. This pull request does not depend on any of them (Depends on: none).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)