Skip to content

NSP script: read the title ID from the package when it has no ticket and no tag - #666

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:nsp-title-id-from-package
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:nsp-title-id-from-package

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

What and why

An NSP with no ticket (a standard-crypto dump, a repack) and no [0100…] tag in its file name ended the build with [RED] no NSP with a readable title ID, although the keys open the package. title_of read a title ID only from the ticket's file name or from a tag in the package's file name. Renaming the file with its title ID worked around it, which pointed at the cause.

With neither, title_of now reads the title ID from the package: nx_extract <prod.keys> --title <package> opens it, decrypts each meta NCA's header with the keys' header_key and prints the lowest title ID (the base game's before its update's or a DLC's). The ticket and then the tag keep their precedence and cost what they did, since the fallback runs only when both are missing. NSP, NSZ (the meta NCA is not compressed), XCI and XCZ take the same path. nx_extract is built into a temporary folder for it, because the build folder is named after the title ID. No key value is printed.

Reported in LNPANDY/NX2Apple#177 by @ericklobet-beep. @1upbyte's rename of the file pointed at the cause. Reference entry: docs/reference/packing.md.

Checked

  • Tests: all of dm/tools/tests (612 tests, OK, 17 skipped). test_nsp_scan.py gains tests for the precedence (ticket, tag, package, the reader is never called when a ticket or tag names the package), for scan_nsps with ticketless untagged base, update and DLC packages, for the unchanged [RED] stop when nothing reads, and for the reader's command line and output handling. The reader's C# side needs real keys, so the tests stub it at its boundary and do not exercise it.
  • Real packages: with /Volumes/NX/keys/prod.keys, nx_extract --title printed the right title ID for the Tears of the Kingdom base NSP (no ticket in it), its update, three Hades and Smash packages including a DLC, and the Smash and Batman NSZ files. Through symlinks without a tag, title_of returned None for the ticketless base and scan_nsps with the reader resolved base and update to 0100F2C0115B6000. No XCI or XCZ was at hand, they go through the same OpenNsp code.
  • Games run, with title ID and version: none, the change stops before the build.
  • Devices and OS: macOS 27, Apple silicon.
  • Lint: dm/tools/lint_python.py reports 0 new findings.

Docs

  • The finding is in its docs/reference/packing.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • No game files, keys or data extracted from a game in the change or the attachments

…ves its title ID from its own meta NCA

title_of took the title ID only from the ticket's file name or a [title ID] tag in the file name. An NSP without a ticket (a standard-crypto dump, a repack) and without a tag ended the scan with 'no NSP with a readable title ID', although the keys open it. With neither, title_of now asks nx_extract --title, which reads the meta NCA's header (header_key) and prints the lowest title ID. NSP, NSZ, XCI and XCZ all work. The ticket and the tag keep their precedence and cost nothing more.
seedds added a commit that referenced this pull request Oct 30, 2026
…ves its title ID from its own meta NCA (PR #666)

title_of took the title ID only from the ticket's file name or a [title ID] tag in the file name. An NSP without a ticket (a standard-crypto dump, a repack) and without a tag ended the scan with 'no NSP with a readable title ID', although the keys open it (LNPANDY/NX2Apple#177). With neither, title_of now asks nx_extract --title, which reads the meta NCA's header (header_key) and prints the lowest title ID. NSP, NSZ, XCI and XCZ all work. The ticket and the tag keep their precedence and cost nothing more.

On landing: nx_extract's usage lists --title; without dotnet the reader stops with a BuildError that says what to do instead of a Python traceback (tested); the reference entry links Tears of the Kingdom's note, which lists it under "Found on this game".

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thank you @v0lumehi, this is landed on main as 85578fc, with you as co-author. Reading the title ID from the meta NCA is the right fix, and it applies to every game. I checked it on real packages: base, update and DLC NSPs, two XCIs, and ticketless DLC packages behind untagged names.

Three small additions on landing:

  • nx_extract's usage message now lists --title.
  • Without dotnet, the reader now stops with a BuildError that says what to do (install .NET SDK 10 or add the title ID to the file name) instead of a Python traceback. There is a test for it in test_nsp_scan.py.
  • The packing.md entry links Tears of the Kingdom's note, and that note lists the fix under "Found on this game".

Closing since it went in as a separate commit.

@seedds seedds closed this Oct 30, 2026
ZhaowTao added a commit to ZhaowTao/nxnative that referenced this pull request Nov 7, 2026
…off (Persona 5 Royal)

A program's shader libraries are loaded in the background as soon as the game makes
the program (nvn_mtl.m mtl_prog_prefetch, from nvnProgramSetShaders), whether or not a
draw uses them. It had a switch, DM_NVN_PREFETCH=0, but no front end could offer it:
dm/ios/Sources/player_env.h filters the DM_NVN_ prefix as a diagnostic, so it cannot be
saved from Documents/env.txt either.

On iOS a loaded library is a mapping the process keeps for good: NvShader holds the
MTLFunction, the function holds the library, and the shader table keeps the shader by
key. A game with a very large shader tree fills the process's mapping limit that way and
is ended with vnode-limit. Persona 5 Royal is 24,826 pipelines, 88,792 metallib and
30,646 json (119,439 files, 1.3 GB) and was ended after 60-100 s in every configuration
tried on an iPhone 17 Pro, while Breath of the Wild (4,829 pipelines) and Rhythm Heaven
Groove (100 metallib) run for hours on the same device and build
(LNPANDY/NX2Apple#665, seedds#666).

Off, one run held 30 fps for 34 minutes: 61,200 presents, p50 33.34 ms, 1,773 MiB, 410,000
audio callbacks with no underrun, no crash; with it on the same build aborted in a
prefetch worker at 5 min 33 s.

- settings.tsv gains the row for every NVN game, in Performance, with the iOS default
  from the profile and the Mac default on (the shape DM_PSO_MTL4 has).
- player_env.h carries the exception DM_NVN_ENC_THREAD already has, so a player build
  keeps the launcher's value.
- game.py takes the profile key nvn_prefetch (on / off) and writes DM_GAME_NVN_PREFETCH,
  which settings.py resolves as the iOS default.
- Persona 5 Royal's profile sets it off, so a player never has to find the row.
- The test covers the row's graphics API, both platforms' defaults and the Mac.

Off bounds nothing by itself: the mappings still grow, from what is drawn instead of what
is in the program, and a long session still ends somewhere. The prefetch staying unbounded
is seedds#665's subject.
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…ves its title ID from its own meta NCA (PR seedds#666)

title_of took the title ID only from the ticket's file name or a [title ID] tag in the file name. An NSP without a ticket (a standard-crypto dump, a repack) and without a tag ended the scan with 'no NSP with a readable title ID', although the keys open it (LNPANDY/NX2Apple#177). With neither, title_of now asks nx_extract --title, which reads the meta NCA's header (header_key) and prints the lowest title ID. NSP, NSZ, XCI and XCZ all work. The ticket and the tag keep their precedence and cost nothing more.

On landing: nx_extract's usage lists --title; without dotnet the reader stops with a BuildError that says what to do instead of a Python traceback (tested); the reference entry links Tears of the Kingdom's note, which lists it under "Found on this game".

Co-authored-by: v0lumehi <[email protected]>
lucaszhongsj pushed a commit to lucaszhongsj/nxnative that referenced this pull request Nov 19, 2026
…off (Persona 5 Royal)

A program's shader libraries are loaded in the background as soon as the game makes the
program (nvn_mtl.m mtl_prog_prefetch, from nvnProgramSetShaders), whether or not a draw
uses them. It had a switch, DM_NVN_PREFETCH=0, but no front end could offer it:
dm/ios/Sources/player_env.h filters the DM_NVN_ prefix as a diagnostic, so it cannot be
saved from Documents/env.txt either.

On iOS a loaded library is a mapping the process keeps for good: NvShader holds the
MTLFunction, the function holds the library, and the shader table keeps the shader by
key. A game with a very large shader tree fills the process's mapping limit that way and
is ended with vnode-limit. Persona 5 Royal is 24,826 pipelines, 88,792 metallib and
30,646 json (119,439 files, 1.3 GB) and was ended after 60-100 s in every configuration
tried on an iPhone 17 Pro, while Breath of the Wild (4,829 pipelines) and Rhythm Heaven
Groove (100 metallib) run for hours on the same device and build
(LNPANDY/NX2Apple#665, seedds#666).

Off, one run held 30 fps for 99,600 frames (about 55 minutes) with the switch in
Documents/env.txt, the path a player takes: no jetsam, no vnode-limit, no argument buffer
abort. 34 minutes / 61,200 presents was the same switch set as a launch environment; with
it on the same build aborted in a prefetch worker at 5 min 33 s.

- settings.tsv gains the row for every NVN game, in Performance, with the iOS default
  from the profile and the Mac default on (the shape DM_PSO_MTL4 has).
- player_env.h carries the exception DM_NVN_ENC_THREAD already has, so a player build
  keeps the launcher's value.
- game.py takes the profile key nvn_prefetch (on / off) and writes DM_GAME_NVN_PREFETCH,
  which settings.py resolves as the iOS default.
- Persona 5 Royal's profile sets it off, so a player never has to find the row.
- docs_patches.py classifies the new key (`game` to `host`, memory), or it exits on a
  switch it cannot classify and `tools/engine.py sync` fails once the patches apply. The
  generated docs/agents/game-patches.md is left alone: on this pin the generator's own
  profile-switch table is down to one row (game.py's header_one split left `switches()`
  reading the four lines of header()), so a hand-edit would fight the next regeneration.
- The test covers the row's graphics API, both platforms' defaults and the Mac.

The tests pass (17 in test_launcher_settings.py). Off bounds nothing by itself: the
mappings still grow, from what is drawn instead of what is in the program, and a long
session still ends somewhere.

Upstream-Status: forwarded seedds#1209
Reason: Persona 5 Royal fills the iOS mapping limit and is ended after 60-100 s; the prefetch switch existed but no front end could reach it, and the game ships it off in its profile
Issue: LNPANDY/NX2Apple#665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants