Repository navigation
feat(artifacts): inventory Nintendo DS ROM binaries, overlays and file tables offline - #14664
Conversation
…e tables offline Recognition now claims a Nintendo DS ROM from the cartridge header: stored logo CRC 0xCF56, unit code 0, 2, or 3, an ARM9 offset after the header, and a matching logo-area or header CRC. Inspection records those header facts on the root and lists arm9.bin, arm7.bin, overlays/<cpu>/overlay_<id>.bin, FNT-named data/<path> files, and unnamed fat/<id>.bin files as stored byte ranges. A checksum mismatch, a partial table, or a range past the end of the file leaves coverage unknown. Secure-area encryption, compressed overlays, and NitroARC archives stay undecoded, and the format is registered for inventory, extraction, and the docs.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was established. SummaryAdds offline Nintendo DS ROM inspection and extraction through the existing artifact workflows.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Local ROM] --> B[Header recognition]
B --> C[Bounded header and table reads]
C --> D[Parse facts, member ranges, and limitations]
D --> E[Check paths and aggregate member bytes]
E --> F[Shared positional reader]
F --> G[Hashed inventory and metadata]
G --> H[Comparison]
G --> I[Contained extraction]
Reviews (10) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
…ntory # Conflicts: # src/domain/analysisView/artifactInventoryView.ts
# Conflicts: # .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md # .cursor-plugin/skills/reverse-engineer-anything/references/native-and-artifacts.md # docs/getting-started/cli.md
Summary
Nintendo DS cartridge ROMs (
.nds) carry an ARM9 and an ARM7 binary, overlay files and a NitroROM filesystem in one file. REA does not recognize the format today, so a.ndsfile comes back as an unknown blob. To find the CPU binaries, their load addresses, or the files in the ROM's filesystem, an analyst has to unpack it with a separate tool outside REA and loses per-member Evidence.This adds an offline
ndsartifact format.inspect-artifactandextract-artifact(and the MCPinspect_artifact/extract_artifacttools) read the cartridge header, the FAT, the FNT directory tree and both overlay tables, report the header facts and listarm9.bin,arm7.bin, each overlay file and each filesystem file as stored byte ranges that can be hashed and extracted. Nothing is decrypted, decompressed or executed. No issue exists for this; it is a format-inspection and ordinary-extraction addition within the supported contribution scope.Problem and expected behavior
Use case: given
game.nds, see its title, game code, unit code, where each CPU binary loads and starts, how many files, directories and overlays it declares, and whether its logo and header checksums hold, then extractarm9.binor a filesystem file for further analysis.Observable outcome:
ndsregardless of filename when the stored logo CRC at0x15Cis0xCF56, the unit code is 0, 2 or 3, the ARM9 binary starts after the header, and either the logo area or the header checksum at0x15Eagrees with its stored CRC-16/MODBUS value.format_metadata(kind: "nds") reports identity,arm9andarm7placement, table locations,total_used_rom_size,header_size, declared and computedlogo_crcandheader_crc, and file, directory and overlay counts.arm9.bin,arm7.bin,overlays/<cpu>/overlay_<id>.bin,data/<path>for files named by the FNT, andfat/<id>.binfor FAT files that no name or overlay reached. Each member carrieskind: "nds-entry"metadata with its role and FAT file ID, plus the overlay table row for overlays.completeonly when both checksums agree, every table was read in full and every range fits in the file. A checksum mismatch, a range past the end of the file, a partial table, a directory loop, an unsafe or repeated name, or a file ID claimed twice leaves coverageunknownwith a limitation that names the problem. A range is never clipped; an entry that does not fit is not listed.0x160bytes or an unknown unit code is refused rather than read as a container.Change and scope
src/domain/ndsRom.tsowns parsing: header recognition and CRC-16/MODBUS, header facts, table read ranges, the FAT, FNT directory walk and overlay tables, the member list and limitations.src/artifacts/NdsRomArtifactReader.tsreads the header and each table through bounded positional reads and lists members as stored ranges of the ROM throughPositionalArtifactReader.artifactFormatRecognition.ts(after every format with a leading signature, since DS has none), registration inartifactFormats.ts,ndsandnds-entrymetadata inartifactFormatMetadata.ts, inventory view, artifact graph, target format and reader type wiring, and a CI scope entry.REA_settings. The FNT walk visits each directory once and stops when it would read more bytes than the FNT holds, so its work is bounded by the table it already read. Repeated limitations of one kind are itemized up to 8 times (NDS_LIMITATION_EXAMPLES) and one more line counts the rest; this fixed ceiling keeps the report size independent of a hostile table's entry count without hiding how many problems were found.docs/nds-roms.md, a row indocs/reference/supported-targets.md, CLI examples indocs/getting-started/cli.md, the docs index and sidebar, and an NDS entry in the skill references under.agents/skills/reverse-engineer-anything/and.cursor-plugin/.Not included: secure-area decryption, compressed overlays, NitroARC (
NARC) archives inside files, the DSi extended header, and the ARM9 module-parameter footer (not part ofarm9.bin).Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the Author readiness and
Author checklist unchecked. Maintainers can help resolve open questions.
Contract and boundary impact
ndsRom.tsproduces the header facts, table interpretation and member ranges; the reader, inventory graph and inventory view consume them without reparsing raw bytes.nds.nds, classified as an archive target; existing formats unchanged. Recognition runs after all signature-based formats, so files those formats already claim are unaffected.ndsandnds-entrymetadata shapes; members carry their source ranges and SHA-256.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none committed; authored skill references updated under.agents/skills/reverse-engineer-anything/and.cursor-plugin/.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/domain/ndsRom.test.ts(CRC-16/MODBUS, recognition by logo CRC and checksum, a wrong logo CRC not claimed, header facts, a header CRC mismatch as a limitation, an unknown unit code refused, member ranges, an empty overlay table, a FAT entry past the file end, a directory loop, an unsafe name listed by file ID, a repeated name, an overlay and a directory claiming the same file ID, two overlays naming one file ID, overlapping directory file ID ranges, table read clamping, bounded itemizing of repeated limitations, directories sharing one subtable),src/artifacts/NdsRomArtifactReader.test.ts(classification as an archive target, hashed inventory, extraction of ARM9, ARM7 and a selected file),src/artifacts/NdsRomArtifactReader.boundaries.test.ts(truncated header, ARM9 past the file, FAT past the file, empty overlay table past the file, partial FNT, overlay with no FAT entry, subdirectory ID below the directory range), andsrc/application/binary/TargetFormatVocabularies.test.ts. Fixtures are built insrc/domain/ndsRom.fixture.ts; the fixture solves the logo area's CRC with zero bytes, so it carries no copy of the boot logo.ndsformat value or reader, so a.ndsfile is not recognized there. The CLI output below is executed against this branch.rea inspect-artifact game.nds --jsonon a ROM generated byndsRomFixture(). Excerpt of the inventory substep's rootformat_metadata:{ "kind": "nds", "title": "REA TEST", "game_code": "REAE", "maker_code": "01", "unit_code": 0, "unit": "nds", "rom_version": 1, "arm9": { "rom_offset": 16384, "entry_address": 33556480, "ram_address": 33554432, "size": 256 }, "arm7": { "rom_offset": 16640, "entry_address": 37224448, "ram_address": 37224448, "size": 128 }, "fnt": { "offset": 16800, "length": 64 }, "fat": { "offset": 16864, "length": 24 }, "arm9_overlay_table": { "offset": 16768, "length": 32 }, "arm7_overlay_table": { "offset": 0, "length": 0 }, "total_used_rom_size": 16998, "header_size": 16384, "logo_crc": { "declared": 53078, "computed": 53078 }, "header_crc": { "declared": 11432, "computed": 11432 }, "file_count": 3, "directory_count": 2, "arm9_overlay_count": 1, "arm7_overlay_count": 0 }Coverage was
{"scope":"container-entries","status":"complete"}and the occurrences were:{"logical_path":"arm7.bin","declared_size":128,"source_location":{"offset":16640,"length":128}} {"logical_path":"arm9.bin","declared_size":256,"source_location":{"offset":16384,"length":256}} {"logical_path":"data/data/a.bin","declared_size":8,"source_location":{"offset":16990,"length":8}} {"logical_path":"data/readme.txt","declared_size":30,"source_location":{"offset":16960,"length":30}} {"logical_path":"overlays/arm9/overlay_0000.bin","declared_size":64,"source_location":{"offset":16896,"length":64}}The overlay member's metadata was
{"kind":"nds-entry","role":"arm9-overlay","file_id":0,"overlay":{"overlay_id":0,"ram_address":34603008,"ram_size":64,"bss_size":16,"static_init_start":34603040,"static_init_end":34603044,"flags":0}}.rea extract-artifact game.nds --output-root "$PWD/out" --jsonwrote all five members withcontainment_verified: true;data/readme.txt(30 bytes) readshello from a synthetic DS ROM, andarm9.binhas SHA-2560240065834f267ff0359380b5888a2835e77f4cb68345b5ee8ec685efcf03d09, matchingshasum -a 256on the written file.Limitation example: on a copy whose FAT entry for file 2 was changed to end past the file,
inspect-artifactreturned coverage{"scope":"container-entries","status":"unknown"}, did not listdata/data/a.bin, and added the limitation "DS FAT entry 2 spans 16990-17254, outside the 16998-byte file; file 2 is not listed."Refusal example: a copy cut to 256 bytes and a copy with unit code 7 both exited 1 with
"code":"target_unavailable","message":"Cannot open artifact: unsupported binary format."and"constraint":"file_format_rejected".For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.
Not a boundary fix. The new reader's boundary tests cover truncated input, ranges and tables past the end of the file, and malformed table references. Cancellation is handled by the shared positional reader and is not separately tested for this format.
For evidence-bearing changes:
Demo
Rendered walkthrough of the CLI inspect output above (simulated terminal, values taken from a real run on generated fixtures).
rea-nds-demo.mp4
Validation performed
npm run test:local -- src/application/binary/TargetFormatVocabularies.test.ts src/artifacts/NdsRomArtifactReader.boundaries.test.ts src/artifacts/NdsRomArtifactReader.test.ts src/domain/ndsRom.test.ts: 4 files, 83 tests passednpm run check:fast(typecheck, lint, architecture guards): passed, "Architecture guards passed across 3135 source files."npm run docs:check: passed, includingtests/conformance/readmeConsistency.test.ts(8 tests)npm run format:check: "All matched files use the correct format."npm run compile, thennode scripts/rea.mjs inspect-artifactandextract-artifacton generated ROMs: output as shown aboveCompatibility, safety, and release
nds./,\,..or non-ASCII bytes, or a repeated name, is reported and its file is listed underfat/<id>.bininstead. Table reads are capped at the format's ID-space ceilings before allocation, directory loops are walked once, and the number of itemized limitations is bounded.AI was used for assistance.
Author readiness
Human owner: @mvanhorn
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.