Files
ps5debug-NG/debugger/source/net.c
T
OpenSourcereR-dev 72eb2104c7 v1.2.6: FW 8-13.x poke/breakpoints/watchpoints + FW-agnostic title/content/version + SIGPIPE crash fix
Makes the "initial" 8-13.x support from v1.2.5 actually functional.
HW-validated on FW 8.xx, 9.xx, 10.xx and 12.xx (all watchpoint types,
breakpoints, title id, content id, version etc.). FW-agnostic by design; 11/13.x
are lower-risk but not tested.

Memory write (poke) on FW >= 8.40:
- mdbg write op (0x13) is kernel-gated with EPERM on FW >= 8.40, so pokes
  failed. Route writes through a DMAP page-table walk (kernel_copyin on the
  physical alias) on FW >= 8.40; mdbg stays the path on < 8.40 and as a
  fallback.
- PROC_ALLOC pre-faults its pages so writes land on freshly-allocated
  demand-zero memory.

Breakpoints / watchpoints on FW 9.x-13.x:
- Extend the kernel-dbreg allowlist to 9.00-13.20; HW BP/WP were silently
  no-oping on 9.x+.
- SW (INT3) breakpoints write the 0xCC via the DMAP path (mdbg rejected it
  on FW >= 8.40).
- Clear DR6 after each debug exception: FW 11/12 stops re-delivering a
  HW BP/WP trap after a few hits when the sticky DR6 status is left set;
  plus re-arm the debug regs for data watchpoints.

Game ID / Content ID / Version - firmware-agnostic:
- Resolve title id and content id by pattern-scanning the proc struct
  instead of per-FW offsets (which shifted at 8.x and 12.x).
- Foreground-app command resolves the title id robustly so the param.sfo
  game version reads correctly on 12.x.

Console crash on client disconnect (SIGPIPE):
- Closing the client mid-operation raised SIGPIPE in the server thread and
  killed the host SceShellCore. Suppress it: MSG_NOSIGNAL on sends +
  SO_NOSIGPIPE on the sockets.

Load notification now shows the running firmware version, and the credits
line was updated.

Documentation:
- Rewrote PROTOCOL.md against the v1.2.6 sources (commands, packet structs,
  status/bit-swap semantics, scan/xref wire formats, enums).
- Corrected and expanded README: per-release firmware support table with
  verification status, and accuracy fixes throughout.

Bump version 1.2.5 to 1.2.6.
2026-06-03 07:20:46 +00:00

69 lines
1.8 KiB
C

// SPDX-License-Identifier: GPL-3.0-only
#include "protocol.h"
#include "sdk_shim.h"
#include "net.h"
int net_send_all(int fd, const void *buf, int len) {
const char *p = (const char *)buf;
int left = len;
while (left > 0) {
int chunk = (left > NET_MAX_LENGTH) ? NET_MAX_LENGTH : left;
ssize_t n = send(fd, p, chunk, MSG_NOSIGNAL);
if (n <= 0) return -1;
p += n;
left -= (int)n;
}
return 0;
}
int net_recv_all(int fd, void *buf, int len, int force) {
char *p = (char *)buf;
int left = len;
while (left > 0) {
int chunk = (left > NET_MAX_LENGTH) ? NET_MAX_LENGTH : left;
int flags = force ? MSG_WAITALL : 0;
ssize_t n = recv(fd, p, chunk, flags);
if (n <= 0) return -1;
p += n;
left -= (int)n;
}
return 0;
}
static inline uint32_t bitswap32(uint32_t x) {
return ((x >> 1) & 0x55555555u) | ((x << 1) & 0xAAAAAAAAu);
}
int net_send_int32(int fd, uint32_t value) {
uint32_t wire = bitswap32(value);
return net_send_all(fd, &wire, sizeof(wire));
}
extern long __crt_syscall(long sysno, ...);
int net_select(int fd, void *readfds, void *writefds, void *exceptfds, void *timeout) {
return (int)__crt_syscall(93, fd, readfds, writefds, exceptfds, timeout);
}
int net_get_ip_address(char *out) {
if (sceNetCtlInit() < 0) return -1;
uint8_t info[0x100];
int rc = sceNetCtlGetInfo(0xE, info);
if (rc < 0) return -1;
memcpy(out, info, 0x10);
sceNetCtlTerm();
return rc;
}
void *net_alloc_buffer(uint32_t size) {
if (size == 0) return NULL;
void *p = malloc(size);
if (!p) return NULL;
volatile char *cp = (volatile char *)p;
for (uint32_t i = 0; i < size; i += 0x1000) cp[i] = 0;
if (size > 0) cp[size - 1] = 0;
return p;
}