ps2pack stub: pass the launch arguments to the payload #4

Merged
techwritescode merged 1 commit from stub-forward-args into main 2026-09-29 23:37:52 +00:00

The packed program lost its launch arguments. The stub calls SetupThread on its own stack, so the kernel stores the launch arguments in the stub's buffer; the payload's own SetupThread then gets nothing usable and argv[0] reads as garbage. For ps2link that meant the working directory fell back to host:/ and IPCONFIG.DAT was never found next to the ELF.

The stub now keeps the arguments in its own buffer (behind a pid word, laid out as struct sargs_start) and, after unpacking, starts the payload with ExecPS2 using them, like the stock ps2-packer stub.

Checked in PCSX2 by printing the bytes of argv[0]: unpacked host:unpacked.elf; packed with the old stub 01 00 00 ...; packed with this stub host:packed-exec2.elf. On hardware, ps2link launched from mc0:/ABC now gets cwd=mc0:/ABC and passes the network tests.

🤖 Generated with Claude Code

The packed program lost its launch arguments. The stub calls `SetupThread` on its own stack, so the kernel stores the launch arguments in the stub's buffer; the payload's own `SetupThread` then gets nothing usable and `argv[0]` reads as garbage. For ps2link that meant the working directory fell back to `host:/` and `IPCONFIG.DAT` was never found next to the ELF. The stub now keeps the arguments in its own buffer (behind a pid word, laid out as `struct sargs_start`) and, after unpacking, starts the payload with `ExecPS2` using them, like the stock ps2-packer stub. Checked in PCSX2 by printing the bytes of `argv[0]`: unpacked `host:unpacked.elf`; packed with the old stub `01 00 00 ...`; packed with this stub `host:packed-exec2.elf`. On hardware, ps2link launched from `mc0:/ABC` now gets `cwd=mc0:/ABC` and passes the network tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ps2pack stub: pass the launch arguments to the payload
Some checks failed
Build / build (push) Successful in 54s
Release / build (amd64, linux) (push) Successful in 55s
Release / build (amd64, windows) (push) Successful in 55s
Release / build-macos (push) Has been cancelled
Release / release (push) Has been cancelled
9b4503efd8
The stub's own SetupThread made the kernel hand the launch arguments to the stub, so the
payload's SetupThread got none and argv[0] read as garbage (cwd fell back to host:/).
The stub now keeps them in its own buffer and starts the payload with ExecPS2 using them,
as the stock ps2-packer stub does.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
techwritescode deleted branch stub-forward-args 2026-09-29 23:37:53 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ps2/tools!4
No description provided.