13 Commits
Author SHA1 Message Date
HexwellandClaude Fable 5 7e64b92d98 refactor(log): route every call site through the shared logger
There were seven ways to log, each invented where the previous one was not
reachable:

  OnionHEN_log   libonion_platform, the only one with a file sink
  shellui_log    libonion_ipc, klog only — because it did not depend on
                 libonion_platform
  game_log       same body as shellui_log
  onion_ipc_log  same body again
  logf           libonion_ipc's IPC server, with a sink the host had to
                 register
  log_msg        onion_elfldr_server
  crash_log      util's fault handler, plus a second copy in common/
  boot_log       bootstrapper's fault handler
  klog_printf / klog_puts / printf / puts, called directly

A message's destination therefore depended on which module happened to emit
it: ShellUI's ~300 records went to volatile klog and never reached a log file,
while the daemon's went to klog, stdout and disk.

Everything now goes through the LOG_* macros. All seven legacy entry points
are gone, and klog_printf survives only as a sink inside log.c.

The bare -nostdlib libraries deliberately did not get their own backend. Those
flags only affect the static library's own link step; each is linked into a
host with full libc and pthread, which is why they already called vsnprintf.
A second backend would have recreated the split this removes.

Levels were inferred from message text rather than applied uniformly — the old
entry points carried no severity, so a blanket mapping would either bury real
failures at debug or promote routine chatter to error. Result: 291 error, 63
warn, 140 info, 309 debug.

Consequences worth noting:

  * ShellUI records now reach the log file, so a user report finally contains
    what the injected process did. In release builds most of them are debug
    and compile out, so this costs nothing on a retail unit.
  * The IPC server's log-sink injection is gone; both servers registered the
    same forwarder.
  * common/backtrace.cpp and backtrace.hpp are deleted. That was a third copy
    of the frame walking plus its own crash_log, and every caller of
    printBacktrace/printBacktraceForCrash had already been commented out.
  * Fault handlers use onion_log_emergency, so crash records go to the same
    file as everything else instead of a separate crash log.

The shared entry point carries a printf format attribute, which the old
shellui_log explicitly avoided. That attribute found seven real format
defects: %p given typed pointers, %lx given a MonoObject*, %p given a
uint64_t, and %u given an unsigned long. Four of them only compile in debug
builds, so they had gone unnoticed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 21:10:08 +08:00
HexwellandClaude Fable 5 8db337607a refactor(build): extract shared CMake target helpers
All 17 module CMakeLists repeated the same prologue: language standards, the
PS5 SDK header paths, a clang check, the cross-compile triple, the output
directory layout and an objcopy strip step. The triple appeared 17 times and
the strip block 6 times, each needing manual sync.

Add source/cmake/OnionTarget.cmake with onion_module_prologue,
onion_output_dirs and onion_strip_debug. Language standards stay opt-in
arguments because the loader-side C modules are C17 while the rest are C11,
and a shared default would silently downgrade them. Per-module compiler flags
are left alone since the modules genuinely differ.

Drop IS_SUBPROJECT and IS_CLANG, which were assigned in 11 and 6 modules
respectively and never read anywhere.

Add CONFIGURE_DEPENDS to the seven source-listing globs that lacked it, so a
newly added source file triggers a re-configure instead of being silently
omitted from the build.

Hoist -DDEBUG onto the shared C flags in the five modules that only passed it
to C++, so both languages in a target see the same macros. No .c file keys
off DEBUG today, so this changes no behaviour.

Compile and link flags were captured from build.ninja before and after: all
132 compile edges and 17 link edges are unchanged except for the intended
-DDEBUG addition.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 19:50:30 +08:00
Hexwell a27eb928a1 fix: isolate private stack for remote ptrace calls
Use a red-zone-safe, ABI-aligned stack window for pt_call, pt_call2, and
pt_syscall so elfldr_load cannot clobber SceShellUIMain mid-SwapBuffers.
Fix single-step return detection to compare against entry_rsp, and add
inject stage logs for the load/args window.
2026-07-16 23:23:50 +08:00
Hexwell 31ad34afb7 chore: remove orphaned headers 2026-07-16 17:48:16 +08:00
Hexwell aad2cdaabc refactor: rebrand OrionHEN to OnionHEN
Rename product, namespaces, libraries, paths, and assets from Orion/orion
to Onion/onion across the tree. TCP stack-shutdown magic is now ONIO
(0x4F4E494F) to match the corrected branding.
2026-07-15 18:23:16 +08:00
Hexwell 598cc586e9 refactor(inject): rename to set_ucred_to_ptrace; drop attach retries
Root fix stays: elevate with PTRACE_AUTHID only. Rename away from
set_ucred_to_debugger so the API cannot imply DEBUG_AUTHID. Remove
pt_attach ECHILD poll loops and multi-attempt toolbox inject — those
were workarounds, not the cause. Keep a single waitpid(WUNTRACED) after
PT_ATTACH.
2026-07-10 18:36:24 +08:00
Hexwell 5880505d16 refactor: unify pt/elfldr into liborion_elfldr and deepen proc/platform seams
Merge the three pt/elfldr clones (bootstrapper, libNineS, unpacker) into a
single liborion_elfldr with one authid policy (elevate once at inject entry,
never per ptrace). Wire consumers through shared headers; drop dead unpacker
loader sources. Route shellui if_exists through orion/platform and daemon
ShellUI/BigApp pid lookup through orion_proc. Document the layout and audit
status in docs/arch.md and docs/architecture-audit.md.
2026-07-10 17:35:49 +08:00
Hexwell 8f6564e11b refactor(NineS): consume liborion_proc for proc/ucred
Drop duplicate allproc/ucred sources from NineS. Headers are shims to
orion/*, injector uses get_module_info, and CMake builds orion_proc before
NineS so inject and daemon share one process stack.
2026-07-10 15:38:43 +08:00
Hexwell f75fe02830 refactor(daemon): split msg.cpp into inject, settings, and FS modules
Keep IPC_loop as the only transport entry in msg.cpp. Move toolbox/fps
injection, LoadSettings, and remount/chmod/reply helpers into dedicated
TUs behind daemon_ops.hpp so inject changes no longer touch the IPC ring.
2026-07-10 15:38:42 +08:00
Hexwell 2eb3b7ec1d chore: remove dead assets and slim error translator
Drop unused hello_world ELF blob, sqlite headers/lib, and orphan
demo headers. Replace the 14k SCE error dump with a ~300-entry
install/BGFT table for DPI, cutting ~7MB from the source tree.
2026-07-10 14:51:54 +08:00
Hexwell 37f549b899 feat(nines): add get_module_info and broader module name matching
Match filename, libname, and sandboxed path basename. Prefer a non-allocating
get_module_info API and fix handle leaks on the successful get_module_handle path.
2026-07-10 13:47:16 +08:00
Hexwell 25c0500016 update: harden libNineS inject with scoped authid and int3 wait
Align injector/pt with kylin-core: elevate debugger authid for the inject
window only, and waitpid after stager int3 before restoring registers.
2026-07-10 01:04:15 +08:00
Hexwell 37b0ff3143 init: init 2026-07-09 23:48:02 +08:00