Commit Graph

3 Commits

Author SHA1 Message Date
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
67f8a5338d psin_data: reject block tables that run past the region; read 0x62 enums both ways
Review on #1077 (@kapitche): block sizes came straight from the table, so a
damaged size made the walker allocate gigabytes. block_table now rejects
blocks that end past the first section. Every real container fills the region
exactly, so no counts change.

The same review asked why 0x62 was read as s32. LENM lists values on both
sides of the sign bit for 0x62 enums, so a value now counts as listed under
either reading. Unlisted enum values drop from 31,624 to 827; the 30,577
'hash-like' values in story000_script were this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:57:44 +00:00
eabcb993a7 psin_data: decode PSIN instance data through the LSCH schema (PROC-46)
The region between the PSIN header and LSCH is a block table plus its data
blocks: 16-byte rows {u32 type, u32 size, 0xaa x 8}, 8 bytes of 0x70 padding,
then the blocks, each 16-byte aligned, ending exactly at the first section.
LRSC's 0DRP header names the root block at +0x10. Pointers are u64 with the
block number in the low 20 bits and the byte offset above.

tools/psin_data.py walks every value reachable from the root (embedded
structs, struct and string pointers, the 0x5c/0x52/0x54/0x50 arrays, the 0x71
binary map, the 0x75 SwissTable and the 0x73 open-addressed table, the 16-byte
0x44 string with its in-place form) and reports counts and checks only.
Unknown member types are counted and skipped.

Over the 17,507 complete containers with LSCH and LRSC in package 1.0.2.1 the
block tables fill the region 17,507 times and the walk reaches 129,100,004 of
129,117,812 block bytes (99.986%). The rest is behind the three member types
it does not decode (0x5a, 0x76, 0x77).

docs/psin.md gets an "Instance data" section. The header's +8 "version" and
+12 "hash table bytes" are the first block-table row: 22 is a 0x16 block,
found on 1,010 of 18,640 streams. The type-code readings the instance data
confirms are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:34:55 +00:00