Commit Graph

64 Commits

Author SHA1 Message Date
Matt Nadareski
cf586f7af2 Add Nintendo Disc extensions tests 2026-05-12 22:47:19 -04:00
Matt Nadareski
b805c91cb3 Add notes and reconfigure based on IO porting 2026-05-12 21:55:11 -04:00
Matt Nadareski
2a0e8e2eb0 First round of cleanup for DolphinLib additions 2026-05-12 20:33:53 -04:00
Dimensional
49aa6895b6 Dolphin lib (#85)
* Add GCZ, WIA/RVZ, and NintendoDisc (GameCube/Wii) format support

Port of DolphinIsoLib into SabreTools.Serialization architecture:
- Data.Models: GCZ/, WIA/, NintendoDisc/ model subdirectories (15 files)
- Serialization.Readers: GCZ, WIA, NintendoDisc readers
- Serialization.Writers: GCZ, WIA writers (structural metadata; full round-trip TODO)
- Wrappers: NintendoDisc, GCZ, WIA wrappers with Encryption partial class
- Wrappers: WiaRvzCompressionHelper (BZip2/LZMA/LZMA2/Zstd, net462+ guarded)
- WrapperType + WrapperFactory: GCZ, WIA, NintendoDisc entries added

GetInnerWrapper() decompression and NintendoDisc.Extraction FST extraction
are stubbed with TODO comments pending full implementation.

* Implement GetInnerWrapper for GCZ and WIA, full NintendoDisc extraction

* Add GCZ/WIA/RVZ write pipeline and Nintendo disc compression helpers

* Add WIA/RVZ table decompression, NintendoDisc/GCZ printing, NintendoDisc detection for .iso files

* Fix NintendoDisc header layout, GC magic, and add embedded disc header to WIA/GCZ printing

- Fix GCMagicWord: 0xC23D3C1F -> 0xC2339F3D (confirmed from Dolphin DiscUtils.h)
- Fix disc header field layout to match Dolphin's confirmed offsets:
  MakerCode is bytes 4-5 of the 6-char GameId (no separate field at 0x006),
  DiscNumber at 0x006, DiscVersion at 0x007, unused region is 14 bytes (0x00A-0x017)
- Update NintendoDisc reader: derive MakerCode from GameId[4..5], fix skip count
- Add ParseDiscHeaderOnly() to reader for partial (short) stream parsing
- Guard DisableHash/DisableEnc reads at the 0x080 boundary for 128-byte embedded headers
- Guard DOL/FST skip for streams shorter than full 0x440 boot block
- Fix WrapperFactory: NintendoDisc magic detection now precedes .iso -> ISO9660 fallback
- Add GameId-prefix heuristic in WrapperFactory for GC discs lacking magic word
- Add GameId-prefix platform fallback in reader for GC discs without GCMagicWord
- Add DiscHeader property to WIA wrapper (parsed from Header2.DiscHeader bytes)
- Add DiscHeader property to GCZ wrapper (decompresses first block only)
- Add ReadDiscHeader() helper to GCZ for lightweight first-block decompression
- Print embedded disc header (Game ID, Maker, Disc/Rev, Title) in WIA.Printing.cs and GCZ.Printing.cs

* Fix Wii partition extraction: correct IV, FST size shift, partition naming

- Block decryption: IV is at raw block offset 0x3D0 (still-encrypted),
  matching Dolphin/DolphinIsoLib WiiPartitionDecryptor.DecryptBlock exactly.
- FST size field at boot.bin 0x428 is also stored >>2 on Wii; apply <<2
  to get true byte size.
- Partition folder naming now matches DolphinIsoLib WiiDiscExtractor exactly:
  type 0->GM+n, 1->UP+n, 2->CH+n, printable ASCII unknown->raw 4-char string,
  non-printable->P{index}. SSBB VC channels extract as HA8E, HA9E, etc.
- ExtractionTool peek buffer increased from 16 to 32 bytes.

Verified: SSBB GM0 extracts 5524 files, boot.bin/fst.bin byte-identical
to Dolphin reference extraction.

* Fix FST extraction: create zero-byte files instead of skipping them

Files with fileSize=0 in the FST were silently skipped. Now they are
created as empty files, matching Dolphin/DolphinIsoLib behavior.

Verified: SSBB now extracts 5958 files with 0 missing, 0 extra,
0 size mismatches, and 0 hash mismatches vs DolphinIsoLib reference.

* Add GCZ/WIA/RVZ virtual stream extraction via NintendoDisc wrapper

* Address PR #85 review comments (Copilot + mnadareski)

* Address PR #85 review comments

* Replace custom endian helpers and SHA1 with SabreTools.IO equivalents

* Update GCZ.Printing.cs

* Update NintendoDisc.Printing.cs

* Update WIA.Printing.cs

* Add WIA/RVZ Wii partition crypto round-trip support

- Add AesCbc internal helper (BouncyCastle AES-CBC encrypt/decrypt)
- Add NintendoDisc.CommonKeyProvider hook for injectable test keys
- Fix sha1.Terminate() missing in all three ComputeSha1 helpers in WIA.cs
- Fix Wii partition dataOff alignment to 0x8000 boundary
- Add WIA.EncryptWiiGroup (internal) for re-encrypting plaintext groups
- Add WIA.DumpIso to WIA.Writing.cs (WIA/RVZ -> flat ISO conversion)
- Add WiaVirtualStream on-demand group decompression
- Add _preDecryptedReader bypass on NintendoDisc for WIA extraction path
- Add WIATests.cs with Wii crypto round-trip test using synthetic data
- Move DumpIso from WIA.Extraction.cs to WIA.Writing.cs
- Bump DumpIso read buffer from 1 MiB to 2 MiB (aligns to WIA chunk size)
- Add InternalsVisibleTo SabreTools.Wrappers.Test in csproj

* Remove hardcoded Wii common keys from NintendoDisc.Encryption

- Delete the embedded WiiCommonKeyRetail and WiiCommonKeyKorean byte
  arrays from NintendoDisc.Encryption.cs.
- Make CommonKeyProvider public so any caller (not just tests) can
  inject keys; DecryptTitleKey now returns null when no key is
  available for the requested index rather than falling back to
  hardcoded values.
- Add NintendoDiscEncryptionTests.cs:
    - Argument guard and no-provider tests for DecryptTitleKey.
    - Fake-key round-trip test (encrypt then decrypt with injected key).
    - Integration test that reads TestData/NintendoDisc/keys.json,
      verifies each key against hardcoded SHA256 constants, and skips
      silently if the file is absent or the keys do not match.
    - LoadKeyProvider helper (named JSON format, index-keyed).
- Add [Collection(NintendoDisc)] to both NintendoDiscEncryptionTests
  and WIATests to prevent parallel access to the static
  CommonKeyProvider from racing between test classes.
- Add TestData/NintendoDisc/keys.json.example documenting the
  expected key file format.
- Add Newtonsoft.Json reference to SabreTools.Wrappers.Test.csproj.

* Didn't actually commit the changes. My bad. Fixed.

* Edited a comment

* Added in XUnit outputs that show up in Test Viewer in VS

---------

Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
2026-05-12 10:41:32 -04:00
Matt Nadareski
9ed671f595 Editorconfig cleanup 2026-04-28 09:26:49 -04:00
Deterous
a2b9db3afd PC Engine CD-ROM Header Support (#91) 2026-04-28 09:24:36 -04:00
Matt Nadareski
49ea4302b6 Add mostly-working version of JSON printing to older .NET 2026-04-27 18:56:10 -04:00
Matt Nadareski
59f76b1036 Editorconfig cleanup 2026-04-27 13:28:23 -04:00
Deterous
6fa3631c80 Add Opera FileSystem support (#90)
* Add Opera FileSystem support

* Fix tests
2026-04-27 13:24:30 -04:00
Matt Nadareski
b24f96ac0f Fix documentation 2026-04-25 21:51:42 -04:00
Matt Nadareski
201af08f5f Document alternative TGZ layout 2026-04-25 21:45:53 -04:00
Deterous
c179cf410b XboxISO separate functions for partition extraction (#89)
* XboxISO funcs for partition extraction

* Add new parameter with default
2026-04-19 23:59:39 -04:00
Matt Nadareski
2462305e0b Editorconfig cleanup, use extensions 2026-04-19 09:33:55 -04:00
Deterous
e383771fb6 XRD File Support (#87) 2026-04-19 09:04:25 -04:00
Deterous
94f86fe1d1 Peek in XDVDFS, Support XB00104M (#86)
* Peek in XDVDFS, Support XB00104M

* var
2026-04-18 21:30:44 -04:00
Deterous
9a59f7c540 Fix SVOD serialization and printing (#84)
* Fix SVOD printing

* Fix SVOD descriptor

* Clearer check
2026-04-17 09:39:10 -04:00
Matt Nadareski
5694cdf9a9 Editorconfig cleanup 2026-04-15 08:44:42 -04:00
Deterous
dab850103b XDVDFS FileWriter (#83) 2026-04-15 08:41:55 -04:00
Matt Nadareski
5b22902d03 Add QD image writer 2026-04-14 12:45:31 -04:00
Matt Nadareski
4e70a7665c Add NES cart writer 2026-04-14 12:33:27 -04:00
Matt Nadareski
650402df39 Add FDS image writer 2026-04-14 12:17:42 -04:00
Matt Nadareski
fead0d781c Add LNX cart writer 2026-04-14 12:03:19 -04:00
Matt Nadareski
3896b75b3b Add A78 cart writer 2026-04-14 11:59:12 -04:00
Matt Nadareski
ea2a1daadf Add NES image writing 2026-04-14 10:55:09 -04:00
Matt Nadareski
5968a367e8 Add FDS image writing 2026-04-14 10:33:30 -04:00
Matt Nadareski
b439cc3e35 Attempt to avoid input file overwriting 2026-04-14 10:27:23 -04:00
Matt Nadareski
3675a8ac75 Fix flaw in writable interface 2026-04-14 10:25:05 -04:00
Matt Nadareski
e16b485a7b Add LNX cart writing 2026-04-14 10:19:04 -04:00
Matt Nadareski
b51879bbec Add A78 cart writing 2026-04-14 10:13:05 -04:00
Matt Nadareski
f26c5bfebc Add IWritable interface 2026-04-14 09:59:23 -04:00
Matt Nadareski
4d5e7eb755 Minor editorconfig change 2026-04-13 10:04:24 -04:00
Matt Nadareski
7d14681fc9 Editorconfig and some manual cleanup 2026-04-13 09:43:40 -04:00
Deterous
0e5380ad1a Xbox ISO Support (#81)
* Xbox ISO support

* Fixes

* Print XGDType

* Review
2026-04-13 09:39:29 -04:00
Matt Nadareski
2494b44647 Start scaffolding disc image wrapper helper 2026-04-11 20:56:46 -04:00
Deterous
c88ea9ce30 Support optional header in STFS, fix endianness in Descriptor (#80)
* Fix endianness in STFS Descriptor

* Support optional header for installer packages

* Fix field types

* Fix syntax

* Fix build
2026-04-09 09:57:26 -04:00
Matt Nadareski
574b993985 Editorconfig cleanup of STFS 2026-04-07 22:20:14 -04:00
Deterous
7485a43364 Secure Transacted File System (STFS) Support (#78)
* Initial STFS support

* Fix build errors

* Fix more build errors

* Final fix

* Cleanup printer

* Fix indent
2026-04-07 22:14:39 -04:00
Matt Nadareski
adedc502e3 Editorconfig cleanup of Xenon 2026-04-06 10:46:04 -04:00
Deterous
388567c9c6 Initial XEX support (#77)
* Initial XEX support

* Fix build

* Fix reader

* Fix reader, again

* Rename field to CertificateOffset

* Update reader

* Update Printer

* Update Printer

* Parse Certificate

* More info

* Fix build
2026-04-06 10:43:32 -04:00
Matt Nadareski
81c47b297d Editorconfig cleanup of ZAR 2026-04-02 02:23:02 -04:00
Deterous
5bb8557555 ZArchive support (#75)
* ZArchive support

* Fix offset record format

* Simplfiy Extensions

* Delete unused writers and test data

* Rework reader

* Fix build
2026-04-02 02:18:47 -04:00
Deterous
28f4808dbb Read/write with variable initial offset (#74) 2026-03-29 21:54:16 -04:00
Matt Nadareski
0debcaa8d1 Slightly fix wrapper factory 2026-03-28 23:25:58 -04:00
Matt Nadareski
f1558587c3 Printer was really redundant 2026-03-28 23:12:41 -04:00
Matt Nadareski
d39c2e81d0 XDVDFS editorconfig cleanup 2026-03-28 23:06:46 -04:00
Deterous
00ee106f4a Xbox DVD Filesystem support (XISO) (#73)
* Xbox DVD Filesystem support (XISO)

* Apply file attributes to extracted files

* Fix

* Fix build and PR review

* Support Archive file attribute
2026-03-28 22:59:30 -04:00
Matt Nadareski
8de1fbc52f Reduce enum overhead in metadata 2026-03-26 22:51:14 -04:00
HeroponRikiBestest
e61aec89ea Use correct section size for matroschka package extraction (#71)
Not sure how it took this long for me to encounter an issue.
2026-03-26 13:40:21 -04:00
Matt Nadareski
3f6e5c2383 Migrate these internal extensions to real extensions 2026-03-26 09:34:19 -04:00
Matt Nadareski
2ae3291a30 BSP and VBSP should not share lump types 2026-03-26 09:29:32 -04:00