mirror of
https://github.com/Pharaoh2k/ps5debug-NG.git
synced 2026-10-21 11:23:27 -05:00
The variadic __crt_syscall reads each argument as a 64-bit long; a bare int (e.g. the -1 mmap fd) leaves the upper 32 bits undefined and can fail call-site-dependently. Route the remaining bare sites through the typed ps5debug_syscall wrapper (behavior-preserving): net.c select(93), debug.c wait4(7), proc_remote.c ptrace(26) + wait4(7), installer find_pid.c sysctl(202), installer proc_remote.c ptrace(26).
36 lines
817 B
C
36 lines
817 B
C
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include "sdk_shim.h"
|
|
|
|
int find_proc_pid_by_name(const char *name)
|
|
{
|
|
if (!name) return -1;
|
|
|
|
for (int pid = 1; pid < 0x2710; pid++) {
|
|
int mib[4];
|
|
uint8_t kinfo[0x448];
|
|
size_t outlen = 0x448;
|
|
|
|
mib[0] = 1;
|
|
mib[1] = 0xE;
|
|
mib[2] = 1;
|
|
mib[3] = pid;
|
|
|
|
if (ps5debug_syscall(202 /*sysctl*/, (long)(intptr_t)mib, 4L /*namelen*/,
|
|
(long)(intptr_t)kinfo,
|
|
(long)(intptr_t)&outlen, 0L, 0L) != 0)
|
|
continue;
|
|
|
|
char comm[0x14];
|
|
memcpy(comm, &kinfo[0x1BF], 0x13);
|
|
comm[0x13] = 0;
|
|
|
|
if (strcmp(comm, name) == 0)
|
|
return pid;
|
|
}
|
|
return -1;
|
|
}
|