Skip to content

docs(libkernel_sys): record the module list sceKernelGetModuleListInternal and the check order of sceKernelGetModuleInfoInternal on firmware 11.60 - #26803

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-sys-module-list-internal-console-1160
Nov 25, 2026

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What

The debt entry for sceKernelGetModuleInfoInternal, sceKernelGetModuleListInternal and sceKernelLoadStartModuleForSysmodule (docs/dev/debt/libkernel_sys.md) says that sceKernelGetModuleListInternal returns the same list as sceKernelGetModuleList, "as fpPS4 does", that fpPS4 marks this as a guess, and that "neither is checked on a PS5"; it also describes the check order of sceKernelGetModuleInfoInternal (EFAULT for a null pointer, EINVAL when st_size is not 0x1A8, ESRCH for an unknown handle) as shadPS4's. A probe on a PS5 with firmware 11.60, from a payload process, measured both. sceKernelGetModuleListInternal returned 5 modules (eboot.bin, libkernel_sys.sprx, libSceLibcInternal.sprx, libSceSysmodule.sprx, libSceNet.sprx; line 4 of the raw output) where sceKernelGetModuleList returned 1 (line 5), so the two lists are not the same there. sceKernelGetModuleInfoInternal checked in the order of the entry: a NULL info returned EFAULT (14) first, for an unknown handle too (lines 22 and 23); a wrong st_size (0, 0x1A7, 0x1A9, 0x1B0, 0x100) returned EINVAL (22), also for an unknown handle (lines 13 to 17 and 21); the handles -1 and 0x7fff returned ESRCH (3) with the right st_size (lines 19 and 20); the handle 0 returned 0 (line 18).

This pull request records that as a change fragment, docs/dev/debt/changes/docs-libkernel-sys-module-list-internal-console-1160.md, and it splits the entry in two, because one entry holding both new passages (the check-order sentence and the list measurement put into the old entry unchanged) would be 1351 characters and the limit is 1000: the first entry keeps sceKernelGetModuleInfoInternal and sceKernelLoadStartModuleForSysmodule with one added sentence for the check order (848 characters, 951 before); the second, new one is sceKernelGetModuleListInternal with the list result (537 characters). All other words of the existing entry stay; the sentence about sceKernelGetModuleListInternal moves into the second entry, and its closing words "and neither is checked on a PS5" are replaced by the measurement. Counted with the list marker, as check_conventions does.

AnyPS5 still returns the list of sceKernelGetModuleList for sceKernelGetModuleListInternal; no code changes, and this says nothing about a title process: the five modules are the ones of a payload process, and a title process may differ. It also says nothing about sceKernelIsModuleLoaded, which asks sceKernelGetModuleListInternal, for a title.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005, line 1 of the raw output), from a homebrew payload process, on 2026-11-18 at 05:05 UTC (the console's own clock in the PROBE line reads 06:47:43Z, 1 h 42 min ahead of the runner's clock). One run, END 23 (line 25). A title process may differ. The probe changed nothing: besides loading libkernel.sprx and looking the names up with dlsym, it called only sceKernelGetModuleListInternal, sceKernelGetModuleList and sceKernelGetModuleInfoInternal.

Call PS5, payload process, firmware 11.60 here
sceKernelGetModuleListInternal 5 modules (line 4) the entry says it returns the list of sceKernelGetModuleList
sceKernelGetModuleList 1 module (line 5)
sceKernelGetModuleInfoInternal, NULL info EFAULT before the handle is checked (lines 22, 23) as the entry says
wrong st_size, any handle EINVAL before ESRCH (lines 13 to 17, 21) as the entry says
handle -1 or 0x7fff, right st_size ESRCH (lines 19, 20) as the entry says

Documentation change: no test was added or run. The fragment is one commit (head 9d8433e605) on main at 61cce6e, only the fragment file, 9 lines in; its blob has no carriage return. On the head merged into main at a40a139 I ran tools/check_conventions.py --base upstream/main (no finding, 0 errors) and tools/debt_fold.py --check (exit code 0). The first comment holds the probe source and the raw output. Not tested: Linux, macOS, the CI runner, a title process, a second run, and firmware other than 11.60.

Overlap: counted on 2026-11-24 from the 2467 open pull requests (file lists from the GitHub API, the 17 with 100 or more files read in full through the files API; the patches of the 1554 pull requests that change a file under docs/dev/debt/ or a libkernel or module file were searched for sceKernelGetModuleListInternal, sceKernelGetModuleInfoInternal, sceKernelLoadStartModuleForSysmodule and the fragment name, at 21:36 to 22:04 UTC). This pull request adds one file, docs/dev/debt/changes/docs-libkernel-sys-module-list-internal-console-1160.md, and no code; no open pull request has a file of that name. Eleven open pull requests change docs/dev/debt/libkernel_sys.md (#21464, #19486, #18190, #17936, #15037, #12642, #12315, #12130, #10657, #9302, #9297), none of them the entry of these three functions. #18112 (mirror libkernel exports through libkernel_web) adds sceKernelGetModuleInfoInternal_nid_no_patch in code; it changes neither the entry nor the fragment. A merge of this head into main at a40a139 was checked with git merge-tree and is clean; as the head only adds a new file, it cannot conflict with another pull request unless that one adds the same file. This pull request does not depend on any of them (Depends on: none).

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 (no graphics change)
  • AI-assisted: yes

…ernal and the check order of sceKernelGetModuleInfoInternal on firmware 11.60

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk; PROBE_BUILD is the first 12 hex digits of the SHA-256 of the source as run, 6cb7c4cbca94) and its raw output from the run of 2026-11-18 at 05:05 UTC (runner clock). The clock in the PROBE line is the console's own clock. The probe reads only: it lists the modules and asks for the module information of the listed handles and of some invalid ones. In the source shown below an internal label after Probe in the first line of its header comment was removed (Probe:); the code is unchanged, and PROBE_BUILD is the hash of the original file. The raw output is verbatim.

raw output (stdout)
PROBE	module_info_internal	fw=0x11600005	build=6cb7c4cbca94	pid=269	utc=2026-11-18T06:47:43Z
CASE	0	load libkernel.sprx	0	2	loaded
CASE	0b	dlsym of the functions (nothing is loaded)	0	0	ListInternal=1 (0 none, 1 libkernel, 2 global) InfoInternal=1 LoadStartModuleForSysmodule_exists=1 GetModuleList=1 GetModuleInfo=1
CASE	1.1	sceKernelGetModuleListInternal(list[256], 256, &n)	0	0	rc=0x00000000 errno=0 actual=5
CASE	1.2	sceKernelGetModuleList(list[256], 256, &n)	0	0	rc=0x00000000 errno=0 actual=1 same_count_and_handles_as_Internal=0
CASE	1.3	sceKernelGetModuleListInternal(list[4], 4, &n)	-2147352564	12	rc=0x8002000c errno=12 actual=0
CASE	1.4	sceKernelGetModuleListInternal(list, 0, &n)	-2147352564	12	rc=0x8002000c errno=12 actual=77
CASE	2.1	sceKernelGetModuleInfoInternal(handle #1 in the list)	0	0	rc=0x00000000 errno=0 st_size=0x0 name=eboot.bin segment_count=4 ref_count=3 segments: [+0 size 54000 prot 4] [+54000 size 1c000 prot 1] [+70000 size 4000 prot 1] [+74000 size 110000 prot 3] equals_GetModuleInfo=1
CASE	2.2	sceKernelGetModuleInfoInternal(handle #2 in the list)	0	0	rc=0x00000000 errno=0 st_size=0x0 name=libkernel_sys.sprx segment_count=4 ref_count=3 segments: [+0 size 4c000 prot 4] [+4c000 size 20000 prot 1] [+6c000 size 4000 prot 1] [+70000 size 38000 prot 3] equals_GetModuleInfo=1
CASE	2.3	sceKernelGetModuleInfoInternal(handle #3 in the list)	0	0	rc=0x00000000 errno=0 st_size=0x0 name=libSceLibcInternal.sprx segment_count=4 ref_count=3 segments: [+0 size 128000 prot 4] [+128000 size 80000 prot 1] [+1a8000 size 8000 prot 1] [+1b0000 size 14000 prot 3] equals_GetModuleInfo=1
CASE	2.4	sceKernelGetModuleInfoInternal(handle #4 in the list)	0	0	rc=0x00000000 errno=0 st_size=0x0 name=libSceSysmodule.sprx segment_count=4 ref_count=1 segments: [+0 size c000 prot 4] [+c000 size 8000 prot 1] [+14000 size 4000 prot 1] [+18000 size 14000 prot 3] equals_GetModuleInfo=1
CASE	2.5	sceKernelGetModuleInfoInternal(handle #5 in the list)	0	0	rc=0x00000000 errno=0 st_size=0x0 name=libSceNet.sprx segment_count=4 ref_count=2 segments: [+0 size 34000 prot 4] [+34000 size c000 prot 1] [+40000 size 4000 prot 1] [+44000 size 1a4000 prot 3] equals_GetModuleInfo=1
CASE	3.1	InfoInternal(valid handle, st_size 0x0)	-2147352554	22	rc=0x80020016 errno=22
CASE	3.2	InfoInternal(valid handle, st_size 0x1a7)	-2147352554	22	rc=0x80020016 errno=22
CASE	3.3	InfoInternal(valid handle, st_size 0x1a9)	-2147352554	22	rc=0x80020016 errno=22
CASE	3.4	InfoInternal(valid handle, st_size 0x1b0)	-2147352554	22	rc=0x80020016 errno=22
CASE	3.5	InfoInternal(valid handle, st_size 0x100)	-2147352554	22	rc=0x80020016 errno=22
CASE	4.1	InfoInternal(handle 0, st_size 0x1A8)	0	0	rc=0x00000000 errno=0
CASE	4.2	InfoInternal(handle -1, st_size 0x1A8)	-2147352573	3	rc=0x80020003 errno=3
CASE	4.3	InfoInternal(handle 32767, st_size 0x1A8)	-2147352573	3	rc=0x80020003 errno=3
CASE	4.4	InfoInternal(invalid handle 0x7fff, wrong st_size 0x100)	-2147352554	22	rc=0x80020016 errno=22
CASE	5.1	InfoInternal(invalid handle 0x7fff, NULL info)	-2147352562	14	rc=0x8002000e errno=14 fault_signal=0
CASE	5.2	InfoInternal(valid handle, NULL info)	-2147352562	14	rc=0x8002000e errno=14 fault_signal=0
CASE	5.3	sceKernelGetModuleListInternal(NULL list, 8, &n)	-2147352562	14	rc=0x8002000e errno=14 actual=0 fault_signal=0
END	23
probe.c
/* Probe: sceKernelGetModuleInfoInternal and sceKernelGetModuleListInternal, read only, payload process, firmware 11.60 (debt libkernel_sys.md entry:
   they answer for every loaded module, system modules included; sceKernelGetModuleInfoInternal fills the 0x1A8-byte SceKernelModuleInfoEx of a
   module handle the way sceKernelGetModuleInfoFromAddr does for an address, with shadPS4's checks in their order: EFAULT for a null pointer, EINVAL
   when st_size is not 0x1A8, ESRCH for an unknown handle; sceKernelGetModuleListInternal returns the same list as sceKernelGetModuleList, as
   fpPS4 does, which fpPS4 marks as a guess; neither is checked on a PS5). Prototypes from the repo: int sceKernelGetModuleInfoInternal(int handle,
   ModuleInfoEx* info) with the 0x1A8-byte layout (st_size at 0, the name at 8, the handle at 0x108, four segments of address, size and protection
   from 0x160, segment_count at 0x1A0, ref_count at 0x1A4), int sceKernelGetModuleListInternal(int* handles, size_t count, size_t* actual); for the
   comparison int sceKernelGetModuleList(int*, size_t, size_t*) and int sceKernelGetModuleInfo(int, ModuleInfo*) (0x160 bytes). The names are looked
   up with dlsym in libkernel.sprx, then in the global scope; sceKernelLoadStartModuleForSysmodule is only looked up and never called, no module is
   loaded. Cases: the existence of the exports; both lists into a 256-entry array (return code, the number, whether the number and the handles in order are
   equal); the list with a count of 4 and of 0 (return code, actual); then for the first 8 handles the info from the Internal function (return code, st_size
   as returned, the base name of the module only, at most 24 characters, the segment count, the sizes and protections of the segments and their addresses
   as offsets from the first segment, ref_count) and whether name, segment count and the segments equal those of sceKernelGetModuleInfo; the error
   order: a NULL info (single call, guarded), st_size 0, 0x1A7, 0x1A9, 0x1B0 and 0x100 with a valid handle, the handles 0, -1 and 0x7fff with a valid
   st_size, then both faults at once (NULL info with an invalid handle, a wrong st_size with an invalid handle). No path, no absolute address
   is printed. A fault in the NULL call is caught by a guard (one hit, more than eight end the probe with _exit(125)). Nothing is written, nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h>   /* only for kernel_get_fw_version() */

#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
   itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif

static volatile int g_handle = -1;
static int (*volatile g_setmargins)(int, int, int) = 0; /* unused here */
static void reset_rate(void) {
  if (g_setmargins && g_handle >= 0) g_setmargins(g_handle, 0, 0);
}

static void probe_alarm(int sig) {
  static const char msg[] = "TIMEOUT\tprobe self limit\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
}

/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
   thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
   as a second safeguard. */
static void* probe_watchdog(void* arg) {
  static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
  unsigned left = PROBE_MAX_S;
  (void)arg;
  while (left) left = sleep(left);
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
  return 0;
}

static void probe_watchdog_start(void) {
  pthread_t t;
  if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}

static int cases = 0;

static void probe_header(void) {
  char utc[32];
  time_t now = time(0);
  probe_watchdog_start();
  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_end(void) {
  printf("END\t%d\n", cases);
  fflush(stdout);
}



#include <setjmp.h>

typedef int (*fn_list)(int*, size_t, size_t*);
typedef int (*fn_info_ex)(int, void*);
typedef int (*fn_info)(int, void*);

static sigjmp_buf guard_env;
static volatile int guard_sig = 0, guard_active = 0, guard_hits = 0;
static void guard_handler(int s) {
  static const char msg[] = "FAULT\tguard\n";
  guard_sig = s;
  if (!guard_active || ++guard_hits > 8) { (void)!write(1, msg, sizeof msg - 1); _exit(125); }
  guard_active = 0;
  siglongjmp(guard_env, 1);
}

static void* find(void* lk, const char* name) {
  return 0;
}

int main(void) {
  struct sigaction sa;
  memset(&sa, 0, sizeof sa);
  sa.sa_handler = guard_handler;
  sigaction(SIGSEGV, &sa, 0);
  sigaction(SIGBUS, &sa, 0);
  signal(SIGALRM, probe_alarm);
  alarm(PROBE_MAX_S);
  probe_header();
  char extra[320], id[16], label[100];
  (void)find;

  errno = 0;
  void* lk = dlopen("libkernel.sprx", RTLD_LAZY);
  probe_case("0", "load libkernel.sprx", lk ? 0 : -1, errno, lk ? "loaded" : dlerror());
  if (!lk) { probe_end(); return 0; }
  fn_list l_int = (fn_list)dlsym(lk, "sceKernelGetModuleListInternal");
  fn_info_ex i_int = (fn_info_ex)dlsym(lk, "sceKernelGetModuleInfoInternal");
  void* lsm = dlsym(lk, "sceKernelLoadStartModuleForSysmodule");
  int where_l = l_int ? 1 : 0, where_i = i_int ? 1 : 0;
  if (!l_int) { l_int = (fn_list)dlsym(RTLD_DEFAULT, "sceKernelGetModuleListInternal"); where_l = l_int ? 2 : 0; }
  if (!i_int) { i_int = (fn_info_ex)dlsym(RTLD_DEFAULT, "sceKernelGetModuleInfoInternal"); where_i = i_int ? 2 : 0; }
  if (!lsm) lsm = dlsym(RTLD_DEFAULT, "sceKernelLoadStartModuleForSysmodule");
  fn_list l_pub = (fn_list)dlsym(lk, "sceKernelGetModuleList");
  fn_info i_pub = (fn_info)dlsym(lk, "sceKernelGetModuleInfo");
  snprintf(extra, sizeof extra, "ListInternal=%d (0 none, 1 libkernel, 2 global) InfoInternal=%d LoadStartModuleForSysmodule_exists=%d GetModuleList=%d GetModuleInfo=%d",
           where_l, where_i, lsm != 0, l_pub != 0, i_pub != 0);
  probe_case("0b", "dlsym of the functions (nothing is loaded)", 0, 0, extra);
  if (!l_int && !i_int) { probe_end(); return 0; }

  int h1[256], h2[256];
  size_t n1 = 0, n2 = 0;
  int have = 0;
  memset(h1, 0, sizeof h1);
  memset(h2, 0, sizeof h2);
  if (l_int) {
    errno = 0;
    int r = l_int(h1, 256, &n1);
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d actual=%zu", (unsigned)r, errno, n1);
    probe_case("1.1", "sceKernelGetModuleListInternal(list[256], 256, &n)", r, errno, extra);
    have = r == 0;
  }
  if (l_pub) {
    errno = 0;
    int r = l_pub(h2, 256, &n2);
    int same = n1 == n2;
    for (size_t k = 0; same && k < n1 && k < 256; ++k) if (h1[k] != h2[k]) same = 0;
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d actual=%zu same_count_and_handles_as_Internal=%d", (unsigned)r, errno, n2, l_int ? same : -1);
    probe_case("1.2", "sceKernelGetModuleList(list[256], 256, &n)", r, errno, extra);
  }
  if (l_int) {
    int small[4];
    size_t a = 0;
    errno = 0;
    int r = l_int(small, 4, &a);
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d actual=%zu", (unsigned)r, errno, a);
    probe_case("1.3", "sceKernelGetModuleListInternal(list[4], 4, &n)", r, errno, extra);
    a = 77;
    errno = 0;
    r = l_int(small, 0, &a);
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d actual=%zu", (unsigned)r, errno, a);
    probe_case("1.4", "sceKernelGetModuleListInternal(list, 0, &n)", r, errno, extra);
  }

  /* c) info of the first 8 handles */
  int first = 0;
  if (i_int && have) {
    for (size_t k = 0; k < 8 && k < n1; ++k) {
      unsigned char b[0x1A8];
      memset(b, 0xaa, sizeof b);
      unsigned long long ssz = 0x1A8;
      memcpy(b, &ssz, 8);
      errno = 0;
      int r = i_int(h1[k], b);
      int e = errno;
      unsigned long long st = 0;
      memcpy(&st, b, 8);
      char nm[25];
      memcpy(nm, b + 8, 24);
      nm[24] = 0;
      const char* base = strrchr(nm, '/');
      base = base ? base + 1 : nm;
      unsigned segc = 0, refc = 0;
      memcpy(&segc, b + 0x1A0, 4);
      memcpy(&refc, b + 0x1A4, 4);
      unsigned long long a0 = 0;
      char seg[160] = "";
      for (unsigned s = 0; s < segc && s < 4; ++s) {
        unsigned long long ad = 0;
        unsigned sz = 0;
        int pr = 0;
        memcpy(&ad, b + 0x160 + s * 16, 8);
        memcpy(&sz, b + 0x160 + s * 16 + 8, 4);
        memcpy(&pr, b + 0x160 + s * 16 + 12, 4);
        if (s == 0) a0 = ad;
        char t[40];
        snprintf(t, sizeof t, " [+%llx size %x prot %d]", ad - a0, sz, pr);
        strncat(seg, t, sizeof seg - strlen(seg) - 1);
      }
      int eq = -1;
      if (i_pub) {
        unsigned char p[0x160];
        memset(p, 0, sizeof p);
        unsigned long long psz = 0x160;
        memcpy(p, &psz, 8);
        int pr = i_pub(h1[k], p);
        eq = pr == 0 && memcmp(p + 8, b + 8, 256) == 0 && memcmp(p + 0x108, b + 0x160, 64) == 0 && memcmp(p + 0x148, b + 0x1A0, 4) == 0;
      }
      snprintf(id, sizeof id, "2.%zu", k + 1);
      snprintf(label, sizeof label, "sceKernelGetModuleInfoInternal(handle #%zu in the list)", k + 1);
      snprintf(extra, sizeof extra, "rc=0x%08x errno=%d st_size=0x%llx name=%s segment_count=%u ref_count=%u segments:%s equals_GetModuleInfo=%d", (unsigned)r, e, st, base, segc,
               refc, seg, eq);
      probe_case(id, label, r, e, extra);
      if (k == 0) first = h1[0];
    }
  }

  /* d) error order */
  if (i_int) {
    int hv = have && n1 ? h1[0] : 1;
    unsigned long long sizes[5] = {0, 0x1A7, 0x1A9, 0x1B0, 0x100};
    for (int i = 0; i < 5; ++i) {
      unsigned char b[0x1B8];
      memset(b, 0, sizeof b);
      memcpy(b, &sizes[i], 8);
      errno = 0;
      int r = i_int(hv, b);
      snprintf(id, sizeof id, "3.%d", i + 1);
      snprintf(label, sizeof label, "InfoInternal(valid handle, st_size 0x%llx)", sizes[i]);
      snprintf(extra, sizeof extra, "rc=0x%08x errno=%d", (unsigned)r, errno);
      probe_case(id, label, r, errno, extra);
    }
    int bad[3] = {0, -1, 0x7fff};
    for (int i = 0; i < 3; ++i) {
      unsigned char b[0x1A8];
      memset(b, 0, sizeof b);
      unsigned long long ssz = 0x1A8;
      memcpy(b, &ssz, 8);
      errno = 0;
      int r = i_int(bad[i], b);
      snprintf(id, sizeof id, "4.%d", i + 1);
      snprintf(label, sizeof label, "InfoInternal(handle %d, st_size 0x1A8)", bad[i]);
      snprintf(extra, sizeof extra, "rc=0x%08x errno=%d", (unsigned)r, errno);
      probe_case(id, label, r, errno, extra);
    }
    unsigned char b[0x1A8];
    memset(b, 0, sizeof b);
    unsigned long long wrong = 0x100;
    memcpy(b, &wrong, 8);
    errno = 0;
    int r = i_int(0x7fff, b);
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d", (unsigned)r, errno);
    probe_case("4.4", "InfoInternal(invalid handle 0x7fff, wrong st_size 0x100)", r, errno, extra);
    guard_sig = 0;
    r = -1;
    int e = 0;
    if (sigsetjmp(guard_env, 1) == 0) {
      guard_active = 1;
      errno = 0;
      r = i_int(0x7fff, 0);
      e = errno;
      guard_active = 0;
    }
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d fault_signal=%d", (unsigned)r, e, (int)guard_sig);
    probe_case("5.1", "InfoInternal(invalid handle 0x7fff, NULL info)", r, e, extra);
    guard_sig = 0;
    r = -1;
    e = 0;
    if (sigsetjmp(guard_env, 1) == 0) {
      guard_active = 1;
      errno = 0;
      r = i_int(hv, 0);
      e = errno;
      guard_active = 0;
    }
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d fault_signal=%d", (unsigned)r, e, (int)guard_sig);
    probe_case("5.2", "InfoInternal(valid handle, NULL info)", r, e, extra);
  }
  if (l_int) {
    guard_sig = 0;
    int r = -1, e = 0;
    size_t a = 0;
    if (sigsetjmp(guard_env, 1) == 0) {
      guard_active = 1;
      errno = 0;
      r = l_int(0, 8, &a);
      e = errno;
      guard_active = 0;
    }
    snprintf(extra, sizeof extra, "rc=0x%08x errno=%d actual=%zu fault_signal=%d", (unsigned)r, e, a, (int)guard_sig);
    probe_case("5.3", "sceKernelGetModuleListInternal(NULL list, 8, &n)", r, e, extra);
  }
  (void)first;

  probe_end();
  return 0;
}

AI-assisted (Claude Code).

@oneandonlydean
oneandonlydean merged commit 763df12 into boykopovar:main Nov 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants