Compare commits

..

1263 Commits
1.7.0 ... 3.2.0

Author SHA1 Message Date
Matt Nadareski
3798dbcb47 Bump version 2026-08-31 19:15:36 -04:00
Matt Nadareski
2a70a9a20e Update IO to 2.3.0 2026-08-28 13:11:31 -04:00
Matt Nadareski
6f92f85f5d Convert BFPK writing to use GrindCore zlib 2026-08-27 14:01:50 -04:00
Matt Nadareski
b7851601a4 Convert GCZ writing to use GrindCore zlib 2026-08-27 13:59:38 -04:00
Matt Nadareski
cb2a96c413 Convert GCZ to use GrindCore zlib 2026-08-27 13:57:49 -04:00
Matt Nadareski
69c0843a0d Convert GZip to use GrindCore zlib 2026-08-27 13:56:09 -04:00
Matt Nadareski
0171ea9da7 Convert IS-CAB to use GrindCore zlib 2026-08-27 13:53:23 -04:00
Matt Nadareski
e493af25e0 Convert CExe to use GrindCore zlib 2026-08-27 12:37:26 -04:00
Matt Nadareski
62427576e9 Convert SGA to use GrindCore zlib 2026-08-27 12:30:01 -04:00
Matt Nadareski
e80ea00872 Update packages 2026-08-27 09:36:42 -04:00
Matt Nadareski
ce1cd15978 Fix locking issues with item dictionary implementation 2026-08-11 22:04:32 -04:00
HeroponRikiBestest
2a604bd73a Ensure that the data being read is actually large enough to have a debug directory entry parsed from it (#96) 2026-07-30 20:44:49 -04:00
Matt Nadareski
bcc0a5bd1e Add set type RomVault game extension field 2026-07-23 17:03:14 -04:00
Matt Nadareski
32d9e8a09d Add dir RomVault header extension field 2026-07-23 16:45:12 -04:00
Matt Nadareski
d0f5ac322d Add subset RomVault header extension field 2026-07-23 16:15:27 -04:00
Matt Nadareski
05c86e4c24 Add support for BLAKE3 2026-07-23 11:36:54 -04:00
Matt Nadareski
1d76967a08 Ignore bad IS-CAB group names 2026-07-19 21:09:59 -04:00
Matt Nadareski
b9ffd61252 Bump version 2026-07-10 13:29:35 -04:00
Matt Nadareski
b4e1f6b729 Update packages, relax requirements 2026-07-10 11:23:17 -04:00
Matt Nadareski
451fc0b394 Bump version 2026-07-06 09:57:11 -04:00
HeroponRikiBestest
79ca9f617e Add sim parsing for Steam2 sim/sid installers (#95)
* Add model for sim file

* Add sim parsing for steam2 installer set

* First round of fixes
2026-07-06 09:21:17 -04:00
Matt Nadareski
a602686551 Trim path separators from start of filenames on extract 2026-07-05 23:28:24 -04:00
Matt Nadareski
4083aed12f Some filenames in MS-CAB start with one or more separators 2026-07-01 10:18:20 -04:00
Matt Nadareski
717de3608c Add Logiqx serial and version machine fields 2026-06-22 16:35:03 -04:00
Matt Nadareski
88aae0dd26 Bump version 2026-06-12 08:56:35 -04:00
Matt Nadareski
499fc44004 Ensure a 2-byte read is possible 2026-06-07 21:56:17 -04:00
Matt Nadareski
07325be930 Clean up parameter 2026-05-29 22:27:27 -04:00
Matt Nadareski
481020bd08 Move useful helper to a better place 2026-05-22 09:24:03 -04:00
Matt Nadareski
5642f601a3 Minor cleanup 2026-05-21 10:38:38 -04:00
Deterous
b42a12f051 Recursive InfoPrint for ISO9660 and XDVDFS (#94)
* Recursive InfoPrint for XDVDFS / XboxISO

* Cleanup, full file paths

* Add safety

* Recursive ISO9660 printing

* Naive decode filename

* comment
2026-05-21 10:32:20 -04:00
Matt Nadareski
a5879b46f1 Slightly more cleanup around IS-CAB and printing 2026-05-18 19:52:44 -04:00
Matt Nadareski
9a14cc2620 Fix major issues in IS-CAB 2026-05-18 19:23:35 -04:00
Matt Nadareski
a777df13db Take directory into account for IS-CAB 2026-05-18 13:35:59 -04:00
Matt Nadareski
78d7bc310f Add placebo recursive flag for now 2026-05-18 10:24:30 -04:00
Matt Nadareski
ae3978241c Add expected header size as a comment 2026-05-18 10:03:57 -04:00
Matt Nadareski
390e39ef30 Add Z3DS metadata structures 2026-05-18 09:54:33 -04:00
Matt Nadareski
5ef595e01a Add Z3DS file header structure 2026-05-18 09:39:48 -04:00
Matt Nadareski
371623e3fa See if org-level CONTRIBUTING works 2026-05-16 14:59:41 -04:00
Matt Nadareski
7eb669cef3 Update CONTRIBUTING to be more accurate 2026-05-15 13:04:19 -04:00
Matt Nadareski
4eac10c15c Add CONTRIBUTING document 2026-05-15 10:58:39 -04:00
Matt Nadareski
495368f28d Update gitignore for new VSCode feature 2026-05-15 10:24:55 -04:00
Matt Nadareski
a2d15f301b Move it around 2026-05-14 20:52:12 -04:00
Matt Nadareski
d3c9849908 Attempt to fix detection issues 2026-05-14 20:08:32 -04:00
Matt Nadareski
249c51933b Update packages 2026-05-14 09:25:26 -04:00
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
3f71628600 Split WIA models into separate files 2026-05-04 11:47:49 -04:00
Matt Nadareski
f729eae48a Add GCZ, Nintendo disc, and WIA models
Code originally by https://github.com/Dimensional and split off from https://github.com/SabreTools/SabreTools.Serialization/pull/85/
2026-05-04 09:59:14 -04:00
Matt Nadareski
f6877d82cd Remove errant header field setting 2026-04-28 13:58:59 -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
Matt Nadareski
b9b1b24f67 Update date in license 2026-04-22 09:35:17 -04:00
Matt Nadareski
d28a88e193 Handle comments in XML in a smarter way 2026-04-21 14:23:35 -04:00
Matt Nadareski
c02698edcd Fix M1 and MESS parsing, similar to ListXML 2026-04-21 12:22:41 -04:00
Matt Nadareski
41bfe8edce Fix tests 2026-04-21 12:06:33 -04:00
Matt Nadareski
9c66f6ef57 RamOption was a problematic read 2026-04-21 12:03:08 -04:00
Matt Nadareski
3a6ee3a37c Remove preemptive filtering 2026-04-21 10:59:45 -04:00
Matt Nadareski
7227f01ebc Support old item type filter string 2026-04-21 09:30:24 -04:00
Matt Nadareski
2bf686675e Port Reports namespace from ST 2026-04-20 14:03:49 -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
Deterous
ab4bb4cca3 Fix XDVDFS bug (#88)
* Fix XDVDFS bug

* Move check and seek earlier
2026-04-19 22:13:01 -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
Matt Nadareski
bba9bfcbd6 Editorconfig cleanup 2026-04-18 21:32:37 -04:00
Deterous
94f86fe1d1 Peek in XDVDFS, Support XB00104M (#86)
* Peek in XDVDFS, Support XB00104M

* var
2026-04-18 21:30:44 -04:00
Matt Nadareski
63c13254d7 Handle all empty elements 2026-04-18 21:20:56 -04:00
Matt Nadareski
7d6092452f Handle uncommon case of no find elements 2026-04-18 21:10:01 -04:00
Matt Nadareski
6c2098c5d2 Add "boot" element for OpenMSX, fix missing skip 2026-04-18 20:53:18 -04:00
Matt Nadareski
70bef7d6c9 EOF loops always need to skip 2026-04-18 20:31:37 -04:00
Matt Nadareski
87df32284d Fix issue with comments in OpenMSX 2026-04-18 20:24:07 -04:00
Matt Nadareski
fda2e39296 The lists of keys are actually useful 2026-04-18 16:34:20 -04:00
Matt Nadareski
fe58061a2d Found out why these helpers were this way 2026-04-18 12:45:58 -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
25ab9acb57 Do not access dictionary with index 2026-04-17 09:14:39 -04:00
Matt Nadareski
ecd4e7d1df Make user logs more accurate 2026-04-17 08:48:08 -04:00
Matt Nadareski
024200ebc4 Minor cleanup around loops 2026-04-16 23:39:33 -04:00
Matt Nadareski
ad9828de3c Slight cleanup around bucketing 2026-04-16 23:22:48 -04:00
Matt Nadareski
d6e974a3ab Make grouping/bucketing a private class too 2026-04-16 23:09:48 -04:00
Matt Nadareski
c482160b5b Fix tests 2026-04-16 22:29:03 -04:00
Matt Nadareski
d9a50d0c9e Add removal helper method 2026-04-16 22:16:03 -04:00
Matt Nadareski
7acb97e78e Add and use IndexedTable private class 2026-04-16 22:08:03 -04:00
Matt Nadareski
c409c47ae5 Remove outdated note 2026-04-16 19:17:45 -04:00
Matt Nadareski
2caab2c9cf Remove items when machine is removed for DB 2026-04-16 17:00:16 -04:00
Matt Nadareski
0feb4130fe Fix some DB-specific tests 2026-04-16 16:56:02 -04:00
Matt Nadareski
c90dcd7d59 Fix missing and unnecessary assignments 2026-04-16 16:41:01 -04:00
Matt Nadareski
2884dcab5b Remove need for GetMachineForItem 2026-04-16 16:11:25 -04:00
Matt Nadareski
ff69b83e05 Get methods should return all info 2026-04-16 15:55:12 -04:00
Matt Nadareski
2a2a2a46f9 Remove need for GetSourceForItem 2026-04-16 15:37:41 -04:00
Matt Nadareski
cb8d2885aa Add constructors with index instead of object 2026-04-16 14:14:30 -04:00
Matt Nadareski
3e55071d41 Add machines but don't invoke ItemDB 2026-04-16 13:59:15 -04:00
Matt Nadareski
af568d6a57 Make callers responsible for machine and source setting 2026-04-16 13:52:58 -04:00
Matt Nadareski
8f746824d6 Allow callers to set source and machine index 2026-04-16 13:27:29 -04:00
Matt Nadareski
334ab130da Remove unnecessary framework gating 2026-04-16 13:03:34 -04:00
Matt Nadareski
b8966f5e37 Remove unnecessary RemapDatItemToMachine method 2026-04-16 13:00:13 -04:00
Matt Nadareski
096f9d4b96 Remove external item to machine mappings 2026-04-16 12:54:43 -04:00
Matt Nadareski
b6c6296c29 Remove external item to source mappings 2026-04-16 12:39:24 -04:00
Matt Nadareski
8173806537 Add machine and source indexes to DatItem, currently unused 2026-04-16 12:26:52 -04:00
Matt Nadareski
af12310504 Rename ItemDictionaryDB to ItemDatabase 2026-04-16 11:51:28 -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
c646141bdf Remove DesignerCategory attribute usage 2026-04-15 00:27:48 -04:00
Matt Nadareski
ca02ed6b09 Add CICM sidecar models 2026-04-14 22:56:09 -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
Matt Nadareski
3d33f44eca Make inverted DataArea less impactful 2026-04-09 23:56:36 -04:00
Matt Nadareski
5f9eaef9f2 Make inverted DiskArea less impactful 2026-04-09 23:36:50 -04:00
Matt Nadareski
b0a9464d2b Make inverted Part less impactful 2026-04-09 23:29:00 -04:00
Matt Nadareski
5d4453fb1e Minor formatting fix 2026-04-09 22:57:50 -04:00
Matt Nadareski
ca3ebf33a8 Flatten Analog out of existence 2026-04-09 22:21:15 -04:00
Matt Nadareski
853e2ff5c0 Flatten Extension out of existence 2026-04-09 22:06:41 -04:00
Matt Nadareski
967d9ffe87 Flatten Instance out of existence 2026-04-09 21:34:00 -04:00
Matt Nadareski
27a93fa86a Clean up Rom ordering 2026-04-09 21:16:45 -04:00
Matt Nadareski
770f6f75d5 Flatten Condition out of existence 2026-04-09 21:13:55 -04:00
Matt Nadareski
2a700dee9c Add skeleton filter overrides for nested items 2026-04-09 20:33:34 -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
45956e9128 This enum no longer has use 2026-04-08 23:37:59 -04:00
Matt Nadareski
baf68f3f81 Replace all instances of XXXXXX with proper test values 2026-04-08 21:04:11 -04:00
Matt Nadareski
9d63be5cc7 Merge pull request #79 from SabreTools/attempt-metadata-overhaul 2026-04-08 10:16:06 -04:00
Matt Nadareski
c78bde1fb2 Merge branch 'main' into attempt-metadata-overhaul 2026-04-07 22:20:28 -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
0363b1dd96 Slight code cleanliness updates 2026-04-07 11:23:10 -04:00
Matt Nadareski
94658ae225 Filter tree is reflection-free 2026-04-07 11:17:57 -04:00
Matt Nadareski
76c5dc40e3 Checkpoint reflection replacement 2026-04-07 10:37:03 -04:00
Matt Nadareski
6ba4a5b3ab Checkpoint reflection replacement 2026-04-07 10:26:58 -04:00
Matt Nadareski
18b3152a6c Checkpoint reflection replacement 2026-04-07 10:14:54 -04:00
Matt Nadareski
3412bbf33a Checkpoint reflection replacement 2026-04-07 09:36:43 -04:00
Matt Nadareski
278bfafae5 Checkpoint reflection replacement 2026-04-07 09:24:23 -04:00
Matt Nadareski
b4be581879 Checkpoint reflection replacement 2026-04-07 09:12:27 -04:00
Matt Nadareski
39a31b3a97 Checkpoint reflection replacement 2026-04-06 19:10:40 -04:00
Matt Nadareski
2d6e9d7875 Add RomVault subheader 2026-04-06 18:51:09 -04:00
Matt Nadareski
f3d6adbe1d Add RV-specific deduped status 2026-04-06 18:37:56 -04:00
Matt Nadareski
0350d8f58f Checkpoint reflection replacement 2026-04-06 16:19:20 -04:00
Matt Nadareski
2aca55a895 Add machine type analogue filtering again 2026-04-06 15:39:40 -04:00
Matt Nadareski
4772768c1f Handle item type filtering properly again 2026-04-06 15:03:16 -04:00
Matt Nadareski
adfc2cde84 Checkpoint reflection replacement 2026-04-06 14:46:34 -04:00
Matt Nadareski
6cab41b58e Merge branch 'main' into attempt-metadata-overhaul 2026-04-06 10:46:53 -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
c0872cb97b Checkpoint reflection replacement 2026-04-06 10:18:00 -04:00
Matt Nadareski
e2b2f4d8a5 Rename "CRC" to "CRC32" where appropriate 2026-04-06 07:44:19 -04:00
Matt Nadareski
6a7d6e16b7 Fix framework difference 2026-04-05 19:28:06 -04:00
Matt Nadareski
f6f5818767 This utility method has been relocated in ST 2026-04-05 14:58:29 -04:00
Matt Nadareski
fe0768dad7 DepotInformation should be responsible for path generation 2026-04-05 14:02:06 -04:00
Matt Nadareski
d6edc33dd2 TypeHelper was only used by Filter in general 2026-04-05 11:28:48 -04:00
Matt Nadareski
d78c1eb9ed GetProperties is only used by filters 2026-04-05 11:24:47 -04:00
Matt Nadareski
15794e07f7 Remove one reflection-based helper 2026-04-05 11:21:56 -04:00
Matt Nadareski
d8e4f963c0 Statically cache item type names to avoid slowdowns 2026-04-05 11:15:07 -04:00
Matt Nadareski
f93d254a64 Try to make DAT statistics less intense 2026-04-05 11:00:36 -04:00
Matt Nadareski
25f50d19e2 Convert the last ToArrays that can be converted 2026-04-05 10:42:19 -04:00
Matt Nadareski
752f5d31d4 Avoid round-trip collection conversion 2026-04-05 10:40:54 -04:00
Matt Nadareski
83407133d6 Be more explicit about per-type missing fields 2026-04-05 10:22:44 -04:00
Matt Nadareski
742c991deb Remove now-redundant Equals methods 2026-04-05 02:24:05 -04:00
Matt Nadareski
3caf65822f Forgot to clean up some typing 2026-04-05 02:09:11 -04:00
Matt Nadareski
0eb5da5fd4 Default sort is never done, so CompareTo is useless 2026-04-05 01:59:34 -04:00
Matt Nadareski
337d4c0fed Metadata DatItem should be abstract 2026-04-05 01:51:07 -04:00
Matt Nadareski
5ffc9fef43 Cleanup around DatItem and DatItem<T>
This is both big and not big. The not big part of this is that I essentially just moved some stuff up to the typed type that used to live in the untyped type. The big part is that this allows every single DatItem implementation to be significantly cleaner with their implementations of the methods and internal model.
2026-04-05 01:36:32 -04:00
Matt Nadareski
1a10e10fd6 ModelBackedItem had no actual utility anymore 2026-04-05 01:19:46 -04:00
Matt Nadareski
1997346988 ModelBackedItem doesn't need to be equatable 2026-04-05 01:08:41 -04:00
Matt Nadareski
0ed13167ba Invert some if statements to be clearer 2026-04-05 00:35:09 -04:00
Matt Nadareski
285f3a267e NoFilter attribute no longer matters 2026-04-05 00:26:23 -04:00
Matt Nadareski
2969324015 None of these are constants now 2026-04-05 00:25:56 -04:00
Matt Nadareski
72dac4d6e2 The smallest cleanup 2026-04-05 00:21:19 -04:00
Matt Nadareski
ed72df79a6 Make FilterObject slightly more maintainable, slightly 2026-04-05 00:15:40 -04:00
Matt Nadareski
bf852ef038 DictionaryBase is no more, bon voyage 2026-04-04 23:13:36 -04:00
Matt Nadareski
e31be83832 RomProperties, no, not that one 2026-04-04 22:31:23 -04:00
Matt Nadareski
0b99602bc7 Convert Metadata file keys to proper properties 2026-04-04 21:17:28 -04:00
Matt Nadareski
3b2b4bc525 Notes 2026-04-04 20:35:57 -04:00
Matt Nadareski
bd8c008610 Attempt to make Equals redirection less 2026-04-04 20:30:33 -04:00
Matt Nadareski
0491133329 Move hash-based equality checkers lower down the chain 2026-04-04 20:04:01 -04:00
Matt Nadareski
4b20273d42 EqualTo has obsoleted itself into the bin 2026-04-04 19:55:44 -04:00
Matt Nadareski
a4f844cd6a Not sure how these slipped by 2026-04-04 19:49:02 -04:00
Matt Nadareski
8fe2b51d6f Further reduce calls to EqualTo 2026-04-04 19:47:00 -04:00
Matt Nadareski
c819be57a5 Reduce calls to EqualTo 2026-04-04 19:14:11 -04:00
Matt Nadareski
040ad65a5e DeepClone was left as self-referential, like this commit message 2026-04-04 18:48:00 -04:00
Matt Nadareski
f9437314cb Finalize property conversion for header 2026-04-04 18:46:35 -04:00
Matt Nadareski
ebf67d39cf Lazily make OfflineList-specific header items properties 2026-04-04 18:24:58 -04:00
Matt Nadareski
ca2a289a3f This remark was wrong 2026-04-04 17:59:39 -04:00
Matt Nadareski
cd49a64c2b Split header skipper and header row into separate properties 2026-04-04 17:58:09 -04:00
Matt Nadareski
b547792799 Two more header keys to properties 2026-04-04 16:34:13 -04:00
Matt Nadareski
2f72349e7b Small fixes to Machine 2026-04-04 16:20:42 -04:00
Matt Nadareski
8f82d3a28d Properties are not fields 2026-04-04 16:07:37 -04:00
Matt Nadareski
7a9f5d1fa1 Machine is now propertyful 2026-04-04 16:06:07 -04:00
Matt Nadareski
b8d4adf0e7 Clean up machine properties 2026-04-04 15:21:16 -04:00
Matt Nadareski
d08427f1ba Trurip finally gets integrated, more at 11 2026-04-04 15:17:58 -04:00
Matt Nadareski
12e1086838 Convert Dump to using properties 2026-04-04 14:23:31 -04:00
Matt Nadareski
274919fd6a Convert Dump to using properties 2026-04-04 14:23:27 -04:00
Matt Nadareski
096f1d9534 Remove get/set name methods where appropriate 2026-04-04 14:07:37 -04:00
Matt Nadareski
5ab48845e3 Remove one more use of DeepClone 2026-04-04 13:39:14 -04:00
Matt Nadareski
4acd2d9fd6 Reduce generic DictionaryBase use 2026-04-04 13:31:12 -04:00
Matt Nadareski
0458489a4f Remove two places where DeepClone wasn't needed 2026-04-04 13:13:16 -04:00
Matt Nadareski
9c1d2e7b9c Streamline metadata cloning 2026-04-04 13:11:10 -04:00
Matt Nadareski
ba371d971d Clean up EqualTo helpers 2026-04-04 12:41:36 -04:00
Matt Nadareski
9828119bdd Further reduce use of GetName and SetName 2026-04-04 12:31:47 -04:00
Matt Nadareski
d72c7c9cc0 Convert most keys to properties for Machine 2026-04-04 12:21:09 -04:00
Matt Nadareski
eb2f5babd9 Migrate DataArea, DiskArea, and Part to property-driven 2026-04-04 11:40:48 -04:00
Matt Nadareski
872fdc2a10 Reduce redirection for Name setters and getters 2026-04-04 10:25:49 -04:00
Matt Nadareski
845a0cb998 Convert Archive fully over to properties 2026-04-04 02:18:55 -04:00
Matt Nadareski
3f3f73a56f Convert Slot fully over to properties 2026-04-04 01:46:00 -04:00
Matt Nadareski
4bb670ac15 Convert Port fully over to properties 2026-04-04 01:36:42 -04:00
Matt Nadareski
9e721c5c43 Convert Input fully over to properties 2026-04-04 01:28:17 -04:00
Matt Nadareski
9ffa2a5e23 Convert Disk fully over to properties 2026-04-04 01:15:40 -04:00
Matt Nadareski
e5e279a48d Convert Device fully over to properties 2026-04-04 00:25:50 -04:00
Matt Nadareski
f7ac1073b0 Convert subitems for Configuration and DipSwitch 2026-04-04 00:08:56 -04:00
Matt Nadareski
a8c060ff26 Turn Condition keys into properties as a test 2026-04-03 23:33:11 -04:00
Matt Nadareski
2fdecebe66 Reduce use of GetName and SetName, prefer direct 2026-04-03 22:57:58 -04:00
Matt Nadareski
cdc55e721e Split Input.Control and Input.ControlAttr 2026-04-03 22:31:10 -04:00
Matt Nadareski
b55a932b2b String Machine keys to properties 2026-04-03 22:17:31 -04:00
Matt Nadareski
8e2f519e15 Convert most of Media over to properties 2026-04-03 19:47:58 -04:00
Matt Nadareski
5b3ff31f85 Make ReleaseDetails more complete 2026-04-03 19:11:55 -04:00
Matt Nadareski
c623c2b1f6 Make Serials more complete 2026-04-03 18:50:04 -04:00
Matt Nadareski
97b04b26a3 Make SourceDetails more complete 2026-04-03 18:31:31 -04:00
Matt Nadareski
5ccfde54f5 Convert last long key to property 2026-04-03 17:49:45 -04:00
Matt Nadareski
9df08780db Handle an enum that needed to be handled 2026-04-03 17:41:36 -04:00
Matt Nadareski
e01537c2f4 Get rid of Software metadata item
Apparently this was a mistake that has proliferated over a very long time. The Software item that was being modeled was actually the game/machine equivilent from SoftwareList. But because there's both an item called SoftwareList and a DAT type called SoftwareList, some wire got crossed and they were mentally combined. Undoing this allows for a more proper internal model, including a couple of extraneous keys that were included originally.
2026-04-03 17:25:09 -04:00
Matt Nadareski
154be08a53 Disable broken tree test 2026-04-03 16:58:48 -04:00
Matt Nadareski
e3927ca3e6 Fix longstanding TODOs around Software items 2026-04-03 16:02:44 -04:00
Matt Nadareski
fb711001e9 Add TODO question because I have no idea 2026-04-03 14:05:34 -04:00
Matt Nadareski
52edf9d20c Convert Release fully over to properties 2026-04-03 14:02:03 -04:00
Matt Nadareski
62b2fd3325 Original is cloneable and comparable 2026-04-03 13:48:43 -04:00
Matt Nadareski
716abed8b8 Convert Input mostly over to properties 2026-04-03 13:38:26 -04:00
Matt Nadareski
b6ab8a19be Convert Driver fully over to properties 2026-04-03 13:22:17 -04:00
Matt Nadareski
1d5514b29d Convert Display and Video fully over to properties 2026-04-03 13:08:36 -04:00
Matt Nadareski
32dd30adab Fix test 2026-04-03 12:31:33 -04:00
Matt Nadareski
2ed0c1f732 Convert Video mostly over to properties 2026-04-03 12:31:24 -04:00
Matt Nadareski
4fecf8b498 Remove long specifier for concrete values 2026-04-03 12:02:24 -04:00
Matt Nadareski
c9c31af8ea Convert Display mostly over to properties 2026-04-03 11:57:30 -04:00
Matt Nadareski
e604ef314b Convert DipLocation fully over to properties 2026-04-03 11:15:57 -04:00
Matt Nadareski
e3d3fe7c1a Fix broken tests 2026-04-03 11:05:59 -04:00
Matt Nadareski
280e65775a Convert ConfLocation fully over to properties 2026-04-03 10:59:04 -04:00
Matt Nadareski
33958d37fd Use ICloneable implementations in DeepClone 2026-04-03 10:33:10 -04:00
Matt Nadareski
dc773dba5e Convert Chip fully over to properties 2026-04-03 10:26:20 -04:00
Matt Nadareski
cdb74a9e26 Use IEquatable where possible 2026-04-03 10:10:34 -04:00
Matt Nadareski
600b0a6dbd Fill in some accidental gaps 2026-04-03 10:04:32 -04:00
Matt Nadareski
3f82312943 Convert Control fully over to properties 2026-04-03 09:46:10 -04:00
Matt Nadareski
08e0aa5b77 Convert refresh rates to properties, fix format 2026-04-03 00:04:11 -04:00
Matt Nadareski
3c6cfef070 Convert size keys to size properties 2026-04-02 23:45:17 -04:00
Matt Nadareski
11803aa34c Convert Sound.Channels to long as a test 2026-04-02 22:45:33 -04:00
Matt Nadareski
2b472c6f37 Migrate DAT filename to a property (used by ST) 2026-04-02 22:17:39 -04:00
Matt Nadareski
a914ee12c3 Convert DAT format to a property 2026-04-02 22:16:04 -04:00
Matt Nadareski
49d3d9c096 Migrate most header string keys to properties 2026-04-02 22:01:42 -04:00
Matt Nadareski
0df6378713 Move item type override per-item 2026-04-02 21:07:41 -04:00
Matt Nadareski
c0fd4d1334 Turn dupe type key into a metadata property 2026-04-02 20:41:14 -04:00
Matt Nadareski
c87db265dd Turn removal key into a metadata property 2026-04-02 20:34:09 -04:00
Matt Nadareski
d3f5dccf5b Make Source inherent to DatItem instead of passing through 2026-04-02 17:06:01 -04:00
Matt Nadareski
61ea4b2668 Compare machines in DatItem equality 2026-04-02 16:25:52 -04:00
Matt Nadareski
355aa4b94c Make Machine inherent to DatItem instead of passing through 2026-04-02 16:23:16 -04:00
Matt Nadareski
ca95e96402 Make "simple" metadata items equatable 2026-04-02 16:07:34 -04:00
Matt Nadareski
1e27b5d720 Make "simple" metadata items cloneable 2026-04-02 15:49:06 -04:00
Matt Nadareski
11c4097cba Rename Clone extension to DeepClone to avoid conflicts 2026-04-02 15:32:24 -04:00
Matt Nadareski
12ec3678b8 Fill in a few more string properties 2026-04-02 14:28:46 -04:00
Matt Nadareski
7df083c0b2 Reduce use of SetName 2026-04-02 13:35:11 -04:00
Matt Nadareski
c74942362c Name property cleanup, fixes 2026-04-02 13:21:37 -04:00
Matt Nadareski
c61aea7eac Move common string-only to properties 2026-04-02 11:18:49 -04:00
Matt Nadareski
8356aed5b0 Device.Manadatory converted to property 2026-04-02 02:43:29 -04:00
Matt Nadareski
3ef7b5860d Make large filter helper static 2026-04-02 02:28:00 -04:00
Matt Nadareski
276448a914 Merge branch 'main' into attempt-metadata-overhaul 2026-04-02 02:25:22 -04:00
Deterous
9993e574a0 Fix Xbox Executable TLS offset (#76)
* Fix XBE TLS address

* Break early

* Fix relative address
2026-04-02 02:24:08 -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
Matt Nadareski
c4524d20f0 Enum type conversion to property 2026-04-02 02:18:08 -04:00
Matt Nadareski
4c9ff19cf3 Runnable is Runnable 2026-04-01 22:06:24 -04:00
Matt Nadareski
451e89afff Boolean stuff convert to property 2026-04-01 21:59:16 -04:00
Matt Nadareski
826df09a3e Handle "Default" properties 2026-04-01 16:52:55 -04:00
Matt Nadareski
dfa39947ce Add GetProperties helper method and use it 2026-04-01 15:40:04 -04:00
Matt Nadareski
88d182cfd1 The map is curiously BLANK 2026-04-01 14:24:43 -04:00
Matt Nadareski
d2b8a4aa2c Remove NameKey from all current locations 2026-04-01 13:42:07 -04:00
Matt Nadareski
5812d197a5 Change Name to concrete property 2026-04-01 13:18:45 -04:00
Matt Nadareski
6810dce2ed Remove redundant ItemType declarations 2026-04-01 11:37:44 -04:00
Matt Nadareski
3e2bba866d Change ItemType into concerete property 2026-04-01 11:24:33 -04:00
Matt Nadareski
4035d9db86 Add some common Metadata objects for NIDB 2026-04-01 10:37:25 -04:00
Matt Nadareski
1cec6fa918 Add No-Intro database export reader and writer 2026-03-31 22:09:32 -04:00
Matt Nadareski
b82d464b12 Add No-Intro database export models 2026-03-31 20:44:17 -04:00
Matt Nadareski
3f5b3d10fd Not sure why this enum was separate 2026-03-31 19:48:26 -04:00
Matt Nadareski
af5d161fe4 Use original XML writer settings 2026-03-31 18:30:16 -04:00
Matt Nadareski
e2e19db294 Correctness fix to include XML declaration 2026-03-31 18:15:36 -04:00
Matt Nadareski
0b055a563e Directly document No-Intro Logiqx info 2026-03-31 18:10:44 -04:00
Matt Nadareski
4d362bb791 Use XmlTextWriter for XML DAT writing 2026-03-31 18:08:40 -04:00
Matt Nadareski
0670231606 Use XmlTextReader for XML DAT reading 2026-03-31 00:01:44 -04:00
Matt Nadareski
ea2bfbcb1f XDVDFS editorconfig cleanup 2026-03-29 21:55:23 -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
Matt Nadareski
07fe4415fe Reduce complexity of ExtractionTool invocation 2026-03-28 23:01:50 -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
a2c7588e1c Size filters should be AND not OR to allow for ranges 2026-03-27 21:07:48 -04:00
Matt Nadareski
5898bec0e9 Pedanitcally fill other filter operations 2026-03-27 20:57:11 -04:00
Matt Nadareski
8f71041e7e DatFormat does not need to be a flag 2026-03-27 10:47:20 -04:00
Matt Nadareski
4fd89ced29 Remove ported extension 2026-03-27 10:40:39 -04:00
Matt Nadareski
55522bf59b Port split format extension from ST 2026-03-27 09:31:19 -04:00
Matt Nadareski
de4566ec26 Fix Linux publish script 2026-03-27 08:49:08 -04:00
Matt Nadareski
078cd88bcd Gate unpublished builds behind a flag 2026-03-27 08:45:40 -04:00
Matt Nadareski
e9902f0907 Reduce extension confusion 2026-03-27 00:48:44 -04:00
Matt Nadareski
e5679b9152 A couple more small cleanup items 2026-03-27 00:32:12 -04:00
Matt Nadareski
7d29c3d7d9 Fix build 2026-03-27 00:16:58 -04:00
Matt Nadareski
1212603414 Reduce Reflection use in object creation 2026-03-26 23:59:53 -04:00
Matt Nadareski
9929199f31 Remove Reflection from DatItem<T> 2026-03-26 23:46:20 -04:00
Matt Nadareski
a7a622e118 Revert incorrect assumption 2026-03-26 23:14:38 -04:00
Matt Nadareski
225922e5bc TypeHelper comment and formatting cleanup 2026-03-26 23:10:06 -04:00
Matt Nadareski
465ece5ea3 Fix namespace mixup 2026-03-26 23:07:12 -04:00
Matt Nadareski
8de1fbc52f Reduce enum overhead in metadata 2026-03-26 22:51:14 -04:00
Matt Nadareski
29620c0c4f Metadata code cleanup 2026-03-26 20:40:49 -04:00
Matt Nadareski
3a3b20df11 Reduce repeated lookups and reads 2026-03-26 16:52:07 -04:00
Matt Nadareski
85aefc8d90 Move required extension 2026-03-26 15:16:12 -04:00
Matt Nadareski
52ad2ff89c Move required extension 2026-03-26 15:15:59 -04:00
Matt Nadareski
8356fc5970 Thin out ModelBackedItem wrapper class 2026-03-26 13:52:00 -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
363ffee738 AttributeHelper code was only ever used in converters 2026-03-26 11:30:40 -04:00
Matt Nadareski
ce2ddf1636 Simplify SabreTools.Metadata base namespace 2026-03-26 11:27:29 -04:00
Matt Nadareski
dd29c8245a Slight simplification to GetDepotPath 2026-03-26 11:23:30 -04:00
Matt Nadareski
fdee2103ad Rename GetAttribute to GetMappingAttribute to be more accurate 2026-03-26 11:17:43 -04:00
Matt Nadareski
b72fcfc60b Fill in a couple READMEs 2026-03-26 10:58:14 -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
Matt Nadareski
c216129b37 Be more explicit about support 2026-03-26 09:05:58 -04:00
Deterous
2fdc2407dd Extract blank directories from ISO9660 filesystem (#70) 2026-03-25 09:04:14 -04:00
Matt Nadareski
5205fac739 Add non-published packages to publish scripts 2026-03-24 21:20:11 -04:00
Matt Nadareski
8a51f5d8ab Wire through already-added CRC-16 and CRC-64 2026-03-24 21:19:09 -04:00
Matt Nadareski
9c7993f8f1 Run tests and fix the rest 2026-03-24 19:42:36 -04:00
Matt Nadareski
8f49e190d8 Fix everything 2026-03-24 19:17:25 -04:00
Matt Nadareski
e11a08b587 Port metadata functionality from ST 2026-03-24 18:03:01 -04:00
Matt Nadareski
5f0fdcfd8d Update to IO 2.0.0 2026-03-24 18:02:49 -04:00
Matt Nadareski
1053ff7f23 Add ConditionalHashEquals tests 2026-03-22 20:26:28 -04:00
Matt Nadareski
de6a08539a Wrong filename 2026-03-22 20:22:22 -04:00
Matt Nadareski
219392e3a0 Port DictionaryBase extensions from ST
Notably, this is missing the equality checking because ST introduces a new type called "ModelBackedItem", which is specifically a type backed by a DictionaryBase item, with extensions. It is very similar to a Wrapper, but has different common utility. If there is a way to migrate that here, then the equality methods can come here as well.
2026-03-22 20:22:04 -04:00
Matt Nadareski
2ade7495c7 This will be public anyway 2026-03-22 02:44:12 -04:00
Matt Nadareski
1acd448838 Make validation methods public 2026-03-22 02:05:43 -04:00
Matt Nadareski
a8ed7a38f8 Fix issue with 3DS key assignment 2026-03-22 01:58:11 -04:00
Matt Nadareski
5208fc3e33 Add removal comment 2026-03-22 01:53:40 -04:00
Matt Nadareski
3dfbd23867 Pass in fixed crypto key flag as bool 2026-03-22 01:52:26 -04:00
Matt Nadareski
994a366770 Put initial value generators in common region 2026-03-22 01:35:36 -04:00
Matt Nadareski
d1b061fac5 Port 3DS decrypt/encrypt in a functional manner 2026-03-22 01:34:36 -04:00
Matt Nadareski
6e73c93c89 Port PartitionKeys class from NDecrypt 2026-03-22 01:10:39 -04:00
Matt Nadareski
5544ab0b8a Add majority of data extensions tests, fix minor issues 2026-03-21 20:09:10 -04:00
Matt Nadareski
8bec2087eb Add removal note 2026-03-21 17:55:14 -04:00
Matt Nadareski
50e27f926d Use separate libraries as references in executables 2026-03-21 16:41:09 -04:00
Matt Nadareski
ecc88316bd Nicer readme linking 2026-03-21 16:34:52 -04:00
Matt Nadareski
7689c6dd07 Libraries
This change looks dramatic, but it's just separating out the already-split namespaces into separate top-level folders. In theory, every single one could be built into their own Nuget package. `SabreTools.Serialization` still builds the normal Nuget package that is used by all other projects and includes all namespaces.
2026-03-21 16:26:56 -04:00
Matt Nadareski
bec0aeb04c Another size read mismatch in IRD 2026-03-20 22:09:07 -04:00
Matt Nadareski
2f8ee5545e IRD game title is UTF-8 2026-03-20 22:07:35 -04:00
Matt Nadareski
015ad062ac Prefix sizes were being read incorrectly for IRD parsing 2026-03-20 22:01:13 -04:00
Matt Nadareski
ae6608e2a7 Allow GCF checksum header to have dummy0 value of 0 (fixes #69) 2026-03-19 16:18:24 -04:00
Matt Nadareski
ca78898e93 Move wrapper factory file after namespace change 2026-03-18 22:17:07 -04:00
Matt Nadareski
a6ee92da32 Fix build 2026-03-18 17:27:06 -04:00
Matt Nadareski
b2eb0b5e67 Extensions classes should be named as such 2026-03-18 17:15:03 -04:00
Matt Nadareski
685fadbfdf Move wrapper utility classes into Wrappers namespace 2026-03-18 16:55:48 -04:00
Matt Nadareski
638934e6b0 Attributes should live in the Models namespace where it's used 2026-03-18 16:49:14 -04:00
Matt Nadareski
cd2e170175 Move ported attribute to root 2026-03-18 16:42:23 -04:00
Matt Nadareski
68b5436f59 Wrappers to its own namespace 2026-03-18 16:37:59 -04:00
Matt Nadareski
b2f074048d Create extensions test project 2026-03-18 16:21:16 -04:00
Matt Nadareski
3147974879 Create OID test project 2026-03-18 16:20:00 -04:00
Matt Nadareski
1a53c093b8 OID to its own namespace 2026-03-18 16:18:10 -04:00
Matt Nadareski
e4d26d4d81 Put interfaces in respective namespaces 2026-03-18 16:13:02 -04:00
Matt Nadareski
b3e25bb6a6 Fix interface file names to match internal names 2026-03-18 16:02:40 -04:00
Matt Nadareski
37d5b79b96 Rename directories to visually help determine real namespace 2026-03-18 15:56:45 -04:00
Matt Nadareski
75fef90a14 Reader options apparently moved fully 2026-03-17 19:47:27 -04:00
Matt Nadareski
9389797448 Bump version 2026-03-15 20:23:35 -04:00
Matt Nadareski
8b7112d12f uint is more correct 2026-03-14 20:51:22 -04:00
Matt Nadareski
4add8f3e64 Update TODO for accuracy 2026-03-14 11:52:07 -04:00
Matt Nadareski
9e6c6af985 Fix missing section case, should never be hit 2026-03-14 11:24:29 -04:00
Matt Nadareski
c82b56d084 Better clarify comment 2026-03-14 11:23:29 -04:00
Matt Nadareski
ea4c51b9f2 Use first nonzero-sized section as overlay address basis 2026-03-14 11:20:40 -04:00
HeroponRikiBestest
463c3ba50d Accurately get OverlayAddress for UPX-compressed executables (#67)
* Add alternate path for OverlayAddress for upx-compressed executables, for benefit of extractions that need an accurate overlay address.

* Use SectionNames

* Update SabreTools.Serialization/Wrappers/PortableExecutable.cs

---------

Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
2026-03-14 11:18:19 -04:00
Matt Nadareski
92356903cc Format alternate title IDs too 2026-03-13 21:15:34 -04:00
Matt Nadareski
82ed800a32 Add formatted Title ID output 2026-03-13 21:01:38 -04:00
Matt Nadareski
81cd284a80 Add debug/retail-adjusted values as passthru 2026-03-13 13:32:33 -04:00
Matt Nadareski
1eba7403a3 Add Cxbx-Reloaded references 2026-03-13 12:31:33 -04:00
Matt Nadareski
b47af580e3 Add remaining certificate fields 2026-03-13 12:29:17 -04:00
Matt Nadareski
cff722ba67 Fix issues found during testing 2026-03-13 12:10:45 -04:00
Matt Nadareski
810338d011 Create XBE wrapper 2026-03-13 11:40:01 -04:00
Matt Nadareski
76910047e7 Fill out XBE reader 2026-03-13 11:05:31 -04:00
Matt Nadareski
a8e53c2d07 Remove invalid extensions 2026-03-13 11:01:27 -04:00
Matt Nadareski
bb61a1b795 Add RVA mapping helpers for XBE 2026-03-13 10:52:54 -04:00
Matt Nadareski
1d83d40b9b Move XBE models, add skeleton reader 2026-03-13 10:51:31 -04:00
Matt Nadareski
3459c99b29 Add XBE models 2026-03-13 10:28:05 -04:00
Matt Nadareski
d102e2fc0b Add SNES models 2026-03-11 11:47:39 -04:00
Matt Nadareski
c7a932c07f Add secondary FDS/QD sources 2026-03-10 20:05:51 -04:00
Matt Nadareski
1c334dfb1b Add untested FDS <-> QD conversion 2026-03-10 19:49:12 -04:00
Matt Nadareski
a6656fd5e6 Add QD file support 2026-03-10 18:11:42 -04:00
Matt Nadareski
1e1bf2e27c Handle headerless FDS 2026-03-10 17:58:49 -04:00
Matt Nadareski
de5794b3ae Fix FDS reader 2026-03-10 17:47:11 -04:00
Matt Nadareski
f4192416f7 Fix build 2026-03-10 17:31:09 -04:00
Matt Nadareski
70fe830241 Add fwNES FDS file support 2026-03-10 17:27:58 -04:00
Matt Nadareski
e8394d6665 Rename NES cart models a bit 2026-03-10 17:06:01 -04:00
Matt Nadareski
2b64d34e7a Add Atari Lynx cart support 2026-03-10 14:28:09 -04:00
Matt Nadareski
1909851ed4 Add XGD security sector models 2026-03-10 13:18:58 -04:00
Matt Nadareski
9ce074529a Use documentation for endianness 2026-03-08 13:12:42 -04:00
Matt Nadareski
e2581fc423 Add Atari 7800 cart support 2026-03-07 21:27:11 -05:00
Matt Nadareski
f75bc21d54 Add NES cart extraction 2026-03-07 11:32:47 -05:00
Matt Nadareski
8844632fc7 Nicer NES formatting 2026-03-06 16:50:23 -05:00
Matt Nadareski
2f3ecb88f0 Remove unused enum 2026-03-06 16:26:19 -05:00
Matt Nadareski
6e93aa65b6 Split more things 2026-03-06 16:17:18 -05:00
Matt Nadareski
ca264ce91e Cleanup 2026-03-06 16:00:36 -05:00
Matt Nadareski
b339f213b8 Split NES 2.0 combined pieces 2026-03-06 15:53:16 -05:00
Matt Nadareski
93a6926b43 Split flag 10 2026-03-06 15:36:02 -05:00
Matt Nadareski
5e758d4b38 Split flag 7 2026-03-06 15:16:41 -05:00
Matt Nadareski
756d5fe03c Split flag 6 2026-03-06 14:59:19 -05:00
Matt Nadareski
ff67caee25 Make flags slightly more readable 2026-03-06 14:26:40 -05:00
Matt Nadareski
234f865234 Fix minor typo 2026-03-06 13:53:58 -05:00
Matt Nadareski
2d380770f5 Full printing for NES is overwhelming 2026-03-06 13:51:32 -05:00
Matt Nadareski
3f23df868f Fix logic inversion issue 2026-03-06 13:49:15 -05:00
Matt Nadareski
d150bde546 Add NES cart tests 2026-03-06 13:43:16 -05:00
Matt Nadareski
d108a815d7 Finish NES cart extension properties 2026-03-06 13:39:47 -05:00
Matt Nadareski
7dfb015dd5 Fix reading PRG and CHR 2026-03-06 13:23:17 -05:00
Matt Nadareski
5c973bac96 Fill in large number of extensions for NES cart 2026-03-06 13:18:49 -05:00
Matt Nadareski
c6b96d82dc Add simple extension properties 2026-03-06 12:51:02 -05:00
Matt Nadareski
9f2765edd0 Add NES cart printing 2026-03-06 12:47:59 -05:00
Matt Nadareski
b77e866be4 Add NES TODOs 2026-03-06 11:12:14 -05:00
Matt Nadareski
3995017174 Wire up NES cart to wrapper factories 2026-03-06 11:11:26 -05:00
Matt Nadareski
714c8d4901 Add generic NES cart wrapper 2026-03-06 11:08:41 -05:00
Matt Nadareski
9e68cf7abe Add NES cart reader 2026-03-06 11:03:54 -05:00
Matt Nadareski
1875adfe5f Add NES 1.0 and 2.0 models 2026-03-06 10:35:07 -05:00
Matt Nadareski
ebe4ff7426 Update packages 2026-03-05 11:27:45 -05:00
Matt Nadareski
e9eb3eb4be Generic resource entry is now used 2026-02-12 18:25:24 -05:00
Matt Nadareski
c99f86ee95 Add unused generic resource entry 2026-02-12 16:55:27 -05:00
Matt Nadareski
bb7b1c50a1 Move debug object parsers 2026-02-12 16:07:04 -05:00
Matt Nadareski
d56c8a3d83 Move unused parser 2026-02-12 16:04:16 -05:00
Matt Nadareski
c5f732584b Do the same for string table resource 2026-02-12 16:02:09 -05:00
Matt Nadareski
3e0a6dbf32 Move old version of AlignToBoundary 2026-02-12 15:53:40 -05:00
Matt Nadareski
b91c060dad Do the same for assembly manifest 2026-02-12 15:50:24 -05:00
Matt Nadareski
f0a0fc3137 Do the same for font groups 2026-02-12 15:46:50 -05:00
Matt Nadareski
ad3df18b24 Do the same for version info 2026-02-12 14:08:12 -05:00
Matt Nadareski
d089af71a4 Remove now-redundant As extensions 2026-02-12 13:54:53 -05:00
Matt Nadareski
5f9f037430 Add note about migration to IO 2026-02-12 13:48:21 -05:00
Matt Nadareski
939a2bab41 Move some extension parsers to more common location 2026-02-12 13:44:41 -05:00
Matt Nadareski
2d969048e3 Add currently-unused resource data base class 2026-02-12 13:09:44 -05:00
Matt Nadareski
dc86ed1456 Use accelerator table type 2026-02-12 13:04:37 -05:00
Matt Nadareski
a2b392234d Slight cleanup for clarity 2026-02-12 12:52:52 -05:00
Matt Nadareski
f56014b8a6 This can never be null 2026-02-12 12:46:49 -05:00
Matt Nadareski
3a485d34a1 Correct a couple of things 2026-02-12 12:27:36 -05:00
Matt Nadareski
e1da5f192c Do not overread PKZIP extra fields on malformed (fixes #65) 2026-01-29 14:05:36 -05:00
Matt Nadareski
c15809dd72 Remove unused usings 2026-01-28 21:31:59 -05:00
HeroponRikiBestest
89a67d1bd2 Implement model, reader, wrapper for valve SKU sis files. (#62)
* Try again

* Fix import alphebetization

* Fixes.

* first part of first attempt at a model

* Reimplement Sku Sis parsing

* First round of fixes

* Make sure stream isn't closed

* Missed this newline
2026-01-28 21:30:08 -05:00
Matt Nadareski
c4c6709478 Make note of why only partial driverstatus 2026-01-28 09:55:07 -05:00
Matt Nadareski
5e1f6ac4b3 Partially hook up driverstatus for CMP 2026-01-28 09:52:35 -05:00
Matt Nadareski
8f8d86d0bb Clean up some formatting things 2026-01-27 12:03:01 -05:00
HeroponRikiBestest
ecca11e2f3 Flush before closing in microsoftcabinet.extraction (#61)
I had previously been under the assumption that closing always guaranteed a flush. I don't know of any issues that were being caused, but I should push this before i forget.
2026-01-25 21:41:35 -05:00
Matt Nadareski
527b09c6bc Add debug flag to interface definitions (fixes #60) 2026-01-25 20:07:59 -05:00
Matt Nadareski
69b6595434 Missed this one too 2026-01-25 19:48:07 -05:00
Matt Nadareski
59b918c75f Apparently didn't rename this 2026-01-25 19:46:39 -05:00
Matt Nadareski
344132b50a Add editorconfig, fix issues 2026-01-25 16:15:05 -05:00
Matt Nadareski
a35e58e9cc Fix some errant formatting 2026-01-25 15:08:37 -05:00
Matt Nadareski
4300d94858 Use newer "is not null" syntax 2026-01-25 14:32:49 -05:00
Matt Nadareski
ee85a84d8f Use newer "is null" syntax 2026-01-25 14:30:18 -05:00
Matt Nadareski
2959d82231 Formatting cleanup 2026-01-25 13:38:52 -05:00
HeroponRikiBestest
5dfe6aefb0 Convert Installshield Executable code to use proper reader/wrapper instead of living in PortableExecutable (#59)
* Figure out how to access OverlayAddress in wrapper or reader (ideally the latter) for a non-PE reader/wrapper

* Code works

* Remove TODOs

* First round of fixes.

* use constants

* remove comment
2026-01-25 13:36:17 -05:00
HeroponRikiBestest
7f7d0f84ef Re-enable stream extraction for MScab (#58)
* Re-enable extraction from stream

* Remove todo pre PR

* Properly support all situations, remove whitespace
2026-01-25 12:24:28 -05:00
Matt Nadareski
4bfaf36e24 Formatting cleanup 2026-01-24 21:43:08 -05:00
HeroponRikiBestest
695fc4b0af Change mscab extraction to use state handling, break into more helper methods (#57)
* Attempt 1

* Use private helper class

* Remove comment

* Add missing summaries

* Don't use create pattern

* Remove removed variable summary

* Reduce what needs to be passed in

* Further reduce what needs to be passed in

* These didn't get tabbed for some reason

* First round of fixes.

* Second round of changes

* Add a few comments.
2026-01-24 21:41:23 -05:00
Matt Nadareski
f16ed9742f Support WoD info CMP block type 2026-01-24 11:37:29 -05:00
Matt Nadareski
6bfe68b8cf Formatting and comment cleanup 2026-01-24 10:24:35 -05:00
HeroponRikiBestest
2e5c5b3c79 Extract Ms-cabs while reading instead of loading all datablocks into memory (#56)
* WIP

* WIP 2

* Todo: you're missing a read somehow and getting misaligned by two bytes? maybe properly implementing the buffer will magically fix it

* continued blocks my behated

* Pre-major-testing

* Forgot to add summaries

* Attempt to properly roll back. The state i wanted to roll back to wasn't in a commit before.

* Figured out the issue with the rolled back commit, this has to be a while loop because of 0 byte files. Reimplemented clean code.

* Comment so I don't forget why it's like this

* Skip unsupported compression types before opening filestream.

* Reenable non-start cab skipping

* TODO so i don't forget

* TODO so I don't forget

* iterate on continued block correctly.

* Handle incomplete extraction better

* Remove TODOs to ready for PR comments

* Missed one

* Some minor fixes before rewriting everything

* Next round of fixes.

* Next set of fixes

* Fix debug output
2026-01-24 10:08:18 -05:00
Matt Nadareski
2a6e193756 Formatting cleanup 2026-01-05 13:48:36 -05:00
HeroponRikiBestest
65a86d87f0 Fix mszip relying on exceptions (#52)
* Better fix

* initial

* Fixed

* Move function to proper location, clear memory better

* work so far

* more

* more work

* No more per file seeking

* Finished work for now.

* First round of fixes.

* Return if array is empty too
2026-01-05 13:45:20 -05:00
HeroponRikiBestest
d7131dfa4c fix naming (#53) 2025-12-04 11:10:46 -05:00
HeroponRikiBestest
a228b16314 Fix GCF extraction (#48) 2025-12-04 10:46:13 -05:00
Matt Nadareski
b8c9048ac6 Update GrindCore to 0.6.5 2025-12-02 19:35:20 -05:00
HeroponRikiBestest
0b54350d59 Explicitly handle password-protected archives rather than repeatedly throwing exceptions (#47)
* Explicitly handle password-protected archives rather than repeatedly throwing exceptions

* Fix logic error

* Continues

* Remove bool
2025-12-02 09:38:11 -05:00
Deterous
59eddb7129 Fix ISO9660 extraction of large files (#46)
* ExtentLength is uint

* Fix

* fix2

* fix3

* fix4

* Invert multi extent final extent logic
2025-12-02 07:31:31 -05:00
Matt Nadareski
1096232f9d Update GC libraries 2025-11-30 19:40:35 -05:00
Matt Nadareski
4b39ee8d00 Add CRC-16 and CRC-64 dat support 2025-11-29 10:11:05 -05:00
Matt Nadareski
27a9b12bbf Bump version 2025-11-25 07:45:09 -05:00
Matt Nadareski
11319c3341 Update GC.SharpCompress 2025-11-25 07:44:29 -05:00
Matt Nadareski
4de061e0d1 Bump version 2025-11-24 08:59:19 -05:00
Matt Nadareski
258e894c30 Update GC.SharpCompress 2025-11-23 19:59:28 -05:00
Matt Nadareski
8658eaf4e0 Format GHA definitions 2025-11-17 08:39:16 -05:00
Matt Nadareski
6d341abc75 Fix comment about CFB 2025-11-17 08:33:00 -05:00
Matt Nadareski
4821d63b4a Off-by-one spacing 2025-11-15 09:10:34 -05:00
Matt Nadareski
0617bf3170 Process all folders in all MS-CAB files in a set (fixes #43) 2025-11-15 09:00:28 -05:00
Matt Nadareski
425d13a2ac Fix inconsistencies in IS-CAB 2025-11-14 23:21:04 -05:00
Matt Nadareski
8a1e90f537 Reduce unnecessary casts 2025-11-14 21:33:55 -05:00
Matt Nadareski
ddc00948ed Remove red herring zlib code 2025-11-14 21:08:55 -05:00
Matt Nadareski
c96ee81f06 Simplify fixed statements 2025-11-14 20:36:46 -05:00
Matt Nadareski
f6201e2c35 In-depth cleanup with .NET 10 concepts 2025-11-14 14:06:43 -05:00
Matt Nadareski
d63fcfcf7f Minor formatting change to external code 2025-11-14 10:30:15 -05:00
Matt Nadareski
dcc50c4c23 Remove empty .gitmodules 2025-11-14 10:28:55 -05:00
Matt Nadareski
60e46e580d Cache more properties using the field keyword 2025-11-14 10:14:50 -05:00
Matt Nadareski
0638998773 Use auto-fields where possible 2025-11-14 09:48:00 -05:00
Matt Nadareski
ad3113987b Add support for .NET 10 2025-11-14 09:06:59 -05:00
Matt Nadareski
f2f0d0f2e7 Try to fix self-referencing MS-CAB 2025-11-13 14:07:46 -05:00
Matt Nadareski
f7fd2f6f65 Name some type parameters 2025-11-11 09:57:38 -05:00
Matt Nadareski
281c18e21d Bump version 2025-11-06 08:08:10 -05:00
Matt Nadareski
1a9c8b5392 Scaffolding for the future 2025-11-06 08:01:04 -05:00
Deterous
831a272f4b Final ISO9660 fix (#41)
* debug

* using

* Test fix

* Final fix
2025-11-05 20:26:42 -05:00
Matt Nadareski
f47e68b9ba Add Mode0 and Mode2 formless models 2025-11-05 09:49:32 -05:00
Matt Nadareski
eaabd2ee77 Add static readers for CD-ROM sector types 2025-11-05 09:37:56 -05:00
Matt Nadareski
a269edd6ea Missed one explicit type 2025-11-05 09:20:48 -05:00
Matt Nadareski
3bb501ce0c Separate out some helper methods 2025-11-05 09:14:37 -05:00
Deterous
d0006a4653 Custom ISO Stream for full CDROM support (#40)
* Implement custom ISO stream for CDROM support

* Delete old files

* Delete old test

* Leaner CDROM wrapper

* Fix custom stream

* WrapperBase using ISO stream

* Reset stream after deserializing

* Fix SeekOrigin

* Return to cached position

* CDROM Constants

* correct ns

* fix href
2025-11-05 08:20:34 -05:00
Matt Nadareski
c48a1394bc Be descriptive about types 2025-11-04 14:15:39 -05:00
Matt Nadareski
fcf7fcfd44 Be descriptive about types 2025-11-04 10:49:03 -05:00
Matt Nadareski
cca08e7103 Use consistent naming 2025-11-04 10:27:00 -05:00
Matt Nadareski
b908732f5c Fix logical block extension 2025-11-04 10:25:55 -05:00
Matt Nadareski
4ee4a6e85f Slight extension cleanup 2025-11-04 10:07:57 -05:00
Matt Nadareski
7990f11bab Remove unnecessary null checks 2025-11-04 09:54:24 -05:00
Matt Nadareski
427f7c9136 Remove unnecessary null checks 2025-11-04 09:46:03 -05:00
Matt Nadareski
f938f1593d Formatting update for readability 2025-11-04 09:15:12 -05:00
Matt Nadareski
480a1834ed Logic inversion and slight cleanup 2025-11-03 20:16:54 -05:00
Matt Nadareski
df5acc648c Minor cleanup 2025-11-03 10:31:30 -05:00
Matt Nadareski
10569e6aa1 Add tests for CDROM 2025-11-03 10:29:52 -05:00
Matt Nadareski
e5103b4830 Fix format comment for ExtractionTool 2025-11-03 09:27:57 -05:00
Matt Nadareski
513646fc53 Fix ExtractionTool publish 2025-11-03 09:03:45 -05:00
Matt Nadareski
27f723bf2f CascLibSharp isn't used and can be removed 2025-11-03 08:53:04 -05:00
Matt Nadareski
6511ecb5ad Merge pull request #39 from SabreTools/storm
Directly include StormLibSharp
2025-11-03 08:39:47 -05:00
Matt Nadareski
7bf6e6f344 Code cleanup and slight modernization 2025-11-03 08:36:12 -05:00
Matt Nadareski
d3e340ae39 Add and use MPQ filename constants 2025-11-02 23:21:29 -05:00
Matt Nadareski
22167a9617 Recursion isn't needed now 2025-11-02 22:27:02 -05:00
Matt Nadareski
48bea55133 Enable extraction on all .NET versions (not OSes) 2025-11-02 22:20:21 -05:00
Matt Nadareski
42239919e5 Enable StormLib for all .NET versions 2025-11-02 22:07:40 -05:00
Matt Nadareski
4840d9df6e Remove NoWarn and fix issues 2025-11-02 21:41:58 -05:00
Matt Nadareski
1378b87ea6 Directly include StormLibSharp code 2025-11-02 21:11:39 -05:00
Matt Nadareski
6b48164b97 Remove StormLibSharp as submodule 2025-11-02 21:07:51 -05:00
Matt Nadareski
50b09aa249 Automated cleanup 2025-11-02 19:28:16 -05:00
Deterous
ecbd147f6d CD-ROM (Volume Descriptor Set) support (#37)
* CD-ROM Wrapper

* Fix CDROMVolume Reader

* Fix SectorMode enum
2025-11-02 19:21:19 -05:00
HeroponRikiBestest
c13df79848 Fix extraction of recent MPF-zipped logs (#38)
* Fix extraction of recent MPF-zipped logs

* Use greater than or equal to

* corrected logic
2025-11-02 08:35:02 -05:00
Deterous
48bcc1de5b ISO9660: Skip interleaved files and other fixes (#35)
* Skip interleaved files

* Fix warning logic

* Refactor

* Fix extraction

* Multi extent

* review
2025-11-01 22:52:41 -04:00
Matt Nadareski
d082f5de25 Auto formatting cleanup 2025-10-31 21:07:13 -04:00
Deterous
c2321669b6 Support ISO9660 Extended Attribute Record (#34)
* Support ISO9660 Extended Attribute Record

* fix

* Fix

* Don't extract multi-extent files

* ReadUInt16LittleEndian

* debug

* Fix

* Skip EAR when extracting files

* Add comment about EAR

* Fix same-name extraction

* Safer directory parsing

* even safer

* return null

* more directory record checks

* not nullable nullable

* init system use

* valid records should pass

* review

* remove empty case
2025-10-31 21:04:45 -04:00
Matt Nadareski
e382635b85 Fix accidental recursion 2025-10-31 14:01:25 -04:00
Matt Nadareski
b4e02d7f8c Ensure default values in models when not optional 2025-10-31 13:59:28 -04:00
Matt Nadareski
0dc8a0b6c0 One missed explicit endian read 2025-10-31 09:36:28 -04:00
Matt Nadareski
171834986d Fix build from previous cleanup 2025-10-31 00:01:35 -04:00
Matt Nadareski
97af686b73 ZSTD model cleanup 2025-10-30 23:59:25 -04:00
Matt Nadareski
7d627ffc6f XZP model cleanup 2025-10-30 23:59:08 -04:00
Matt Nadareski
d924f25eb2 XZ model cleanup 2025-10-30 23:57:15 -04:00
Matt Nadareski
abd8ef3b1f Xbox model cleanup 2025-10-30 23:55:08 -04:00
Matt Nadareski
e9b8dba3a6 WiseInstaller model cleanup 2025-10-30 23:54:22 -04:00
Matt Nadareski
aaff7e7332 WAD3 model cleanup 2025-10-30 23:50:44 -04:00
Matt Nadareski
2fa00d1a16 VPK model cleanup 2025-10-30 23:48:26 -04:00
Matt Nadareski
8a2a2ecd12 TAR model cleanup 2025-10-30 23:45:14 -04:00
Matt Nadareski
98517bdd8c StarForce model cleanup 2025-10-30 23:43:06 -04:00
Matt Nadareski
dfe76f7e7e SpoonInstaller model cleanup 2025-10-30 23:41:40 -04:00
Matt Nadareski
a2e24b1f5f SGA model cleanup 2025-10-30 23:40:45 -04:00
Matt Nadareski
6a4e76e245 SevenZip model cleanup 2025-10-30 23:34:20 -04:00
Matt Nadareski
1ebec97e0e SecuROM model cleanup 2025-10-30 23:34:06 -04:00
Matt Nadareski
b9f03b02f0 RealArcade model cleanup 2025-10-30 23:31:19 -04:00
Matt Nadareski
2c06760778 RAR model cleanup 2025-10-30 23:31:01 -04:00
Matt Nadareski
3f0ee70b71 Quantum model cleanup 2025-10-30 23:30:45 -04:00
Matt Nadareski
05b34f158b PortableExecutable model cleanup 2025-10-30 23:29:24 -04:00
Matt Nadareski
e08db935b4 PlayStation4 model cleanup 2025-10-30 23:07:12 -04:00
Matt Nadareski
47da068bd3 PlayStation3 model cleanup 2025-10-30 23:06:46 -04:00
Matt Nadareski
9de669606d PlayJ model cleanup 2025-10-30 23:05:24 -04:00
Matt Nadareski
a02d50e61d PKZIP model cleanup 2025-10-30 23:01:55 -04:00
Matt Nadareski
069dab7fba PIC model cleanup 2025-10-30 22:58:02 -04:00
Matt Nadareski
d65edadbbb PFF model cleanup 2025-10-30 22:56:23 -04:00
Matt Nadareski
6307a51c0a PAK model cleanup 2025-10-30 22:54:37 -04:00
Matt Nadareski
d27c602bdf OLE model cleanup 2025-10-30 22:52:56 -04:00
Matt Nadareski
59fe9cb113 Nitro model cleanup 2025-10-30 22:51:16 -04:00
Matt Nadareski
b4b7ba75cb NewExecutable model cleanup 2025-10-30 22:47:17 -04:00
Matt Nadareski
d02e0c16c4 NCF model cleanup 2025-10-30 22:39:08 -04:00
Matt Nadareski
4aa0eb54b7 N3DS model cleanup 2025-10-30 22:36:21 -04:00
Matt Nadareski
c4f73abcb6 MSDOS model cleanup 2025-10-30 22:15:10 -04:00
Matt Nadareski
73dec51a4d MoPaQ model cleanup 2025-10-30 22:12:06 -04:00
Matt Nadareski
b7c3c094ae MicrosoftCabinet model cleanup 2025-10-30 22:07:29 -04:00
Matt Nadareski
97702ab3d5 LZ model cleanup 2025-10-30 22:03:22 -04:00
Matt Nadareski
a9b5fe706c LinearExecutable model cleanup 2025-10-30 22:00:42 -04:00
Matt Nadareski
198d48610c LDSCRYPT model cleanup 2025-10-30 21:55:01 -04:00
Matt Nadareski
c0e0344914 IRD model cleanup 2025-10-30 21:54:27 -04:00
Matt Nadareski
d49b2f1b60 InstallShieldExecutable model cleanup 2025-10-30 21:52:20 -04:00
Matt Nadareski
ec7172466b InstallShieldCabinet model cleanup 2025-10-30 21:51:15 -04:00
Matt Nadareski
d75a512ead InstallShieldArchiveV3 model cleanup 2025-10-30 21:43:38 -04:00
Matt Nadareski
af8b6906b6 GZIP model cleanup 2025-10-30 21:40:25 -04:00
Matt Nadareski
96bc301e6d GCF model cleanup 2025-10-30 21:38:17 -04:00
Matt Nadareski
c10749f34d DVD model cleanup 2025-10-30 21:32:21 -04:00
Matt Nadareski
0e4235c8ba Delphi model cleanup 2025-10-30 21:30:41 -04:00
Matt Nadareski
b2d31bb87e CueSheets model cleanup 2025-10-30 21:30:13 -04:00
Matt Nadareski
3ee88793da COFF model cleanup 2025-10-30 21:29:24 -04:00
Matt Nadareski
ad0f01c3ef CHD model cleanup 2025-10-30 21:27:37 -04:00
Matt Nadareski
63a96a7cf8 CFB model cleanup 2025-10-30 21:26:19 -04:00
Matt Nadareski
b8d8ca9a5c BZip2 model cleanup 2025-10-30 21:22:33 -04:00
Matt Nadareski
6b0fca31ae BSP model cleanup 2025-10-30 21:21:56 -04:00
Matt Nadareski
c147b12b10 Bitmap model cleanup 2025-10-30 20:58:03 -04:00
Matt Nadareski
7884b0b775 BFPK model cleanup 2025-10-30 20:57:35 -04:00
Matt Nadareski
9f3c263328 BDPlus model cleanup 2025-10-30 20:55:39 -04:00
Matt Nadareski
b830ce3d73 AdvancedInstaller model cleanup 2025-10-30 20:54:32 -04:00
Matt Nadareski
e8b7f33bf0 AACS model cleanup 2025-10-30 20:52:35 -04:00
Matt Nadareski
eae75c5943 Allow byte arrays to be non-null in most models 2025-10-30 20:44:16 -04:00
Matt Nadareski
c1f5ebcae1 Remove experiments 2025-10-30 19:50:03 -04:00
Matt Nadareski
acb8e98fe2 Add ImgBurn and UltraISO check extensions 2025-10-30 17:04:29 -04:00
Matt Nadareski
a24a92e97c Add unset reserved bytes extension 2025-10-30 16:22:05 -04:00
Matt Nadareski
f2d2fe97bb Override 2025-10-30 12:06:42 -04:00
Matt Nadareski
705252eec7 Unify Skeleton to ISO-9660 2025-10-30 12:03:13 -04:00
Matt Nadareski
69ae0456f0 Add skeleton printing and tests 2025-10-30 11:50:37 -04:00
Deterous
f07bd07cce Redumper skeleton support (#32)
* Skeleton support

* hide ISO extract

* Return true

* Don't inherit ISO9660

* fix

* fix2

* Skeleton
2025-10-30 11:46:45 -04:00
Matt Nadareski
9db2d2ca05 Reduce complexity of Zstd filename generation 2025-10-30 10:23:50 -04:00
Deterous
85248b0135 ISO 9660 Extraction (#31)
* ISO9660 Extraction

* Fix build

* Decode strings in Printer

* Double comment
2025-10-30 10:00:10 -04:00
Matt Nadareski
8663edc7df Fix unsynced ISO position 2025-10-30 08:20:46 -04:00
Matt Nadareski
b9cc9e40fd Changes based on a code sweep with unrelated issue 2025-10-30 07:51:08 -04:00
HeroponRikiBestest
5ce085ad2b Implement basic ZSTD detection and extraction. (#30)
* Implement basic ZSTD detection and extraction.

* Fix comment

* Remove newline

* Add newline

* Move section

* more newlines banished to the ether

* fix comment and name

* fix final i think
2025-10-29 22:01:23 -04:00
Matt Nadareski
d24f8a2fce Add ECMA link to models readme 2025-10-29 10:11:39 -04:00
Matt Nadareski
a73e830209 This extension is useful 2025-10-29 09:46:12 -04:00
Matt Nadareski
146fb42fd0 Replace remaining Seek with SeekIfPossible 2025-10-29 09:34:52 -04:00
Matt Nadareski
5b54ed719e Better integrate new printing model 2025-10-29 09:23:45 -04:00
Matt Nadareski
02d011228e IRD wrapper exists and should be used 2025-10-29 08:57:01 -04:00
Matt Nadareski
07adfd20a3 Add tests for ISO9660 2025-10-29 08:55:45 -04:00
Matt Nadareski
1d00abd6cc Make printing a wrapper extension 2025-10-29 08:53:14 -04:00
Deterous
36c2cc2f15 ISO 9660 support (#29)
* Begin defining ISO9660 models

* Fix initial models

* Improve ISO9660 models

* ISO9660 models

* Fix fields

* Nullable and enums

* Fix flags attribute

* Start ISO9660 Reader code

* semicolon

* Fix build

* Use EqualsExactly

* Fix build

* Update ISO9660.cs

* Update ISO9660.cs

* Move DirectoryRecordDateTime class

* ParseDirectoryRecordDateTime function

* ST refactoring

* fix return

* return array

* ISO9660 wrapper

* Initial printing code

* semicolon

* Fix

* orphan variable name

* fix null ref

* ISO9660 Printer

* Fix DirectoryRecord parsing

* fix

* test

* test

* Fix reader

* extractable ISO

* partial wrapper class

* namespace

* extension property

* path tables

* Cleanup

* rename directory

* fix

* fix

* typo

* fix2

* Fix

* Cleanup reader

* Count list property

* Parse Path Tables

* fix model name

* fix

* fix2

* fix3

* print path table records

* debug errors

* debug error

* debug

* undo debug

* Fix casting

* Validate path table locations

* print table numbers

* Printer cleanup

* fix printer

* printer++

* Print DecDateTime

* else if

* BootSystemUse

* Use Linq

* custom zero check

* fix

* Update ISO9660.cs

* Update ISO9660.cs

* Update ISO9660.cs

* Update ISO9660.cs

* fix

* debug

* debug2

* debug3

* debug4

* debug5

* debug6

* debug7

* debug8

* Array.TrueForAll

* Update ISO9660.cs

* fix

* cleanup

* typo

* Use BothInt numerics

* using SabreTools.Numerics

* Test nonnull

* nonnull bothint

* Print invalid BothInts

* Print directory record

* typo

* fix

* null check

* directory descriptors

* cleanup printer

* semicolon

* Fix

* flags never null

* more non nullable

* no null

* AppendLineBothEndian

* fix

* rename to Directory

* fix

* namespace

* full namespace

* fix

* cleanup

* Parse directories

* fix

* Fix

* Test parse directories

* PeekByteValue

* Revert CI changes

* Dummy extractor

* Review and fixes

* Fixes

* Final fix

* big endian directory search

* fix big endian changes

* Final fix
2025-10-29 08:46:08 -04:00
Matt Nadareski
27cf01ce84 Add printing cases for empty alongside null 2025-10-28 09:52:53 -04:00
Matt Nadareski
1e94163693 Add both-endian StringBuilder extensions
This has to use a new name for the both-endian handling because otherwise the implicit type handling will otherwise cause compilation errors.
2025-10-28 09:49:38 -04:00
Matt Nadareski
db1f94775b Convert some known Peek calls 2025-10-27 22:55:25 -04:00
Matt Nadareski
ce394eb4e9 Seek, if possible 2025-10-27 22:43:56 -04:00
Matt Nadareski
15109bed88 Update IO to 1.8.0 2025-10-27 22:15:54 -04:00
Matt Nadareski
8a18c8de34 Update rolling tag 2025-10-26 20:31:03 -04:00
HeroponRikiBestest
2f093a80c7 increase buffer size for isexe reading / writing based on deterous's … (#28)
* increase buffer size for isexe reading / writing based on deterous's input

* remove comment
2025-10-26 18:54:35 -04:00
Matt Nadareski
5df1af9c17 Minor cleanup and additions 2025-10-23 16:05:12 -04:00
HeroponRikiBestest
d5ab37a5a6 Add extraction for installshield executables. (#27)
* Add extractor for installshield executables.

* Add comment

* Fix intendation.

* Ensure PRs recursively pull

* Rebase

* Fix formatting for parsex

* newline before obj.name

* Changed while loop check to a position vs length check

* Specify type for chunkSize

* declare chunksize as a const int outside of the loop

* Open file writer with using

* Call fs.flush after every write.

* Improved chunk writing loop.

* Remove now-unecessary variable

* Properly handle extracting files of size greater than int32.

* Use long for overlay address

* create deserializer outside of loop.

* Move null check.

* Don't cache position.

---------

Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
2025-10-23 15:38:51 -04:00
Matt Nadareski
ed9ecf0da9 Ensure PRs recursively pull 2025-10-23 12:08:47 -04:00
Matt Nadareski
4fc17197ca Fix inverted logic of file only flag 2025-10-19 17:59:56 -04:00
Matt Nadareski
94a9cf0c3f Minor tweak to Wise debug statements 2025-10-17 09:56:04 -04:00
Matt Nadareski
1d9e12183f Bump version 2025-10-07 12:42:06 -04:00
Matt Nadareski
aaa8bbe709 This was inconsistent too 2025-10-07 11:25:35 -04:00
Matt Nadareski
805d1b9ad8 Not sure why this part was inconsistent 2025-10-07 11:21:39 -04:00
Matt Nadareski
d24d3e5adb Remove now-unused constants 2025-10-07 10:48:31 -04:00
Matt Nadareski
d3a7d552c3 Use main feature pattern with InfoPrint 2025-10-07 10:20:57 -04:00
Matt Nadareski
9f1c5e2bd2 Use main feature pattern with ExtractionTool 2025-10-07 10:04:19 -04:00
Matt Nadareski
1ec4ea8354 Update packages 2025-10-07 09:37:42 -04:00
Matt Nadareski
e4fab52489 Use CommandLine library for executables 2025-10-06 09:32:01 -04:00
Matt Nadareski
e029fa4833 Skip warning around GC.SharpCompress inclusion 2025-10-05 17:02:44 -04:00
Matt Nadareski
2c3f229a6a Bump version 2025-10-05 16:59:33 -04:00
Matt Nadareski
3558d3532c Do not update offset on name offset 2025-10-02 13:33:51 -04:00
Matt Nadareski
ad5314dc22 Minor tweak 2025-10-01 20:08:33 -04:00
Matt Nadareski
eaa5bb5662 Sections can't be null 2025-10-01 20:06:05 -04:00
Matt Nadareski
fcdc703595 Update readme to be accurate again 2025-09-30 20:58:52 -04:00
Matt Nadareski
ef9fa562ab More BZip documenting 2025-09-30 20:35:40 -04:00
Matt Nadareski
ac285c48fe Start documenting BZip in code 2025-09-30 20:25:18 -04:00
Matt Nadareski
e57ad65210 Migrate to GrindCore fork of SharpCompress 2025-09-30 19:52:14 -04:00
Matt Nadareski
0fc3a30422 Print a couple more XZ fields 2025-09-30 14:09:40 -04:00
Matt Nadareski
49f6704694 Add initial XZ printer 2025-09-30 14:05:34 -04:00
Matt Nadareski
6df712c538 Add XZ parsing to wrapper 2025-09-30 13:56:21 -04:00
Matt Nadareski
bda3076a30 Further XZ parsing fixes 2025-09-30 13:56:11 -04:00
Matt Nadareski
89e8e7c706 Fix more XZ parsing; use read-from-end 2025-09-30 13:22:26 -04:00
Matt Nadareski
c10835d221 Start fixing XZ parsing 2025-09-30 13:08:53 -04:00
Matt Nadareski
a6801350ea Fix issue with XZ enum 2025-09-30 12:48:12 -04:00
Matt Nadareski
c7a5a62041 Require exact versions for build 2025-09-30 11:09:37 -04:00
Matt Nadareski
749b35e5cb Slight tweak to CHD v5 model 2025-09-30 10:59:44 -04:00
Matt Nadareski
3c520d33eb Add XZ reader, fix some minor issues 2025-09-30 09:47:19 -04:00
Matt Nadareski
635170a051 Add reference for BZ2 2025-09-29 23:38:40 -04:00
Matt Nadareski
9619311d11 Store variable-length numbers as ulong 2025-09-29 23:32:58 -04:00
Matt Nadareski
4bee14835c Fix last couple of commits 2025-09-29 23:12:23 -04:00
Matt Nadareski
f44059e16a Add XZ variable length helper methods 2025-09-29 23:07:05 -04:00
Matt Nadareski
bfb206a06d Add XZ models 2025-09-29 22:56:53 -04:00
Matt Nadareski
6b7b05eb31 Port some extensions for GZip from ST 2025-09-29 22:04:10 -04:00
Matt Nadareski
a9a2a04332 Store raw extras field for odd formatting 2025-09-29 21:49:20 -04:00
Matt Nadareski
50459645dd Add a couple GZ constants 2025-09-29 21:39:37 -04:00
Matt Nadareski
564386038f Try using Environment instead of compiler flags 2025-09-29 12:29:14 -04:00
Matt Nadareski
9f229aad47 Bump version 2025-09-29 07:27:50 -04:00
Matt Nadareski
f6f6ea21b4 Sync README with help text 2025-09-28 21:47:37 -04:00
Matt Nadareski
ec416d5631 Document all local samples 2025-09-27 22:47:43 -04:00
Matt Nadareski
335cbca8fb Add clarification 2025-09-27 22:04:20 -04:00
Matt Nadareski
ab8d5ec475 Split unknown AddD field, fix TODO 2025-09-27 22:02:10 -04:00
Matt Nadareski
ef9f050fbf Signature is clearly a string 2025-09-27 21:47:55 -04:00
Matt Nadareski
46b1838d72 Clean up some things around AddD 2025-09-27 21:46:03 -04:00
HeroponRikiBestest
2b9a527743 Small fix just in case. (#25) 2025-09-27 12:59:02 -04:00
HeroponRikiBestest
cb41f8a8a6 Temporary fix for solid archive detection until SharpCompress makes another release. (#24) 2025-09-27 12:32:10 -04:00
Matt Nadareski
fcf003af7d Split Wise extraction to be smarter 2025-09-27 08:26:57 -04:00
Matt Nadareski
350924545c Fix bzip constants 2025-09-26 23:49:35 -04:00
Matt Nadareski
ae6bf0f2da Fix issues from manual testing 2025-09-26 22:52:09 -04:00
Matt Nadareski
7395d9842c Complete Spoon Installer extraction 2025-09-26 22:30:59 -04:00
Matt Nadareski
741a1e13d0 Add framework for Spoon Installer extraction 2025-09-26 22:27:27 -04:00
Matt Nadareski
447064afc1 Add Spoon Installer reader 2025-09-26 22:23:20 -04:00
Matt Nadareski
a443a6833a Add integer values for better research 2025-09-26 22:18:41 -04:00
Matt Nadareski
160239eba7 Add Spoon Installer models and notes 2025-09-26 22:12:27 -04:00
Matt Nadareski
04fb3fd363 Fix documentation issue 2025-09-26 22:02:35 -04:00
Matt Nadareski
ba60c9b516 Add extraction for Advanced Installer 2025-09-26 19:56:51 -04:00
Matt Nadareski
f8ddfcf5ae Add framework for Advanced Installer extraction 2025-09-26 19:43:39 -04:00
Matt Nadareski
c379bdcadc Fix description 2025-09-26 16:49:21 -04:00
Matt Nadareski
575caeda92 Make fixes from manual testing 2025-09-26 16:38:56 -04:00
Matt Nadareski
0d4dcf4a60 Start implementing Advanced Installer reader 2025-09-26 16:30:38 -04:00
Matt Nadareski
ddb14a69d0 Forgot to rename Writers folder 2025-09-26 16:29:16 -04:00
Matt Nadareski
f1ace61076 Introduce and use BaseMetadataSerializer 2025-09-26 16:00:33 -04:00
Matt Nadareski
0f5f866cd2 Rename IModelSerializer to ICrossModel 2025-09-26 15:48:36 -04:00
Matt Nadareski
bd866c5b05 Update package tags 2025-09-26 15:36:22 -04:00
Matt Nadareski
07ea1abbf8 Use correct block format for readme 2025-09-26 15:33:38 -04:00
Matt Nadareski
6853376f60 Unify type parameter naming 2025-09-26 15:28:53 -04:00
Matt Nadareski
0e67f0bff4 Move wrapper interfaces to better namespace 2025-09-26 15:20:49 -04:00
Matt Nadareski
6035c19f47 Move IPrinter interface to better namespace 2025-09-26 15:13:43 -04:00
Matt Nadareski
592a3d3505 Rename *Serializer interfaces to *Writer 2025-09-26 15:10:59 -04:00
Matt Nadareski
2c092ed665 Rename *Deserializer interfaces to *Reader 2025-09-26 15:02:43 -04:00
Matt Nadareski
2bd4a00df4 Rename Serializers to Writers 2025-09-26 14:59:45 -04:00
Matt Nadareski
f0639b28b9 Rename Deserializers to Readers 2025-09-26 14:57:20 -04:00
Matt Nadareski
775bab6656 Add AACS extension 2025-09-26 14:27:49 -04:00
Matt Nadareski
c82d865cd5 Move Extensions to Data path 2025-09-26 13:15:55 -04:00
Matt Nadareski
0b95b9509a Move Printers to Data path 2025-09-26 13:11:57 -04:00
Matt Nadareski
d8185e3970 Move Models to Data path 2025-09-26 13:06:18 -04:00
Matt Nadareski
b3a3766d77 Create and use Attributes namespace 2025-09-26 12:44:16 -04:00
Matt Nadareski
3681682fe8 Internal rename of OID namespace to have Data prefix 2025-09-26 12:29:52 -04:00
Matt Nadareski
12c292d038 Namespace reference cleanup 2025-09-26 12:27:10 -04:00
Matt Nadareski
5af4de2878 Migrate remaining models from Models 2025-09-26 12:09:34 -04:00
Matt Nadareski
2e7f18c407 Migrate non-executable models from Models 2025-09-26 11:57:18 -04:00
Matt Nadareski
48248b2832 Add namespace to the readme 2025-09-26 11:43:49 -04:00
Matt Nadareski
c6082fa7c7 Migrate support file models from Models 2025-09-26 11:42:28 -04:00
Matt Nadareski
3af19510a8 Migrate archive models from Models 2025-09-26 10:57:15 -04:00
Matt Nadareski
2a12b8132f Add README for Models namespace 2025-09-26 10:24:36 -04:00
Matt Nadareski
3daec985ba Migrate metadata models from Models 2025-09-26 10:20:48 -04:00
Matt Nadareski
4b79ee103c Simplify overlay address finding slightly 2025-09-25 21:34:41 -04:00
Matt Nadareski
077abd590a Use constants, add CFB detection to overlays and resources 2025-09-25 21:13:07 -04:00
Matt Nadareski
cab890b1d9 Remove erroneous duplicate code 2025-09-25 20:29:51 -04:00
Matt Nadareski
d3f0858ec4 Forgot the second adjustment 2025-09-25 20:28:25 -04:00
Matt Nadareski
97896b91d7 Cap overlay at 0x10000 bytes 2025-09-25 20:14:41 -04:00
Matt Nadareski
ca354b3b7f Comment about entry point data caching 2025-09-25 16:24:20 -04:00
Matt Nadareski
d035211a64 Off by one? 2025-09-25 16:20:15 -04:00
Matt Nadareski
75728a4d1d Handle large overlays in extraction 2025-09-25 14:07:01 -04:00
Matt Nadareski
265789ea84 Overlay address in PE should be long, fix caching 2025-09-25 13:55:44 -04:00
Matt Nadareski
4577311432 Adjust overlay address for PE using certificate table 2025-09-25 13:53:56 -04:00
Matt Nadareski
963c333c2e Cache the overlay length 2025-09-25 13:50:51 -04:00
Matt Nadareski
6eff6cf3b6 Add TODOs to handle large overlays 2025-09-25 13:41:51 -04:00
Matt Nadareski
c9794691bb Limit overlay caching to int.MaxValue 2025-09-25 13:40:29 -04:00
Matt Nadareski
9574232719 Bump version 2025-09-24 11:06:47 -04:00
Matt Nadareski
676bf584d6 Clean up some console writes 2025-09-24 10:55:39 -04:00
Matt Nadareski
0a4fd01ede Gate MS-CAB warning behind debug to avoid confusion 2025-09-24 10:51:27 -04:00
Matt Nadareski
6cb4023498 Update namespaces in README 2025-09-24 10:50:12 -04:00
Matt Nadareski
8f775dbb3b This should be ObjectIdentifier not strictly ASN.1 2025-09-24 10:47:00 -04:00
Matt Nadareski
91785eab1f Fix tests 2025-09-24 10:40:39 -04:00
Matt Nadareski
4f8751667a Namespace ASN models until Models is updated 2025-09-24 10:40:30 -04:00
Matt Nadareski
ad7508c464 Add some more OIDs 2025-09-24 10:11:21 -04:00
Matt Nadareski
97a9e141ae Add some more OIDs 2025-09-24 09:54:18 -04:00
Matt Nadareski
842a0c3daf Remove useless PathProcessor helper class 2025-09-24 09:43:27 -04:00
Matt Nadareski
b6acde9145 Make consistent with other deserializers 2025-09-24 09:27:24 -04:00
Matt Nadareski
b97dbc2ac5 Simplify extension code slightly 2025-09-24 09:22:23 -04:00
Matt Nadareski
e03852bd7e Simplify ASN.1 integration 2025-09-24 09:19:46 -04:00
Matt Nadareski
0db5de204e Rename TLV deserializer to be more consistent 2025-09-24 09:06:26 -04:00
Matt Nadareski
5fe3f14419 Make TypeLengthValue more model-like 2025-09-24 09:00:48 -04:00
Matt Nadareski
ffe1d9a82d Create and use TypeLengthValue deserializer 2025-09-24 08:54:25 -04:00
Matt Nadareski
11d6560290 Update IO to 1.7.5 2025-09-24 08:30:24 -04:00
Matt Nadareski
e29d8e6728 Integrate ASN.1 code from separate library 2025-09-24 08:25:11 -04:00
Matt Nadareski
918e81a4cb Move extensions to new namespace for cleanliness 2025-09-23 09:58:44 -04:00
Matt Nadareski
ad0ddede38 Fix reference issue 2025-09-22 21:21:43 -04:00
Matt Nadareski
e969b12884 Move wrapper factory up a level 2025-09-22 21:14:33 -04:00
Matt Nadareski
7a5475255f Fix the fake wrapper tests 2025-09-22 20:14:01 -04:00
Matt Nadareski
0ffd436de8 Update packages 2025-09-22 20:07:18 -04:00
Matt Nadareski
4f685187e9 COFF naming doesn't need to continue 2025-09-22 12:56:19 -04:00
Matt Nadareski
2b356b37b1 Sync NE overlay handling with PE 2025-09-22 10:08:46 -04:00
Matt Nadareski
7c56268eb1 Add PFF version 0 detection 2025-09-22 09:35:46 -04:00
Matt Nadareski
970a54e6e3 Add placeholder SFFS wrapper 2025-09-22 09:13:27 -04:00
Matt Nadareski
e35ddf0780 Always overwrite on output, ensure flushed streams 2025-09-21 21:10:40 -04:00
Matt Nadareski
bf35b7c10b Bump version 2025-09-21 12:35:37 -04:00
Matt Nadareski
4026b8ca09 Handle differently-encoded XMLs as textfiles 2025-09-21 12:10:58 -04:00
Matt Nadareski
6d2e2d8c3b Handle some invalid parsing cases that were missed previously 2025-09-21 11:44:58 -04:00
Matt Nadareski
a2b08157cc Fix issue with split resource tables 2025-09-21 11:23:53 -04:00
Matt Nadareski
0108ecf4c1 Bump version 2025-09-21 09:33:55 -04:00
Matt Nadareski
4921da0bb5 Fix issues from porting MPQ from BOS 2025-09-21 00:04:16 -04:00
Matt Nadareski
0c836bb3b1 Try one more thing? 2025-09-20 23:39:49 -04:00
Matt Nadareski
a8e41c1505 Try this 2025-09-20 23:24:12 -04:00
Matt Nadareski
f67e1c9d2b Bump version 2025-09-20 22:38:08 -04:00
Matt Nadareski
f0ce58a79e Move two things out of the lock 2025-09-20 22:32:54 -04:00
Matt Nadareski
b7f782c1b7 Update packages 2025-09-20 22:31:58 -04:00
Matt Nadareski
5e39e169b2 Clean up PE printing a bit 2025-09-20 20:17:38 -04:00
Matt Nadareski
104c5ccad4 XML resources and overlay 2025-09-20 19:48:45 -04:00
Matt Nadareski
d15b4d7d23 Bump version 2025-09-20 10:47:38 -04:00
Matt Nadareski
60e6a75d5e Make public again 2025-09-20 10:40:19 -04:00
Matt Nadareski
484415d0e5 Ensure the resource table has been parsed for version info 2025-09-20 10:36:09 -04:00
Matt Nadareski
0ef9b447c4 Remove extraneous semicolon 2025-09-20 10:34:08 -04:00
Matt Nadareski
8f64e2defd Minor cleanup to previous commit 2025-09-20 10:32:53 -04:00
HeroponRikiBestest
fbdadce129 Add Matroschka processing. (#23)
* Made changes

* Temporary hack to not rely on models without significantly changing current code. Revert all of this with offset-based reading later.

Also added unnecessary casting in wrapperfactory so serialization will build locally. Revert this, since I assume it somehow builds fine for GA/sabre/etc.

* small fixes

* Store matroschka section as PE extension

* Move extractor out of deserializer, remove weird hack

* Potential GA fix

* More potential GA fixes.

* I have no idea why GA hits that error but not me

* Giving up on GA for now

* fix locking issues

* Fix GA building; thank you sabre

* Minor improvements all around

* Catch some braced single-line if statements

* Use var more

* Seperate deserializer into helper methods

* Make file path reading much more sane

* Removed MatroschkaHeaderType enum

* Removed MatroschkaGapType enum, further simplify matgaphelper.

* Remove MatroschkaHasUnknown enum, further simplify Unknown value reading.

* Cache initial offset.

* Remove TryCreate patterns.

* Rename matroschka variable to package

* Newline after object

* Rename to obj

* Remove a few unecessary TODOs

* Seperate hexstring byte read to another line.

* Fix documentation.

* More private static

* Changed data.position setting to seeking. NTS: check if this broke anything later

* rename entries to obj

* MatroschkaEntry to var

* Newline

* Alphabetical

* More alphabetical.

* section to package

* Move private variables.

* Move to extension properties.

* Revert section finding.

* Remove uneeded _dataSource lock and access.

* combine lines and make var

* Combine two null checks.

* Packaged files, some past commits I think I forgot to push.

* Missed two

* newline

* space

* newline

* Combine two lines

* Removed comment

* Return false explicitly

* Change hashing string implementation

* Fix order.

* Use offset reading instead of filedataarray

* Change file reading around a little preemptively for BOS

---------

Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
2025-09-20 10:00:54 -04:00
Matt Nadareski
d3e7abfaa3 Normalize ReadRangeFromSource use 2025-09-20 09:49:42 -04:00
Matt Nadareski
b2279e97b2 CHD is all big-endian 2025-09-18 21:18:43 -04:00
Matt Nadareski
7cf969336f Fix this bumble 2025-09-18 20:54:30 -04:00
Matt Nadareski
f73d48166a Source isn't needed here anymore 2025-09-18 09:46:01 -04:00
Matt Nadareski
53af618fe4 Proof-of-concept Wise section caching 2025-09-18 09:40:15 -04:00
Matt Nadareski
5d2cf58477 Fix this being finicky 2025-09-17 12:56:32 -04:00
Matt Nadareski
664e7dce28 Greater than but not equal 2025-09-17 10:30:35 -04:00
Matt Nadareski
14a8f00864 Clean up nonstandard deserializers 2025-09-16 23:24:49 -04:00
Matt Nadareski
0b889fdc06 Remove weird holdover property 2025-09-16 23:11:14 -04:00
Matt Nadareski
e336efc149 Do the same for serializers 2025-09-16 22:29:52 -04:00
Matt Nadareski
4cd52162eb Static implementations using reflection go away 2025-09-16 22:25:40 -04:00
Matt Nadareski
eab9fff711 One slipped through the cracks 2025-09-16 22:22:32 -04:00
Matt Nadareski
d4f3511060 These don't need to call the reflection one 2025-09-16 22:21:22 -04:00
Matt Nadareski
ed12bbb35c Avoid hidden reflection call for most cases 2025-09-16 22:20:13 -04:00
Matt Nadareski
aa4629fe99 MPQ needs a distinction 2025-09-16 22:12:18 -04:00
Matt Nadareski
1950f23cf4 This should actually be a different exception type 2025-09-16 22:08:50 -04:00
Matt Nadareski
ca7c88cef6 Add better summaries for things 2025-09-16 22:07:05 -04:00
Matt Nadareski
10848e6c51 Fix issue with seeking by introducing more constructors 2025-09-16 21:54:26 -04:00
Matt Nadareski
f5d0f065c1 Handle unknown AACS records a bit better for now 2025-09-16 20:11:41 -04:00
Matt Nadareski
17b0573b0b Handle memory-padded resources tables and non-local resources 2025-09-12 10:50:22 -04:00
Matt Nadareski
7f1d843d96 Minor bugfix in name retrieval 2025-09-12 09:28:27 -04:00
Matt Nadareski
cc4837c1d1 More partial classes for reasonable things 2025-09-12 09:09:40 -04:00
Matt Nadareski
588ee5bfe4 Make partial classes for extraction 2025-09-12 09:02:03 -04:00
Matt Nadareski
e9b1b2750f Fill out the placeholder 2025-09-11 12:32:44 -04:00
Matt Nadareski
1d6fa06e97 Placeholder for section table trailer data 2025-09-11 12:24:56 -04:00
Matt Nadareski
2c22924239 Seek to section table to match docs 2025-09-11 12:17:48 -04:00
Matt Nadareski
eb01dd1e25 Add note for later 2025-09-11 12:14:07 -04:00
Matt Nadareski
0a3cb79b1c Fix issue found in encrypted and obfuscated PE 2025-09-11 12:07:22 -04:00
Matt Nadareski
da9eace8cc Slight tweak to printing again 2025-09-11 11:47:07 -04:00
Matt Nadareski
526a02b8b6 Slight tweak to printing again 2025-09-11 11:44:58 -04:00
Matt Nadareski
658c7a1c3b Add another safeguard? 2025-09-11 11:10:11 -04:00
Matt Nadareski
af84474795 Fix invalid base relocation table parsing 2025-09-11 10:58:15 -04:00
Matt Nadareski
42913c6732 Invalid export should be null, not empty 2025-09-11 10:49:01 -04:00
Matt Nadareski
2cdf544518 Fix an oddly-reading format 2025-09-11 10:45:17 -04:00
Matt Nadareski
652ec58238 Fix certificate table info printing 2025-09-11 10:41:09 -04:00
Matt Nadareski
f8531daa5c Ensure overlay accounts for certificates properly 2025-09-11 10:40:09 -04:00
Matt Nadareski
e9e89b0b43 This has been consistently wrong 2025-09-11 10:33:10 -04:00
Matt Nadareski
55e788a894 Ignore invalid certificate entries 2025-09-11 10:21:51 -04:00
Matt Nadareski
b28bb93ccb Handle non-section data with valid RVA 2025-09-11 10:11:05 -04:00
Matt Nadareski
367aab0f83 Add placeholder for figuring something out later 2025-09-11 09:59:42 -04:00
Matt Nadareski
9dcf3b9e0a The offset needs to be passed all the way 2025-09-11 09:42:48 -04:00
Matt Nadareski
3c514110ce The offset needs to be passed fully 2025-09-11 09:29:46 -04:00
Matt Nadareski
c9b0c2dace Deliberately don't retain position 2025-09-11 09:27:56 -04:00
Matt Nadareski
d575b6977e Correctly parse resource data 2025-09-11 09:21:31 -04:00
Matt Nadareski
a00e6a5e2d Start cleaning up resource parsing more 2025-09-11 09:09:56 -04:00
Matt Nadareski
1b9ae83e8c Don't pad most tables to aligned size 2025-09-11 08:35:49 -04:00
Matt Nadareski
8b91eb1caf Bound the import and export tables 2025-09-11 08:33:59 -04:00
Matt Nadareski
2a6a7b5e9a Pass in the correct data 2025-09-11 08:14:24 -04:00
Matt Nadareski
a85943866e Start using table data only in already-bounded tables 2025-09-11 08:12:27 -04:00
Matt Nadareski
797fb519c1 Pass table data in, mostly unused 2025-09-11 07:49:17 -04:00
Matt Nadareski
3ba9d56363 Read table data directly 2025-09-11 07:44:28 -04:00
Matt Nadareski
04cd4e4056 Start wiring through size bounding on table reads 2025-09-11 07:41:17 -04:00
Matt Nadareski
348e170654 There 2025-09-10 21:54:10 -04:00
Matt Nadareski
f5a4ca6276 Finally figure out what I was doing 2025-09-10 21:37:05 -04:00
Matt Nadareski
672c010aa7 Fix a stupid issue 2025-09-10 21:04:09 -04:00
Matt Nadareski
2459d88951 Found the real issue 2025-09-10 20:46:32 -04:00
Matt Nadareski
350d1c8d31 I guess this can be null? 2025-09-10 20:29:26 -04:00
Matt Nadareski
98a3842a3e Fixx off-by-one error 2025-09-10 20:26:17 -04:00
Matt Nadareski
b52a4469ee Remove alignment, add TODO and comments 2025-09-10 11:21:34 -04:00
Matt Nadareski
e3143e21ba Fix comment to be more accurate 2025-09-10 11:18:53 -04:00
Matt Nadareski
1bf2181fd3 Make check a little nicer 2025-09-09 18:56:50 -04:00
Matt Nadareski
1460635aab Move hidden resources parsing to make method nicer 2025-09-09 18:52:35 -04:00
Matt Nadareski
935ec00c86 Notes about hidden resources 2025-09-09 17:15:25 -04:00
Matt Nadareski
473b6de09b Slight cleanup 2025-09-09 16:42:50 -04:00
Matt Nadareski
ba75f2ac2c Try to fix weird resource parsing 2025-09-09 14:54:54 -04:00
Matt Nadareski
a230b39fbc Make relocation block parsing safer 2025-09-09 13:51:40 -04:00
Matt Nadareski
8e963ac62a Fix a couple of potential logic bugs 2025-09-09 13:42:36 -04:00
Matt Nadareski
eaaa89847d Rename to pex and nex for readability 2025-09-09 13:11:27 -04:00
Matt Nadareski
ef76166978 Clean up a few more PE things 2025-09-09 13:11:09 -04:00
Matt Nadareski
72912586a1 Clean up COFF symbol table parsing 2025-09-09 12:18:46 -04:00
Matt Nadareski
fb241a4036 Make things easier to read, add some helpers 2025-09-09 09:57:53 -04:00
Matt Nadareski
368c8b0533 Add section table note 2025-09-09 09:37:03 -04:00
Matt Nadareski
4010325e65 Make note from Models 2025-09-09 09:31:53 -04:00
Matt Nadareski
11dd75ad95 Make import table easier to read 2025-09-08 23:21:45 -04:00
Matt Nadareski
d0480a1311 Make export table easier to read 2025-09-08 22:51:46 -04:00
Matt Nadareski
2be33b845d Be even more careful 2025-09-08 22:09:12 -04:00
Matt Nadareski
2ad42e3a0f Seek and ye shall find 2025-09-08 21:41:46 -04:00
Matt Nadareski
5d1f83800b Add SecuROM AddD deserializer 2025-09-08 21:20:47 -04:00
Matt Nadareski
30e89a7943 Clean this up 2025-09-08 21:13:34 -04:00
Matt Nadareski
61f5dc4cf2 Extract even more types of embedded data 2025-09-08 20:08:43 -04:00
Matt Nadareski
d056c179ed Add embedded UHA support 2025-09-08 08:51:40 -04:00
Matt Nadareski
b9c4bfc67e Expand the search window again 2025-09-08 08:17:01 -04:00
Matt Nadareski
6ab5ee0ae0 Add regions here for maybe future work 2025-09-08 08:03:07 -04:00
Matt Nadareski
94c1a86702 Add AssemblyName extension property to PE 2025-09-08 07:56:40 -04:00
Matt Nadareski
af6dd6a7fc Check for BZip2 and XZ in hidden places too 2025-09-08 07:52:41 -04:00
Matt Nadareski
45d4926d4c Toss the filename at the top of the infoprint output 2025-09-07 20:52:02 -04:00
Matt Nadareski
ce016c5eb0 Bump version 2025-09-06 08:18:43 -04:00
Matt Nadareski
2225c1f2d8 Update Nuget packages 2025-09-05 10:57:14 -04:00
Matt Nadareski
2d0c0d5845 Make a bunch of things cache more safer 2025-09-05 08:32:40 -04:00
Matt Nadareski
60f1756cbb Wrap places where ReadFrom was not being used but still could be parallel 2025-09-05 07:45:55 -04:00
Matt Nadareski
738a1d250a Add inherent locking the the data source in wrappers 2025-09-05 07:36:15 -04:00
Matt Nadareski
c8e65e1e30 Add section string lock 2025-09-03 13:46:12 -04:00
Matt Nadareski
ecb09ce6f2 Make sure source data isn't locked unnecessarily 2025-09-02 23:56:29 -04:00
Matt Nadareski
72a1484a71 More granular locks 2025-09-02 23:51:02 -04:00
Matt Nadareski
de31c10c7c Bump version 2025-09-02 19:22:47 -04:00
HeroponRikiBestest
84483c229c Final fixes. (#21) 2025-09-02 16:08:04 -04:00
Matt Nadareski
b7e35a8fa8 Virtual insanity 2025-09-02 15:53:14 -04:00
Matt Nadareski
8c190a26a5 Math.Max 2025-09-02 15:51:26 -04:00
Matt Nadareski
2e5705125b Ensure that the WISE section only reads section data 2025-09-02 15:01:28 -04:00
Matt Nadareski
daaa92def0 Deal with end offset data 2025-09-02 14:47:49 -04:00
Matt Nadareski
86ec97678e Prep for a different tomorrow 2025-09-02 14:45:00 -04:00
Matt Nadareski
d74b82dc55 Hacky hack hack 2025-09-02 14:30:20 -04:00
Matt Nadareski
821ade2006 That was funny 2025-09-02 13:27:52 -04:00
HeroponRikiBestest
3ee999dccd Fix wise version(?) check for pre-string bytes (#20)
Needed opposite range
2025-09-02 11:02:43 -04:00
Matt Nadareski
f91bda51e1 Non-nullable nullability 2025-09-02 09:01:19 -04:00
Matt Nadareski
47255fc331 Sync NE with PE Wise extraction 2025-09-02 08:00:51 -04:00
Matt Nadareski
f7488bed04 Make CExe helpers static 2025-09-02 07:56:19 -04:00
Matt Nadareski
a94b3a82c4 Update comment 2025-09-02 07:53:42 -04:00
Matt Nadareski
1c8f64f5e6 Search for MS-CAB in resources and overlay 2025-09-02 07:52:29 -04:00
Matt Nadareski
a015e4df3f Add tests for new deserializers and wrappers 2025-09-02 07:48:17 -04:00
Matt Nadareski
2489a49924 Implement Wise section header printer 2025-09-02 07:44:14 -04:00
Matt Nadareski
d418fbd60d Complete the circle of comments 2025-09-02 07:31:15 -04:00
Matt Nadareski
cc2e7704e6 Finding methods don't need debug logging 2025-09-02 07:23:16 -04:00
Matt Nadareski
a980a56dfa Make consistent with other files 2025-09-01 21:12:05 -04:00
Matt Nadareski
da588e3bc0 That was annoying 2025-09-01 21:11:54 -04:00
Matt Nadareski
8b6f45d9b7 Detangle Wise a bit more 2025-09-01 20:37:23 -04:00
Matt Nadareski
9bdfe33baf Move some Wise things around to make more sense in broader context 2025-09-01 20:27:46 -04:00
Matt Nadareski
13d338f615 Fix some issues with desynced wrappers 2025-09-01 18:56:51 -04:00
Matt Nadareski
36a8641c8d I definitely missed these 2025-09-01 18:50:31 -04:00
Matt Nadareski
7bde6f99fc Fix porting issue with Wise 2025-09-01 18:46:15 -04:00
Matt Nadareski
45428ce991 Fix limit issue 2025-09-01 18:42:40 -04:00
Matt Nadareski
8eb5898ef6 Handle some big TODOs 2025-09-01 18:38:43 -04:00
Matt Nadareski
556e1c972c Update packages and upstream changes 2025-09-01 16:43:21 -04:00
Matt Nadareski
df8f3e7122 Clean up usings 2025-08-31 22:08:03 -04:00
Matt Nadareski
da1d575806 MPQ decryption should live separately 2025-08-31 22:07:15 -04:00
Matt Nadareski
c4d40a1dde Fix a couple of missed issues in MPQ 2025-08-31 21:53:27 -04:00
Matt Nadareski
912de926d0 Fix various issues with parsing MPQ; simplify 2025-08-31 21:51:06 -04:00
Matt Nadareski
c60fc1e31f Remove outdated comments 2025-08-31 21:45:35 -04:00
Matt Nadareski
386e607887 Add BET/HET handling based on documentation, not tested 2025-08-31 01:20:33 -04:00
Matt Nadareski
94c9b8d057 Fix MPQ v1 parsing, add hash and block table decrypt 2025-08-31 01:03:15 -04:00
Matt Nadareski
5f81275b10 Add some project references 2025-08-29 14:03:25 -04:00
Matt Nadareski
37c484411b Reimplment MPQ extraction via StormLib 2025-08-29 13:37:54 -04:00
Matt Nadareski
ad1f890742 Add StormLib as submodule 2025-08-29 13:34:59 -04:00
Matt Nadareski
2924529fa7 Start bundling runtimes 2025-08-29 13:31:19 -04:00
Matt Nadareski
ebe675cae1 Add StormLib runtimes 2025-08-29 13:29:15 -04:00
Matt Nadareski
a40c666775 Bundle libraries 2025-08-29 12:59:33 -04:00
Matt Nadareski
2ea060d3b3 Readme 2025-08-29 12:55:21 -04:00
Matt Nadareski
f8a67839dd Clean up some TODOs 2025-08-29 12:34:59 -04:00
Matt Nadareski
2773b12c9b Fix odd write-size mismatches 2025-08-29 12:14:55 -04:00
Matt Nadareski
929e12f976 These values need to be signed 2025-08-29 11:48:19 -04:00
Matt Nadareski
8fbc6c4662 Remove erroneous check 2025-08-29 11:28:37 -04:00
Matt Nadareski
797378e9c8 Better error messages 2025-08-29 11:26:17 -04:00
Matt Nadareski
113464a7d1 Privatize Reader class 2025-08-29 11:09:45 -04:00
Matt Nadareski
a13c837202 Probably fix the MD5 bug in IS-CAB 2025-08-29 11:06:37 -04:00
Matt Nadareski
48765f1ae5 Fix IS-CAB deserialization bug 2025-08-29 10:44:51 -04:00
Matt Nadareski
091ee56368 Remove Extractor, finally 2025-08-29 10:20:51 -04:00
Matt Nadareski
015a971147 Be smarter about volume opening 2025-08-29 10:17:07 -04:00
Matt Nadareski
7575a01a28 Keep track of the data offset 2025-08-29 10:11:53 -04:00
Matt Nadareski
7aa14cafea This never gets set again 2025-08-29 10:10:52 -04:00
Matt Nadareski
db10721386 Privatize 2025-08-29 10:04:52 -04:00
Matt Nadareski
6112cf8d60 This needed a rename 2025-08-29 10:04:24 -04:00
Matt Nadareski
50caeba322 Sort some filename pattern stuff 2025-08-29 10:03:56 -04:00
Matt Nadareski
b3499984b3 Start porting some functionality 2025-08-29 09:58:40 -04:00
Matt Nadareski
a5609a7a82 More descriptive class name 2025-08-29 09:41:25 -04:00
Matt Nadareski
8626a87860 Start cleaning up duplicate and unnecessary code 2025-08-29 09:37:03 -04:00
Matt Nadareski
fa31cd0e98 Let's see how UnshieldSharp goes 2025-08-29 09:14:33 -04:00
Matt Nadareski
6b6b7c6289 Reduce complexity of MS-CAB extraction paths 2025-08-29 08:29:05 -04:00
Matt Nadareski
baa3b272ab Extraction tool can pretend everything works 2025-08-29 08:20:55 -04:00
Matt Nadareski
d7c4f244cc Make the if/else chain into a switch 2025-08-29 08:13:58 -04:00
Matt Nadareski
e21d226564 Use wrapper description to simplify cases 2025-08-29 08:08:02 -04:00
Matt Nadareski
6ff6a7d4a4 Uncomment MPQ, still not hooked back up 2025-08-29 08:03:01 -04:00
Matt Nadareski
daf19a561c Add UnshieldSharp to ExtractionTool directly 2025-08-29 08:01:27 -04:00
Matt Nadareski
26226a75ff Update nuget packages 2025-08-29 07:56:51 -04:00
Matt Nadareski
4473edf476 Comments cleanup 2025-08-29 07:54:20 -04:00
Matt Nadareski
54cf0a6470 Expand the search window for embedded data 2025-08-28 23:56:05 -04:00
Matt Nadareski
0eb8f7e538 Extract overlay data for NE 2025-08-28 23:52:09 -04:00
Matt Nadareski
23b72c65ba Forgot to use the resource offset 2025-08-28 23:02:25 -04:00
Matt Nadareski
db7d89600c Handle PKZIP SFX by extracting the archive portion 2025-08-28 23:01:55 -04:00
Matt Nadareski
67d51ad1d6 Handle RAR SFX by extracting the archive portion 2025-08-28 22:42:15 -04:00
Matt Nadareski
56b71cf7fe Overlay deals with real data only 2025-08-28 22:41:49 -04:00
Matt Nadareski
e0ec2a521f Handle 7z SFX by extracting the archive portion 2025-08-28 22:21:25 -04:00
Matt Nadareski
e8589ac7b5 Fix offset read issues in resource table 2025-08-28 21:52:35 -04:00
Matt Nadareski
21e425acee Split up PE parsing a bit for readability 2025-08-28 21:35:05 -04:00
Matt Nadareski
ee316052ae Add ExtractionTool to readme 2025-08-28 20:14:08 -04:00
Matt Nadareski
3463936ae0 Fix extracting SFX archives 2025-08-28 20:00:05 -04:00
Matt Nadareski
5ff947b279 Add non-model constructors for PKZIP 2025-08-28 19:59:24 -04:00
Matt Nadareski
fdf2ea84ec Fix intermittent 7z solid issues 2025-08-28 19:59:06 -04:00
Matt Nadareski
ad9b001b6a Downstream from IO 2025-08-28 19:47:34 -04:00
Matt Nadareski
1308571c10 Smarter handling 2025-08-28 15:53:16 -04:00
Matt Nadareski
b8cb3419c1 Fix odd resource parsing issues 2025-08-28 15:49:02 -04:00
Matt Nadareski
02533cf947 Somewhat add SFX support 2025-08-28 15:26:37 -04:00
Matt Nadareski
bf8bd04dc7 Fix missing package 2025-08-28 15:22:05 -04:00
Matt Nadareski
1894376ab6 Initial migration of ExtractionTool 2025-08-28 15:11:21 -04:00
Matt Nadareski
c789e4df44 Replace simpler gzip extract with more robust version 2025-08-28 14:17:15 -04:00
Matt Nadareski
884685de4a Fix GZip extraction 2025-08-28 14:15:39 -04:00
Matt Nadareski
7fda7be457 Fix significant issue with how view streams are used 2025-08-28 14:10:08 -04:00
Matt Nadareski
5daf759033 Add debug logging for tar extraction 2025-08-28 13:16:39 -04:00
Matt Nadareski
589ab0896a Replace SharpCompress with native extract for tar 2025-08-28 13:03:59 -04:00
Matt Nadareski
7645ab978f Fix obvious bug 2025-08-28 12:59:50 -04:00
Matt Nadareski
e6497289da Add experimental tar extraction 2025-08-28 12:56:43 -04:00
Matt Nadareski
95a9f4769d Workaround to read block data 2025-08-28 12:16:07 -04:00
Matt Nadareski
7917601f7a Slight formatting cleanup 2025-08-28 12:14:48 -04:00
Matt Nadareski
3400238fc5 Make tar printing a bit more comprehensive 2025-08-28 12:13:00 -04:00
Matt Nadareski
cbd335c6aa Add and update tests 2025-08-28 10:12:08 -04:00
Matt Nadareski
9feaadd32a Implement gzip parsing and printing 2025-08-28 09:56:52 -04:00
Matt Nadareski
2ec008b3b7 Add extension property to tar 2025-08-28 09:13:02 -04:00
Matt Nadareski
c9a462a1c6 Fix tar parsing and printing 2025-08-28 09:11:04 -04:00
Matt Nadareski
ab44aa7e68 Start implementing tar 2025-08-28 08:14:38 -04:00
Matt Nadareski
9b9d3176ec Slightly more work 2025-08-28 07:54:22 -04:00
Matt Nadareski
5dda3e2c81 Add shell deserializers for gzip and tar 2025-08-28 07:52:43 -04:00
Matt Nadareski
4b8dc12c98 Add PKZIP extension properties 2025-08-27 21:59:30 -04:00
Matt Nadareski
044e4c4c75 Fill out remaining models, add printing 2025-08-27 21:48:01 -04:00
Matt Nadareski
2149630865 Fill in the remaining extras that have models 2025-08-27 20:40:56 -04:00
Matt Nadareski
3d435a1d7e Start parsing some PKZIP extras 2025-08-27 19:20:07 -04:00
Matt Nadareski
f2d993a958 Fix UTF-8 encoded strings 2025-08-27 18:14:11 -04:00
Matt Nadareski
7bf75b8dc5 Minor cleanup 2025-08-27 17:59:11 -04:00
Matt Nadareski
dfbdce1dc8 Be more strictly correct about ZIP64 reading 2025-08-27 17:54:35 -04:00
Matt Nadareski
63f5566e65 Minor formatting fix 2025-08-27 16:45:20 -04:00
Matt Nadareski
4b0f43f6c0 Clean up PKZIP printing 2025-08-27 16:41:00 -04:00
Matt Nadareski
98e1ef7362 Rearrange code to make models updates easier 2025-08-27 15:49:31 -04:00
Matt Nadareski
4e0ffcb3c8 Return nothing and be happy 2025-08-27 13:04:01 -04:00
Matt Nadareski
a93a46d6c0 Start fixing PKZIP deserializing
This does a forward-reading approach on the archive instead of the "proper" way of reading from the end. This change introduces potential issues, as both "deleted" entries and normal ones will be included. It also makes it more difficult to determine if the archive is ZIP64 or not. But it is far more stable than the read-from-the-end approach of the old code.
2025-08-27 12:54:36 -04:00
Matt Nadareski
e163302522 Add part-finding helpers and tests 2025-08-26 21:14:25 -04:00
Matt Nadareski
838afc35c3 Order of operations 2025-08-26 06:52:47 -04:00
Matt Nadareski
3a62bfab57 Fix copy-paste 2025-08-26 06:45:21 -04:00
Matt Nadareski
560b3a246c Use file part count, not partial files 2025-08-26 06:41:01 -04:00
Matt Nadareski
4360916750 Handle archive parts 2025-08-25 22:20:24 -04:00
Matt Nadareski
3f31edc1c0 Fix return comments 2025-08-25 21:02:08 -04:00
Matt Nadareski
bd874d436b Slight renaming to be more accurate 2025-08-25 21:01:20 -04:00
Matt Nadareski
fbc47425f4 Use using to use usings 2025-08-25 20:57:35 -04:00
Matt Nadareski
c9df6ff059 Rename to be consistent 2025-08-25 20:53:25 -04:00
Matt Nadareski
ef6ff85e96 Port more PE extraction 2025-08-25 20:51:35 -04:00
Matt Nadareski
bb93792f57 Remove restriction from RAR 2025-08-25 13:25:07 -04:00
Matt Nadareski
1f7ab4fccb Simpler completeness checks 2025-08-25 13:23:49 -04:00
Matt Nadareski
2535e82618 Maybe fix multipart 7z, RAR, and PKZIP archives 2025-08-25 13:19:28 -04:00
Matt Nadareski
66d80c8523 Add basic PE extraction 2025-08-25 13:06:22 -04:00
Matt Nadareski
834a17fe82 Add region note 2025-08-25 12:50:16 -04:00
Matt Nadareski
ea85167e06 Upstream changes to string reading until IO updated 2025-08-25 12:45:45 -04:00
Matt Nadareski
e007a06dda Allow direct data source access 2025-08-23 21:31:13 -04:00
Matt Nadareski
02f9e1e935 Temporarily downstream class from IO 2025-08-23 21:29:22 -04:00
Matt Nadareski
21b7d431a7 More concise naming 2025-08-23 13:38:19 -04:00
Matt Nadareski
307b932f87 A couple more clarifications 2025-08-23 13:37:39 -04:00
Matt Nadareski
6983d1cd3c This can't be null anymore 2025-08-23 13:36:59 -04:00
Matt Nadareski
a193c9bb3c Remove unnecessary comment 2025-08-23 13:23:44 -04:00
Matt Nadareski
aa67c7ad6d Rename to be simpler 2025-08-23 13:19:26 -04:00
Matt Nadareski
70fc686249 DataSource is a Stream type now 2025-08-23 13:18:46 -04:00
Matt Nadareski
c87a456a46 Move things to base classes 2025-08-23 12:58:09 -04:00
Matt Nadareski
456bb1e95b Intermediary step for extractable shells 2025-08-23 12:23:44 -04:00
Matt Nadareski
b0b334103d Implement shell wrappers for extractable types without a current model 2025-08-23 11:55:54 -04:00
Matt Nadareski
78851e3b57 Pass through data source property, make private 2025-08-20 08:11:48 -04:00
Matt Nadareski
850a883e14 Methods to properties 2025-08-20 08:08:53 -04:00
Matt Nadareski
6e0ced5ffe One more GetEndOffset removal 2025-08-20 08:04:01 -04:00
Matt Nadareski
64cd8febaa This doesn't need private set 2025-08-20 08:00:45 -04:00
Matt Nadareski
6fbe1cffaa GetEndOffset really shouldn't be used 2025-08-20 07:54:52 -04:00
Matt Nadareski
601e781ef9 Data source shennanigans 2025-08-19 22:01:10 -04:00
Matt Nadareski
d26ad35573 Create a new DataSource helper class 2025-08-19 20:49:47 -04:00
Matt Nadareski
b70c510734 Be consistent with model 2025-08-19 20:25:56 -04:00
Matt Nadareski
29a7158488 Clarify that Matching is being used 2025-08-19 15:30:23 -04:00
Matt Nadareski
1227ca020a Fix CreateExecutableWrapper 2025-08-19 09:18:50 -04:00
Matt Nadareski
cd7e6ff98d Fix some logic bugs due to offsets 2025-08-19 09:09:33 -04:00
Matt Nadareski
510a0f77f6 Stop reinventing the wheel 2025-08-19 07:43:21 -04:00
Matt Nadareski
6d1dabb1db Handle only cases where long mattered 2025-08-19 07:41:29 -04:00
Matt Nadareski
2e337891da Fix logic bug with end of file check 2025-08-19 07:36:33 -04:00
Matt Nadareski
d49e18a83e Replace _byteArrayOffset with _initialPosition 2025-08-19 07:34:51 -04:00
Matt Nadareski
c14560ec18 Add initial position to wrapper, currently unused 2025-08-19 07:29:59 -04:00
Matt Nadareski
e3e31cd9f2 Separate files 2025-08-19 07:27:39 -04:00
Matt Nadareski
adf9627045 Stricter with COFF tables 2025-08-17 15:25:25 -04:00
Matt Nadareski
c7b03c7765 This should be a file offset 2025-08-17 15:20:51 -04:00
Matt Nadareski
b5f83215d5 Don't exit parsing unnecessarily 2025-08-17 15:04:38 -04:00
Matt Nadareski
96e3fc5533 Cleanups to PE deserialization 2025-08-17 14:53:03 -04:00
Matt Nadareski
828e7dda03 Add file-only info printing flag 2025-08-13 12:03:06 -04:00
Matt Nadareski
8ef50c30d5 Add and implement IExtractable 2025-08-11 11:39:15 -04:00
Matt Nadareski
cbe1d5b608 Resync NE overlay finding 2025-08-11 11:11:51 -04:00
Matt Nadareski
7123a9e986 Add more NE deserializers 2025-08-10 20:37:42 -04:00
Matt Nadareski
af5996b972 Fill out LE/LX methods at all 2025-08-01 09:04:30 -04:00
Matt Nadareski
15e947784b Use NE helpers 2025-08-01 08:56:14 -04:00
Matt Nadareski
1b382c201e Simplify references in NE 2025-08-01 08:43:01 -04:00
Matt Nadareski
8deca4fb0c Fill out NE methods more 2025-08-01 08:39:14 -04:00
Matt Nadareski
96c4372609 Add data-reading methods for NE 2025-08-01 08:19:41 -04:00
Matt Nadareski
ca7a109037 Add more NE extensions 2025-08-01 07:58:54 -04:00
Matt Nadareski
c54f5b3c5d Add MS-DOS stub extension for LE/LX 2025-07-31 14:35:35 -04:00
Matt Nadareski
652942ab9f Add extensions based on external need 2025-07-31 14:00:55 -04:00
Matt Nadareski
2cc19a9c36 Add some more IS-CAB extensions 2025-07-31 13:44:15 -04:00
Matt Nadareski
6ffb3f4bbd Add IS-CAB OpenVolume helper 2025-07-31 13:34:35 -04:00
Matt Nadareski
bab4278318 Better linking in IS-CAB open set 2025-07-31 13:26:10 -04:00
Matt Nadareski
013d18a426 Better file descriptor method 2025-07-31 13:23:45 -04:00
Matt Nadareski
e94e27910e Add a couple of IS-CAB extensions 2025-07-31 13:20:40 -04:00
Matt Nadareski
34cea6e74a Double-chain IS-CAB like MS-CAB 2025-07-31 13:18:29 -04:00
Matt Nadareski
640e160863 Slight cleanup to the PE deserializer 2025-07-31 12:06:51 -04:00
Matt Nadareski
3100963250 Fix build issue 2025-07-31 11:57:20 -04:00
Matt Nadareski
2086358762 Slight cleanup to the PE wrapper 2025-07-31 11:52:39 -04:00
Matt Nadareski
ae273c589d Use simpler extension where possible 2025-07-31 11:28:09 -04:00
Matt Nadareski
a229015fcd Move major version helper out of deserializer 2025-07-31 11:26:54 -04:00
Matt Nadareski
b001680674 Remove unnecessary code regions for XMID and XeMID 2025-07-31 11:12:35 -04:00
Matt Nadareski
e684133f72 Add InfoPrint to the readme 2025-07-31 11:08:11 -04:00
Matt Nadareski
2b020eecc7 Output hashes to separate file 2025-07-31 10:30:13 -04:00
Matt Nadareski
78f4d6faca Add file hashing option to InfoPrint 2025-07-31 10:26:03 -04:00
Matt Nadareski
f07b7a049e Ensure endianness of reads 2025-07-31 09:41:36 -04:00
Matt Nadareski
544637779c Exception debugging should use Error stream 2025-07-31 09:14:22 -04:00
Matt Nadareski
38b6427e4e Wire through include debug flag 2025-07-31 09:11:43 -04:00
Matt Nadareski
e36822a19c Add more extension properties; clean up 2025-07-31 08:57:35 -04:00
Matt Nadareski
e1a114976f Use correct mask for v3 CFB files 2025-07-30 16:56:15 -04:00
Matt Nadareski
5ba9ab3457 Fix DIFAT assumptions for directory entries 2025-07-30 16:28:54 -04:00
Matt Nadareski
36edf9ed54 Fix parsing of large DIFAT tables in CFB 2025-07-30 15:46:19 -04:00
Matt Nadareski
e788ffa851 Fix MS-CAB block continuation 2025-07-30 15:18:29 -04:00
Matt Nadareski
e0d819b88d Fix spanned blocks, previously skipped 2025-07-30 14:54:19 -04:00
Matt Nadareski
e3b216ad09 Wrap MS-ZIP compression in case of failure 2025-07-30 14:21:13 -04:00
Matt Nadareski
55d0fd452d Add new extension property for CFB 2025-07-30 11:33:49 -04:00
Matt Nadareski
089fd02b2e Sync remaining extraction bits for CFB 2025-07-30 11:32:25 -04:00
Matt Nadareski
8cfd820dcd Sync back extraction fixes for CFB 2025-07-30 11:29:27 -04:00
Matt Nadareski
67ed9860fe Sync back deserialization fixes for CFB 2025-07-30 11:26:04 -04:00
Matt Nadareski
ee924e3a34 Backport some CFB work 2025-07-30 11:04:25 -04:00
Matt Nadareski
9e5085ba79 Add CFB extraction placeholders 2025-07-30 08:31:00 -04:00
Matt Nadareski
dbfdbbff20 Fix CFB stream name handling 2025-07-30 08:21:20 -04:00
Matt Nadareski
21dc72bf11 Decode CFB stream names 2025-07-30 08:08:27 -04:00
Matt Nadareski
c8295c4724 Make CFB printing pretty again 2025-07-29 23:43:22 -04:00
Matt Nadareski
44b4dd3d1b Fix reading CFB v3 directory entries 2025-07-29 23:41:42 -04:00
Matt Nadareski
7e543c6acb Fix some issues with CFB deserialization 2025-07-29 23:08:37 -04:00
Matt Nadareski
63514d149f CFB directory entry names are UTF-16 2025-07-29 22:51:04 -04:00
Matt Nadareski
d7e559749d Normalize extraction methods
This does a few things:
- Ensures that all output directories are normalized for the current operating system
- Ensures that all output files are flushed in case of systematic issues
- Brings MS-CAB extraction up to the same return value quality as other extractors
2025-07-29 21:13:53 -04:00
Matt Nadareski
a2be40fcbc Add CHD version extension 2025-07-29 20:39:48 -04:00
Matt Nadareski
771df5c372 Fall back on OpenNext if needed 2025-07-29 11:52:59 -04:00
Matt Nadareski
2d3d6348ad Remove redundant code 2025-07-29 11:51:28 -04:00
Matt Nadareski
a2bf15f0bc Fix method ordering 2025-07-29 11:49:07 -04:00
Matt Nadareski
0aa25df88f More graceful handling of MS-CAB sets 2025-07-29 11:48:34 -04:00
Matt Nadareski
36afb1c0ee Split out MS-ZIP handling for cleaner code 2025-07-29 11:38:38 -04:00
Matt Nadareski
c9d61906fb Only derive the compression type once per folder 2025-07-29 11:26:23 -04:00
Matt Nadareski
d8440a01d3 Remove redundant check 2025-07-29 08:30:17 -04:00
Matt Nadareski
74d92312ef Split out MS-CAB ExtractFile logic 2025-07-29 08:26:53 -04:00
Matt Nadareski
0dc9823d2b Fix assumption about MS-CAB sets 2025-07-29 08:04:02 -04:00
Matt Nadareski
9c69737073 Fix comments to make more sense 2025-07-28 21:23:18 -04:00
Matt Nadareski
66187dcf04 Keep tweaking extraction 2025-07-28 21:20:47 -04:00
Matt Nadareski
79943560bc Keep tweaking extraction 2025-07-28 21:14:51 -04:00
Matt Nadareski
b3321f9c9a Keep tweaking extraction 2025-07-28 20:58:49 -04:00
Matt Nadareski
428c269a49 Keep tweaking extraction 2025-07-28 20:56:23 -04:00
Matt Nadareski
e84964a321 Add MS-CAB extract and decompression 2025-07-28 20:31:40 -04:00
Matt Nadareski
0394ea5356 Remove unused using 2025-07-28 19:43:53 -04:00
Matt Nadareski
852b086920 Add IS-CAB obfuscation code 2025-07-28 19:41:07 -04:00
Matt Nadareski
b7fceee2b7 Port more MS-CAB helpers from BOS 2025-07-28 15:22:28 -04:00
Matt Nadareski
ecf6c957c9 Port OpenNext/OpenPrevious from BOS 2025-07-28 15:13:19 -04:00
Matt Nadareski
5e0b0070ff Make MS-CAB doubly-linked 2025-07-28 12:45:23 -04:00
Matt Nadareski
9934bc31a3 Fix build 2025-07-28 12:31:03 -04:00
Matt Nadareski
7b4711f5cf Implement OpenSet for MS-CAB 2025-07-28 12:27:18 -04:00
Matt Nadareski
844066815d Add extension properties for MS-CAB 2025-07-28 12:09:28 -04:00
Matt Nadareski
3a6293e696 Port some code from UnshieldSharp 2025-07-28 11:57:54 -04:00
Matt Nadareski
3210b8601d Add IS-CAB CreateFilenamePattern from UnshieldSharp 2025-07-28 11:35:24 -04:00
Matt Nadareski
181788802d Move PathProcessors to the correct namespace 2025-07-28 10:27:11 -04:00
Matt Nadareski
4b627ce776 Move wrapper-specific helpers to correct namespace 2025-07-28 10:25:25 -04:00
Matt Nadareski
8b799bb5c8 Port Nitro decryption step 2025-07-28 08:47:26 -04:00
Matt Nadareski
5bc8336fce Move StringBuilderExtensions to better namespace 2025-07-27 20:56:15 -04:00
Matt Nadareski
4f9f8ddcec Fix build 2025-07-27 20:49:18 -04:00
Matt Nadareski
29f1f63ef8 Add nested dir support for Logiqx, fix existing dir support 2025-07-27 20:48:49 -04:00
Matt Nadareski
48ecdff5f7 Fix AlignToBoundary a bit 2025-07-24 10:56:31 -04:00
Matt Nadareski
411acd2d5a Add AlignToBoundary for byte arrays 2025-07-24 10:55:52 -04:00
Matt Nadareski
e6742fe889 Fix missed AlignToBoundary case 2025-07-24 10:47:21 -04:00
Matt Nadareski
b6561719a7 Add SecuROM DFA 2025-07-24 10:40:31 -04:00
Matt Nadareski
2bf3d6f9a6 Use more constants in GetFileType 2025-07-24 10:19:20 -04:00
Matt Nadareski
b2700b5975 Add MESS ListXML support 2025-07-24 09:36:37 -04:00
Matt Nadareski
95b28874da Add MESS ListXML support 2025-07-24 09:36:13 -04:00
Matt Nadareski
4934ee837c Be consistent about end-of-file newlines 2025-07-24 09:31:28 -04:00
Matt Nadareski
3cbfd5cd10 Add .NET Standard 2.0 and 2.1 2025-07-24 09:19:38 -04:00
Matt Nadareski
da28ce310b Update nuget packages 2025-07-24 09:16:11 -04:00
HeroponRikiBestest
ac6d93a3b9 Add extra validity checks for GCF (#17)
* Add extra validity checks for GCF

* Remove "for validity"
2025-07-12 15:49:35 -04:00
Matt Nadareski
104028204d Fix relocation table parsing issues (fixes #16) 2025-06-28 20:00:21 -04:00
Matt Nadareski
d3e61b42dd Attempt to fix export table name table 2025-06-24 17:14:25 -04:00
Matt Nadareski
6351cabb62 Add CMP tests for non-quote serialization 2025-05-28 09:51:45 -04:00
Matt Nadareski
ddef42126b Fix old .NET 2025-05-19 12:15:30 -04:00
Matt Nadareski
9dd39a7f02 Bump version 2025-05-19 12:13:35 -04:00
Matt Nadareski
ca7f7e97e7 Omit namespaces on XML writing 2025-05-19 12:12:05 -04:00
Matt Nadareski
8a40349b0c Write tests for ReadQuotedString, fix issues 2025-05-14 20:52:59 -04:00
Matt Nadareski
6ec6fa4973 Remove now-unused using 2025-05-13 11:26:17 -04:00
Matt Nadareski
f0644710e6 Remove faulty offset code 2025-05-13 09:44:59 -04:00
Matt Nadareski
34048726ab Fix cref formatting in summaries 2025-05-13 09:25:06 -04:00
Matt Nadareski
60ce6c9370 Handle offset sizes for Logiqx rom 2025-05-13 09:24:01 -04:00
Matt Nadareski
554fccc236 Update IO to 1.6.3 2025-05-12 08:26:42 -04:00
Matt Nadareski
7611c043c3 Fix how conditions are used for references 2025-02-25 21:17:17 -05:00
Matt Nadareski
976d793474 Fix currently non-affecting bug 2024-12-30 23:17:52 -05:00
Matt Nadareski
f0f997fadd Bump version 2024-12-30 22:51:13 -05:00
Matt Nadareski
0ce3c9892d Remove attempt at caching version info strings 2024-12-30 22:40:52 -05:00
Matt Nadareski
9743565285 Update copyright 2024-12-30 21:39:36 -05:00
Matt Nadareski
fcfe9e4790 Remove unnecessary action step 2024-12-30 21:39:30 -05:00
Matt Nadareski
be36432296 Update packages 2024-12-30 21:28:13 -05:00
Matt Nadareski
fb725bff19 Bump version 2024-12-30 20:55:30 -05:00
Matt Nadareski
2384cf9f9f Add source data lock on cached values 2024-12-30 20:47:12 -05:00
Matt Nadareski
1261930fd9 Ensure .NET versions are installed for testing 2024-12-19 10:53:19 -05:00
Matt Nadareski
120de4e49f Allow symbols to be packed 2024-12-18 08:05:16 -05:00
Matt Nadareski
354a51769b Bump version 2024-12-18 08:01:07 -05:00
Matt Nadareski
a9f937baa3 Find remaining non-explicit endinaness calls 2024-12-17 22:38:57 -05:00
Matt Nadareski
1790d82a6e Cap overlay checks to 16 MiB 2024-12-17 15:50:02 -05:00
Matt Nadareski
261c20e95a Get rid of erroneous double semicolons 2024-12-17 15:43:22 -05:00
Matt Nadareski
ed6556b1f0 Cache version info strings 2024-12-17 01:05:41 -05:00
Matt Nadareski
a86af8c32a Expand printed detections 2024-12-17 00:52:24 -05:00
Matt Nadareski
1670ab45a0 Fix SFO deserialization 2024-12-17 00:27:30 -05:00
Deterous
7dc4750f3b Add Deserializer for AppPkgHeader (#14)
* Add Deserializer for AppPkgHeader

* Fix typo

* add using System.Text

* Fix typo
2024-12-17 00:10:38 -05:00
Matt Nadareski
b5f366680d Explicit endianness in extensions 2024-12-17 00:00:28 -05:00
Matt Nadareski
fa9e9a0b2b Be explicit about endianness 2024-12-16 23:08:45 -05:00
Matt Nadareski
2239b82a4b Update packages 2024-12-16 15:00:44 -05:00
Matt Nadareski
3b631678f5 Port Quantum extraction (nw) 2024-12-13 14:30:38 -05:00
Matt Nadareski
2b111a9688 Port BFPK extraction 2024-12-13 14:25:32 -05:00
Matt Nadareski
0bda1f4f88 Bump version 2024-12-13 10:44:00 -05:00
Matt Nadareski
7d50e0e1c5 Fix filename map 2024-12-11 21:17:39 -05:00
Matt Nadareski
224a4caab0 Add secondary link for ISAv3 2024-12-11 14:42:00 -05:00
Matt Nadareski
b4689da404 Add reference from UnshieldSharp 2024-12-11 14:39:27 -05:00
Matt Nadareski
af66657399 Slightly safer indexing 2024-12-11 14:34:11 -05:00
Matt Nadareski
0f3e2d8275 Add 2 more extension properties 2024-12-11 14:25:46 -05:00
Matt Nadareski
d664b6defc Use const for data offset 2024-12-11 14:18:32 -05:00
Matt Nadareski
adbf74a6e0 Add ISAv3 extraction 2024-12-11 14:17:35 -05:00
Matt Nadareski
7eb401efed Port obvious things from UnshieldSharp 2024-12-11 14:04:29 -05:00
Matt Nadareski
ba97381b99 Add more ISAv3 stuff 2024-12-11 13:56:01 -05:00
Matt Nadareski
3de92de225 Add Compression package 2024-12-11 13:31:54 -05:00
Matt Nadareski
01a195c8aa Bump version 2024-12-10 15:44:48 -05:00
Matt Nadareski
12d43ef68a Update Models to 1.5.6 2024-12-10 15:41:12 -05:00
Matt Nadareski
0df806a6d1 Display debug in selected options 2024-12-06 11:46:28 -05:00
Matt Nadareski
f8c713b260 Use publish script and update README 2024-12-06 11:42:22 -05:00
Matt Nadareski
4d0122f97c Trust nobody, not even yourself 2024-12-03 02:12:39 -05:00
Matt Nadareski
7874950a7a Bump version 2024-12-03 01:04:46 -05:00
Matt Nadareski
577afc8947 Fix issue with PE extensions 2024-12-03 01:02:22 -05:00
Matt Nadareski
5a3e69e8ed Bump version 2024-11-30 21:32:15 -05:00
Matt Nadareski
67ee595eb4 More clearing out of old null checks 2024-11-30 02:49:10 -05:00
Matt Nadareski
992f8eaeb8 Reduce more nullable-array-nullable 2024-11-29 22:54:36 -05:00
Matt Nadareski
dde5a57136 Fix some misconfigured framework gating 2024-11-29 22:20:46 -05:00
Matt Nadareski
ae49950ae6 Go back to Vector3D direct deserialization 2024-11-29 21:41:49 -05:00
Matt Nadareski
b56ea3a479 Remove now-unneeded guards in printers 2024-11-29 21:35:56 -05:00
Matt Nadareski
03d4ea046d Update Models and IO 2024-11-29 20:48:50 -05:00
Matt Nadareski
248741b2c0 Add one forgotten check to a test 2024-11-29 02:00:01 -05:00
Matt Nadareski
ef307664e2 Remove now-redundant real metadata files 2024-11-29 01:57:32 -05:00
Matt Nadareski
05c497a5a0 Add roundtrip serialization tests for metadata files 2024-11-29 01:54:40 -05:00
Matt Nadareski
f8239780b2 Improve OpenMSX test, add AttractMode test 2024-11-29 00:21:10 -05:00
Matt Nadareski
ff12bf8205 Add serializer boundary tests; migrate old file 2024-11-29 00:04:02 -05:00
Matt Nadareski
0c3adf055c Add wrapper tests 2024-11-28 23:22:53 -05:00
Matt Nadareski
d9b1f5d45f Fix issue found by tests 2024-11-28 23:06:09 -05:00
Matt Nadareski
5ab3dded30 Remove while true from cuesheet parsing 2024-11-28 23:00:31 -05:00
Matt Nadareski
991d9ead27 Deserializers should have their own guards 2024-11-28 22:57:12 -05:00
Matt Nadareski
25c0d036f2 Length can throw on read-forward streams 2024-11-28 22:24:37 -05:00
Matt Nadareski
c06d8151e6 Add short-circuit for 0-length arrays 2024-11-28 22:15:25 -05:00
Matt Nadareski
0e9ba25637 Add required extension property 2024-11-28 22:09:07 -05:00
Matt Nadareski
bd7ca7f3a7 CanSeek can throw on read-forward streams 2024-11-28 22:01:03 -05:00
Matt Nadareski
26146554a3 Ensure read errors don't throw on wrapper creation 2024-11-28 21:58:49 -05:00
Matt Nadareski
884746a5a1 Add more extension properties 2024-11-28 20:50:43 -05:00
Matt Nadareski
ab0e68110c Move helper classes out of Wrappers 2024-11-27 23:43:50 -05:00
Matt Nadareski
e166d18903 Add extensions based on common use 2024-11-27 22:38:05 -05:00
Matt Nadareski
2152ba43a8 Minor formatting changes in extensions 2024-11-27 22:07:48 -05:00
Matt Nadareski
f42c5d04ee Fix issues from BSP29 (unsupported) 2024-11-27 21:45:26 -05:00
Matt Nadareski
ea535fa393 Read Vector3D manually 2024-11-27 21:33:24 -05:00
Matt Nadareski
e6d118e8cc Fix build 2024-11-27 21:26:23 -05:00
Matt Nadareski
35a921e436 Update Models to 1.5.4 2024-11-27 21:22:24 -05:00
Matt Nadareski
25cc3e42f3 Do length checks in V/BSP 2024-11-27 21:05:04 -05:00
Matt Nadareski
14344756da Port all non-compression extraction from BOS 2024-11-27 20:54:13 -05:00
Matt Nadareski
cb270d3185 Fix SizeOf issue in old .NET 2024-11-27 20:37:07 -05:00
Matt Nadareski
d5cef39f1b Forgot one named entity 2024-11-27 20:31:56 -05:00
Matt Nadareski
b782af427e Move simple extraction from BOS back for V/BSP 2024-11-27 20:30:48 -05:00
Matt Nadareski
6b503a0733 Perform more deserializer cleanup 2024-11-27 20:30:31 -05:00
Matt Nadareski
4a3741312e Reduce unncessary methods in deserialization 2024-11-27 16:14:56 -05:00
Matt Nadareski
aed140a684 Be smarter with using statements in tests 2024-11-27 14:25:53 -05:00
Matt Nadareski
5b93df9703 Split old monolithic deserializer test file 2024-11-27 14:18:08 -05:00
Matt Nadareski
5ae162400c Handle unexpected deserializer results 2024-11-27 14:04:20 -05:00
Matt Nadareski
f828b57159 Perform correctness and TODO cleanup 2024-11-27 13:47:07 -05:00
Matt Nadareski
d0cfc67f07 Update Deserializers and add empty/null/invalid tests 2024-11-27 12:43:52 -05:00
Matt Nadareski
2f48c3110c Update CrossModel converters and add tests 2024-11-27 10:16:23 -05:00
Matt Nadareski
6cdc35c82f Update packages 2024-11-26 19:51:39 -05:00
Matt Nadareski
9214a22cc9 Bump version 2024-11-20 20:05:03 -05:00
Matt Nadareski
5ba1156245 Fix return comments 2024-11-20 20:02:36 -05:00
Matt Nadareski
cb91cdff1d Minor formatting quibbles 2024-11-20 20:01:28 -05:00
Matt Nadareski
4df6a4e79d Reduce use of IEnumerable where not necessary 2024-11-20 19:51:49 -05:00
Matt Nadareski
5b82a48267 Update ASN.1 to 1.4.2 2024-11-20 16:06:00 -05:00
Matt Nadareski
8f70c50a48 Trim strings and only include them if the right length 2024-11-20 15:48:12 -05:00
Matt Nadareski
5fe4d81fa4 Ensure strings are read properly 2024-11-20 15:42:24 -05:00
Matt Nadareski
7d3addbf0a Print embedded zip as embedded zip 2024-11-20 15:12:23 -05:00
Matt Nadareski
b7d5873eb7 Wrap ASN.1 call until fixed in library 2024-11-20 15:07:13 -05:00
Matt Nadareski
4e40cc19d5 TODO cleanup 2024-11-20 14:54:22 -05:00
Matt Nadareski
1bc9316bc1 Update packages 2024-11-20 14:35:37 -05:00
Matt Nadareski
c995ec1dca Miscellaneous cleanup 2024-11-19 12:40:32 -05:00
Matt Nadareski
4d2fbbae04 Update Models to 1.5.2 2024-11-19 01:04:50 -05:00
Matt Nadareski
2776928946 Bump version 2024-11-15 22:38:35 -05:00
Matt Nadareski
8cc87c6540 Recombine WrapperBase files 2024-11-15 22:26:45 -05:00
Matt Nadareski
3c212022aa Use safe enumeration 2024-11-15 22:25:28 -05:00
Matt Nadareski
511c4d09e5 Update ASN1 to 1.4.1 and IO to 1.5.1 2024-11-15 22:22:22 -05:00
Matt Nadareski
d7eba27dc5 Framework only matters for executable 2024-11-15 21:10:27 -05:00
Matt Nadareski
09370618ca Reorder some methods 2024-11-14 20:51:25 -05:00
Matt Nadareski
2197167088 Add remaining easy sizes per partition 2024-11-14 20:48:42 -05:00
Matt Nadareski
b527635fe7 Add remaining easy offsets per partition 2024-11-14 20:46:56 -05:00
Matt Nadareski
695309bc32 Bump version 2024-11-14 13:32:19 -05:00
Matt Nadareski
97b2f68ec7 Use offsets instead of guessing... 2024-11-14 13:27:02 -05:00
Matt Nadareski
593044dbf3 Fix code binary check in N3DS 2024-11-14 12:49:16 -05:00
Matt Nadareski
1fcf44fb8d Bump version 2024-11-14 11:32:17 -05:00
Matt Nadareski
a2a472baf9 Fix top level printing issue 2024-11-14 11:24:08 -05:00
Matt Nadareski
b5b4a50d94 Fix deserialization of NCCH extended header
The actual fix to this is somewhere in the conversion code where an array of Enum values somehow just... fails? I'm not totally sure how that's happening but this is the easiest way around it until that auto stuff can be fixed.
2024-11-14 11:20:46 -05:00
Matt Nadareski
f1b5464052 Extend N3DS wrapper further 2024-11-14 03:17:11 -05:00
Matt Nadareski
2c0224db22 Fix byte order for N3DS IV 2024-11-14 00:12:35 -05:00
Matt Nadareski
1e78eecb40 Bump version 2024-11-13 23:13:55 -05:00
Matt Nadareski
3626faea60 Fix building N3DS cart image 2024-11-13 23:05:26 -05:00
Matt Nadareski
a0177f1174 Add bitmasks helper method 2024-11-13 21:29:43 -05:00
Matt Nadareski
db5fe4a2cd Add extension property for backup header 2024-11-13 21:25:46 -05:00
Matt Nadareski
5716143168 Bump version 2024-11-13 20:48:55 -05:00
Matt Nadareski
2a59b23149 Add more extensions to N3DS wrapper 2024-11-13 20:47:25 -05:00
Matt Nadareski
bdbec4ed02 Update Models to 1.5.1 2024-11-13 20:41:13 -05:00
Matt Nadareski
25193f1805 Start making fixes to N3DS 2024-11-13 20:21:32 -05:00
2188 changed files with 249193 additions and 669603 deletions

167
.editorconfig Normal file
View File

@@ -0,0 +1,167 @@
# top-most EditorConfig file
root = true
# C# files
[*.cs]
# Indentation and spacing
charset = utf-8
indent_size = 4
indent_style = space
tab_width = 4
trim_trailing_whitespace = true
# New line preferences
end_of_line = lf
insert_final_newline = true
max_line_length = unset
# using directive preferences
csharp_using_directive_placement = outside_namespace
dotnet_diagnostic.IDE0005.severity = error
# Code-block preferences
csharp_style_namespace_declarations = block_scoped
csharp_style_prefer_method_group_conversion = true
csharp_style_prefer_top_level_statements = false
# Expression-level preferences
csharp_prefer_simple_default_expression = true
csharp_style_inlined_variable_declaration = true
csharp_style_unused_value_assignment_preference = discard_variable
csharp_style_unused_value_expression_statement_preference = discard_variable
dotnet_diagnostic.IDE0001.severity = warning
dotnet_diagnostic.IDE0002.severity = warning
dotnet_diagnostic.IDE0004.severity = warning
dotnet_diagnostic.IDE0010.severity = error
dotnet_diagnostic.IDE0051.severity = warning
dotnet_diagnostic.IDE0052.severity = warning
dotnet_diagnostic.IDE0072.severity = warning
dotnet_diagnostic.IDE0080.severity = warning
dotnet_diagnostic.IDE0100.severity = error
dotnet_diagnostic.IDE0110.severity = error
dotnet_diagnostic.IDE0120.severity = warning
dotnet_diagnostic.IDE0121.severity = warning
dotnet_diagnostic.IDE0240.severity = error
dotnet_diagnostic.IDE0241.severity = error
dotnet_style_coalesce_expression = true
dotnet_style_namespace_match_folder = false
dotnet_style_null_propagation = true
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_collection_expression = when_types_loosely_match
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
dotnet_style_prefer_compound_assignment = true
csharp_style_prefer_simple_property_accessors = true
dotnet_style_prefer_simplified_interpolation = true
dotnet_style_prefer_simplified_boolean_expressions = true
csharp_style_prefer_unbound_generic_type_in_nameof = true
# Field preferences
dotnet_diagnostic.IDE0044.severity = warning
dotnet_style_readonly_field = true
# Language keyword vs. framework types preferences
dotnet_diagnostic.IDE0049.severity = error
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
# Modifier preferences
csharp_prefer_static_local_function = true
csharp_style_prefer_readonly_struct = true
dotnet_diagnostic.IDE0036.severity = warning
dotnet_diagnostic.IDE0040.severity = error
dotnet_diagnostic.IDE0380.severity = error
dotnet_style_require_accessibility_modifiers = always
# New-line preferences
dotnet_diagnostic.IDE2000.severity = warning
dotnet_diagnostic.IDE2002.severity = warning
dotnet_diagnostic.IDE2003.severity = warning
dotnet_diagnostic.IDE2004.severity = warning
dotnet_diagnostic.IDE2005.severity = warning
dotnet_diagnostic.IDE2006.severity = warning
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_style_allow_statement_immediately_after_block_experimental = false
# Null-checking preferences
csharp_style_conditional_delegate_call = true
# Parameter preferences
dotnet_code_quality_unused_parameters = all
dotnet_diagnostic.IDE0280.severity = error
# Parentheses preferences
dotnet_diagnostic.IDE0047.severity = warning
dotnet_diagnostic.IDE0048.severity = warning
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = always_for_clarity
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
# Pattern-matching preferences
dotnet_diagnostic.IDE0019.severity = warning
dotnet_diagnostic.IDE0020.severity = warning
dotnet_diagnostic.IDE0038.severity = warning
dotnet_diagnostic.IDE0066.severity = none
dotnet_diagnostic.IDE0083.severity = warning
dotnet_diagnostic.IDE0260.severity = warning
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_prefer_not_pattern = true
csharp_style_prefer_pattern_matching = true
# this. and Me. preferences
dotnet_style_qualification_for_event = false
dotnet_style_qualification_for_field = false
dotnet_style_qualification_for_method = false
dotnet_style_qualification_for_property = false
# var preferences
csharp_style_var_for_built_in_types = false
csharp_style_var_when_type_is_apparent = true
# .NET formatting options
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
# C# formatting options
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

48
.github/workflows/build_and_test.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: Build and Test
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Run tests
run: dotnet test
- name: Run publish script
run: ./publish-nix.sh -d
- name: Update rolling tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f rolling
git push origin :refs/tags/rolling || true
git push origin rolling --force
- name: Upload to rolling
uses: ncipollo/release-action@v1.20.0
with:
allowUpdates: True
artifacts: "*.nupkg,*.snupkg,*.zip"
body: "Last built commit: ${{ github.sha }}"
name: "Rolling Release"
prerelease: True
replacesArtifacts: True
tag: "rolling"
updateOnlyUnreleased: True

View File

@@ -1,49 +0,0 @@
name: Nuget Pack
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build library
run: dotnet build
- name: Run tests
run: dotnet test
- name: Pack
run: dotnet pack
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: 'Nuget Package'
path: 'SabreTools.Serialization/bin/Release/*.nupkg'
- name: Upload to rolling
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: True
artifacts: 'SabreTools.Serialization/bin/Release/*.nupkg'
body: 'Last built commit: ${{ github.sha }}'
name: 'Rolling Release'
prerelease: True
replacesArtifacts: True
tag: "rolling"
updateOnlyUnreleased: True

View File

@@ -1,55 +0,0 @@
name: Build InfoPrint
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
project: [InfoPrint]
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64]
framework: [net9.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0]
conf: [Debug] #[Release, Debug]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}}
- name: Archive build
run: |
cd ${{ matrix.project }}/bin/Debug/${{ matrix.framework }}/${{ matrix.runtime }}/publish/
zip -r ${{ github.workspace }}/${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip ./
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}
path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip
- name: Upload to rolling
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: True
artifacts: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip
body: 'Last built commit: ${{ github.sha }}'
name: 'Rolling Release'
prerelease: True
replacesArtifacts: True
tag: "rolling"
updateOnlyUnreleased: True

View File

@@ -3,18 +3,21 @@ name: Build PR
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Build
run: dotnet build
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Run tests
run: dotnet test
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Build
run: dotnet build
- name: Run tests
run: dotnet test

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.lscache
*.suo
*.user
*.userosscache

26
.vscode/launch.json vendored
View File

@@ -1,16 +1,30 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (ExtractionTool)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/ExtractionTool/bin/Debug/net10.0/ExtractionTool.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false,
"justMyCode": false
},
{
"name": ".NET Core Launch (InfoPrint)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/InfoPrint/bin/Debug/net9.0/InfoPrint.dll",
"program": "${workspaceFolder}/InfoPrint/bin/Debug/net10.0/InfoPrint.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

View File

@@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>3.2.0</Version>
</PropertyGroup>
<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`)) OR $(TargetFramework.StartsWith(`net10`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>
<!-- These are needed for dealing with native Windows DLLs -->
<ItemGroup Condition="'$(RuntimeIdentifier)'=='win-x86'">
<ContentWithTargetPath Include="..\runtimes\win-x86\native\StormLib.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<TargetPath>StormLib.dll</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)'=='win-x64'">
<ContentWithTargetPath Include="..\runtimes\win-x64\native\StormLib.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<TargetPath>StormLib.dll</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Wrappers\SabreTools.Wrappers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.CommandLine" Version="1.5.0" />
<PackageReference Include="SabreTools.IO" Version="2.3.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.11" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,194 @@
using System;
using System.IO;
using SabreTools.CommandLine;
using SabreTools.CommandLine.Inputs;
using SabreTools.IO.Extensions;
using SabreTools.Numerics.Extensions;
using SabreTools.Wrappers;
namespace ExtractionTool.Features
{
internal sealed class MainFeature : Feature
{
#region Feature Definition
public const string DisplayName = "main";
/// <remarks>Flags are unused</remarks>
private static readonly string[] _flags = [];
/// <remarks>Description is unused</remarks>
private const string _description = "";
#endregion
#region Inputs
private const string _debugName = "debug";
internal readonly FlagInput DebugInput = new(_debugName, ["-d", "--debug"], "Enable debug mode");
private const string _outputPathName = "output-path";
internal readonly StringInput OutputPathInput = new(_outputPathName, ["-o", "--outdir"], "Set output path for extraction (required)");
#endregion
#region Properties
/// <summary>
/// Enable debug output for relevant operations
/// </summary>
public bool Debug { get; private set; }
/// <summary>
/// Output path for archive extraction
/// </summary>
public string OutputPath { get; private set; } = string.Empty;
#endregion
public MainFeature()
: base(DisplayName, _flags, _description)
{
RequiresInputs = true;
Add(DebugInput);
Add(OutputPathInput);
}
/// <inheritdoc/>
public override bool Execute()
{
// Get the options from the arguments
Debug = GetBoolean(_debugName);
OutputPath = GetString(_outputPathName) ?? string.Empty;
// Validate the output path
if (!ValidateExtractionPath())
return false;
// Loop through the input paths
for (int i = 0; i < Inputs.Count; i++)
{
string arg = Inputs[i];
ExtractPath(arg);
}
return true;
}
/// <inheritdoc/>
public override bool VerifyInputs() => Inputs.Count > 0;
/// <summary>
/// Wrapper to extract data for a single path
/// </summary>
/// <param name="path">File or directory path</param>
private void ExtractPath(string path)
{
// Normalize by getting the full path
path = Path.GetFullPath(path);
Console.WriteLine($"Checking possible path: {path}");
// Check if the file or directory exists
if (File.Exists(path))
{
ExtractFile(path);
}
else if (Directory.Exists(path))
{
foreach (string file in path.SafeEnumerateFiles("*", SearchOption.AllDirectories))
{
ExtractFile(file);
}
}
else
{
Console.WriteLine($"{path} does not exist, skipping...");
}
}
/// <summary>
/// Print information for a single file, if possible
/// </summary>
/// <param name="path">File path</param>
private void ExtractFile(string file)
{
try
{
Console.WriteLine($"Attempting to extract all files from {file}");
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
// Read the first 32 bytes
byte[] magic = stream.PeekBytes(32);
// Get the file type
string extension = Path.GetExtension(file).TrimStart('.');
WrapperType ft = WrapperFactory.GetFileType(magic ?? [], extension);
// Print out the file format
Console.WriteLine($"File format found: {ft}");
// Setup the wrapper to extract
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
// If we don't have a wrapper
if (wrapper is null)
{
Console.WriteLine($"Either {ft} is not supported or something went wrong during parsing!");
Console.WriteLine();
return;
}
// If the wrapper is not extractable
if (wrapper is not IExtractable extractable)
{
Console.WriteLine($"{ft} is not supported for extraction!");
Console.WriteLine();
return;
}
// Print the preamble
Console.WriteLine($"Attempting to extract from '{wrapper.Description()}'");
Console.WriteLine();
// Attempt the extraction
Directory.CreateDirectory(OutputPath);
extractable.Extract(OutputPath, Debug);
}
catch (Exception ex)
{
Console.WriteLine(Debug ? ex : "[Exception opening file, please try again]");
Console.WriteLine();
}
}
/// <summary>
/// Validate the extraction path
/// </summary>
private bool ValidateExtractionPath()
{
// Null or empty output path
if (string.IsNullOrEmpty(OutputPath))
{
Console.WriteLine("Output directory required for extraction!");
Console.WriteLine();
return false;
}
// Malformed output path or invalid location
try
{
OutputPath = Path.GetFullPath(OutputPath);
Directory.CreateDirectory(OutputPath);
}
catch
{
Console.WriteLine("Output directory could not be created!");
Console.WriteLine();
return false;
}
return true;
}
}
}

79
ExtractionTool/Program.cs Normal file
View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using ExtractionTool.Features;
using SabreTools.CommandLine;
using SabreTools.CommandLine.Features;
namespace ExtractionTool
{
public static class Program
{
public static void Main(string[] args)
{
#if NET462_OR_GREATER || NETCOREAPP
// Register the codepages
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
#endif
// Create the command set
var mainFeature = new MainFeature();
var commandSet = CreateCommands(mainFeature);
// If we have no args, show the help and quit
if (args is null || args.Length == 0)
{
commandSet.OutputAllHelp();
return;
}
// Cache the first argument and starting index
string featureName = args[0];
// Try processing the standalone arguments
var topLevel = commandSet.GetTopLevel(featureName);
switch (topLevel)
{
// Standalone Options
case Help help: help.ProcessArgs(args, 0, commandSet); return;
// Default Behavior
default:
if (!mainFeature.ProcessArgs(args, 0))
{
commandSet.OutputAllHelp();
return;
}
else if (!mainFeature.VerifyInputs())
{
Console.Error.WriteLine("At least one input is required");
commandSet.OutputAllHelp();
return;
}
mainFeature.Execute();
break;
}
}
/// <summary>
/// Create the command set for the program
/// </summary>
private static CommandSet CreateCommands(MainFeature mainFeature)
{
List<string> header = [
"Extraction Tool",
string.Empty,
"ExtractionTool <options> file|directory ...",
string.Empty,
];
var commandSet = new CommandSet(header);
commandSet.Add(new Help(["-?", "-h", "--help"]));
commandSet.Add(mainFeature.DebugInput);
commandSet.Add(mainFeature.OutputPathInput);
return commandSet;
}
}
}

View File

@@ -0,0 +1,284 @@
using System;
using System.IO;
using System.Text;
using SabreTools.CommandLine;
using SabreTools.CommandLine.Inputs;
using SabreTools.Hashing;
using SabreTools.IO.Extensions;
using SabreTools.Numerics.Extensions;
using SabreTools.Wrappers;
namespace InfoPrint.Features
{
internal sealed class MainFeature : Feature
{
#region Feature Definition
public const string DisplayName = "main";
/// <remarks>Flags are unused</remarks>
private static readonly string[] _flags = [];
/// <remarks>Description is unused</remarks>
private const string _description = "";
#endregion
#region Inputs
private const string _debugName = "debug";
internal readonly FlagInput DebugInput = new(_debugName, ["-d", "--debug"], "Enable debug mode");
private const string _fileOnlyName = "file-only";
internal readonly FlagInput FileOnlyInput = new(_fileOnlyName, ["-f", "--file"], "Print to file only");
private const string _hashName = "hash";
internal readonly FlagInput HashInput = new(_hashName, ["-c", "--hash"], "Output file hashes");
private const string _jsonName = "json";
internal readonly FlagInput JsonInput = new(_jsonName, ["-j", "--json"], "Print info as JSON");
private const string _recursiveName = "recursive";
internal readonly FlagInput RecursiveInput = new(_recursiveName, ["-r", "--recursive"], "Recursively print info from embedded files");
#endregion
/// <summary>
/// Enable debug output for relevant operations
/// </summary>
public bool Debug { get; private set; }
/// <summary>
/// Output information to file only, skip printing to console
/// </summary>
public bool FileOnly { get; private set; }
/// <summary>
/// Print external file hashes
/// </summary>
public bool Hash { get; private set; }
/// <summary>
/// Enable JSON output
/// </summary>
public bool Json { get; private set; }
/// <summary>
/// Enable outputting subfile information
/// </summary>
public bool Recursive { get; private set; }
public MainFeature()
: base(DisplayName, _flags, _description)
{
RequiresInputs = true;
Add(DebugInput);
Add(HashInput);
Add(FileOnlyInput);
Add(JsonInput);
Add(RecursiveInput);
}
/// <inheritdoc/>
public override bool Execute()
{
// Get the options from the arguments
Debug = GetBoolean(_debugName);
Hash = GetBoolean(_hashName);
FileOnly = GetBoolean(_fileOnlyName);
Json = GetBoolean(_jsonName);
Recursive = GetBoolean(_recursiveName);
// Loop through the input paths
for (int i = 0; i < Inputs.Count; i++)
{
string arg = Inputs[i];
PrintPathInfo(arg);
}
return true;
}
/// <inheritdoc/>
public override bool VerifyInputs() => Inputs.Count > 0;
/// <summary>
/// Wrapper to print information for a single path
/// </summary>
/// <param name="path">File or directory path</param>
private void PrintPathInfo(string path)
{
Console.WriteLine($"Checking possible path: {path}");
// Check if the file or directory exists
if (File.Exists(path))
{
PrintFileInfo(path);
}
else if (Directory.Exists(path))
{
foreach (string file in path.SafeEnumerateFiles("*", SearchOption.AllDirectories))
{
PrintFileInfo(file);
}
}
else
{
Console.WriteLine($"{path} does not exist, skipping...");
}
}
/// <summary>
/// Print information for a single file, if possible
/// </summary>
/// <param name="file">File path</param>
private void PrintFileInfo(string file)
{
Console.WriteLine($"Attempting to print info for {file}");
// Get the base info output name
string filenameBase = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}";
// If we have the hash flag
if (Hash)
{
var hashBuilder = PrintHashInfo(file);
if (hashBuilder is not null)
{
// Create the output data
string hashData = hashBuilder.ToString();
// Write the output data
using var hsw = new StreamWriter(File.OpenWrite($"{filenameBase}.hashes"));
hsw.WriteLine(hashData);
hsw.Flush();
}
}
try
{
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
// Read the first 32 bytes
byte[] magic = stream.PeekBytes(32);
// Get the file type
string extension = Path.GetExtension(file).TrimStart('.');
WrapperType ft = WrapperFactory.GetFileType(magic ?? [], extension);
// Print out the file format
Console.WriteLine($"File format found: {ft}");
// Setup the wrapper to print
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
// If we don't have a wrapper
if (wrapper is null)
{
Console.WriteLine($"Either {ft} is not supported or something went wrong during parsing!");
Console.WriteLine();
return;
}
// If the wrapper is not printable
if (wrapper is not IPrintable printable)
{
Console.WriteLine($"{ft} is not supported for printing!");
Console.WriteLine();
return;
}
// If we have the JSON flag
if (Json)
{
// Create the output data
string serializedData = printable.ExportJSON(Recursive);
// Write the output data
using var jsw = new StreamWriter(File.OpenWrite($"{filenameBase}.json"));
jsw.WriteLine(serializedData);
jsw.Flush();
}
// Create the output data
var builder = new StringBuilder();
printable.PrintInformation(builder, Recursive);
// Only print to console if enabled
if (!FileOnly)
Console.WriteLine(builder);
using var sw = new StreamWriter(File.OpenWrite($"{filenameBase}.txt"));
sw.WriteLine(file);
sw.WriteLine();
sw.WriteLine(builder.ToString());
sw.Flush();
}
catch (Exception ex)
{
Console.WriteLine(Debug ? ex : "[Exception opening file, please try again]");
Console.WriteLine();
}
}
/// <summary>
/// Print hash information for a single file, if possible
/// </summary>
/// <param name="file">File path</param>
/// <returns>StringBuilder representing the hash information, if possible</returns>
private StringBuilder? PrintHashInfo(string file)
{
// Ignore missing files
if (!File.Exists(file))
return null;
Console.WriteLine($"Attempting to hash {file}, this may take a while...");
try
{
// Get all file hashes for flexibility
var hashes = HashTool.GetFileHashes(file);
if (hashes is null)
{
if (Debug) Console.WriteLine($"Hashes for {file} could not be retrieved");
return null;
}
// Output subset of available hashes
var builder = new StringBuilder();
if (hashes.TryGetValue(HashType.CRC16, out string? crc16) && crc16 is not null)
builder.AppendLine($"CRC-16 checksum: {crc16}");
if (hashes.TryGetValue(HashType.CRC32, out string? crc32) && crc32 is not null)
builder.AppendLine($"CRC-32 checksum: {crc32}");
if (hashes.TryGetValue(HashType.CRC64, out string? crc64) && crc64 is not null)
builder.AppendLine($"CRC-64 checksum: {crc64}");
if (hashes.TryGetValue(HashType.MD2, out string? md2) && md2 is not null)
builder.AppendLine($"MD2 hash: {md2}");
if (hashes.TryGetValue(HashType.MD4, out string? md4) && md4 is not null)
builder.AppendLine($"MD4 hash: {md4}");
if (hashes.TryGetValue(HashType.MD5, out string? md5) && md5 is not null)
builder.AppendLine($"MD5 hash: {md5}");
if (hashes.TryGetValue(HashType.RIPEMD128, out string? ripemd128) && ripemd128 is not null)
builder.AppendLine($"RIPEMD-128 hash: {ripemd128}");
if (hashes.TryGetValue(HashType.RIPEMD160, out string? ripemd160) && ripemd160 is not null)
builder.AppendLine($"RIPEMD-160 hash: {ripemd160}");
if (hashes.TryGetValue(HashType.SHA1, out string? sha1) && sha1 is not null)
builder.AppendLine($"SHA-1 hash: {sha1}");
if (hashes.TryGetValue(HashType.SHA256, out string? sha256) && sha256 is not null)
builder.AppendLine($"SHA-256 hash: {sha256}");
if (hashes.TryGetValue(HashType.SHA384, out string? sha384) && sha384 is not null)
builder.AppendLine($"SHA-384 hash: {sha384}");
if (hashes.TryGetValue(HashType.SHA512, out string? sha512) && sha512 is not null)
builder.AppendLine($"SHA-512 hash: {sha512}");
return builder;
}
catch (Exception ex)
{
Console.WriteLine(Debug ? ex : "[Exception opening file, please try again]");
return null;
}
}
}
}

View File

@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.7.0</Version>
<Version>3.2.0</Version>
</PropertyGroup>
<!-- Support All Frameworks -->
@@ -19,15 +20,21 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`)) OR $(TargetFramework.StartsWith(`net10`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Serialization\SabreTools.Serialization.csproj" />
<ProjectReference Include="..\SabreTools.Wrappers\SabreTools.Wrappers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.CommandLine" Version="1.5.0" />
<PackageReference Include="SabreTools.Hashing" Version="2.1.0" />
<PackageReference Include="SabreTools.IO" Version="2.3.0" />
</ItemGroup>
</Project>

View File

@@ -1,119 +0,0 @@
using System;
using System.Collections.Generic;
namespace InfoPrint
{
/// <summary>
/// Set of options for the test executable
/// </summary>
internal sealed class Options
{
#region Properties
/// <summary>
/// Enable debug output for relevant operations
/// </summary>
public bool Debug { get; private set; } = false;
/// <summary>
/// Set of input paths to use for operations
/// </summary>
public List<string> InputPaths { get; private set; } = [];
#if NETCOREAPP3_1_OR_GREATER
/// <summary>
/// Enable JSON output
/// </summary>
public bool Json { get; private set; } = false;
#endif
#endregion
/// <summary>
/// Parse commandline arguments into an Options object
/// </summary>
public static Options? ParseOptions(string[] args)
{
// If we have invalid arguments
if (args == null || args.Length == 0)
return null;
// Create an Options object
var options = new Options();
// Parse the features
int index = 0;
for (; index < args.Length; index++)
{
string arg = args[index];
bool featureFound = false;
switch (arg)
{
case "-?":
case "-h":
case "--help":
return null;
default:
break;
}
// If the flag wasn't a feature
if (!featureFound)
break;
}
// Parse the options and paths
for (; index < args.Length; index++)
{
string arg = args[index];
switch (arg)
{
case "-d":
case "--debug":
options.Debug = true;
break;
case "-j":
case "--json":
#if NET6_0_OR_GREATER
options.Json = true;
#else
Console.WriteLine("JSON output not available in .NET Framework");
#endif
break;
default:
options.InputPaths.Add(arg);
break;
}
}
// Validate we have any input paths to work on
if (options.InputPaths.Count == 0)
{
Console.WriteLine("At least one path is required!");
return null;
}
return options;
}
/// <summary>
/// Display help text
/// </summary>
public static void DisplayHelp()
{
Console.WriteLine("Information Printing Program");
Console.WriteLine();
Console.WriteLine("infoprint.exe <options> file|directory ...");
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine("-?, -h, --help Display this help text and quit");
Console.WriteLine("-d, --debug Enable debug mode");
#if NET6_0_OR_GREATER
Console.WriteLine("-j, --json Print info as JSON");
#endif
}
}
}

View File

@@ -1,8 +1,8 @@
using System;
using System.IO;
using SabreTools.IO.Extensions;
using SabreTools.Serialization;
using SabreTools.Serialization.Wrappers;
using System.Collections.Generic;
using InfoPrint.Features;
using SabreTools.CommandLine;
using SabreTools.CommandLine.Features;
namespace InfoPrint
{
@@ -10,127 +10,69 @@ namespace InfoPrint
{
public static void Main(string[] args)
{
// Get the options from the arguments
var options = Options.ParseOptions(args);
// Create the command set
var mainFeature = new MainFeature();
var commandSet = CreateCommands(mainFeature);
// If we have an invalid state
if (options == null)
// If we have no args, show the help and quit
if (args is null || args.Length == 0)
{
Options.DisplayHelp();
commandSet.OutputAllHelp();
return;
}
// Loop through the input paths
foreach (string inputPath in options.InputPaths)
// Cache the first argument and starting index
string featureName = args[0];
// Try processing the standalone arguments
var topLevel = commandSet.GetTopLevel(featureName);
switch (topLevel)
{
#if NETFRAMEWORK
PrintPathInfo(inputPath, false, options.Debug);
#else
PrintPathInfo(inputPath, options.Json, options.Debug);
#endif
// Standalone Options
case Help help: help.ProcessArgs(args, 0, commandSet); return;
// Default Behavior
default:
if (!mainFeature.ProcessArgs(args, 0))
{
commandSet.OutputAllHelp();
return;
}
else if (!mainFeature.VerifyInputs())
{
Console.Error.WriteLine("At least one input is required");
commandSet.OutputAllHelp();
return;
}
mainFeature.Execute();
break;
}
}
/// <summary>
/// Wrapper to print information for a single path
/// Create the command set for the program
/// </summary>
/// <param name="path">File or directory path</param>
/// <param name="json">Enable JSON output, if supported</param>
/// <param name="debug">Enable debug output</param>
private static void PrintPathInfo(string path, bool json, bool debug)
private static CommandSet CreateCommands(MainFeature mainFeature)
{
Console.WriteLine($"Checking possible path: {path}");
List<string> header = [
"Information Printing Program",
string.Empty,
"InfoPrint <options> file|directory ...",
string.Empty,
];
// Check if the file or directory exists
if (File.Exists(path))
{
PrintFileInfo(path, json, debug);
}
else if (Directory.Exists(path))
{
#if NET20 || NET35
foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
#else
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
#endif
{
PrintFileInfo(file, json, debug);
}
}
else
{
Console.WriteLine($"{path} does not exist, skipping...");
}
}
var commandSet = new CommandSet(header);
/// <summary>
/// Print information for a single file, if possible
/// </summary>
private static void PrintFileInfo(string file, bool json, bool debug)
{
Console.WriteLine($"Attempting to print info for {file}");
try
{
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
// Read the first 8 bytes
byte[]? magic = stream.ReadBytes(8);
stream.Seek(0, SeekOrigin.Begin);
// Get the file type
string extension = Path.GetExtension(file).TrimStart('.');
WrapperType ft = WrapperFactory.GetFileType(magic ?? [], extension);
// Print out the file format
Console.WriteLine($"File format found: {ft}");
// Setup the wrapper to print
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
// If we don't have a wrapper
if (wrapper == null)
{
Console.WriteLine($"Either {ft} is not supported or something went wrong during parsing!");
Console.WriteLine();
return;
}
// Get the base info output name
string filenameBase = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss.ffff}";
#if NET6_0_OR_GREATER
// If we have the JSON flag
if (json)
{
// Create the output data
string serializedData = wrapper.ExportJSON();
Console.WriteLine(serializedData);
// Write the output data
using var jsw = new StreamWriter(File.OpenWrite($"{filenameBase}.json"));
jsw.WriteLine(serializedData);
}
commandSet.Add(new Help(["-?", "-h", "--help"]));
commandSet.Add(mainFeature.DebugInput);
commandSet.Add(mainFeature.HashInput);
commandSet.Add(mainFeature.FileOnlyInput);
#if NETCOREAPP
commandSet.Add(mainFeature.JsonInput);
#endif
// Create the output data
var builder = wrapper.ExportStringBuilder();
if (builder == null)
{
Console.WriteLine("No item information could be generated");
return;
}
// Write the output data
Console.WriteLine(builder);
using var sw = new StreamWriter(File.OpenWrite($"{filenameBase}.txt"));
sw.WriteLine(builder.ToString());
}
catch (Exception ex)
{
Console.WriteLine(debug ? ex : "[Exception opening file, please try again]");
Console.WriteLine();
}
return commandSet;
}
}
}
}

7
LICENSE Normal file
View File

@@ -0,0 +1,7 @@
Copyright (c) 2018-2026 Matt Nadareski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

100
README.MD
View File

@@ -1,6 +1,8 @@
# SabreTools.Serialization
This library comprises of serializers that both read and write from files and streams to the dedicated models as well as convert to and from the common internal models. This library is partially used by the current parsing and writing code but none of the internal model serialization is used.
[![Build and Test](https://github.com/SabreTools/SabreTools.Serialization/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/SabreTools/SabreTools.Serialization/actions/workflows/build_and_test.yml)
This meta-library comprises of serializers that both read and write from files and streams to the dedicated models as well as convert to and from the common internal models. This library is partially used by the current parsing and writing code but none of the internal model serialization is used.
Find the link to the Nuget package [here](https://www.nuget.org/packages/SabreTools.Serialization).
@@ -10,37 +12,83 @@ For the most recent stable build, download the latest release here: [Releases Pa
For the latest WIP build here: [Rolling Release](https://github.com/SabreTools/SabreTools.Serialization/releases/tag/rolling)
## Interfaces
## InfoPrint
Below is a table representing the various conversion interfaces that are implemented within this library.
**InfoPrint** is a reference implementation for the deserialization and printing features of the library, packaged as a standalone executable for all supported platforms. It will attempt to detect and display information about many supported file types, optionally both hashing the file and outputting the information to a JSON file.
| Interface Name | Source Type | Destination Type |
| --- | --- | --- |
| `IByteDeserializer` | `byte[]?` | Model |
| `IByteSerializer` | Model | `byte[]?` |
| `IFileDeserializer` | `string?` path | Model |
| `IFileSerializer` | Model | `string?` path |
| `IModelSerializer` | Model | Model |
| `IStreamDeserializer` | `Stream?` | Model |
| `IStreamSerializer` | Model | `Stream?` |
| `IStringDeserializer` | `string?` representation | Model |
| `IStringSerializer` | Model | `string?` representation |
```text
InfoPrint <options> file|directory ...
Below is a table representing the various non-conversion interfaces that are implemented within this library.
Options:
-?, -h, --help Display this help text
-d, --debug Enable debug mode
-c, --hash Output file hashes
-f, --file Print to file only
-j, --json Print info as JSON
-r, --recursive Recursively print info from embedded files
```
| Interface Name | Purpose |
## ExtractionTool
**ExtractionTool** is a reference implementation for the extraction features of the library, packaged as a standalone executable for all supported platforms. It will attempt to detect and extract many supported file types. See the table below for supported extraction functionality.
```text
ExtractionTool <options> file|directory ...
Options:
-?, -h, --help Display this help text
-d, --debug Enable debug mode
-o, --outdir [PATH] Set output path for extraction (required)
```
| Format Name | Notes |
| --- | --- |
| `IPrinter` | Provides a formatted output for a model |
| `IWrapper` / `IWrapper<T>` | Wraps a model or set of models to provide additional functionality |
| 7-zip archive | .NET Framework 4.6.2 and greater |
| Atari 7800 (A78) Cart Image | Header and ROM data |
| Atari Lynx (LNX) Cart Image | Header and ROM data |
| BFPK custom archive format | |
| bzip2 archive | .NET Framework 4.6.2 and greater |
| Compound File Binary (CFB) | Only CFB common pieces extractable |
| fwNES FDS file | Header and disk data |
| gzip archive | |
| Half-Life Game Cache File (GCF) | |
| Half-Life Level (BSP) | |
| Half-Life Package File (PAK) | |
| Half-Life Texture Package File (WAD3) | |
| Half-Life 2 Level (VBSP) | |
| InstallShield Archive V3 (Z) | |
| InstallShield CAB | |
| ISO9660 | ISO and BIN files |
| Microsoft cabinet file | Does not support LZX or Quantum compression |
| Microsoft LZ-compressed files | KWAJ, QBasic, and SZDD variants |
| MoPaQ game data archive (MPQ) | Windows only |
| New Exectuable | Embedded archives and executables in the overlay and Wise installer |
| Nintendo Entertainment System (NES) Cart Image | Header, Trainer data, PRG-ROM, CHR-ROM, Unheadered ROM, and PlayChoice-10 INST-ROM |
| NovaLogic Game Archive Format (PFF) | |
| PKZIP and derived files (ZIP, etc.) | .NET Framework 4.6.2 and greater |
| Portable Executable | Embedded archives and executables in the resources and overlay, CExe-packed data, SFX archives (7-zip, PKZIP, and RAR), and Wise installer |
| Quantum archive (Q) | Currently not working |
| RAR archive (RAR) | .NET Framework 4.6.2 and greater |
| SGA game archive | |
| Tape archive (TAR) | |
| Valve Package File (VPK) | |
| XBox Package File (XZP) | |
| Xbox DVD Filesystem (XISO) | |
| xz archive (XZ) | .NET Framework 4.6.2 and greater |
| ZArchive | |
## Namespaces
Below is a table of all namespaces within the library and what they represent
Below are a list of the included namespaces with links to their README files:
| Namespace | Description |
| --- | --- |
| `SabreTools.Serialization.CrossModel` | Convert between models; mainly used for metadata files converting to and from a common, `Dictionary`-based model |
| `SabreTools.Serialization.Deserializers` | Convert from external sources to models |
| `SabreTools.Serialization.Printers` | Export model information in a formatted manner |
| `SabreTools.Serialization.Serializers` | Convert from models to external sources |
| `SabreTools.Serialization.Wrappers` | Classes that wrap serialization and models to allow for including extension properties |
- [SabreTools.Data.Extensions](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Data.Extensions)
- [SabreTools.Data.Models](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Data.Models)
- [SabreTools.Metadata.DatFiles](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Metadata.DatFiles)
- [SabreTools.Metadata.DatItems](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Metadata.Datitems)
- [SabreTools.Metadata.Filter](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Metadata.Filter)
- [SabreTools.Metadata.Reports](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Metadata.Reports)
- [SabreTools.ObjectIdentifier](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.ObjectIdentifier)
- [SabreTools.Serialization.CrossModel](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Serialization.CrossModel)
- [SabreTools.Serialization.Readers](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Serialization.Readers)
- [SabreTools.Serialization.Writers](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Serialization.Writers)
- [SabreTools.Wrappers](https://github.com/SabreTools/SabreTools.Serialization/tree/main/SabreTools.Wrappers)

View File

@@ -0,0 +1,141 @@
using SabreTools.Data.Models.Atari7800;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class Atari7800CartExtensionsTests
{
[Theory]
[InlineData((AudioDevice)0, "POKEY - none, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
// POKEY
[InlineData(AudioDevice.Pokey440, "POKEY - @440, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
[InlineData(AudioDevice.Pokey450, "POKEY - @450, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
[InlineData(AudioDevice.Pokey450Plus440, "POKEY - @450+@440, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
[InlineData(AudioDevice.Pokey800, "POKEY - @800, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
[InlineData(AudioDevice.Pokey4000, "POKEY - @4000, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
[InlineData((AudioDevice)0x0007, "Unknown 7, No YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
// YM2151
[InlineData(AudioDevice.YM2151460, "POKEY - none, YM2151 @460, No COVOX @430, No ADPCM Audio Stream @420")]
// COVOX
[InlineData(AudioDevice.COVOX430, "POKEY - none, No YM2151 @460, COVOX @430, No ADPCM Audio Stream @420")]
// ADPCM
[InlineData(AudioDevice.ADPCMAudioStream420, "POKEY - none, No YM2151 @460, No COVOX @430, ADPCM Audio Stream @420")]
public void FromAudioDeviceTest(AudioDevice audio, string expected)
{
string actual = audio.FromAudioDevice();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData((CartType)0, "N/A")]
[InlineData(CartType.PokeyAt4000, "pokey at $4000")]
[InlineData(CartType.SupergameBankSwitched, "supergame bank switched")]
[InlineData(CartType.SupergameRamAt4000, "supergame ram at $4000")]
[InlineData(CartType.RomAt4000, "rom at $4000")]
[InlineData(CartType.Bank6At4000, "bank 6 at $4000")]
[InlineData(CartType.BankedRam, "banked ram")]
[InlineData(CartType.PokeyAt450, "pokey at $450")]
[InlineData(CartType.MirrorRamAt4000, "mirror ram at $4000")]
[InlineData(CartType.ActivisionBanking, "activision banking")]
[InlineData(CartType.AbsoluteBanking, "absolute banking")]
[InlineData(CartType.PokeyAt440, "pokey at $440")]
[InlineData(CartType.Ym2151At460461, "ym2151 at $460/$461")]
[InlineData(CartType.Souper, "souper")]
[InlineData(CartType.Banksets, "banksets")]
[InlineData(CartType.HaltBankedRam, "halt banked ram")]
[InlineData(CartType.PokeyAt800, "pokey@800")]
public void FromCartTypeTest(CartType type, string expected)
{
string actual = type.FromCartType();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(ControllerType.None, "none")]
[InlineData(ControllerType.Joystick, "7800 joystick")]
[InlineData(ControllerType.Lightgun, "lightgun")]
[InlineData(ControllerType.Paddle, "paddle")]
[InlineData(ControllerType.Trakball, "trakball")]
[InlineData(ControllerType.VcsJoystick, "2600 joystick")]
[InlineData(ControllerType.VcsDriving, "2600 driving")]
[InlineData(ControllerType.VcsKeypad, "2600 keypad")]
[InlineData(ControllerType.STMouse, "ST mouse")]
[InlineData(ControllerType.AmigaMouse, "Amiga mouse")]
[InlineData(ControllerType.AtariVoxSaveKey, "AtariVox/SaveKey")]
[InlineData(ControllerType.SNES2Atari, "SNES2Atari")]
[InlineData(ControllerType.Mega7800, "Mega7800")]
public void FromControllerTypeTest(ControllerType type, string expected)
{
string actual = type.FromControllerType();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(Interrupt.None, "None")]
[InlineData(Interrupt.Pokey1, "POKEY 1 (@450 | @800 | @4000)")]
[InlineData(Interrupt.Pokey2, "POKEY 2 (@440)")]
[InlineData(Interrupt.YM2151, "YM2151")]
public void FromInterruptTest(Interrupt interrupt, string expected)
{
string actual = interrupt.FromInterrupt();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(Mapper.Linear, "Linear")]
[InlineData(Mapper.SuperGame, "SuperGame")]
[InlineData(Mapper.Activision, "Activision")]
[InlineData(Mapper.Absolute, "Absolute")]
[InlineData(Mapper.Souper, "Souper")]
public void FromMapperTest(Mapper mapper, string expected)
{
string actual = mapper.FromMapper();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(MapperOptions.SuperGameNone, "Option at @4000 - none, Standard ROM")]
[InlineData(MapperOptions.SuperGame16KRAM, "Option at @4000 - 16K RAM, Standard ROM")]
[InlineData(MapperOptions.SuperGame8KEXRAMA8, "Option at @4000 - 8K EXRAM/A8, Standard ROM")]
[InlineData(MapperOptions.SuperGame32KEXRAMM2, "Option at @4000 - 32K EXRAM/M2, Standard ROM")]
[InlineData(MapperOptions.SuperGameEXROM, "Option at @4000 - EXROM, Standard ROM")]
[InlineData(MapperOptions.SuperGameEXFIX, "Option at @4000 - EXFIX, Standard ROM")]
[InlineData(MapperOptions.SuperGame32KEXRAMX2, "Option at @4000 - 32k EXRAM/X2, Standard ROM")]
[InlineData(MapperOptions.BanksetRom, "Option at @4000 - none, Bankset ROM")]
public void FromMapperOptionsTest(MapperOptions options, string expected)
{
string actual = options.FromMapperOptions();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(SaveDevice.None, "None")]
[InlineData(SaveDevice.HSC, "HSC")]
[InlineData(SaveDevice.SaveKeyAtariVox, "SaveKey/AtariVox")]
public void FromSaveDeviceTest(SaveDevice device, string expected)
{
string actual = device.FromSaveDevice();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(SlotPassthroughDevice.None, "None")]
[InlineData(SlotPassthroughDevice.XM, "XM")]
public void FromSlotPassthroughDeviceTest(SlotPassthroughDevice device, string expected)
{
string actual = device.FromSlotPassthroughDevice();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData((TVType)0, "NTSC, Component, Single-region")]
[InlineData(TVType.PAL, "PAL, Component, Single-region")]
[InlineData(TVType.Composite, "NTSC, Composite, Single-region")]
[InlineData(TVType.MultiRegion, "NTSC, Component, Multi-region")]
public void FromTVTypeTest(TVType type, string expected)
{
string actual = type.FromTVType();
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,18 @@
using SabreTools.Data.Models.AtariLynx;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class AtariLynxCartExtensionsTests
{
[Theory]
[InlineData(Rotation.NoRotation, "No rotation (horizontal, buttons right)")]
[InlineData(Rotation.RotateLeft, "Rotate left (vertical, buttons down)")]
[InlineData(Rotation.RotateRight, "Rotate right (vertical, buttons up)")]
public void FromRotationTest(Rotation rotation, string expected)
{
string actual = rotation.FromRotation();
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,65 @@
using System.IO;
using SabreTools.Data.Models.CDROM;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class CDROMExtensionsTests
{
[Theory]
[InlineData(new byte[0], SectorMode.UNKNOWN)]
[InlineData(new byte[] { 0x00 }, SectorMode.MODE0)]
[InlineData(new byte[] { 0x01 }, SectorMode.MODE1)]
[InlineData(new byte[] { 0x02 }, SectorMode.UNKNOWN)]
[InlineData(new byte[] { 0x02, 0x00, 0x00, 0x00 }, SectorMode.MODE2_FORM1)]
[InlineData(new byte[] { 0x02, 0x00, 0x00, 0x20 }, SectorMode.MODE2_FORM2)]
[InlineData(new byte[] { 0x03 }, SectorMode.UNKNOWN)]
public void GetSectorModeTest(byte[] bytes, SectorMode expected)
{
var stream = new MemoryStream(bytes);
SectorMode actual = stream.GetSectorMode();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(SectorMode.UNKNOWN, 2336)]
[InlineData(SectorMode.MODE0, 2336)]
[InlineData(SectorMode.MODE1, 2048)]
[InlineData(SectorMode.MODE2, 2336)]
[InlineData(SectorMode.MODE2_FORM1, 2048)]
[InlineData(SectorMode.MODE2_FORM2, 2324)]
public void GetUserDataSizeTest(SectorMode mode, long expected)
{
long actual = mode.GetUserDataSize();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(SectorMode.UNKNOWN, 2064)]
[InlineData(SectorMode.MODE0, 2064)]
[InlineData(SectorMode.MODE1, 2064)]
[InlineData(SectorMode.MODE2, 2064)]
[InlineData(SectorMode.MODE2_FORM1, 2072)]
[InlineData(SectorMode.MODE2_FORM2, 2072)]
public void GetUserDataEndTest(SectorMode mode, long expected)
{
long actual = mode.GetUserDataEnd();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(SectorMode.UNKNOWN, 16)]
[InlineData(SectorMode.MODE0, 16)]
[InlineData(SectorMode.MODE1, 16)]
[InlineData(SectorMode.MODE2, 16)]
[InlineData(SectorMode.MODE2_FORM1, 24)]
[InlineData(SectorMode.MODE2_FORM2, 24)]
public void GetUserDataStart(SectorMode mode, long expected)
{
long actual = mode.GetUserDataStart();
Assert.Equal(expected, actual);
}
// TODO: Figure out how to add UserDataStream tests
}
}

View File

@@ -0,0 +1,17 @@
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class CFBExtensionsTests
{
[Theory]
[InlineData(null, null)]
[InlineData(new byte[0], "")]
// TODO: Create more artifical tests
public void DecodeStreamNameTest(byte[]? bytes, string? expected)
{
string? actual = bytes.DecodeStreamName();
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,138 @@
using SabreTools.Data.Models.ISO9660;
using SabreTools.Numerics;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class ISO9660ExtensionsTests
{
[Fact]
public void GetLogicalBlockSize_Generic_SectorLength()
{
VolumeDescriptor vd = new GenericVolumeDescriptor();
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(sectorLength, actual);
}
[Fact]
public void GetLogicalBlockSize_PVD_ValidBothEndian_ValidBlockSize_BlockSize()
{
VolumeDescriptor vd = new PrimaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(2048, 2048)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(2048, actual);
}
[Fact]
public void GetLogicalBlockSize_PVD_ValidBothEndian_InvalidBlockSize_SectorLength()
{
VolumeDescriptor vd = new PrimaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(2352, 2352)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(4096, actual);
}
[Fact]
public void GetLogicalBlockSize_PVD_InvalidBothEndian_ValidLE_LEValue()
{
VolumeDescriptor vd = new PrimaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(2048, -1)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(2048, actual);
}
[Fact]
public void GetLogicalBlockSize_PVD_InvalidBothEndian_ValidBE_BEValue()
{
VolumeDescriptor vd = new PrimaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(-1, 2048)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(2048, actual);
}
[Fact]
public void GetLogicalBlockSize_PVD_InvalidBothEndian_BothInvalid_SectorLength()
{
VolumeDescriptor vd = new PrimaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(-1, -2)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(sectorLength, actual);
}
[Fact]
public void GetLogicalBlockSize_SVD_ValidBothEndian_ValidBlockSize_BlockSize()
{
VolumeDescriptor vd = new SupplementaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(2048, 2048)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(2048, actual);
}
[Fact]
public void GetLogicalBlockSize_SVD_ValidBothEndian_InvalidBlockSize_SectorLength()
{
VolumeDescriptor vd = new SupplementaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(2352, 2352)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(4096, actual);
}
[Fact]
public void GetLogicalBlockSize_SVD_InvalidBothEndian_ValidLE_LEValue()
{
VolumeDescriptor vd = new SupplementaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(2048, -1)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(2048, actual);
}
[Fact]
public void GetLogicalBlockSize_SVD_InvalidBothEndian_ValidBE_BEValue()
{
VolumeDescriptor vd = new SupplementaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(-1, 2048)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(2048, actual);
}
[Fact]
public void GetLogicalBlockSize_SVD_InvalidBothEndian_BothInvalid_SectorLength()
{
VolumeDescriptor vd = new SupplementaryVolumeDescriptor
{
LogicalBlockSize = new BothInt16(-1, -2)
};
short sectorLength = 4096;
short actual = vd.GetLogicalBlockSize(sectorLength);
Assert.Equal(sectorLength, actual);
}
}
}

View File

@@ -0,0 +1,156 @@
using SabreTools.Data.Models.InstallShieldCabinet;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class InstallShieldCabinetExtensionsTests
{
#region IsCompressed
[Fact]
public void IsCompressed_Null_True()
{
FileDescriptor? fd = null;
bool actual = fd.IsCompressed();
Assert.True(actual);
}
[Fact]
public void IsCompressed_Compressed_True()
{
FileDescriptor? fd = new FileDescriptor { Flags = FileFlags.FILE_COMPRESSED };
bool actual = fd.IsCompressed();
Assert.True(actual);
}
[Fact]
public void IsCompressed_NotCompressed_False()
{
FileDescriptor? fd = new FileDescriptor { Flags = 0 };
bool actual = fd.IsCompressed();
Assert.False(actual);
}
#endregion
#region IsInvalid
[Fact]
public void IsInvalid_Null_True()
{
FileDescriptor? fd = null;
bool actual = fd.IsInvalid();
Assert.True(actual);
}
[Fact]
public void IsInvalid_Invalid_True()
{
FileDescriptor? fd = new FileDescriptor { Flags = FileFlags.FILE_INVALID };
bool actual = fd.IsInvalid();
Assert.True(actual);
}
[Fact]
public void IsInvalid_Valid_False()
{
FileDescriptor? fd = new FileDescriptor { Flags = 0 };
bool actual = fd.IsInvalid();
Assert.False(actual);
}
#endregion
#region IsObfuscated
[Fact]
public void IsObfuscated_Null_False()
{
FileDescriptor? fd = null;
bool actual = fd.IsObfuscated();
Assert.False(actual);
}
[Fact]
public void IsObfuscated_Obfuscated_True()
{
FileDescriptor? fd = new FileDescriptor { Flags = FileFlags.FILE_OBFUSCATED };
bool actual = fd.IsObfuscated();
Assert.True(actual);
}
[Fact]
public void IsObfuscated_NotObfuscated_False()
{
FileDescriptor? fd = new FileDescriptor { Flags = 0 };
bool actual = fd.IsObfuscated();
Assert.False(actual);
}
#endregion
#region IsSplit
[Fact]
public void IsSplit_Null_False()
{
FileDescriptor? fd = null;
bool actual = fd.IsSplit();
Assert.False(actual);
}
[Fact]
public void IsSplit_Split_True()
{
FileDescriptor? fd = new FileDescriptor { Flags = FileFlags.FILE_SPLIT };
bool actual = fd.IsSplit();
Assert.True(actual);
}
[Fact]
public void IsSplit_NotSplitFalse()
{
FileDescriptor? fd = new FileDescriptor { Flags = 0 };
bool actual = fd.IsSplit();
Assert.False(actual);
}
#endregion
#region GetMajorVersion
[Fact]
public void GetMajorVersion_NullCabinet_NegativeOne()
{
Cabinet? cabinet = null;
int actual = cabinet.GetMajorVersion();
Assert.Equal(-1, actual);
}
[Fact]
public void GetMajorVersion_NullHeader_NegativeOne()
{
CommonHeader? cabinet = null;
int actual = cabinet.GetMajorVersion();
Assert.Equal(-1, actual);
}
[Theory]
[InlineData(0x00000000, 0)]
[InlineData(0x00000004, 4)]
[InlineData(0x01000000, 0)]
[InlineData(0x01004000, 4)]
[InlineData(0x02000000, 0)]
[InlineData(0x02000190, 4)]
[InlineData(0x04000000, 0)]
[InlineData(0x04000190, 4)]
public void GetMajorVersionTest(uint version, int expected)
{
CommonHeader? cabinet = new CommonHeader { Version = version };
int actual = cabinet.GetMajorVersion();
Assert.Equal(expected, actual);
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
using SabreTools.Data.Models.NES;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class NESCartExtensionsTests
{
[Theory]
[InlineData(ConsoleType.StandardSystem, "Nintendo Entertainment System/Family Computer")]
[InlineData(ConsoleType.VSUnisystem, "VS Unisystem")]
[InlineData(ConsoleType.PlayChoice10, "PlayChoice-10 (8 KB of Hint Screen data stored after CHR data)")]
[InlineData(ConsoleType.ExtendedConsoleType, "Extended Console Type")]
public void FromConsoleTypeTest(ConsoleType type, string expected)
{
string actual = type.FromConsoleType();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(CPUPPUTiming.RP2C02, "RP2C02 (NTSC NES)")]
[InlineData(CPUPPUTiming.RP2C07, "RP2C07 (Licensed PAL NES)")]
[InlineData(CPUPPUTiming.MultipleRegion, "Multiple-region")]
[InlineData(CPUPPUTiming.UA6538, "UA6538 (Dendy)")]
public void FromCPUPPUTimingTest(CPUPPUTiming timing, string expected)
{
string actual = timing.FromCPUPPUTiming();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(DefaultExpansionDevice.Unspecified, "Unspecified")]
[InlineData(DefaultExpansionDevice.StandardControllers, "Standard NES/Famicom controllers")]
[InlineData(DefaultExpansionDevice.NESFourScore, "NES Four Score/Satellite with two additional standard controllers")]
[InlineData(DefaultExpansionDevice.FamicomFourPlayersAdapter, "Famicom Four Players Adapter with two additional standard controllers using the 'simple' protocol")]
[InlineData(DefaultExpansionDevice.VsSystem4016, "Vs. System (1P via $4016)")]
[InlineData(DefaultExpansionDevice.VsSystem4017, "Vs. System (1P via $4017)")]
[InlineData(DefaultExpansionDevice.Reserved06, "Reserved (0x06)")]
[InlineData(DefaultExpansionDevice.VsZapper, "Vs. Zapper")]
[InlineData(DefaultExpansionDevice.Zapper4017, "Zapper ($4017)")]
[InlineData(DefaultExpansionDevice.TwoZappers, "Two Zappers")]
[InlineData(DefaultExpansionDevice.BandaiHyperShotLightgun, "Bandai Hyper Shot Lightgun")]
[InlineData(DefaultExpansionDevice.PowerPadSideA, "Power Pad Side A")]
[InlineData(DefaultExpansionDevice.PowerPadSideB, "Power Pad Side B")]
[InlineData(DefaultExpansionDevice.FamilyTrainerSideA, "Family Trainer Side A")]
[InlineData(DefaultExpansionDevice.FamilyTrainerSideB, "Family Trainer Side B")]
[InlineData(DefaultExpansionDevice.ArkanoidVausControllerNES, "Arkanoid Vaus Controller (NES)")]
[InlineData(DefaultExpansionDevice.ArkanoidVausControllerFamicom, "Arkanoid Vaus Controller (Famicom)")]
[InlineData(DefaultExpansionDevice.TwoVausControllersPlusFamicomDataRecorder, "Two Vaus Controllers plus Famicom Data Recorder")]
[InlineData(DefaultExpansionDevice.KonamiHyperShotController, "Konami Hyper Shot Controller")]
[InlineData(DefaultExpansionDevice.CoconutsPachinkoController, "Coconuts Pachinko Controller")]
[InlineData(DefaultExpansionDevice.ExcitingBoxingPunchingBag, "Exciting Boxing Punching Bag (Blowup Doll)")]
[InlineData(DefaultExpansionDevice.JissenMahjongController, "Jissen Mahjong Controller")]
[InlineData(DefaultExpansionDevice.YonezawaPartyTap, "米澤 (Yonezawa) Party Tap")]
[InlineData(DefaultExpansionDevice.OekaKidsTablet, "Oeka Kids Tablet")]
[InlineData(DefaultExpansionDevice.SunsoftBarcodeBattler, "Sunsoft Barcode Battler")]
[InlineData(DefaultExpansionDevice.MiraclePianoKeyboard, "Miracle Piano Keyboard")]
[InlineData(DefaultExpansionDevice.PokkunMoguraaTapTapMat, "Pokkun Moguraa Tap-tap Mat (Whack-a-Mole Mat and Mallet)")]
[InlineData(DefaultExpansionDevice.TopRider, "Top Rider (Inflatable Bicycle)")]
[InlineData(DefaultExpansionDevice.DoubleFisted, "Double-Fisted (Requires or allows use of two controllers by one player)")]
[InlineData(DefaultExpansionDevice.Famicom3DSystem, "Famicom 3D System")]
[InlineData(DefaultExpansionDevice.DoremikkoKeyboard, "Doremikko Keyboard")]
[InlineData(DefaultExpansionDevice.ROBGyromite, "R.O.B. Gyromite")]
[InlineData(DefaultExpansionDevice.FamicomDataRecorder, "Famicom Data Recorder ('silent' keyboard)")]
[InlineData(DefaultExpansionDevice.ASCIITurboFile, "ASCII Turbo File")]
[InlineData(DefaultExpansionDevice.IGSStorageBattleBox, "IGS Storage Battle Box")]
[InlineData(DefaultExpansionDevice.FamilyBASICKeyboardPlusFamicomDataRecorder, "Family BASIC Keyboard plus Famicom Data Recorder")]
[InlineData(DefaultExpansionDevice.DongdaPECKeyboard, "东达 (Dōngdá) PEC Keyboard")]
[InlineData(DefaultExpansionDevice.BitCorpBit79Keyboard, "普澤 (Pǔzé, a.k.a. Bit Corp.) Bit-79 Keyboard")]
[InlineData(DefaultExpansionDevice.SuborKeyboard, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusMacroWinnersMouse, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Macro Winners Mouse")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusSuborMouse4016, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Subor Mouse via $4016")]
[InlineData(DefaultExpansionDevice.SNESMouse4016, "SNES Mouse ($4016)")]
[InlineData(DefaultExpansionDevice.Multicart, "Multicart")]
[InlineData(DefaultExpansionDevice.TwoSNESControllers, "Two SNES controllers replacing the two standard NES controllers")]
[InlineData(DefaultExpansionDevice.RacerMateBicycle, "RacerMate Bicycle")]
[InlineData(DefaultExpansionDevice.UForce, "U-Force")]
[InlineData(DefaultExpansionDevice.ROBStackUp, "R.O.B. Stack-Up")]
[InlineData(DefaultExpansionDevice.CityPatrolmanLightgun, "City Patrolman Lightgun")]
[InlineData(DefaultExpansionDevice.SharpC1CassetteInterface, "Sharp C1 Cassette Interface")]
[InlineData(DefaultExpansionDevice.StandardControllerWithSwappedInputs, "Standard Controller with swapped Left-Right/Up-Down/B-A")]
[InlineData(DefaultExpansionDevice.ExcaliburSudokuPad, "Excalibur Sudoku Pad")]
[InlineData(DefaultExpansionDevice.ABLPinball, "ABL Pinball")]
[InlineData(DefaultExpansionDevice.GoldenNuggetCasinoExtraButtons, "Golden Nugget Casino extra buttons")]
[InlineData(DefaultExpansionDevice.KedaKeyboard, "科达 (Kēdá) Keyboard")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusSuborMouse4017, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Subor Mouse via $4017")]
[InlineData(DefaultExpansionDevice.PortTestController, "Port test controller")]
[InlineData(DefaultExpansionDevice.BandaiMultiGamePlayerGamepad, "Bandai Multi Game Player Gamepad buttons")]
[InlineData(DefaultExpansionDevice.VenomTVDanceMat, "Venom TV Dance Mat")]
[InlineData(DefaultExpansionDevice.LGTVRemoteControl, "LG TV Remote Control")]
[InlineData(DefaultExpansionDevice.FamicomNetworkController, "Famicom Network Controller")]
[InlineData(DefaultExpansionDevice.KingFishingController, "King Fishing Controller")]
[InlineData(DefaultExpansionDevice.CroakyKaraokeController, "Croaky Karaoke Controller")]
[InlineData(DefaultExpansionDevice.KingwonKeyboard, "科王 (Kēwáng, a.k.a. Kingwon) Keyboard")]
[InlineData(DefaultExpansionDevice.ZechengKeyboard, "泽诚 (Zéchéng) Keyboard")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusL90RotatedPS2Mouse4017, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus L90-rotated PS/2 mouse in $4017")]
[InlineData(DefaultExpansionDevice.PS2KeyboardInUM6578PS2PortPS2Mouse4017, "PS/2 Keyboard in UM6578 PS/2 port, PS/2 Mouse via $4017")]
[InlineData(DefaultExpansionDevice.PS2MouseInUM6578PS2Port, "PS/2 Mouse in UM6578 PS/2 port")]
[InlineData(DefaultExpansionDevice.YuxingMouse4016, "裕兴 (Yùxìng) Mouse via $4016")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusYuxingMouse4016, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus 裕兴 (Yùxìng) Mouse mouse in $4016")]
[InlineData(DefaultExpansionDevice.GigggleTVPump, "Gigggle TV Pump")]
[InlineData(DefaultExpansionDevice.BBKKeyboardPlusR90RotatedPS2Mouse4017, "步步高 (Bùbùgāo, a.k.a. BBK) Keyboard plus R90-rotated PS/2 mouse in $4017")]
[InlineData(DefaultExpansionDevice.MagicalCooking, "Magical Cooking")]
[InlineData(DefaultExpansionDevice.SNESMouse4017, "SNES Mouse ($4017)")]
[InlineData(DefaultExpansionDevice.Zapper4016, "Zapper ($4016)")]
[InlineData(DefaultExpansionDevice.ArkanoidVausControllerPrototype, "Arkanoid Vaus Controller (Prototype)")]
[InlineData(DefaultExpansionDevice.TVMahjongGameController, "TV 麻雀 Game (TV Mahjong Game) Controller")]
[InlineData(DefaultExpansionDevice.MahjongGekitouDensetsuController, "麻雀激闘伝説 (Mahjong Gekitou Densetsu) Controller")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusXInvertedPS2Mouse4017, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus X-inverted PS/2 mouse in $4017")]
[InlineData(DefaultExpansionDevice.IBMPCXTKeyboard, "IBM PC/XT Keyboard")]
[InlineData(DefaultExpansionDevice.SuborKeyboardPlusMegaBookMouse, "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Mega Book Mouse")]
public void FromDefaultExpansionDeviceTest(DefaultExpansionDevice device, string expected)
{
string actual = device.FromDefaultExpansionDevice();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(ExtendedConsoleType.RegularSystem, "Regular NES/Famicom/Dendy")]
[InlineData(ExtendedConsoleType.NintendoVsSystem, "Nintendo Vs. System")]
[InlineData(ExtendedConsoleType.Playchoice10, "Playchoice 10")]
[InlineData(ExtendedConsoleType.RegularFamicloneDecimalMode, "Regular Famiclone, but with CPU that supports Decimal Mode")]
[InlineData(ExtendedConsoleType.RegularNESWithEPSM, "Regular NES/Famicom with EPSM module or plug-through cartridge")]
[InlineData(ExtendedConsoleType.VRTechnologyVT01, "V.R. Technology VT01 with red/cyan STN palette")]
[InlineData(ExtendedConsoleType.VRTechnologyVT02, "V.R. Technology VT02")]
[InlineData(ExtendedConsoleType.VRTechnologyVT03, "V.R. Technology VT03")]
[InlineData(ExtendedConsoleType.VRTechnologyVT09, "V.R. Technology VT09")]
[InlineData(ExtendedConsoleType.VRTechnologyVT32, "V.R. Technology VT32")]
[InlineData(ExtendedConsoleType.VRTechnologyVT369, "V.R. Technology VT369")]
[InlineData(ExtendedConsoleType.UMCUM6578, "UMC UM6578")]
[InlineData(ExtendedConsoleType.FamicomNetworkSystem, "Famicom Network System")]
[InlineData(ExtendedConsoleType.ReservedD, "Reserved (0x0D)")]
[InlineData(ExtendedConsoleType.ReservedE, "Reserved (0x0E)")]
[InlineData(ExtendedConsoleType.ReservedF, "Reserved (0x0F)")]
public void FromExtendedConsoleTypeTest(ExtendedConsoleType type, string expected)
{
string actual = type.FromExtendedConsoleType();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(NametableArrangement.Vertical, "Vertical")]
[InlineData(NametableArrangement.Horizontal, "Horizontal")]
public void FromNametableArrangementTest(NametableArrangement arrangement, string expected)
{
string actual = arrangement.FromNametableArrangement();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(TVSystem.NTSC, "NTSC")]
[InlineData(TVSystem.PAL, "PAL")]
public void FromTVSystemTest(TVSystem system, string expected)
{
string actual = system.FromTVSystem();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(TVSystemExtended.NTSC, "NTSC")]
[InlineData(TVSystemExtended.DualCompatible1, "Dual-compatible (0x01)")]
[InlineData(TVSystemExtended.PAL, "PAL")]
[InlineData(TVSystemExtended.DualCompatible3, "Dual-compatible (0x03)")]
public void FromTVSystemExtendedTest(TVSystemExtended system, string expected)
{
string actual = system.FromTVSystemExtended();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(VsHardwareType.VsUnisystem, "Vs. Unisystem (normal)")]
[InlineData(VsHardwareType.VsUnisystemRBIBaseballProtection, "Vs. Unisystem (RBI Baseball protection)")]
[InlineData(VsHardwareType.VsUnisystemTKOBoxingProtection, "Vs. Unisystem (TKO Boxing protection)")]
[InlineData(VsHardwareType.VsUnisystemSuperXeviousProtection, "Vs. Unisystem (Super Xevious protection)")]
[InlineData(VsHardwareType.VsUnisystemVsIceClimberJapanProtection, "Vs. Unisystem (Vs. Ice Climber Japan protection)")]
[InlineData(VsHardwareType.VsDualSystem, "Vs. Dual System (normal)")]
[InlineData(VsHardwareType.VsDualSystemRaidOnBungelingBayProtection, "Vs. Dual System (Raid on Bungeling Bay protection)")]
public void FromVsHardwareTypeTest(VsHardwareType type, string expected)
{
string actual = type.FromVsHardwareType();
Assert.Equal(expected, actual);
}
[Theory]
[InlineData(VsSystemType.AnyRP2C03RC2C03Variant, "Any RP2C03/RC2C03 variant")]
[InlineData(VsSystemType.Reserved1, "Reserved (0x01)")]
[InlineData(VsSystemType.RP2C040001, "RP2C04-0001")]
[InlineData(VsSystemType.RP2C040002, "RP2C04-0002")]
[InlineData(VsSystemType.RP2C040003, "RP2C04-0003")]
[InlineData(VsSystemType.RP2C040004, "RP2C04-0004")]
[InlineData(VsSystemType.Reserved6, "Reserved (0x06)")]
[InlineData(VsSystemType.Reserved7, "Reserved (0x07)")]
[InlineData(VsSystemType.RC2C0501, "RC2C05-01 (signature unknown)")]
[InlineData(VsSystemType.RC2C0502, "RC2C05-02 ($2002 AND $3F =$3D)")]
[InlineData(VsSystemType.RC2C0503, "RC2C05-03 ($2002 AND $1F =$1C)")]
[InlineData(VsSystemType.RC2C0504, "RC2C05-04 ($2002 AND $1F =$1B)")]
[InlineData(VsSystemType.ReservedC, "Reserved (0x0C)")]
[InlineData(VsSystemType.ReservedD, "Reserved (0x0D)")]
[InlineData(VsSystemType.ReservedE, "Reserved (0x0E)")]
[InlineData(VsSystemType.ReservedF, "Reserved (0x0F)")]
public void FromVsSystemTypeTest(VsSystemType type, string expected)
{
string actual = type.FromVsSystemType();
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,61 @@
using SabreTools.Data.Models.NewExecutable;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class NewExecutableExtensionsTests
{
#region IsIntegerType
[Fact]
public void IsIntegerType_RTIE_HighBitSet_True()
{
var entry = new ResourceTypeInformationEntry { TypeID = 0xFFFF };
bool actual = entry.IsIntegerType();
Assert.True(actual);
}
[Fact]
public void IsIntegerType_RTIE_HighBitClear_False()
{
var entry = new ResourceTypeInformationEntry { TypeID = 0x0000 };
bool actual = entry.IsIntegerType();
Assert.False(actual);
}
[Fact]
public void IsIntegerType_RTRE_HighBitSet_True()
{
var entry = new ResourceTypeResourceEntry { ResourceID = 0xFFFF };
bool actual = entry.IsIntegerType();
Assert.True(actual);
}
[Fact]
public void IsIntegerType_RTRE_HighBitClear_False()
{
var entry = new ResourceTypeResourceEntry { ResourceID = 0x0000 };
bool actual = entry.IsIntegerType();
Assert.False(actual);
}
#endregion
#region GetEntryType
[Theory]
[InlineData(0x00, SegmentEntryType.Unused)]
[InlineData(0x01, SegmentEntryType.FixedSegment)]
[InlineData(0xAA, SegmentEntryType.FixedSegment)]
[InlineData(0xFE, SegmentEntryType.FixedSegment)]
[InlineData(0xFF, SegmentEntryType.MoveableSegment)]
public void GetEntryTypeTest(byte segmentIndicator, SegmentEntryType expected)
{
var entry = new EntryTableBundle { SegmentIndicator = segmentIndicator };
SegmentEntryType actual = entry.GetEntryType();
Assert.Equal(expected, actual);
}
#endregion
}
}

View File

@@ -0,0 +1,129 @@
using SabreTools.Data.Models.NintendoDisc;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class NintendoDiscExtensionsTests
{
#region GetPlatform
[Fact]
public void GetPlatform_Object_WiiMagic_Wii()
{
var header = new DiscHeader { WiiMagic = Constants.WiiMagicWord };
Platform actual = header.GetPlatform();
Assert.Equal(Platform.Wii, actual);
}
[Fact]
public void GetPlatform_Object_GCMagic_GC()
{
var header = new DiscHeader { GCMagic = Constants.GCMagicWord };
Platform actual = header.GetPlatform();
Assert.Equal(Platform.GameCube, actual);
}
[Fact]
public void GetPlatform_Object_ValidGameID_GC()
{
var header = new DiscHeader { GameId = "GABC01" };
Platform actual = header.GetPlatform();
Assert.Equal(Platform.GameCube, actual);
}
[Fact]
public void GetPlatform_Object_InvalidGameID_Unknown()
{
var header = new DiscHeader { GameId = "XABC01" };
Platform actual = header.GetPlatform();
Assert.Equal(Platform.Unknown, actual);
}
[Fact]
public void GetPlatform_Object_DefaultHeader_Unknown()
{
var header = new DiscHeader();
Platform actual = header.GetPlatform();
Assert.Equal(Platform.Unknown, actual);
}
[Fact]
public void GetPlatform_Bytes_WiiMagic_Wii()
{
byte[] header =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00-0x07
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08-0x0F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10-0x17
0x5D, 0x1C, 0x9E, 0xA3, 0x00, 0x00, 0x00, 0x00, // 0x18-0x1F
];
Platform actual = header.GetPlatform();
Assert.Equal(Platform.Wii, actual);
}
[Fact]
public void GetPlatform_Bytes_GCMagic_GC()
{
byte[] header =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00-0x07
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08-0x0F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10-0x17
0x00, 0x00, 0x00, 0x00, 0xC2, 0x33, 0x9F, 0x3D, // 0x18-0x1F
];
Platform actual = header.GetPlatform();
Assert.Equal(Platform.GameCube, actual);
}
[Fact]
public void GetPlatform_Bytes_ValidGameID_GC()
{
byte[] header = [(byte)'G', (byte)'A', (byte)'B', (byte)'C'];
Platform actual = header.GetPlatform();
Assert.Equal(Platform.GameCube, actual);
}
[Fact]
public void GetPlatform_Bytes_InvalidGameID_Unknown()
{
byte[] header = [(byte)'G', (byte)'A', (byte)'B', 0x00];
Platform actual = header.GetPlatform();
Assert.Equal(Platform.Unknown, actual);
}
[Fact]
public void GetPlatform_Bytes_DefaultHeader_Unknown()
{
byte[] header = [];
Platform actual = header.GetPlatform();
Assert.Equal(Platform.Unknown, actual);
}
#endregion
#region IsGameCubeTitleType
[Theory]
[InlineData('\0', false)]
[InlineData('a', false)]
[InlineData('A', false)]
[InlineData('d', false)]
[InlineData('D', true)]
[InlineData('g', false)]
[InlineData('G', true)]
[InlineData('r', false)]
[InlineData('R', true)]
public void IsGameCubeTitleTypeTest(char c, bool expected)
{
bool actual = c.IsGameCubeTitleType();
Assert.Equal(expected, actual);
}
#endregion
}
}

View File

@@ -0,0 +1,26 @@
using SabreTools.Data.Models.OperaFS;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class OperaFSExtensionsTests
{
[Fact]
public void DirectoryDescriptor_EqualsExactly_Empty()
{
var dir1 = new DirectoryDescriptor();
var dir2 = new DirectoryDescriptor();
bool actual = dir1.EqualsExactly(dir2);
Assert.True(actual);
}
[Fact]
public void DirectoryRecord_EqualsExactly_Empty()
{
var dr1 = new DirectoryRecord();
var dr2 = new DirectoryRecord();
bool actual = dr1.EqualsExactly(dr2);
Assert.True(actual);
}
}
}

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Data.Extensions\SabreTools.Data.Extensions.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,213 @@
using System;
using SabreTools.Data.Models.ASN1;
using Xunit;
#pragma warning disable IDE0230 // Use UTF-8 string literal
namespace SabreTools.Data.Extensions.Test
{
public class TypeLengthValueTests
{
#region Formatting
[Fact]
public void Format_EOC()
{
string expected = "Type: V_ASN1_EOC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_EOC, Length = 0, Value = null };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ZeroLength()
{
string expected = "Type: V_ASN1_NULL, Length: 0";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_NULL, Length = 0, Value = null };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_InvalidConstructed()
{
string expected = "Type: V_ASN1_OBJECT, V_ASN1_CONSTRUCTED, Length: 1, Value: [INVALID DATA TYPE]";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_OBJECT | ASN1Type.V_ASN1_CONSTRUCTED, Length = 1, Value = false };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidConstructed()
{
string expected = "Type: V_ASN1_OBJECT, V_ASN1_CONSTRUCTED, Length: 3, Value:\n Type: V_ASN1_BOOLEAN, Length: 1, Value: True";
var boolTlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BOOLEAN, Length = 1, Value = new byte[] { 0x01 } };
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_OBJECT | ASN1Type.V_ASN1_CONSTRUCTED, Length = 3, Value = new TypeLengthValue[] { boolTlv } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_InvalidDataType()
{
string expected = "Type: V_ASN1_OBJECT, Length: 1, Value: [INVALID DATA TYPE]";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_OBJECT, Length = 1, Value = false };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_InvalidLength()
{
string expected = "Type: V_ASN1_NULL, Length: 1, Value: [NO DATA]";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_NULL, Length = 1, Value = Array.Empty<byte>() };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_InvalidBooleanLength()
{
string expected = "Type: V_ASN1_BOOLEAN, Length: 2 [Expected length of 1], Value: True";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BOOLEAN, Length = 2, Value = new byte[] { 0x01 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_InvalidBooleanArrayLength()
{
string expected = "Type: V_ASN1_BOOLEAN, Length: 1 [Expected value length of 1], Value: True";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BOOLEAN, Length = 1, Value = new byte[] { 0x01, 0x00 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidBoolean()
{
string expected = "Type: V_ASN1_BOOLEAN, Length: 1, Value: True";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BOOLEAN, Length = 1, Value = new byte[] { 0x01 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidInteger()
{
string expected = "Type: V_ASN1_INTEGER, Length: 1, Value: 1";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_INTEGER, Length = 1, Value = new byte[] { 0x01 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidBitString_NoBits()
{
string expected = "Type: V_ASN1_BIT_STRING, Length: 1, Value with 0 unused bits";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BIT_STRING, Length = 1, Value = new byte[] { 0x00 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidBitString_Bits()
{
string expected = "Type: V_ASN1_BIT_STRING, Length: 1, Value with 1 unused bits: 01";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BIT_STRING, Length = 1, Value = new byte[] { 0x01, 0x01 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidOctetString()
{
string expected = "Type: V_ASN1_OCTET_STRING, Length: 1, Value: 01";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_OCTET_STRING, Length = 1, Value = new byte[] { 0x01 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidObject()
{
string expected = "Type: V_ASN1_OBJECT, Length: 3, Value: 0.1.2.3 (/ITU-T/1/2/3)";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_OBJECT, Length = 3, Value = new byte[] { 0x01, 0x02, 0x03 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidUTF8String()
{
string expected = "Type: V_ASN1_UTF8STRING, Length: 3, Value: ABC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_UTF8STRING, Length = 3, Value = new byte[] { 0x41, 0x42, 0x43 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidPrintableString()
{
string expected = "Type: V_ASN1_PRINTABLESTRING, Length: 3, Value: ABC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_PRINTABLESTRING, Length = 3, Value = new byte[] { 0x41, 0x42, 0x43 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidTeletexString()
{
string expected = "Type: V_ASN1_TELETEXSTRING, Length: 3, Value: ABC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_TELETEXSTRING, Length = 3, Value = new byte[] { 0x41, 0x42, 0x43 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidIA5String()
{
string expected = "Type: V_ASN1_IA5STRING, Length: 3, Value: ABC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_IA5STRING, Length = 3, Value = new byte[] { 0x41, 0x42, 0x43 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_InvalidUTCTime()
{
string expected = "Type: V_ASN1_UTCTIME, Length: 3, Value: ABC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_UTCTIME, Length = 3, Value = new byte[] { 0x41, 0x42, 0x43 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidUTCTime()
{
string expected = "Type: V_ASN1_UTCTIME, Length: 3, Value: 1980-01-01 00:00:00";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_UTCTIME, Length = 3, Value = new byte[] { 0x31, 0x39, 0x38, 0x30, 0x2D, 0x30, 0x31, 0x2D, 0x30, 0x31, 0x20, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidBmpString()
{
string expected = "Type: V_ASN1_BMPSTRING, Length: 6, Value: ABC";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_BMPSTRING, Length = 6, Value = new byte[] { 0x41, 0x00, 0x42, 0x00, 0x43, 0x00 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
[Fact]
public void Format_ValidUnformatted()
{
string expected = "Type: V_ASN1_OBJECT_DESCRIPTOR, Length: 1, Value: 01";
var tlv = new TypeLengthValue { Type = ASN1Type.V_ASN1_OBJECT_DESCRIPTOR, Length = 1, Value = new byte[] { 0x01 } };
string actual = tlv.Format();
Assert.Equal(expected, actual);
}
#endregion
}
}

View File

@@ -0,0 +1,59 @@
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class WiseScriptExtensionsTests
{
[Theory]
// Defined functions
[InlineData("f0", "Add Directory to PATH")]
[InlineData("f1", "Add to AUTOEXEC.BAT")]
[InlineData("f2", "Add to CONFIG.SYS")]
[InlineData("f3", "Add to SYSTEM.INI")]
[InlineData("f8", "Read INI Value")]
[InlineData("f9", "Get Registry Key Value")]
[InlineData("f10", "Register Font")]
[InlineData("f11", "Win32 System Directory")]
[InlineData("f12", "Check Configuration")]
[InlineData("f13", "Search for File")]
[InlineData("f15", "Read/Write Binary File")]
[InlineData("f16", "Set Variable")]
[InlineData("f17", "Get Environment Variable")]
[InlineData("f19", "Check if File/Dir Exists")]
[InlineData("f20", "Set File Attributes")]
[InlineData("f21", "Set Files/Buffers")]
[InlineData("f22", "Find File in Path")]
[InlineData("f23", "Check Disk Space")]
[InlineData("f25", "Insert Line Into Text File")]
[InlineData("f27", "Parse String")]
[InlineData("f28", "Exit Installation")]
[InlineData("f29", "Self-Register OCXs/DLLs")]
[InlineData("f30", "Install DirectX Components")]
[InlineData("f31", "Wizard Block")]
[InlineData("f33", "Read/Update Text File")]
[InlineData("f34", "Post to HTTP Server")]
[InlineData("f35", "Prompt for Filename")]
[InlineData("f36", "Start/Stop Service")]
[InlineData("f38", "Check HTTP Connection")]
// Undefined functions
[InlineData("f4", "UNDEFINED f4")]
[InlineData("f5", "UNDEFINED f5")]
[InlineData("f6", "UNDEFINED f6")]
[InlineData("f7", "UNDEFINED f7")]
[InlineData("f14", "UNDEFINED f14")]
[InlineData("f18", "UNDEFINED f18")]
[InlineData("f24", "UNDEFINED f24")]
[InlineData("f26", "UNDEFINED f26")]
[InlineData("f32", "UNDEFINED f32")]
[InlineData("f37", "UNDEFINED f37")]
// External DLL
[InlineData(null, null)]
[InlineData("f99", "UNDEFINED f99")]
[InlineData("func", "External: func")]
public void FromWiseFunctionIdTest(string? functionId, string? expected)
{
string? actual = functionId.FromWiseFunctionId();
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,20 @@
using System.Linq;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class XZExtensionsTests
{
[Fact]
public void VariableLengthIntegerTest()
{
ulong expected = 123456789;
byte[] encoded = expected.EncodeVariableLength();
Assert.True(encoded.SequenceEqual<byte>([0x95, 0x9A, 0xEF, 0x3A]));
ulong actual = encoded.DecodeVariableLength(maxSize: 16, out int length);
Assert.Equal(expected, actual);
Assert.Equal(4, length);
}
}
}

View File

@@ -0,0 +1,17 @@
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class XboxExecutableExtensionsTests
{
[Theory]
[InlineData(0x00000000, "0000-000")]
[InlineData(0x4142000F, "AB-015")]
[InlineData(0x3132F000, "12-61440")]
public void ToFormattedXBETitleIDTest(uint value, string expected)
{
string actual = value.ToFormattedXBETitleID();
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,18 @@
using SabreTools.Data.Models.ZArchive;
using Xunit;
namespace SabreTools.Data.Extensions.Test
{
public class ZArchiveExtensionsTests
{
[Fact]
public void GetName_Null()
{
var de = new DirectoryEntry();
NameTable nt = new NameTable();
string? expected = null;
string? actual = de.GetName(nt);
Assert.Equal(expected, actual);
}
}
}

View File

@@ -0,0 +1,327 @@
using System.Collections.Generic;
using SabreTools.Data.Models.Atari7800;
namespace SabreTools.Data.Extensions
{
public static class Atari7800CartExtensions
{
/// <summary>
/// Convert a <see cref="AudioDevice"/> value to string
/// </summary>
public static string FromAudioDevice(this AudioDevice audio)
{
string[] devices = new string[4];
byte pokey = (byte)((byte)audio & 0x07);
devices[0] = pokey switch
{
0 => "POKEY - none",
1 => "POKEY - @440",
2 => "POKEY - @450",
3 => "POKEY - @450+@440",
4 => "POKEY - @800",
5 => "POKEY - @4000",
_ => $"Unknown {pokey}",
};
byte ym2151 = (byte)(((byte)audio >> 3) & 0x01);
devices[1] = ym2151 switch
{
0 => "No YM2151 @460",
1 => "YM2151 @460",
_ => $"Unknown {ym2151}",
};
byte covox = (byte)(((byte)audio >> 4) & 0x01);
devices[2] = covox switch
{
0 => "No COVOX @430",
1 => "COVOX @430",
_ => $"Unknown {covox}",
};
byte adpcm = (byte)(((byte)audio >> 5) & 0x01);
devices[3] = adpcm switch
{
0 => "No ADPCM Audio Stream @420",
1 => "ADPCM Audio Stream @420",
_ => $"Unknown {adpcm}",
};
return string.Join(", ", [.. devices]);
}
/// <summary>
/// Convert a <see cref="CartType"/> value to string
/// </summary>
public static string FromCartType(this CartType type)
{
List<string> types = [];
#if NET20 || NET35
if ((type & CartType.PokeyAt4000) != 0)
#else
if (type.HasFlag(CartType.PokeyAt4000))
#endif
types.Add("pokey at $4000");
#if NET20 || NET35
if ((type & CartType.SupergameBankSwitched) != 0)
#else
if (type.HasFlag(CartType.SupergameBankSwitched))
#endif
types.Add("supergame bank switched");
#if NET20 || NET35
if ((type & CartType.SupergameRamAt4000) != 0)
#else
if (type.HasFlag(CartType.SupergameRamAt4000))
#endif
types.Add("supergame ram at $4000");
#if NET20 || NET35
if ((type & CartType.RomAt4000) != 0)
#else
if (type.HasFlag(CartType.RomAt4000))
#endif
types.Add("rom at $4000");
#if NET20 || NET35
if ((type & CartType.Bank6At4000) != 0)
#else
if (type.HasFlag(CartType.Bank6At4000))
#endif
types.Add("bank 6 at $4000");
#if NET20 || NET35
if ((type & CartType.BankedRam) != 0)
#else
if (type.HasFlag(CartType.BankedRam))
#endif
types.Add("banked ram");
#if NET20 || NET35
if ((type & CartType.PokeyAt450) != 0)
#else
if (type.HasFlag(CartType.PokeyAt450))
#endif
types.Add("pokey at $450");
#if NET20 || NET35
if ((type & CartType.MirrorRamAt4000) != 0)
#else
if (type.HasFlag(CartType.MirrorRamAt4000))
#endif
types.Add("mirror ram at $4000");
#if NET20 || NET35
if ((type & CartType.ActivisionBanking) != 0)
#else
if (type.HasFlag(CartType.ActivisionBanking))
#endif
types.Add("activision banking");
#if NET20 || NET35
if ((type & CartType.AbsoluteBanking) != 0)
#else
if (type.HasFlag(CartType.AbsoluteBanking))
#endif
types.Add("absolute banking");
#if NET20 || NET35
if ((type & CartType.PokeyAt440) != 0)
#else
if (type.HasFlag(CartType.PokeyAt440))
#endif
types.Add("pokey at $440");
#if NET20 || NET35
if ((type & CartType.Ym2151At460461) != 0)
#else
if (type.HasFlag(CartType.Ym2151At460461))
#endif
types.Add("ym2151 at $460/$461");
#if NET20 || NET35
if ((type & CartType.Souper) != 0)
#else
if (type.HasFlag(CartType.Souper))
#endif
types.Add("souper");
#if NET20 || NET35
if ((type & CartType.Banksets) != 0)
#else
if (type.HasFlag(CartType.Banksets))
#endif
types.Add("banksets");
#if NET20 || NET35
if ((type & CartType.HaltBankedRam) != 0)
#else
if (type.HasFlag(CartType.HaltBankedRam))
#endif
types.Add("halt banked ram");
#if NET20 || NET35
if ((type & CartType.PokeyAt800) != 0)
#else
if (type.HasFlag(CartType.PokeyAt800))
#endif
types.Add("pokey@800");
// If no flags are set
if (types.Count == 0)
types.Add("N/A");
return string.Join(", ", [.. types]);
}
/// <summary>
/// Convert a <see cref="ControllerType"/> value to string
/// </summary>
public static string FromControllerType(this ControllerType type)
{
return type switch
{
ControllerType.None => "none",
ControllerType.Joystick => "7800 joystick",
ControllerType.Lightgun => "lightgun",
ControllerType.Paddle => "paddle",
ControllerType.Trakball => "trakball",
ControllerType.VcsJoystick => "2600 joystick",
ControllerType.VcsDriving => "2600 driving",
ControllerType.VcsKeypad => "2600 keypad",
ControllerType.STMouse => "ST mouse",
ControllerType.AmigaMouse => "Amiga mouse",
ControllerType.AtariVoxSaveKey => "AtariVox/SaveKey",
ControllerType.SNES2Atari => "SNES2Atari",
ControllerType.Mega7800 => "Mega7800",
_ => $"Unknown {(byte)type}",
};
}
/// <summary>
/// Convert a <see cref="Interrupt"/> value to string
/// </summary>
public static string FromInterrupt(this Interrupt interrupt)
{
return interrupt switch
{
Interrupt.None => "None",
Interrupt.Pokey1 => "POKEY 1 (@450 | @800 | @4000)",
Interrupt.Pokey2 => "POKEY 2 (@440)",
Interrupt.YM2151 => "YM2151",
_ => $"Unknown {(byte)interrupt}",
};
}
/// <summary>
/// Convert a <see cref="Mapper"/> value to string
/// </summary>
public static string FromMapper(this Mapper mapper)
{
return mapper switch
{
Mapper.Linear => "Linear",
Mapper.SuperGame => "SuperGame",
Mapper.Activision => "Activision",
Mapper.Absolute => "Absolute",
Mapper.Souper => "Souper",
_ => $"Unknown {(byte)mapper}",
};
}
/// <summary>
/// Convert a <see cref="MapperOptions"/> value to string
/// </summary>
public static string FromMapperOptions(this MapperOptions options)
{
string[] romOptions = new string[2];
byte option4000 = (byte)((byte)options & 0x07);
romOptions[0] = option4000 switch
{
0 => "Option at @4000 - none",
1 => "Option at @4000 - 16K RAM",
2 => "Option at @4000 - 8K EXRAM/A8",
3 => "Option at @4000 - 32K EXRAM/M2",
4 => "Option at @4000 - EXROM",
5 => "Option at @4000 - EXFIX",
6 => "Option at @4000 - 32k EXRAM/X2",
_ => $"Unknown {option4000}",
};
byte romType = (byte)(((byte)options >> 7) & 0x01);
romOptions[1] = romType switch
{
0 => "Standard ROM",
1 => "Bankset ROM",
_ => $"Unknown {romType}",
};
return string.Join(", ", [.. romOptions]);
}
/// <summary>
/// Convert a <see cref="SaveDevice"/> value to string
/// </summary>
public static string FromSaveDevice(this SaveDevice device)
{
return device switch
{
SaveDevice.None => "None",
SaveDevice.HSC => "HSC",
SaveDevice.SaveKeyAtariVox => "SaveKey/AtariVox",
_ => $"Unknown {(byte)device}",
};
}
/// <summary>
/// Convert a <see cref="SlotPassthroughDevice"/> value to string
/// </summary>
public static string FromSlotPassthroughDevice(this SlotPassthroughDevice device)
{
return device switch
{
SlotPassthroughDevice.None => "None",
SlotPassthroughDevice.XM => "XM",
_ => $"Unknown {(byte)device}",
};
}
/// <summary>
/// Convert a <see cref="TVType"/> value to string
/// </summary>
public static string FromTVType(this TVType type)
{
string[] types = new string[3];
byte standard = (byte)((byte)type & 0x01);
types[0] = standard switch
{
0 => "NTSC",
1 => "PAL",
_ => $"Unknown {standard}",
};
byte connection = (byte)(((byte)type >> 1) & 0x01);
types[1] = connection switch
{
0 => "Component",
1 => "Composite",
_ => $"Unknown {standard}",
};
byte region = (byte)(((byte)type >> 2) & 0x01);
types[2] = region switch
{
0 => "Single-region",
1 => "Multi-region",
_ => $"Unknown {standard}",
};
return string.Join(", ", [.. types]);
}
}
}

View File

@@ -0,0 +1,21 @@
using SabreTools.Data.Models.AtariLynx;
namespace SabreTools.Data.Extensions
{
public static class AtariLynxCartExtensions
{
/// <summary>
/// Convert a <see cref="Rotation"/> value to string
/// </summary>
public static string FromRotation(this Rotation rotation)
{
return rotation switch
{
Rotation.NoRotation => "No rotation (horizontal, buttons right)",
Rotation.RotateLeft => "Rotate left (vertical, buttons down)",
Rotation.RotateRight => "Rotate right (vertical, buttons up)",
_ => $"Unknown {(byte)rotation}",
};
}
}
}

View File

@@ -0,0 +1,33 @@
using SabreTools.Data.Models.BSP;
namespace SabreTools.Data.Extensions
{
public static class BSPExtensions
{
/// <summary>
/// Convert a <see cref="BspLumpType"/> value to string
/// </summary>
public static string FromBspLumpType(this BspLumpType type)
{
return type switch
{
BspLumpType.LUMP_ENTITIES => " - LUMP_ENTITIES",
BspLumpType.LUMP_PLANES => " - LUMP_PLANES",
BspLumpType.LUMP_TEXTURES => " - LUMP_TEXTURES",
BspLumpType.LUMP_VERTICES => " - LUMP_VERTICES",
BspLumpType.LUMP_VISIBILITY => " - LUMP_VISIBILITY",
BspLumpType.LUMP_NODES => " - LUMP_NODES",
BspLumpType.LUMP_TEXINFO => " - LUMP_TEXINFO",
BspLumpType.LUMP_FACES => " - LUMP_FACES",
BspLumpType.LUMP_LIGHTING => " - LUMP_LIGHTING",
BspLumpType.LUMP_CLIPNODES => " - LUMP_CLIPNODES",
BspLumpType.LUMP_LEAVES => " - LUMP_LEAVES",
BspLumpType.LUMP_MARKSURFACES => " - LUMP_MARKSURFACES",
BspLumpType.LUMP_EDGES => " - LUMP_EDGES",
BspLumpType.LUMP_SURFEDGES => " - LUMP_SURFEDGES",
BspLumpType.LUMP_MODELS => " - LUMP_MODELS",
_ => string.Empty,
};
}
}
}

View File

@@ -0,0 +1,313 @@
using System;
using System.IO;
using SabreTools.Data.Models.CDROM;
using SabreTools.IO.Extensions;
using SabreTools.Numerics.Extensions;
namespace SabreTools.Data.Extensions
{
public static class CDROMExtensions
{
/// <summary>
/// Get the sector mode for a CD-ROM stream
/// </summary>
/// <param name="stream">Stream to derive the sector mode from</param>
/// <returns>Sector mode from the stream on success, <see cref="SectorMode.UNKNOWN"/> on error</returns>
public static SectorMode GetSectorMode(this Stream stream)
{
try
{
byte modeByte = stream.ReadByteValue();
if (modeByte == 0)
{
return SectorMode.MODE0;
}
else if (modeByte == 1)
{
return SectorMode.MODE1;
}
else if (modeByte == 2)
{
stream.SeekIfPossible(2, SeekOrigin.Current);
byte submode = stream.ReadByteValue();
if ((submode & 0x20) == 0x20)
return SectorMode.MODE2_FORM2;
else
return SectorMode.MODE2_FORM1;
}
else
{
return SectorMode.UNKNOWN;
}
}
catch
{
// Ignore the actual error
return SectorMode.UNKNOWN;
}
}
/// <summary>
/// Get the user data size for a sector mode
/// </summary>
/// <param name="mode">Sector mode to get a value for</param>
/// <returns>User data size, if possible</returns>
public static long GetUserDataSize(this SectorMode mode)
{
return mode switch
{
SectorMode.UNKNOWN => Constants.Mode0DataSize,
SectorMode.MODE0 => Constants.Mode0DataSize,
SectorMode.MODE1 => Constants.Mode1DataSize,
SectorMode.MODE2 => Constants.Mode0DataSize,
SectorMode.MODE2_FORM1 => Constants.Mode2Form1DataSize,
SectorMode.MODE2_FORM2 => Constants.Mode2Form2DataSize,
_ => Constants.Mode0DataSize,
};
}
/// <summary>
/// Get the user data end offset for a sector mode
/// </summary>
/// <param name="mode">Sector mode to get a value for</param>
/// <returns>User data end offset, if possible</returns>
public static long GetUserDataEnd(this SectorMode mode)
{
return mode switch
{
SectorMode.UNKNOWN => Constants.Mode0UserDataEnd,
SectorMode.MODE0 => Constants.Mode0UserDataEnd, // TODO: Support flexible sector length (2352)
SectorMode.MODE1 => Constants.Mode1UserDataEnd,
SectorMode.MODE2 => Constants.Mode0UserDataEnd, // TODO: Support flexible sector length (2352)
SectorMode.MODE2_FORM1 => Constants.Mode2Form1UserDataEnd,
SectorMode.MODE2_FORM2 => Constants.Mode2Form2UserDataEnd, // TODO: Support flexible sector length (2348)
_ => Constants.Mode0UserDataEnd,
};
}
/// <summary>
/// Get the user data start offset for a sector mode
/// </summary>
/// <param name="mode">Sector mode to get a value for</param>
/// <returns>User data start offset, if possible</returns>
public static long GetUserDataStart(this SectorMode mode)
{
return mode switch
{
SectorMode.UNKNOWN => Constants.Mode0UserDataStart,
SectorMode.MODE0 => Constants.Mode0UserDataStart,
SectorMode.MODE1 => Constants.Mode1UserDataStart,
SectorMode.MODE2 => Constants.Mode0UserDataStart,
SectorMode.MODE2_FORM1 => Constants.Mode2Form1UserDataStart,
SectorMode.MODE2_FORM2 => Constants.Mode2Form2UserDataStart,
_ => Constants.Mode0UserDataStart,
};
}
/// <summary>
/// Creates a stream that provides only the user data of a CDROM stream
/// </summary>
public class UserDataStream : Stream
{
// Base CDROM stream (2352-byte sector)
private readonly Stream _baseStream;
// State variables
private long _position = 0;
private SectorMode _currentMode = SectorMode.UNKNOWN;
private long _userDataStart = Constants.Mode1UserDataStart;
private long _userDataEnd = Constants.Mode1UserDataEnd;
#pragma warning disable IDE0044
private long _isoSectorSize = Constants.Mode1DataSize;
#pragma warning restore IDE0044
public UserDataStream(Stream inputStream)
{
if (!inputStream.CanSeek || !inputStream.CanRead)
throw new ArgumentException("Stream must be readable and seekable.", nameof(inputStream));
_baseStream = inputStream;
}
/// <inheritdoc/>
public override bool CanRead => _baseStream.CanRead;
/// <inheritdoc/>
public override bool CanSeek => _baseStream.CanSeek;
/// <inheritdoc/>
public override bool CanWrite => false;
/// <inheritdoc/>
public override void Flush() => _baseStream.Flush();
/// <inheritdoc/>
public override long Length
=> _baseStream.Length / Constants.CDROMSectorSize * _isoSectorSize;
/// <inheritdoc/>
public override void SetLength(long value)
=> throw new NotSupportedException("Setting the length of this stream is not supported.");
/// <inheritdoc/>
public override void Write(byte[] buffer, int offset, int count)
=> throw new NotSupportedException("Writing to this stream is not supported.");
/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
if (disposing)
_baseStream.Dispose();
base.Dispose(disposing);
}
/// <inheritdoc/>
public override long Position
{
// Get the position of the underlying ISO9660 stream
get
{
// Get the user data location based on the current sector mode
SetState(_position);
// Get the number of ISO sectors before current position
long isoPosition = _position / Constants.CDROMSectorSize * _isoSectorSize;
// Add the within-sector position
long remainder = _position % Constants.CDROMSectorSize;
if (remainder > _userDataEnd)
isoPosition += _isoSectorSize;
else if (remainder > _userDataStart)
isoPosition += remainder - _userDataStart;
return isoPosition;
}
set
{
// Seek to the underlying ISO9660 position
Seek(value, SeekOrigin.Begin);
}
}
/// <inheritdoc/>
public override int Read(byte[] buffer, int offset, int count)
{
int totalRead = 0;
int remaining = count;
while (remaining > 0 && _position < _baseStream.Length)
{
// Determine location of current sector
long baseStreamOffset = _position - (_position % Constants.CDROMSectorSize);
// Set the current sector's mode and user data location
SetState(baseStreamOffset);
// Deal with case where base position is not in ISO stream
long remainder = _position % Constants.CDROMSectorSize;
long sectorOffset = remainder - _userDataStart;
if (remainder < _userDataStart)
{
baseStreamOffset += _userDataStart;
sectorOffset = 0;
_position += _userDataStart;
}
else if (remainder >= _userDataEnd)
{
baseStreamOffset += Constants.CDROMSectorSize;
sectorOffset = 0;
_position += Constants.CDROMSectorSize - _userDataEnd + _userDataStart;
}
else
{
baseStreamOffset += remainder;
}
// Sanity check on read location before seeking
if (baseStreamOffset < 0 || baseStreamOffset > _baseStream.Length)
throw new ArgumentOutOfRangeException(nameof(offset), "Attempted to seek outside the stream boundaries.");
// Seek to target position in base CDROM stream
_baseStream.SeekIfPossible(baseStreamOffset, SeekOrigin.Begin);
// Read the remaining bytes, up to max of one ISO sector (2048 bytes)
int bytesToRead = (int)Math.Min(remaining, _isoSectorSize - sectorOffset);
// Don't overshoot end of stream
bytesToRead = (int)Math.Min(bytesToRead, _baseStream.Length - _position);
// Finish reading if no more bytes to be read
if (bytesToRead <= 0)
break;
// Read up to 2048 bytes from base CDROM stream
int bytesRead = _baseStream.Read(buffer, offset + totalRead, bytesToRead);
// Update state for base stream
_position = _baseStream.Position;
if (bytesToRead == (_isoSectorSize - sectorOffset))
_position += Constants.CDROMSectorSize - _userDataEnd + _userDataStart;
// Update state for ISO stream
totalRead += bytesRead;
remaining -= bytesRead;
if (bytesRead == 0)
break;
}
return totalRead;
}
/// <inheritdoc/>
public override long Seek(long offset, SeekOrigin origin)
{
// Get the intended position for the ISO9660 stream
long targetPosition = origin switch
{
SeekOrigin.Begin => offset,
SeekOrigin.Current => Position + offset,
SeekOrigin.End => Length + offset,
_ => throw new ArgumentException("Invalid SeekOrigin.", nameof(origin)),
};
// Get the number of ISO sectors before current position
long newPosition = targetPosition / _isoSectorSize * Constants.CDROMSectorSize;
// Set the current sector's mode and user data location
SetState(newPosition);
// Add the within-sector position
newPosition += _userDataStart + (targetPosition % _isoSectorSize);
if (newPosition < 0 || newPosition > _baseStream.Length)
throw new ArgumentOutOfRangeException(nameof(offset), "Attempted to seek outside the stream boundaries.");
_position = _baseStream.SeekIfPossible(newPosition, SeekOrigin.Begin);
return Position;
}
/// <summary>
/// Update the current stream state based on the location
/// </summary>
/// <param name="sectorLocation">Sector location to update from</param>
private void SetState(long sectorLocation)
{
long current = _baseStream.Position;
long modePosition = sectorLocation - (sectorLocation % Constants.CDROMSectorSize) + 15;
// Get the current sector mode
_baseStream.SeekIfPossible(modePosition, SeekOrigin.Begin);
_currentMode = _baseStream.GetSectorMode();
// Set the user data location variables
_userDataStart = _currentMode.GetUserDataStart();
_userDataEnd = _currentMode.GetUserDataEnd();
// _isoSectorSize = _currentMode.GetUserDataSize();
// Reset the stream position
_baseStream.SeekIfPossible(current, SeekOrigin.Begin);
}
}
}
}

View File

@@ -0,0 +1,99 @@
using System.Text;
namespace SabreTools.Data.Extensions
{
public static class CFBExtensions
{
/// <summary>
/// Decode a MIME-encoded stream name stored as a byte array
/// </summary>
/// <param name="input">Byte array to decode</param>
/// <returns>Decoded string on success, null otherwise</returns>
/// <remarks>Adapted from LibMSI</remarks>
public static string? DecodeStreamName(this byte[]? input)
{
// Ignore invalid inputs
if (input is null)
return null;
else if (input.Length == 0)
return string.Empty;
int count = 0;
int p = 0; // inputBytes[0]
byte[] output = new byte[input.Length + 1];
int q = 0; // output[0]
while (p < input.Length && input[p] != 0)
{
byte ch = input[p];
if ((ch == 0xe3 && input[p + 1] >= 0xa0) || (ch == 0xe4 && input[p + 1] < 0xa0))
{
// UTF-8 encoding of 0x3800..0x47ff.
output[q++] = (byte)Mime2Utf(input[p + 2] & 0x7f);
output[q++] = (byte)Mime2Utf(input[p + 1] ^ 0xa0);
p += 3;
count += 2;
continue;
}
if (ch == 0xe4 && input[p + 1] == 0xa0)
{
// UTF-8 encoding of 0x4800..0x483f.
output[q++] = (byte)Mime2Utf(input[p + 2] & 0x7f);
p += 3;
count++;
continue;
}
output[q++] = input[p++];
if (ch >= 0xc1)
output[q++] = input[p++];
if (ch >= 0xe0)
output[q++] = input[p++];
if (ch >= 0xf0)
output[q++] = input[p++];
count++;
}
output[q] = 0;
return Encoding.UTF8.GetString(output);
}
/// <summary>
/// Decode a MIME-encoded stream name stored as a string
/// </summary>
/// <param name="input">String to decode</param>
/// <returns>Decoded string on success, null otherwise</returns>
/// <remarks>Adapted from LibMSI</remarks>
public static string? DecodeStreamName(this string? input)
{
// Ignore invalid inputs
if (input is null)
return null;
else if (input.Length == 0)
return string.Empty;
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
return inputBytes.DecodeStreamName();
}
/// <summary>
/// Decode a single MIME-encoded byte
/// </summary>
/// <param name="b">Byte to decode</param>
/// <returns>Decoded byte on success, `_` otherwise</returns>
/// <remarks>Adapted from LibMSI</remarks>
private static int Mime2Utf(int b)
{
return b switch
{
< 10 => b + '0',
< 10 + 26 => b - 10 + 'A',
< 10 + 26 + 26 => b - 10 - 26 + 'a',
10 + 26 + 26 => '.',
_ => '_'
};
}
}
}

View File

@@ -0,0 +1,9 @@
#if NET20
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
internal sealed class ExtensionAttribute : Attribute {}
}
#endif

View File

@@ -0,0 +1,54 @@
using SabreTools.Data.Models.ISO9660;
using SabreTools.Numerics;
namespace SabreTools.Data.Extensions
{
public static class ISO9660Extensions
{
/// <summary>
/// Get the logical block size from a sector length
/// </summary>
/// <param name="vd">Volume descriptor containing block information</param>
/// <param name="sectorLength">Defined sector length</param>
/// <returns>Size of a logical block</returns>
public static short GetLogicalBlockSize(this VolumeDescriptor vd, short sectorLength)
{
BothInt16 blockSize;
if (vd is PrimaryVolumeDescriptor pvd)
blockSize = pvd.LogicalBlockSize;
else if (vd is SupplementaryVolumeDescriptor svd)
blockSize = svd.LogicalBlockSize;
else
return sectorLength;
// If the block size is inconsistent
if (!blockSize.IsValid)
{
bool leValid = BlockSizeValid(blockSize.LittleEndian, sectorLength);
bool beValid = BlockSizeValid(blockSize.BigEndian, sectorLength);
if (leValid && !beValid)
blockSize = blockSize.LittleEndian;
else if (beValid && !leValid)
blockSize = blockSize.BigEndian;
else
return sectorLength;
}
// Validate logical block size
if (!BlockSizeValid(blockSize, sectorLength))
blockSize = sectorLength;
return blockSize;
}
/// <summary>
/// Indicates if a block size is valid
/// </summary>
/// <param name="blockSize">Block length to check</param>
/// <param name="sectorLength">Defined sector length</param>
/// <returns>True if the block length is valid, false otherwise</returns>
private static bool BlockSizeValid(short blockSize, short sectorLength)
=> blockSize >= 512 && blockSize <= sectorLength && (blockSize & (blockSize - 1)) == 0;
}
}

View File

@@ -0,0 +1,127 @@
using SabreTools.Data.Models.InstallShieldCabinet;
namespace SabreTools.Data.Extensions
{
public static class InstallShieldCabinetExtensions
{
#region File Descriptors
/// <summary>
/// Indicate if a file descriptor represents a compressed file
/// </summary>
/// <param name="fileDescriptor">File descriptor to check</param>
/// <returns>True if the file is flagged as compressed, false otherwise</returns>
public static bool IsCompressed(this FileDescriptor? fileDescriptor)
{
// Ignore invalid descriptors
if (fileDescriptor is null)
return true;
#if NET20 || NET35
return (fileDescriptor.Flags & FileFlags.FILE_COMPRESSED) != 0;
#else
return fileDescriptor.Flags.HasFlag(FileFlags.FILE_COMPRESSED);
#endif
}
/// <summary>
/// Indicate if a file descriptor represents an invalid file
/// </summary>
/// <param name="fileDescriptor">File descriptor to check</param>
/// <returns>True if the file is flagged as invalid, false otherwise</returns>
public static bool IsInvalid(this FileDescriptor? fileDescriptor)
{
// Ignore invalid descriptors
if (fileDescriptor is null)
return true;
#if NET20 || NET35
return (fileDescriptor.Flags & FileFlags.FILE_INVALID) != 0;
#else
return fileDescriptor.Flags.HasFlag(FileFlags.FILE_INVALID);
#endif
}
/// <summary>
/// Indicate if a file descriptor represents an obfuscated file
/// </summary>
/// <param name="fileDescriptor">File descriptor to check</param>
/// <returns>True if the file is flagged as obfuscated, false otherwise</returns>
public static bool IsObfuscated(this FileDescriptor? fileDescriptor)
{
// Ignore invalid descriptors
if (fileDescriptor is null)
return false;
#if NET20 || NET35
return (fileDescriptor.Flags & FileFlags.FILE_OBFUSCATED) != 0;
#else
return fileDescriptor.Flags.HasFlag(FileFlags.FILE_OBFUSCATED);
#endif
}
/// <summary>
/// Indicate if a file descriptor represents a split file
/// </summary>
/// <param name="fileDescriptor">File descriptor to check</param>
/// <returns>True if the file is flagged as split, false otherwise</returns>
public static bool IsSplit(this FileDescriptor? fileDescriptor)
{
// Ignore invalid descriptors
if (fileDescriptor is null)
return false;
#if NET20 || NET35
return (fileDescriptor.Flags & FileFlags.FILE_SPLIT) != 0;
#else
return fileDescriptor.Flags.HasFlag(FileFlags.FILE_SPLIT);
#endif
}
#endregion
#region Version
/// <summary>
/// Get the major version of an InstallShield Cabinet
/// </summary>
/// <param name="cabinet">Cabinet to derive the version from</param>
/// <returns>Major version of the cabinet, -1 on error</returns>
public static int GetMajorVersion(this Cabinet? cabinet)
{
// Ignore invalid cabinets
if (cabinet is null)
return -1;
return cabinet.CommonHeader.GetMajorVersion();
}
/// <summary>
/// Get the major version of an InstallShield Cabinet
/// </summary>
/// <param name="commonHeader">CommonHeader to derive the version from</param>
/// <returns>Major version of the cabinet, -1 on error</returns>
public static int GetMajorVersion(this CommonHeader? commonHeader)
{
// Ignore invalid headers
if (commonHeader is null)
return -1;
uint majorVersion = commonHeader.Version;
if (majorVersion >> 24 == 1)
{
majorVersion = (majorVersion >> 12) & 0x0F;
}
else if (majorVersion >> 24 == 2 || majorVersion >> 24 == 4)
{
majorVersion &= 0xFFFF;
if (majorVersion != 0)
majorVersion /= 100;
}
return (int)majorVersion;
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,241 @@
using SabreTools.Data.Models.NES;
namespace SabreTools.Data.Extensions
{
public static class NESCartExtensions
{
/// <summary>
/// Convert a <see cref="ConsoleType"/> value to string
/// </summary>
public static string FromConsoleType(this ConsoleType type)
{
return type switch
{
ConsoleType.StandardSystem => "Nintendo Entertainment System/Family Computer",
ConsoleType.VSUnisystem => "VS Unisystem",
ConsoleType.PlayChoice10 => "PlayChoice-10 (8 KB of Hint Screen data stored after CHR data)",
ConsoleType.ExtendedConsoleType => "Extended Console Type",
_ => $"Unknown {(byte)type}",
};
}
/// <summary>
/// Convert a <see cref="CPUPPUTiming"/> value to string
/// </summary>
public static string FromCPUPPUTiming(this CPUPPUTiming timing)
{
return timing switch
{
CPUPPUTiming.RP2C02 => "RP2C02 (NTSC NES)",
CPUPPUTiming.RP2C07 => "RP2C07 (Licensed PAL NES)",
CPUPPUTiming.MultipleRegion => "Multiple-region",
CPUPPUTiming.UA6538 => "UA6538 (Dendy)",
_ => $"Unknown {(byte)timing}",
};
}
/// <summary>
/// Convert a <see cref="DefaultExpansionDevice"/> value to string
/// </summary>
public static string FromDefaultExpansionDevice(this DefaultExpansionDevice device)
{
return device switch
{
DefaultExpansionDevice.Unspecified => "Unspecified",
DefaultExpansionDevice.StandardControllers => "Standard NES/Famicom controllers",
DefaultExpansionDevice.NESFourScore => "NES Four Score/Satellite with two additional standard controllers",
DefaultExpansionDevice.FamicomFourPlayersAdapter => "Famicom Four Players Adapter with two additional standard controllers using the 'simple' protocol",
DefaultExpansionDevice.VsSystem4016 => "Vs. System (1P via $4016)",
DefaultExpansionDevice.VsSystem4017 => "Vs. System (1P via $4017)",
DefaultExpansionDevice.Reserved06 => "Reserved (0x06)",
DefaultExpansionDevice.VsZapper => "Vs. Zapper",
DefaultExpansionDevice.Zapper4017 => "Zapper ($4017)",
DefaultExpansionDevice.TwoZappers => "Two Zappers",
DefaultExpansionDevice.BandaiHyperShotLightgun => "Bandai Hyper Shot Lightgun",
DefaultExpansionDevice.PowerPadSideA => "Power Pad Side A",
DefaultExpansionDevice.PowerPadSideB => "Power Pad Side B",
DefaultExpansionDevice.FamilyTrainerSideA => "Family Trainer Side A",
DefaultExpansionDevice.FamilyTrainerSideB => "Family Trainer Side B",
DefaultExpansionDevice.ArkanoidVausControllerNES => "Arkanoid Vaus Controller (NES)",
DefaultExpansionDevice.ArkanoidVausControllerFamicom => "Arkanoid Vaus Controller (Famicom)",
DefaultExpansionDevice.TwoVausControllersPlusFamicomDataRecorder => "Two Vaus Controllers plus Famicom Data Recorder",
DefaultExpansionDevice.KonamiHyperShotController => "Konami Hyper Shot Controller",
DefaultExpansionDevice.CoconutsPachinkoController => "Coconuts Pachinko Controller",
DefaultExpansionDevice.ExcitingBoxingPunchingBag => "Exciting Boxing Punching Bag (Blowup Doll)",
DefaultExpansionDevice.JissenMahjongController => "Jissen Mahjong Controller",
DefaultExpansionDevice.YonezawaPartyTap => "米澤 (Yonezawa) Party Tap",
DefaultExpansionDevice.OekaKidsTablet => "Oeka Kids Tablet",
DefaultExpansionDevice.SunsoftBarcodeBattler => "Sunsoft Barcode Battler",
DefaultExpansionDevice.MiraclePianoKeyboard => "Miracle Piano Keyboard",
DefaultExpansionDevice.PokkunMoguraaTapTapMat => "Pokkun Moguraa Tap-tap Mat (Whack-a-Mole Mat and Mallet)",
DefaultExpansionDevice.TopRider => "Top Rider (Inflatable Bicycle)",
DefaultExpansionDevice.DoubleFisted => "Double-Fisted (Requires or allows use of two controllers by one player)",
DefaultExpansionDevice.Famicom3DSystem => "Famicom 3D System",
DefaultExpansionDevice.DoremikkoKeyboard => "Doremikko Keyboard",
DefaultExpansionDevice.ROBGyromite => "R.O.B. Gyromite",
DefaultExpansionDevice.FamicomDataRecorder => "Famicom Data Recorder ('silent' keyboard)",
DefaultExpansionDevice.ASCIITurboFile => "ASCII Turbo File",
DefaultExpansionDevice.IGSStorageBattleBox => "IGS Storage Battle Box",
DefaultExpansionDevice.FamilyBASICKeyboardPlusFamicomDataRecorder => "Family BASIC Keyboard plus Famicom Data Recorder",
DefaultExpansionDevice.DongdaPECKeyboard => "东达 (Dōngdá) PEC Keyboard",
DefaultExpansionDevice.BitCorpBit79Keyboard => "普澤 (Pǔzé, a.k.a. Bit Corp.) Bit-79 Keyboard",
DefaultExpansionDevice.SuborKeyboard => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard",
DefaultExpansionDevice.SuborKeyboardPlusMacroWinnersMouse => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Macro Winners Mouse",
DefaultExpansionDevice.SuborKeyboardPlusSuborMouse4016 => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Subor Mouse via $4016",
DefaultExpansionDevice.SNESMouse4016 => "SNES Mouse ($4016)",
DefaultExpansionDevice.Multicart => "Multicart",
DefaultExpansionDevice.TwoSNESControllers => "Two SNES controllers replacing the two standard NES controllers",
DefaultExpansionDevice.RacerMateBicycle => "RacerMate Bicycle",
DefaultExpansionDevice.UForce => "U-Force",
DefaultExpansionDevice.ROBStackUp => "R.O.B. Stack-Up",
DefaultExpansionDevice.CityPatrolmanLightgun => "City Patrolman Lightgun",
DefaultExpansionDevice.SharpC1CassetteInterface => "Sharp C1 Cassette Interface",
DefaultExpansionDevice.StandardControllerWithSwappedInputs => "Standard Controller with swapped Left-Right/Up-Down/B-A",
DefaultExpansionDevice.ExcaliburSudokuPad => "Excalibur Sudoku Pad",
DefaultExpansionDevice.ABLPinball => "ABL Pinball",
DefaultExpansionDevice.GoldenNuggetCasinoExtraButtons => "Golden Nugget Casino extra buttons",
DefaultExpansionDevice.KedaKeyboard => "科达 (Kēdá) Keyboard",
DefaultExpansionDevice.SuborKeyboardPlusSuborMouse4017 => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Subor Mouse via $4017",
DefaultExpansionDevice.PortTestController => "Port test controller",
DefaultExpansionDevice.BandaiMultiGamePlayerGamepad => "Bandai Multi Game Player Gamepad buttons",
DefaultExpansionDevice.VenomTVDanceMat => "Venom TV Dance Mat",
DefaultExpansionDevice.LGTVRemoteControl => "LG TV Remote Control",
DefaultExpansionDevice.FamicomNetworkController => "Famicom Network Controller",
DefaultExpansionDevice.KingFishingController => "King Fishing Controller",
DefaultExpansionDevice.CroakyKaraokeController => "Croaky Karaoke Controller",
DefaultExpansionDevice.KingwonKeyboard => "科王 (Kēwáng, a.k.a. Kingwon) Keyboard",
DefaultExpansionDevice.ZechengKeyboard => "泽诚 (Zéchéng) Keyboard",
DefaultExpansionDevice.SuborKeyboardPlusL90RotatedPS2Mouse4017 => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus L90-rotated PS/2 mouse in $4017",
DefaultExpansionDevice.PS2KeyboardInUM6578PS2PortPS2Mouse4017 => "PS/2 Keyboard in UM6578 PS/2 port, PS/2 Mouse via $4017",
DefaultExpansionDevice.PS2MouseInUM6578PS2Port => "PS/2 Mouse in UM6578 PS/2 port",
DefaultExpansionDevice.YuxingMouse4016 => "裕兴 (Yùxìng) Mouse via $4016",
DefaultExpansionDevice.SuborKeyboardPlusYuxingMouse4016 => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus 裕兴 (Yùxìng) Mouse mouse in $4016",
DefaultExpansionDevice.GigggleTVPump => "Gigggle TV Pump",
DefaultExpansionDevice.BBKKeyboardPlusR90RotatedPS2Mouse4017 => "步步高 (Bùbùgāo, a.k.a. BBK) Keyboard plus R90-rotated PS/2 mouse in $4017",
DefaultExpansionDevice.MagicalCooking => "Magical Cooking",
DefaultExpansionDevice.SNESMouse4017 => "SNES Mouse ($4017)",
DefaultExpansionDevice.Zapper4016 => "Zapper ($4016)",
DefaultExpansionDevice.ArkanoidVausControllerPrototype => "Arkanoid Vaus Controller (Prototype)",
DefaultExpansionDevice.TVMahjongGameController => "TV 麻雀 Game (TV Mahjong Game) Controller",
DefaultExpansionDevice.MahjongGekitouDensetsuController => "麻雀激闘伝説 (Mahjong Gekitou Densetsu) Controller",
DefaultExpansionDevice.SuborKeyboardPlusXInvertedPS2Mouse4017 => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus X-inverted PS/2 mouse in $4017",
DefaultExpansionDevice.IBMPCXTKeyboard => "IBM PC/XT Keyboard",
DefaultExpansionDevice.SuborKeyboardPlusMegaBookMouse => "小霸王 (Xiǎobàwáng, a.k.a. Subor) Keyboard plus Mega Book Mouse",
_ => $"Unknown {(byte)device}",
};
}
/// <summary>
/// Convert a <see cref="ExtendedConsoleType"/> value to string
/// </summary>
public static string FromExtendedConsoleType(this ExtendedConsoleType type)
{
return type switch
{
ExtendedConsoleType.RegularSystem => "Regular NES/Famicom/Dendy",
ExtendedConsoleType.NintendoVsSystem => "Nintendo Vs. System",
ExtendedConsoleType.Playchoice10 => "Playchoice 10",
ExtendedConsoleType.RegularFamicloneDecimalMode => "Regular Famiclone, but with CPU that supports Decimal Mode",
ExtendedConsoleType.RegularNESWithEPSM => "Regular NES/Famicom with EPSM module or plug-through cartridge",
ExtendedConsoleType.VRTechnologyVT01 => "V.R. Technology VT01 with red/cyan STN palette",
ExtendedConsoleType.VRTechnologyVT02 => "V.R. Technology VT02",
ExtendedConsoleType.VRTechnologyVT03 => "V.R. Technology VT03",
ExtendedConsoleType.VRTechnologyVT09 => "V.R. Technology VT09",
ExtendedConsoleType.VRTechnologyVT32 => "V.R. Technology VT32",
ExtendedConsoleType.VRTechnologyVT369 => "V.R. Technology VT369",
ExtendedConsoleType.UMCUM6578 => "UMC UM6578",
ExtendedConsoleType.FamicomNetworkSystem => "Famicom Network System",
ExtendedConsoleType.ReservedD => "Reserved (0x0D)",
ExtendedConsoleType.ReservedE => "Reserved (0x0E)",
ExtendedConsoleType.ReservedF => "Reserved (0x0F)",
_ => $"Unknown {(byte)type}",
};
}
/// <summary>
/// Convert a <see cref="NametableArrangement"/> value to string
/// </summary>
public static string FromNametableArrangement(this NametableArrangement arrangement)
{
return arrangement switch
{
NametableArrangement.Vertical => "Vertical",
NametableArrangement.Horizontal => "Horizontal",
_ => $"Unknown {(byte)arrangement}",
};
}
/// <summary>
/// Convert a <see cref="TVSystem"/> value to string
/// </summary>
public static string FromTVSystem(this TVSystem system)
{
return system switch
{
TVSystem.NTSC => "NTSC",
TVSystem.PAL => "PAL",
_ => $"Unknown {(byte)system}",
};
}
/// <summary>
/// Convert a <see cref="TVSystemExtended"/> value to string
/// </summary>
public static string FromTVSystemExtended(this TVSystemExtended system)
{
return system switch
{
TVSystemExtended.NTSC => "NTSC",
TVSystemExtended.DualCompatible1 => "Dual-compatible (0x01)",
TVSystemExtended.PAL => "PAL",
TVSystemExtended.DualCompatible3 => "Dual-compatible (0x03)",
_ => $"Unknown {(byte)system}",
};
}
/// <summary>
/// Convert a <see cref="VsHardwareType"/> value to string
/// </summary>
public static string FromVsHardwareType(this VsHardwareType type)
{
return type switch
{
VsHardwareType.VsUnisystem => "Vs. Unisystem (normal)",
VsHardwareType.VsUnisystemRBIBaseballProtection => "Vs. Unisystem (RBI Baseball protection)",
VsHardwareType.VsUnisystemTKOBoxingProtection => "Vs. Unisystem (TKO Boxing protection)",
VsHardwareType.VsUnisystemSuperXeviousProtection => "Vs. Unisystem (Super Xevious protection)",
VsHardwareType.VsUnisystemVsIceClimberJapanProtection => "Vs. Unisystem (Vs. Ice Climber Japan protection)",
VsHardwareType.VsDualSystem => "Vs. Dual System (normal)",
VsHardwareType.VsDualSystemRaidOnBungelingBayProtection => "Vs. Dual System (Raid on Bungeling Bay protection)",
_ => $"Unknown {(byte)type}",
};
}
/// <summary>
/// Convert a <see cref="VsSystemType"/> value to string
/// </summary>
public static string FromVsSystemType(this VsSystemType type)
{
return type switch
{
VsSystemType.AnyRP2C03RC2C03Variant => "Any RP2C03/RC2C03 variant",
VsSystemType.Reserved1 => "Reserved (0x01)",
VsSystemType.RP2C040001 => "RP2C04-0001",
VsSystemType.RP2C040002 => "RP2C04-0002",
VsSystemType.RP2C040003 => "RP2C04-0003",
VsSystemType.RP2C040004 => "RP2C04-0004",
VsSystemType.Reserved6 => "Reserved (0x06)",
VsSystemType.Reserved7 => "Reserved (0x07)",
VsSystemType.RC2C0501 => "RC2C05-01 (signature unknown)",
VsSystemType.RC2C0502 => "RC2C05-02 ($2002 AND $3F =$3D)",
VsSystemType.RC2C0503 => "RC2C05-03 ($2002 AND $1F =$1C)",
VsSystemType.RC2C0504 => "RC2C05-04 ($2002 AND $1F =$1B)",
VsSystemType.ReservedC => "Reserved (0x0C)",
VsSystemType.ReservedD => "Reserved (0x0D)",
VsSystemType.ReservedE => "Reserved (0x0E)",
VsSystemType.ReservedF => "Reserved (0x0F)",
_ => $"Unknown {(byte)type}",
};
}
}
}

View File

@@ -1,8 +1,8 @@
using SabreTools.Models.NewExecutable;
using SabreTools.Data.Models.NewExecutable;
namespace SabreTools.Serialization
namespace SabreTools.Data.Extensions
{
public static partial class Extensions
public static class NewExecutableExtensions
{
/// <summary>
/// Determine if a resource type information entry is an integer or offset
@@ -10,9 +10,7 @@ namespace SabreTools.Serialization
/// <param name="entry">Resource type information entry to check</param>
/// <returns>True if the entry is an integer type, false if an offset, null on error</returns>
public static bool IsIntegerType(this ResourceTypeInformationEntry entry)
{
return (entry.TypeID & 0x8000) != 0;
}
=> (entry.TypeID & 0x8000) != 0;
/// <summary>
/// Determine if a resource type resource entry is an integer or offset
@@ -20,9 +18,7 @@ namespace SabreTools.Serialization
/// <param name="entry">Resource type resource entry to check</param>
/// <returns>True if the entry is an integer type, false if an offset, null on error</returns>
public static bool IsIntegerType(this ResourceTypeResourceEntry entry)
{
return (entry.ResourceID & 0x8000) != 0;
}
=> (entry.ResourceID & 0x8000) != 0;
/// <summary>
/// Get the segment entry type for an entry table bundle
@@ -43,4 +39,4 @@ namespace SabreTools.Serialization
return SegmentEntryType.Unused;
}
}
}
}

View File

@@ -0,0 +1,77 @@
using SabreTools.Data.Models.NintendoDisc;
using SabreTools.Numerics.Extensions;
namespace SabreTools.Data.Extensions
{
public static class NintendoDiscExtensions
{
/// <summary>
/// Get the platform associated with a disc header
/// </summary>
public static Platform GetPlatform(this DiscHeader header)
{
if (header.WiiMagic == Constants.WiiMagicWord)
return Platform.Wii;
else if (header.GCMagic == Constants.GCMagicWord)
return Platform.GameCube;
else if (header.GameId.Length >= 1 && IsGameCubeTitleType(header.GameId[0]))
return Platform.GameCube;
else
return Platform.Unknown;
}
/// <summary>
/// Get the platform associated with a disc header
/// </summary>
public static Platform GetPlatform(this byte[] header)
{
// Check for Wii magic bytes
if (header.Length >= 0x1C)
{
int offset = 0x18;
uint magic = header.ReadUInt32BigEndian(ref offset);
if (magic == Constants.WiiMagicWord)
return Platform.Wii;
}
// Check for GameCube magic bytes
if (header.Length >= 0x20)
{
int offset = 0x1C;
uint magic = header.ReadUInt32BigEndian(ref offset);
if (magic == Constants.GCMagicWord)
return Platform.GameCube;
}
// Check for a valid game ID
if (header.Length >= 4)
{
for (int i = 0; i < 4; i++)
{
byte c = header[i];
if (!((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')))
return Platform.Unknown;
}
return Platform.GameCube;
}
return Platform.Unknown;
}
/// <summary>
/// Returns true if the GameId first character is a known GameCube title type prefix.
/// Used as a fallback when the GC magic word is absent from the disc image.
/// </summary>
public static bool IsGameCubeTitleType(this char c)
=> c == 'G' || c == 'D' || c == 'R';
/// <summary>
/// Returns true if the byte is a known Nintendo disc title type code
/// (first byte of the 6-char GameId, e.g. 'G'=GameCube, 'R'=GameCube,
/// 'D'=GameCube demo, 'S'=Wii, 'F'=Wii channel)
/// </summary>
public static bool IsNintendoDiscTitleType(this byte b)
=> b == 'G' || b == 'D' || b == 'R' || b == 'S' || b == 'F';
}
}

View File

@@ -0,0 +1,78 @@
using SabreTools.Data.Models.OperaFS;
using SabreTools.Matching;
namespace SabreTools.Data.Extensions
{
public static class OperaFSExtensions
{
/// <summary>
/// Compare two DirectoryDescriptor objects
/// </summary>
/// <param name="dir1">The provided DirectoryDescriptor</param>
/// <param name="dir2">The DirectoryDescriptor to compare against</param>
/// <returns>True if all fields are equal, otherwise false</returns>
public static bool EqualsExactly(this DirectoryDescriptor dir1, DirectoryDescriptor dir2)
{
if (dir1.NextBlock != dir2.NextBlock)
return false;
if (dir1.PreviousBlock != dir2.PreviousBlock)
return false;
if (dir1.Flags != dir2.Flags)
return false;
if (dir1.FirstFreeByte != dir2.FirstFreeByte)
return false;
if (dir1.FirstEntryOffset != dir2.FirstEntryOffset)
return false;
if (dir1.DirectoryRecords.Length != dir2.DirectoryRecords.Length)
return false;
for (int i = 0; i < dir1.DirectoryRecords.Length; i++)
{
if (!dir1.DirectoryRecords[i].EqualsExactly(dir2.DirectoryRecords[i]))
return false;
}
return true;
}
/// <summary>
/// Compare two DirectoryRecord objects
/// </summary>
/// <param name="dir1">The provided DirectoryRecord</param>
/// <param name="dir2">The DirectoryRecord to compare against</param>
/// <returns>True if all fields are equal, otherwise false</returns>
public static bool EqualsExactly(this DirectoryRecord dr1, DirectoryRecord dr2)
{
if ((byte)dr1.DirectoryRecordFlags != (byte)dr2.DirectoryRecordFlags)
return false;
if (!dr1.UniqueIdentifier.EqualsExactly(dr2.UniqueIdentifier))
return false;
if (!dr1.Type.EqualsExactly(dr2.Type))
return false;
if (dr1.BlockSize != dr2.BlockSize)
return false;
if (dr1.ByteCount != dr2.ByteCount)
return false;
if (dr1.BlockCount != dr2.BlockCount)
return false;
if (dr1.Burst != dr2.Burst)
return false;
if (dr1.Gap != dr2.Gap)
return false;
if (!dr1.Filename.EqualsExactly(dr2.Filename))
return false;
if (dr1.LastAvatarIndex != dr2.LastAvatarIndex)
return false;
if (dr1.AvatarList.Length != dr2.AvatarList.Length)
return false;
for (int i = 0; i < dr1.AvatarList.Length; i++)
{
if (dr1.AvatarList[i] != dr2.AvatarList[i])
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,98 @@
using System;
using SabreTools.Data.Models.COFF;
namespace SabreTools.Data.Extensions
{
// TODO: Add tests
public static class PortableExecutableExtensions
{
/// <summary>
/// Convert a relative virtual address to a physical one
/// </summary>
/// <param name="rva">Relative virtual address to convert</param>
/// <param name="sections">Array of sections to check against</param>
/// <returns>Physical address, 0 on error</returns>
public static uint ConvertVirtualAddress(this uint rva, SectionHeader[] sections)
{
// If we have an invalid section table, we can't do anything
if (sections.Length == 0)
return 0;
// If the RVA is 0, we just return 0 because it's invalid
if (rva == 0)
return 0;
// If the RVA matches a section start exactly, use that
var matchingSection = Array.Find(sections, s => s.VirtualAddress == rva);
if (matchingSection is not null)
return rva - matchingSection.VirtualAddress + matchingSection.PointerToRawData;
// Loop through all of the sections
uint maxVirtualAddress = 0, maxRawPointer = 0;
for (int i = 0; i < sections.Length; i++)
{
// If the section "starts" at 0, just skip it
var section = sections[i];
if (section.PointerToRawData == 0)
continue;
// If the virtual address is greater than the RVA
if (rva < section.VirtualAddress)
continue;
// Cache the maximum matching section data, in case of a miss
if (rva >= section.VirtualAddress)
{
maxVirtualAddress = section.VirtualAddress;
maxRawPointer = section.PointerToRawData;
}
// Attempt to derive the physical address from the current section
if (section.VirtualSize != 0 && rva <= section.VirtualAddress + section.VirtualSize)
return rva - section.VirtualAddress + section.PointerToRawData;
else if (section.SizeOfRawData != 0 && rva <= section.VirtualAddress + section.SizeOfRawData)
return rva - section.VirtualAddress + section.PointerToRawData;
}
return maxRawPointer != 0 ? rva - maxVirtualAddress + maxRawPointer : 0;
}
/// <summary>
/// Find the section a revlative virtual address lives in
/// </summary>
/// <param name="rva">Relative virtual address to convert</param>
/// <param name="sections">Array of sections to check against</param>
/// <returns>Section index, null on error</returns>
public static int ContainingSectionIndex(this uint rva, SectionHeader[] sections)
{
// If we have an invalid section table, we can't do anything
if (sections is null || sections.Length == 0)
return -1;
// If the RVA is 0, we just return -1 because it's invalid
if (rva == 0)
return -1;
// Loop through all of the sections
for (int i = 0; i < sections.Length; i++)
{
// If the section "starts" at 0, just skip it
var section = sections[i];
if (section.PointerToRawData == 0)
continue;
// If the virtual address is greater than the RVA
if (rva < section.VirtualAddress)
continue;
// Attempt to derive the physical address from the current section
if (section.VirtualSize != 0 && rva <= section.VirtualAddress + section.VirtualSize)
return i;
else if (section.SizeOfRawData != 0 && rva <= section.VirtualAddress + section.SizeOfRawData)
return i;
}
return -1;
}
}
}

View File

@@ -0,0 +1,24 @@
# SabreTools.Data.Extensions
This library contains extension methods related to models. These extensions are used in both reader and wrapper code.
## Provided Extension Classes
| Class Name | Applicable Namespace |
| --- | --- |
| `Atari7800CartExtensions` | `SabreTools.Data.Models.Atari7800` |
| `AtariLynxCartExtensions` | `SabreTools.Data.Models.AtariLynx` |
| `BSPExtensions` | `SabreTools.Data.Models.BSP` |
| `CDROMExtensions` | `SabreTools.Data.Models.CDROM` |
| `CFBExtensions` | `SabreTools.Data.Models.CFB` |
| `InstallShieldCabinetExtensions` | `SabreTools.Data.Models.InstallShieldCabinet` |
| `ISO9660Extensions` | `SabreTools.Data.Models.ISO9660` |
| `MetadataExtensions` | `SabreTools.Data.Models.Metadata` |
| `NESCartExtensions` | `SabreTools.Data.Models.NES` |
| `NewExecutableExtensions` | `SabreTools.Data.Models.NewExecutable` |
| `PortableExecutableExtensions` | `SabreTools.Data.Models.COFF` |
| `TypeLengthValueExtensions` | `SabreTools.Data.Models.ASN1` and `SabreTools.ObjectIdentifier` |
| `VBSPExtensions` | `SabreTools.Data.Models.BSP` |
| `WiseScriptExtensions` | `SabreTools.Data.Models.WiseInstaller` |
| `XboxExecutableExtensions` | `SabreTools.Data.Models.XboxExecutable` |
| `XZExtensions` | `SabreTools.Data.Models.XZ` |

View File

@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<IncludeSymbols>true</IncludeSymbols>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>3.2.0</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Description>Extension methods related to models</Description>
<Copyright>Copyright (c) Matt Nadareski 2019-2026</Copyright>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/SabreTools/SabreTools.Serialization</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>models extensions conversion</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NetLegacySupport.Numerics" Version="1.0.1" Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`))" />
<PackageReference Include="SabreTools.IO" Version="2.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Data.Models\SabreTools.Data.Models.csproj" />
<ProjectReference Include="..\SabreTools.ObjectIdentifier\SabreTools.ObjectIdentifier.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,181 @@
using System;
using System.Numerics;
using System.Text;
using SabreTools.Data.Models.ASN1;
using SabreTools.ObjectIdentifier;
namespace SabreTools.Data.Extensions
{
public static class TypeLengthValueExtensions
{
/// <summary>
/// Format a TypeLengthValue as a string
/// </summary>
/// <param name="paddingLevel">Padding level of the item when formatting</param>
/// <returns>String representing the TypeLengthValue, if possible</returns>
public static string Format(this TypeLengthValue tlv, int paddingLevel = 0)
{
// Create the left-padding string
string padding = new(' ', paddingLevel);
// Create the string builder
var formatBuilder = new StringBuilder();
// Append the type
formatBuilder.Append($"{padding}Type: {tlv.Type}");
if (tlv.Type == ASN1Type.V_ASN1_EOC)
return formatBuilder.ToString();
// Append the length
formatBuilder.Append($", Length: {tlv.Length}");
if (tlv.Length == 0)
return formatBuilder.ToString();
// If we have a constructed type
#if NET20 || NET35
if ((tlv.Type & ASN1Type.V_ASN1_CONSTRUCTED) != 0)
#else
if (tlv.Type.HasFlag(ASN1Type.V_ASN1_CONSTRUCTED))
#endif
{
if (tlv.Value is not TypeLengthValue[] valueAsObjectArray)
{
formatBuilder.Append(", Value: [INVALID DATA TYPE]");
return formatBuilder.ToString();
}
formatBuilder.Append(", Value:\n");
for (int i = 0; i < valueAsObjectArray.Length; i++)
{
var child = valueAsObjectArray[i];
string childString = child.Format(paddingLevel + 1);
formatBuilder.Append($"{childString}\n");
}
return formatBuilder.ToString().TrimEnd('\n');
}
// Get the value as a byte array
if (tlv.Value is not byte[] valueAsByteArray)
{
formatBuilder.Append(", Value: [INVALID DATA TYPE]");
return formatBuilder.ToString();
}
else if (valueAsByteArray.Length == 0)
{
formatBuilder.Append(", Value: [NO DATA]");
return formatBuilder.ToString();
}
// If we have a primitive type
switch (tlv.Type)
{
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-boolean"/>
case ASN1Type.V_ASN1_BOOLEAN:
if (tlv.Length > 1)
formatBuilder.Append($" [Expected length of 1]");
else if (valueAsByteArray.Length > 1)
formatBuilder.Append($" [Expected value length of 1]");
bool booleanValue = valueAsByteArray[0] != 0x00;
formatBuilder.Append($", Value: {booleanValue}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-integer"/>
case ASN1Type.V_ASN1_INTEGER:
Array.Reverse(valueAsByteArray);
var integerValue = new BigInteger(valueAsByteArray);
formatBuilder.Append($", Value: {integerValue}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-bit-string"/>
case ASN1Type.V_ASN1_BIT_STRING:
// TODO: Read into a BitArray and print that out instead?
int unusedBits = valueAsByteArray[0];
if (unusedBits == 0)
formatBuilder.Append($", Value with {unusedBits} unused bits");
else
formatBuilder.Append($", Value with {unusedBits} unused bits: {BitConverter.ToString(valueAsByteArray, 1).Replace('-', ' ')}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-octet-string"/>
case ASN1Type.V_ASN1_OCTET_STRING:
formatBuilder.Append($", Value: {BitConverter.ToString(valueAsByteArray).Replace('-', ' ')}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-object-identifier"/>
/// <see cref="http://snmpsharpnet.com/index.php/2009/03/02/ber-encoding-and-decoding-oid-values/"/>
case ASN1Type.V_ASN1_OBJECT:
// Derive array of values
ulong[] objectNodes = Parser.ParseDERIntoArray(valueAsByteArray, tlv.Length);
// Append the dot and modified OID-IRI notations
string? dotNotationString = Parser.ParseOIDToDotNotation(objectNodes);
string? oidIriString = Parser.ParseOIDToOIDIRINotation(objectNodes);
formatBuilder.Append($", Value: {dotNotationString} ({oidIriString})");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-utf8string"/>
case ASN1Type.V_ASN1_UTF8STRING:
formatBuilder.Append($", Value: {Encoding.UTF8.GetString(valueAsByteArray)}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-printablestring"/>
case ASN1Type.V_ASN1_PRINTABLESTRING:
formatBuilder.Append($", Value: {Encoding.ASCII.GetString(valueAsByteArray)}");
break;
//case ASN1Type.V_ASN1_T61STRING:
case ASN1Type.V_ASN1_TELETEXSTRING:
formatBuilder.Append($", Value: {Encoding.ASCII.GetString(valueAsByteArray)}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-ia5string"/>
case ASN1Type.V_ASN1_IA5STRING:
formatBuilder.Append($", Value: {Encoding.ASCII.GetString(valueAsByteArray)}");
break;
case ASN1Type.V_ASN1_UTCTIME:
string utctimeString = Encoding.ASCII.GetString(valueAsByteArray);
if (DateTime.TryParse(utctimeString, out DateTime utctimeDateTime))
formatBuilder.Append($", Value: {utctimeDateTime:yyyy-MM-dd HH:mm:ss}");
else
formatBuilder.Append($", Value: {utctimeString}");
break;
/// <see href="https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-bmpstring"/>
case ASN1Type.V_ASN1_BMPSTRING:
formatBuilder.Append($", Value: {Encoding.Unicode.GetString(valueAsByteArray)}");
break;
// Unimplemented
case ASN1Type.V_ASN1_EOC:
case ASN1Type.V_ASN1_NULL:
case ASN1Type.V_ASN1_OBJECT_DESCRIPTOR:
case ASN1Type.V_ASN1_EXTERNAL:
case ASN1Type.V_ASN1_REAL:
case ASN1Type.V_ASN1_ENUMERATED:
case ASN1Type.V_ASN1_SEQUENCE:
case ASN1Type.V_ASN1_SET:
case ASN1Type.V_ASN1_NUMERICSTRING:
case ASN1Type.V_ASN1_VIDEOTEXSTRING:
case ASN1Type.V_ASN1_GENERALIZEDTIME:
case ASN1Type.V_ASN1_GRAPHICSTRING:
case ASN1Type.V_ASN1_ISO64STRING:
case ASN1Type.V_ASN1_GENERALSTRING:
case ASN1Type.V_ASN1_UNIVERSALSTRING:
case ASN1Type.V_ASN1_PRIMITIVE_TAG:
case ASN1Type.V_ASN1_CONSTRUCTED:
case ASN1Type.V_ASN1_APPLICATION:
case ASN1Type.V_ASN1_CONTEXT_SPECIFIC:
case ASN1Type.V_ASN1_PRIVATE:
default:
formatBuilder.Append($", Value: {BitConverter.ToString(valueAsByteArray).Replace('-', ' ')}");
break;
}
// Return the formatted string
return formatBuilder.ToString();
}
}
}

View File

@@ -0,0 +1,82 @@
using SabreTools.Data.Models.BSP;
namespace SabreTools.Data.Extensions
{
public static class VBSPExtensions
{
/// <summary>
/// Convert a <see cref="VbspLumpType"/> value to string
/// </summary>
public static string FromVbspLumpType(this VbspLumpType type)
{
return type switch
{
VbspLumpType.LUMP_ENTITIES => " - LUMP_ENTITIES",
VbspLumpType.LUMP_PLANES => " - LUMP_PLANES",
VbspLumpType.LUMP_TEXTURES => " - LUMP_TEXDATA",
VbspLumpType.LUMP_VERTICES => " - LUMP_VERTEXES",
VbspLumpType.LUMP_VISIBILITY => " - LUMP_VISIBILITY",
VbspLumpType.LUMP_NODES => " - LUMP_NODES",
VbspLumpType.LUMP_TEXINFO => " - LUMP_TEXINFO",
VbspLumpType.LUMP_FACES => " - LUMP_FACES",
VbspLumpType.LUMP_LIGHTING => " - LUMP_LIGHTING",
VbspLumpType.LUMP_CLIPNODES => " - LUMP_OCCLUSION",
VbspLumpType.LUMP_LEAVES => " - LUMP_LEAVES",
VbspLumpType.LUMP_MARKSURFACES => " - LUMP_FACEIDS",
VbspLumpType.LUMP_EDGES => " - LUMP_EDGES",
VbspLumpType.LUMP_SURFEDGES => " - LUMP_SURFEDGES",
VbspLumpType.LUMP_MODELS => " - LUMP_MODELS",
VbspLumpType.LUMP_WORLDLIGHTS => " - LUMP_WORLDLIGHTS",
VbspLumpType.LUMP_LEAFFACES => " - LUMP_LEAFFACES",
VbspLumpType.LUMP_LEAFBRUSHES => " - LUMP_LEAFBRUSHES",
VbspLumpType.LUMP_BRUSHES => " - LUMP_BRUSHES",
VbspLumpType.LUMP_BRUSHSIDES => " - LUMP_BRUSHSIDES",
VbspLumpType.LUMP_AREAS => " - LUMP_AREAS",
VbspLumpType.LUMP_AREAPORTALS => " - LUMP_AREAPORTALS",
VbspLumpType.LUMP_PORTALS => " - LUMP_PORTALS / LUMP_UNUSED0 / LUMP_PROPCOLLISION",
VbspLumpType.LUMP_CLUSTERS => " - LUMP_CLUSTERS / LUMP_UNUSED1 / LUMP_PROPHULLS",
VbspLumpType.LUMP_PORTALVERTS => " - LUMP_PORTALVERTS / LUMP_UNUSED2 / LUMP_FAKEENTITIES / LUMP_PROPHULLVERTS",
VbspLumpType.LUMP_CLUSTERPORTALS => " - LUMP_CLUSTERPORTALS / LUMP_UNUSED3 / LUMP_PROPTRIS",
VbspLumpType.LUMP_DISPINFO => " - LUMP_DISPINFO",
VbspLumpType.LUMP_ORIGINALFACES => " - LUMP_ORIGINALFACES",
VbspLumpType.LUMP_PHYSDISP => " - LUMP_PHYSDISP",
VbspLumpType.LUMP_PHYSCOLLIDE => " - LUMP_PHYSCOLLIDE",
VbspLumpType.LUMP_VERTNORMALS => " - LUMP_VERTNORMALS",
VbspLumpType.LUMP_VERTNORMALINDICES => " - LUMP_VERTNORMALINDICES",
VbspLumpType.LUMP_DISP_LIGHTMAP_ALPHAS => " - LUMP_DISP_LIGHTMAP_ALPHAS",
VbspLumpType.LUMP_DISP_VERTS => " - LUMP_DISP_VERTS",
VbspLumpType.LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS => " - LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS",
VbspLumpType.LUMP_GAME_LUMP => " - LUMP_GAME_LUMP",
VbspLumpType.LUMP_LEAFWATERDATA => " - LUMP_LEAFWATERDATA",
VbspLumpType.LUMP_PRIMITIVES => " - LUMP_PRIMITIVES",
VbspLumpType.LUMP_PRIMVERTS => " - LUMP_PRIMVERTS",
VbspLumpType.LUMP_PRIMINDICES => " - LUMP_PRIMINDICES",
VbspLumpType.LUMP_PAKFILE => " - LUMP_PAKFILE",
VbspLumpType.LUMP_CLIPPORTALVERTS => " - LUMP_CLIPPORTALVERTS",
VbspLumpType.LUMP_CUBEMAPS => " - LUMP_CUBEMAPS",
VbspLumpType.LUMP_TEXDATA_STRING_DATA => " - LUMP_TEXDATA_STRING_DATA",
VbspLumpType.LUMP_TEXDATA_STRING_TABLE => " - LUMP_TEXDATA_STRING_TABLE",
VbspLumpType.LUMP_OVERLAYS => " - LUMP_OVERLAYS",
VbspLumpType.LUMP_LEAFMINDISTTOWATER => " - LUMP_LEAFMINDISTTOWATER",
VbspLumpType.LUMP_FACE_MACRO_TEXTURE_INFO => " - LUMP_FACE_MACRO_TEXTURE_INFO",
VbspLumpType.LUMP_DISP_TRIS => " - LUMP_DISP_TRIS",
VbspLumpType.LUMP_PHYSCOLLIDESURFACE => " - LUMP_PHYSCOLLIDESURFACE / LUMP_PROP_BLOB",
VbspLumpType.LUMP_WATEROVERLAYS => " - LUMP_WATEROVERLAYS",
VbspLumpType.LUMP_LIGHTMAPPAGES => " - LUMP_LIGHTMAPPAGES / LUMP_LEAF_AMBIENT_INDEX_HDR",
VbspLumpType.LUMP_LIGHTMAPPAGEINFOS => " - LUMP_LIGHTMAPPAGEINFOS / LUMP_LEAF_AMBIENT_INDEX",
VbspLumpType.LUMP_LIGHTING_HDR => " - LUMP_LIGHTING_HDR",
VbspLumpType.LUMP_WORLDLIGHTS_HDR => " - LUMP_WORLDLIGHTS_HDR",
VbspLumpType.LUMP_LEAF_AMBIENT_LIGHTING_HDR => " - LUMP_LEAF_AMBIENT_LIGHTING_HDR",
VbspLumpType.LUMP_LEAF_AMBIENT_LIGHTING => " - LUMP_LEAF_AMBIENT_LIGHTING",
VbspLumpType.LUMP_XZIPPAKFILE => " - LUMP_XZIPPAKFILE",
VbspLumpType.LUMP_FACES_HDR => " - LUMP_FACES_HDR",
VbspLumpType.LUMP_MAP_FLAGS => " - LUMP_MAP_FLAGS",
VbspLumpType.LUMP_OVERLAY_FADES => " - LUMP_OVERLAY_FADES",
VbspLumpType.LUMP_OVERLAY_SYSTEM_LEVELS => " - LUMP_OVERLAY_SYSTEM_LEVELS",
VbspLumpType.LUMP_PHYSLEVEL => " - LUMP_PHYSLEVEL",
VbspLumpType.LUMP_DISP_MULTIBLEND => " - LUMP_DISP_MULTIBLEND",
_ => string.Empty,
};
}
}
}

View File

@@ -0,0 +1,66 @@
using System.Text.RegularExpressions;
namespace SabreTools.Data.Extensions
{
public static class WiseScriptExtensions
{
/// <summary>
/// Convert a Wise function ID to the formal action name
/// </summary>
/// <param name="functionId">Function ID to convert</param>
/// <returns>The formal action name on success, null otherwise</returns>
public static string? FromWiseFunctionId(this string? functionId)
{
return functionId switch
{
"f0" => "Add Directory to PATH",
"f1" => "Add to AUTOEXEC.BAT",
"f2" => "Add to CONFIG.SYS",
"f3" => "Add to SYSTEM.INI",
"f8" => "Read INI Value",
"f9" => "Get Registry Key Value",
"f10" => "Register Font",
"f11" => "Win32 System Directory",
"f12" => "Check Configuration",
"f13" => "Search for File",
"f15" => "Read/Write Binary File",
"f16" => "Set Variable",
"f17" => "Get Environment Variable",
"f19" => "Check if File/Dir Exists",
"f20" => "Set File Attributes",
"f21" => "Set Files/Buffers",
"f22" => "Find File in Path",
"f23" => "Check Disk Space",
"f25" => "Insert Line Into Text File",
"f27" => "Parse String",
"f28" => "Exit Installation",
"f29" => "Self-Register OCXs/DLLs",
"f30" => "Install DirectX Components",
"f31" => "Wizard Block",
"f33" => "Read/Update Text File",
"f34" => "Post to HTTP Server",
"f35" => "Prompt for Filename",
"f36" => "Start/Stop Service",
"f38" => "Check HTTP Connection",
// Undefined function IDs
"f4" => $"UNDEFINED {functionId}",
"f5" => $"UNDEFINED {functionId}",
"f6" => $"UNDEFINED {functionId}",
"f7" => $"UNDEFINED {functionId}",
"f14" => $"UNDEFINED {functionId}",
"f18" => $"UNDEFINED {functionId}",
"f24" => $"UNDEFINED {functionId}",
"f26" => $"UNDEFINED {functionId}",
"f32" => $"UNDEFINED {functionId}",
"f37" => $"UNDEFINED {functionId}",
// External DLL
null => null,
#pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'
_ => Regex.IsMatch(functionId, @"^f[0-9]{1,2}$") ? $"UNDEFINED {functionId}" : $"External: {functionId}",
#pragma warning restore SYSLIB1045
};
}
}
}

View File

@@ -0,0 +1,62 @@
using System.Collections.Generic;
namespace SabreTools.Data.Extensions
{
public static class XZExtensions
{
/// <summary>
/// Decode a value from a variable-length integer
/// </summary>
/// <param name="value">Value to decode</param>
/// <param name="maxSize">Maximum number of bytes to parse</param>
/// <param name="length">Number of bytes parsed</param>
/// <returns>UInt64 representing the decoded integer</returns>
/// <see href="https://tukaani.org/xz/xz-file-format.txt"/>
public static ulong DecodeVariableLength(this byte[] value, int maxSize, out int length)
{
length = 0;
if (maxSize <= 0)
return 0;
if (maxSize > 9)
maxSize = 9;
ulong output = (ulong)(value[0] & 0x7F);
int i = 0;
while ((value[i++] & 0x80) != 0)
{
if (i >= maxSize || value[i] == 0x00)
return 0;
output |= (ulong)(value[i] & 0x7F) << (i * 7);
}
length = i;
return output;
}
/// <summary>
/// Encode a value to a variable-length integer
/// </summary>
/// <param name="value">Value to encode</param>
/// <returns>Byte array representing the encoded integer</returns>
/// <see href="https://tukaani.org/xz/xz-file-format.txt"/>
public static byte[] EncodeVariableLength(this ulong value)
{
if (value > long.MaxValue / 2)
return [];
var output = new List<byte>();
while (value >= 0x80)
{
output.Add((byte)(value | 0x80));
value >>= 7;
}
output.Add((byte)value);
return [.. output];
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using SabreTools.Numerics.Extensions;
namespace SabreTools.Data.Extensions
{
public static class XboxExecutableExtensions
{
/// <summary>
/// Convert a UInt32 to a formatted XBE title ID
/// </summary>
public static string ToFormattedXBETitleID(this uint value)
{
// Convert to a byte array
byte[] data = BitConverter.GetBytes(value);
// Create the prefix
string prefix1 = (0x41 <= data[3] && data[3] <= 0x5A) || (0x30 <= data[3] && data[3] <= 0x39)
? $"{(char)data[3]}"
: $"{data[3]:X2}";
string prefix2 = (0x41 <= data[2] && data[2] <= 0x5A) || (0x30 <= data[2] && data[2] <= 0x39)
? $"{(char)data[2]}"
: $"{data[2]:X2}";
// Create the serial
int offset = 0;
ushort serial = data.ReadUInt16LittleEndian(ref offset);
// Assemble and return
return $"{prefix1}{prefix2}-{serial:D3}";
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Text;
using SabreTools.Data.Models.ZArchive;
namespace SabreTools.Data.Extensions
{
public static class ZArchiveExtensions
{
/// <summary>
/// Retrieves the name of the specified node from the NameTable
/// </summary>
/// <param name="node">Node in the file tree</param>
/// <param name="nameTable">ZArchive NameTable</param>
/// <returns>UTF-8 string representing node's name</returns>
public static string? GetName(this FileDirectoryEntry node, NameTable nameTable)
{
// Check for a valid offset into the NameTable
uint nameOffset = node.NameOffsetAndTypeFlag & Constants.RootNode;
if (nameOffset == Constants.RootNode)
return null;
// Get the index into the name table
var index = Array.IndexOf(nameTable.NameTableOffsets, nameOffset);
if (index < 0)
return null;
// Get the name entry for the requested index
var nameEntry = nameTable.NameEntries[index];
if (nameEntry is null)
return null;
// Decode name to UTF-8
return Encoding.UTF8.GetString(nameEntry.NodeName);
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// This record type is undocumented but found in real media key blocks
/// </summary>
public sealed class CopyrightRecord : Record
{
/// <summary>
/// Null-terminated ASCII string representing the copyright
/// </summary>
[MarshalAs(UnmanagedType.LPStr)]
public string Copyright = string.Empty;
}
}

View File

@@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.AACS
{
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class DriveRevocationListEntry
{
/// <summary>
/// A 2-byte Range value indicates the range of revoked ID’s starting
/// from the ID contained in the record. A value of zero in the Range
/// field indicates that only one ID is being revoked, a value of one
/// in the Range field indicates two ID’s are being revoked, and so on.
/// </summary>
public ushort Range;
/// <summary>
/// A 6-byte Drive ID value identifying the Licensed Drive being revoked
/// (or the first in a range of Licensed Drives being revoked, in the
/// case of a non-zero Range value).
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] DriveID = new byte[6];
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// A properly formatted type 3 or type 4 Media Key Block contains exactly
/// one Drive Revocation List Record. It follows the Host Revocation List
/// Record, although it may not immediately follow it.
///
/// The Drive Revocation List Record is identical to the Host Revocation
/// List Record, except it has type 2016, and it contains Drive Revocation
/// List Entries, not Host Revocation List Entries. The Drive Revocation List
/// Entries refer to Drive IDs in the Drive Certificates.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class DriveRevocationListRecord : Record
{
/// <summary>
/// The total number of Drive Revocation List Entry fields that follow.
/// </summary>
public uint TotalNumberOfEntries { get; set; }
/// <summary>
/// Revocation list entries
/// </summary>
public DriveRevocationSignatureBlock[] SignatureBlocks { get; set; } = [];
}
}

View File

@@ -0,0 +1,17 @@
namespace SabreTools.Data.Models.AACS
{
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class DriveRevocationSignatureBlock
{
/// <summary>
/// The number of Drive Revocation List Entry fields in the signature block.
/// </summary>
public uint NumberOfEntries { get; set; }
/// <summary>
/// A list of 8-byte Host Drive List Entry fields, the length of this
/// list being equal to the number in the signature block.
/// </summary>
public DriveRevocationListEntry[] EntryFields { get; set; } = [];
}
}

View File

@@ -0,0 +1,24 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// A properly formatted MKB shall contain an End of Media Key Block Record.
/// When a device encounters this Record it stops processing the MKB, using
/// whatever Km value it has calculated up to that point as the final Km for
/// that MKB (pending possible checks for correctness of the key, as
/// described previously).
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class EndOfMediaKeyBlockRecord : Record
{
/// <summary>
/// AACS LA’s signature on the data in the Media Key Block up to,
/// but not including, this record. Devices depending on the Version
/// Number in the Type and Version Record must verify the signature.
/// Other devices may ignore the signature data. If any device
/// determines that the signature does not verify or is omitted, it
/// must refuse to use the Media Key.
/// </summary>
/// <remarks><see cref="RecordLength"/>-4 bytes</remarks>
public byte[] SignatureData { get; set; } = [];
}
}

View File

@@ -0,0 +1,69 @@
namespace SabreTools.Data.Models.AACS
{
public enum MediaKeyBlockType : uint
{
/// <summary>
/// (Type 3). This is a normal Media Key Block suitable for being recorded
/// on a AACS Recordable Media. Both Class I and Class II Licensed Products
/// use it to directly calculate the Media Key.
/// </summary>
Type3 = 0x00031003,
/// <summary>
/// (Type 4). This is a Media Key Block that has been designed to use Key
/// Conversion Data (KCD). Thus, it is suitable only for pre-recorded media
/// from which the KCD is derived. Both Class I and Class II Licensed Products
/// use it to directly calculate the Media Key.
/// </summary>
Type4 = 0x00041003,
/// <summary>
/// (Type 10). This is a Class II Media Key Block (one that has the functionality
/// of a Sequence Key Block). This can only be processed by Class II Licensed
/// Products; Class I Licensed Products are revoked in Type 10 Media Key Blocks
/// and cannot process them. This type does not contain the Host Revocation List
/// Record, the Drive Revocation List Record, and the Media Key Data Record, as
/// described in the following sections. It does contain the records shown in
/// Section 3.2.5.2, which are only processed by Class II Licensed Products.
/// </summary>
Type10 = 0x000A1003,
/// <summary>
/// Type 2.0 Category C.
/// This is the Media Key Block Type found on "UHD" media (AACS v2.0)
/// </summary>
/// <see href="https://code.videolan.org/videolan/libaacs/-/blob/master/src/libaacs/mkb.h"/>
Type20 = 0x48141003,
/// <summary>
/// Type 2.1 Category C.
/// This is the Media Key Block Type found on "UHD" media (AACS v2.1)
/// </summary>
/// <see href="https://code.videolan.org/videolan/libaacs/-/blob/master/src/libaacs/mkb.h"/>
Type21 = 0x48151003,
}
public enum RecordType : byte
{
EndOfMediaKeyBlock = 0x02,
ExplicitSubsetDifference = 0x04,
MediaKeyData = 0x05,
SubsetDifferenceIndex = 0x07,
MediaKeyVariantData = 0x0C,
TypeAndVersion = 0x10,
DriveRevocationList = 0x20,
HostRevocationList = 0x21,
VerifyMediaKey = 0x81,
// Not documented
Copyright = 0x7F,
// Record types only found in UHD media (AACS v2)
// <see href="https://code.videolan.org/videolan/libaacs/-/blob/master/src/devtools/mkb_dump.c"/>
Unknown0x28_AACS2 = 0x28,
DriveRevocationList_AACS2 = 0x30,
HostRevocationList_AACS2 = 0x31,
VerifyMediaKey_AACS2 = 0x86,
EmptyRecord0xF8_AACS2 = 0xF8,
}
}

View File

@@ -0,0 +1,11 @@
namespace SabreTools.Data.Models.AACS
{
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class ExplicitSubsetDifferenceRecord : Record
{
/// <summary>
/// In this record, each subset-difference is encoded with 5 bytes.
/// </summary>
public SubsetDifference[] SubsetDifferences { get; set; } = [];
}
}

View File

@@ -0,0 +1,13 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// This represents any record that does not have a concrete model yet
/// </summary>
public sealed class GenericRecord : Record
{
/// <summary>
/// Unparsed data comprising the record after the header
/// </summary>
public byte[] Data { get; set; } = [];
}
}

View File

@@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.AACS
{
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class HostRevocationListEntry
{
/// <summary>
/// A 2-byte Range value indicates the range of revoked ID’s starting
/// from the ID contained in the record. A value of zero in the Range
/// field indicates that only one ID is being revoked, a value of one
/// in the Range field indicates two ID’s are being revoked, and so on.
/// </summary>
public ushort Range;
/// <summary>
/// A 6-byte Host ID value identifying the host being revoked (or the
/// first in a range of hosts being revoked, in the case of a non-zero
/// Range value).
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] HostID = new byte[6];
}
}

View File

@@ -0,0 +1,29 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// A properly formatted type 3 or type 4 Media Key Block shall have exactly
/// one Host Revocation List Record as its second record. This record provides
/// a list of hosts that have been revoked by the AACS LA. The AACS specification
/// is applicable to PC-based system where a Licensed Drive and PC Host act
/// together as the Recording Device and/or Playback Device for AACS Content.
/// AACS uses a drive-host authentication protocol for the host to verify the
/// integrity of the data received from the Licensed Drive, and for the Licensed
/// Drive to check the validity of the host application. The Type and Version
/// Record and the Host Revocation List Record are guaranteed to be the first two
/// records of a Media Key Block, to make it easier for Licensed Drives to extract
/// this data from an arbitrary Media Key Block.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class HostRevocationListRecord : Record
{
/// <summary>
/// The total number of Host Revocation List Entry fields that follow.
/// </summary>
public uint TotalNumberOfEntries { get; set; }
/// <summary>
/// Revocation list entries
/// </summary>
public HostRevocationSignatureBlock[] SignatureBlocks { get; set; } = [];
}
}

View File

@@ -0,0 +1,17 @@
namespace SabreTools.Data.Models.AACS
{
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class HostRevocationSignatureBlock
{
/// <summary>
/// The number of Host Revocation List Entry fields in the signature block.
/// </summary>
public uint NumberOfEntries { get; set; }
/// <summary>
/// A list of 8-byte Host Revocation List Entry fields, the length of this
/// list being equal to the number in the signature block.
/// </summary>
public HostRevocationListEntry[] EntryFields { get; set; } = [];
}
}

View File

@@ -0,0 +1,14 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// A Media Key Block is formatted as a sequence of contiguous Records.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class MediaKeyBlock
{
/// <summary>
/// Records
/// </summary>
public Record[] Records { get; set; } = [];
}
}

View File

@@ -0,0 +1,18 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// This record gives the associated encrypted media key data for the
/// subset-differences identified in the Explicit Subset-Difference Record.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class MediaKeyDataRecord : Record
{
/// <summary>
/// Each subset difference has its associated 16 bytes in this
/// record, in the same order it is encountered in the subset-difference
/// record. This 16 bytes is the ciphertext value C in the media
/// key calculation.
/// </summary>
public byte[][] MediaKeyData { get; set; } = [];
}
}

View File

@@ -0,0 +1,30 @@
using SabreTools.Numerics;
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// Each Record begins with a one-byte Record Type field, followed by a
/// three-byte Record Length field.
///
/// The following subsections describe the currently defined Record types,
/// and how a device processes each. All multi-byte integers, including
/// the length field, are “Big Endian”; in other words, the most significant
/// byte comes first in the record.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public abstract class Record
{
/// <summary>
/// The Record Type field value indicates the type of the Record.
/// </summary>
public RecordType RecordType { get; set; }
/// <summary>
/// The Record Length field value indicates the number of bytes in
/// the Record, including the Record Type and the Record Length
/// fields themselves. Record lengths are always multiples of 4 bytes.
/// </summary>
// <remarks>UInt24 not UInt32</remarks>
public UInt24 RecordLength { get; set; } = new();
}
}

View File

@@ -0,0 +1,23 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.AACS
{
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class SubsetDifference
{
/// <summary>
/// The mask for u is given by the first byte. That byte is
/// treated as a number, the number of low-order 0-bits in
/// the mask. For example, the value 0x01 denotes a mask of
/// 0xFFFFFFFE; value 0x0A denotes a mask of 0xFFFFFC00.
/// </summary>
public byte Mask;
/// <summary>
/// The last 4 bytes are the uv number, most significant
/// byte first.
/// </summary>
public uint Number;
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// This is a speed-up record which can be ignored by devices not wishing to
/// take advantage of it. It is a lookup table which allows devices to quickly
/// find their subset-difference in the Explicit Subset-Difference record,
/// without processing the entire record. This Subset-Difference Index record
/// is always present, and always precedes the Explicit Subset-Difference record
/// in the MKB, although it does not necessarily immediately precede it.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class SubsetDifferenceIndexRecord : Record
{
/// <summary>
/// The number of devices per index offset.
/// </summary>
public uint Span { get; set; }
/// <summary>
/// These offsets refer to the offset within the following Explicit
/// Subset-Difference record, with 0 being the start of the record.
/// </summary>
// <remarks>UInt24 not UInt32</remarks>
public uint[] Offsets { get; set; } = [];
}
}

View File

@@ -0,0 +1,32 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// Devices, except for recording devices which are writing Media Key Block
/// Extensions, may ignore this record. Recording devices shall verify the
/// signature (see End of Media Key Block record) and use the Version Number
/// in this record to determine if a new Media Key BLock Extension is, in
/// fact, more recent than the Media Key Block Extension that is currently
/// on the media.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class TypeAndVersionRecord : Record
{
/// <summary>
/// For AACS applications, the MKBType field is one of three values.
/// It is not an error for a Type 3 Media Key Block to be used for
/// controlling access to AACS Content on pre- recorded media. In
/// this case, the device shall not use the KCD.
/// </summary>
public MediaKeyBlockType MediaKeyBlockType { get; set; }
/// <summary>
/// The Version Number is a 32-bit unsigned integer. Each time the
/// licensing agency changes the revocation, it increments the version
/// number and inserts the new value in subsequent Media Key Blocks.
/// Thus, larger values indicate more recent Media Key Blocks. The
/// Version Numbers begin at 1; 0 is a special value used for test
/// Media Key Blocks.
/// </summary>
public uint VersionNumber { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
namespace SabreTools.Data.Models.AACS
{
/// <summary>
/// A properly formatted MKB shall have exactly one Verify Media Key Record
/// as its first record. The presence of the Verify Media Key Record in an MKB
/// is mandatory, but the use of the Record by a device is not mandatory. The
/// device may use the Verify Media Key Record to verify the correctness of a
/// given MKB, or of its processing of it. If everything is correct, the device
/// should observe the condition:
/// [AES_128D(vKm, C]msb_64 == 0x0123456789ABCDEF)]
/// where Km is the Media Key value.
/// </summary>
/// <see href="https://aacsla.com/wp-content/uploads/2019/02/AACS_Spec_Common_Final_0953.pdf"/>
public sealed class VerifyMediaKeyRecord : Record
{
/// <summary>
/// Bytes 4 through 19 of the Record contain the ciphertext value
/// Cv = AES-128E (Km, 0x0123456789ABCDEF || 0xXXXXXXXXXXXXXXXX)
/// where 0xXXXXXXXXXXXXXXXX is an arbitrary 8-byte value, and Km is
/// the correct final Media Key value.
/// </summary>
/// <remarks>0x10 bytes</remarks>
public byte[] CiphertextValue { get; set; } = new byte[0x10];
}
}

View File

@@ -0,0 +1,59 @@
using System;
#pragma warning disable CA1069 // Enums values should not be duplicated
namespace SabreTools.Data.Models.ASN1
{
/// <summary>
/// ASN.1 type indicators
/// </summary>
[Flags]
public enum ASN1Type : byte
{
#region Types
V_ASN1_EOC = 0x00,
V_ASN1_BOOLEAN = 0x01,
V_ASN1_INTEGER = 0x02,
V_ASN1_BIT_STRING = 0x03,
V_ASN1_OCTET_STRING = 0x04,
V_ASN1_NULL = 0x05,
V_ASN1_OBJECT = 0x06,
V_ASN1_OBJECT_DESCRIPTOR = 0x07,
V_ASN1_EXTERNAL = 0x08,
V_ASN1_REAL = 0x09,
V_ASN1_ENUMERATED = 0x0A,
V_ASN1_UTF8STRING = 0x0C,
V_ASN1_SEQUENCE = 0x10,
V_ASN1_SET = 0x11,
V_ASN1_NUMERICSTRING = 0x12,
V_ASN1_PRINTABLESTRING = 0x13,
V_ASN1_T61STRING = 0x14,
V_ASN1_TELETEXSTRING = 0x14,
V_ASN1_VIDEOTEXSTRING = 0x15,
V_ASN1_IA5STRING = 0x16,
V_ASN1_UTCTIME = 0x17,
V_ASN1_GENERALIZEDTIME = 0x18,
V_ASN1_GRAPHICSTRING = 0x19,
V_ASN1_ISO64STRING = 0x1A,
V_ASN1_VISIBLESTRING = 0x1A,
V_ASN1_GENERALSTRING = 0x1B,
V_ASN1_UNIVERSALSTRING = 0x1C,
V_ASN1_BMPSTRING = 0x1E,
#endregion
#region Modifiers
// Commented out because it is the default
// and can interfere with V_ASN1_EOC
// V_ASN1_UNIVERSAL = 0x00,
V_ASN1_PRIMITIVE_TAG = 0x1F,
V_ASN1_CONSTRUCTED = 0x20,
V_ASN1_APPLICATION = 0x40,
V_ASN1_CONTEXT_SPECIFIC = 0x80,
V_ASN1_PRIVATE = 0xC0,
#endregion
}
}

View File

@@ -0,0 +1,23 @@
namespace SabreTools.Data.Models.ASN1
{
/// <summary>
/// ASN.1 type/length/value class that all types are based on
/// </summary>
public class TypeLengthValue
{
/// <summary>
/// The ASN.1 type
/// </summary>
public ASN1Type Type { get; set; }
/// <summary>
/// Length of the value
/// </summary>
public ulong Length { get; set; }
/// <summary>
/// Generic value associated with <see cref="Type"/>
/// </summary>
public object? Value { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SabreTools.Data.Models.AdvancedInstaller
{
public static class Constants
{
public static readonly byte[] SignatureBytes = [0x41, 0x44, 0x56, 0x49, 0x4E, 0x53, 0x54, 0x53, 0x46, 0x58];
public const string SignatureString = "ADVINSTSFX";
}
}

View File

@@ -0,0 +1,61 @@
namespace SabreTools.Data.Models.AdvancedInstaller
{
/// <summary>
/// Single entry in the file table
/// </summary>
public class FileEntry
{
/// <summary>
/// Unknown
/// </summary>
/// <remarks>
/// Observed values:
/// - 00 00 00 00 (INI)
/// - 01 00 00 00 (MSI, CAB)
/// - 05 00 00 00 (DLL)
/// </remarks>
public uint Unknown0 { get; set; }
/// <summary>
/// Unknown
/// </summary>
/// <remarks>
/// Observed values:
/// - 00 00 00 00 (MSI)
/// - 01 00 00 00 (CAB)
/// - 03 00 00 00 (INI)
/// - 0C 00 00 00 (DLL)
/// </remarks>
public uint? Unknown1 { get; set; }
/// <summary>
/// Unknown, always 0?
/// </summary>
/// <remarks>
/// Observed values:
/// - 00 00 00 00 (DLL, MSI, CAB, INI)
/// </remarks>
public uint? Unknown2 { get; set; }
/// <summary>
/// Size of the file
/// </summary>
public uint FileSize { get; set; }
/// <summary>
/// Offset of the file relative to the start
/// of the SFX stub
/// </summary>
public uint FileOffset { get; set; }
/// <summary>
/// Size of the file name in characters
/// </summary>
public uint NameSize { get; set; }
/// <summary>
/// Unicode-encoded file name
/// </summary>
public string Name { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,109 @@
namespace SabreTools.Data.Models.AdvancedInstaller
{
/// <summary>
/// Structure similar to the end of central directory
/// header in PKZIP files
/// </summary>
public class Footer
{
/// <summary>
/// Unknown
/// </summary>
/// <remarks>
/// Observed values:
/// - 00 00 00 00
/// </remarks>
public uint Unknown0 { get; set; }
/// <summary>
/// Size of the original filename?
/// </summary>
/// <remarks>Doesn't exist in some cases?</remarks>
public uint? OriginalFilenameSize { get; set; }
/// <summary>
/// Unicode-encoded original filename?
/// </summary>
/// <remarks>Doesn't exist in some cases?</remarks>
public string? OriginalFilename { get; set; }
/// <summary>
/// Unknown, possibly a string count?
/// </summary>
/// <remarks>
/// Only seen when the preceeding two fields exist
///
/// Observed values:
/// - 01 00 00 00
/// </remarks>
public uint? Unknown1 { get; set; }
/// <summary>
/// Pointer to <see cref="Unknown0"/>?
/// </summary>
public uint FooterOffset { get; set; }
/// <summary>
/// Number of entries that preceed the footer
/// </summary>
public uint EntryCount { get; set; }
/// <summary>
/// Unknown
/// </summary>
/// <remarks>
/// Observed values:
/// - 64 00 00 00
/// </remarks>
public uint Unknown2 { get; set; }
/// <summary>
/// Unknown offset
/// </summary>
/// <remarks>
/// Points to <see cref="Unknown0"/> if no original filename.
/// Points to <see cref="EntryCount"/> if contains an original filename.
/// </remarks>
public uint UnknownOffset { get; set; }
/// <summary>
/// Offset of the start of the file table
/// </summary>
public uint TablePointer { get; set; }
/// <summary>
/// Offset to the start of the file data
/// </summary>
public uint FileDataStart { get; set; }
/// <summary>
/// Hex string that looks like a key or other identifier
/// </summary>
/// <remarks>32 bytes</remarks>
public string HexString { get; set; } = string.Empty;
/// <summary>
/// Unknown
/// </summary>
/// <remarks>
/// Offset pointer to <see cref="FileDataStart"/>
/// relative to the end of the signature if no filename
/// exists.
///
/// Observed values:
/// - 32 00 00 00 (No original filename)
/// - 13 02 00 00 (Original filename)
/// </remarks>
public uint Unknown3 { get; set; }
/// <summary>
/// "ADVINSTSFX"
/// </summary>
public string Signature { get; set; } = string.Empty;
/// <summary>
/// Unknown, always 0? Padding?
/// </summary>
public ushort? Unknown4 { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
namespace SabreTools.Data.Models.AdvancedInstaller
{
/// <summary>
/// Represents the structure at the end of a Caphyon
/// Advanced Installer SFX file. These SFX files store
/// all files uncompressed sequentially in the overlay
/// of an executable.
///
/// The design is similar to the end of central directory
/// in a PKZIP file. The footer needs to be read before
/// the entry table as both the pointer to the start of
/// the table as well as the entry count are included there.
///
/// The layout of this is derived from the layout in the
/// physical file.
/// </summary>
public class SFX
{
/// <summary>
/// Set of file entries
/// </summary>
public FileEntry[] Entries { get; set; } = [];
/// <summary>
/// Footer representing the central directory
/// </summary>
public Footer Footer { get; set; } = new();
}
}

View File

@@ -0,0 +1,206 @@
using System.Xml;
using System.Xml.Serialization;
#pragma warning disable IDE1006 // Naming Styles
namespace SabreTools.Data.Models.ArchiveDotOrg
{
[XmlRoot("file")]
public class File
{
[XmlAttribute("name")]
public string? Name { get; set; }
/// <remarks>Is this a set of defined values?</remarks>
[XmlAttribute("source")]
public string? Source { get; set; }
[XmlElement("btih")]
public string? BitTorrentMagnetHash { get; set; }
[XmlElement("mtime")]
public string? LastModifiedTime { get; set; }
[XmlElement("size")]
public string? Size { get; set; }
[XmlElement("md5")]
public string? MD5 { get; set; }
[XmlElement("crc32")]
public string? CRC32 { get; set; }
[XmlElement("sha1")]
public string? SHA1 { get; set; }
[XmlElement("filecount")]
public long? FileCount { get; set; }
/// <remarks>Is this a set of defined values?</remarks>
[XmlElement("format")]
public string? Format { get; set; }
[XmlElement("original")]
public string? Original { get; set; }
/// <remarks>Is this a set of defined values?</remarks>
[XmlElement("summation")]
public string? Summation { get; set; }
[XmlElement("matrix_number")]
public string? MatrixNumber { get; set; }
[XmlElement("collection-catalog-number")]
public string? CollectionCatalogNumber { get; set; }
[XmlElement("publisher")]
public string? Publisher { get; set; }
[XmlElement("comment")]
public string? Comment { get; set; }
#region ASR-Related
[XmlElement("asr_detected_lang")]
public string? ASRDetectedLang { get; set; }
[XmlElement("asr_detected_lang_conf")]
public string? ASRDetectedLangConf { get; set; }
[XmlElement("asr_transcribed_lang")]
public string? ASRTranscribedLang { get; set; }
[XmlElement("whisper_asr_module_version")]
public string? WhisperASRModuleVersion { get; set; }
[XmlElement("whisper_model_hash")]
public string? WhisperModelHash { get; set; }
[XmlElement("whisper_model_name")]
public string? WhisperModelName { get; set; }
[XmlElement("whisper_version")]
public string? WhisperVersion { get; set; }
#endregion
#region OCR-Related
[XmlElement("cloth_cover_detection_module_version")]
public string? ClothCoverDetectionModuleVersion { get; set; }
[XmlElement("hocr_char_to_word_hocr_version")]
public string? hOCRCharToWordhOCRVersion { get; set; }
[XmlElement("hocr_char_to_word_module_version")]
public string? hOCRCharToWordModuleVersion { get; set; }
[XmlElement("hocr_fts_text_hocr_version")]
public string? hOCRFtsTexthOCRVersion { get; set; }
[XmlElement("hocr_fts_text_module_version")]
public string? hOCRFtsTextModuleVersion { get; set; }
[XmlElement("hocr_pageindex_hocr_version")]
public string? hOCRPageIndexhOCRVersion { get; set; }
[XmlElement("hocr_pageindex_module_version")]
public string? hOCRPageIndexModuleVersion { get; set; }
[XmlElement("ocr")]
public string? TesseractOCR { get; set; }
[XmlElement("ocr_converted")]
public string? TesseractOCRConverted { get; set; }
[XmlElement("ocr_detected_lang")]
public string? TesseractOCRDetectedLang { get; set; }
[XmlElement("ocr_detected_lang_conf")]
public string? TesseractOCRDetectedLangConf { get; set; }
[XmlElement("ocr_detected_script")]
public string? TesseractOCRDetectedScript { get; set; }
[XmlElement("ocr_detected_script_conf")]
public string? TesseractOCRDetectedScriptConf { get; set; }
[XmlElement("ocr_module_version")]
public string? TesseractOCRModuleVersion { get; set; }
[XmlElement("ocr_parameters")]
public string? TesseractOCRParameters { get; set; }
[XmlElement("pdf_module_version")]
public string? PDFModuleVersion { get; set; }
[XmlElement("word_conf_0_10")]
public string? WordConfidenceInterval0To10 { get; set; }
[XmlElement("word_conf_11_20")]
public string? WordConfidenceInterval11To20 { get; set; }
[XmlElement("word_conf_21_30")]
public string? WordConfidenceInterval21To30 { get; set; }
[XmlElement("word_conf_31_40")]
public string? WordConfidenceInterval31To40 { get; set; }
[XmlElement("word_conf_41_50")]
public string? WordConfidenceInterval41To50 { get; set; }
[XmlElement("word_conf_51_60")]
public string? WordConfidenceInterval51To60 { get; set; }
[XmlElement("word_conf_61_70")]
public string? WordConfidenceInterval61To70 { get; set; }
[XmlElement("word_conf_71_80")]
public string? WordConfidenceInterval71To80 { get; set; }
[XmlElement("word_conf_81_90")]
public string? WordConfidenceInterval81To90 { get; set; }
[XmlElement("word_conf_91_100")]
public string? WordConfidenceInterval91To100 { get; set; }
#endregion
#region Media-Related
[XmlElement("album")]
public string? Album { get; set; }
[XmlElement("artist")]
public string? Artist { get; set; }
[XmlElement("bitrate")]
public string? Bitrate { get; set; }
[XmlElement("creator")]
public string? Creator { get; set; }
[XmlElement("height")]
public string? Height { get; set; }
[XmlElement("length")]
public string? Length { get; set; }
[XmlElement("preview-image")]
public string? PreviewImage { get; set; }
/// <remarks>Is this a set of defined values?</remarks>
[XmlElement("rotation")]
public string? Rotation { get; set; }
[XmlElement("title")]
public string? Title { get; set; }
[XmlElement("track")]
public string? Track { get; set; }
[XmlElement("width")]
public string? Width { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,12 @@
using System.Xml;
using System.Xml.Serialization;
namespace SabreTools.Data.Models.ArchiveDotOrg
{
[XmlRoot("files")]
public class Files
{
[XmlElement("file")]
public File[]? File { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
namespace SabreTools.Data.Models.Atari7800
{
/// <summary>
/// Atari 7800 headered cart
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
public class Cart
{
/// <summary>
/// A78 header
/// </summary>
/// <remarks>If omitted, format is technically BIN</remarks>
public Header? Header { get; set; }
/// <summary>
/// Cartridge data
/// </summary>
public byte[] Data { get; set; } = [];
}
}

View File

@@ -0,0 +1,49 @@
namespace SabreTools.Data.Models.Atari7800
{
public static class Constants
{
/// <summary>
/// A78 magic string (null-padded)
/// </summary>
public static readonly byte[] MagicBytesWithNull =
[
0x41, 0x54, 0x41, 0x52, 0x49, 0x37, 0x38, 0x30,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
/// <summary>
/// A78 magic string (null-padded)
/// </summary>
public const string MagicStringWithNull = "ATARI7800\0\0\0\0\0\0\0";
/// <summary>
/// A78 magic string (space-padded)
/// </summary>
public static readonly byte[] MagicBytesWithSpace =
[
0x41, 0x54, 0x41, 0x52, 0x49, 0x37, 0x38, 0x30,
0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
];
/// <summary>
/// A78 magic string (space-padded)
/// </summary>
public const string MagicStringWithSpace = "ATARI7800 ";
/// <summary>
/// A78 header end magic text
/// </summary>
public static readonly byte[] HeaderEndMagicBytes =
[
0x41, 0x43, 0x54, 0x55, 0x41, 0x4C, 0x20, 0x43,
0x41, 0x52, 0x54, 0x20, 0x44, 0x41, 0x54, 0x41,
0x20, 0x53, 0x54, 0x41, 0x52, 0x54, 0x53, 0x20,
0x48, 0x45, 0x52, 0x45,
];
/// <summary>
/// A78 header end magic text
/// </summary>
public const string HeaderEndMagicString = "ACTUAL CART DATA STARTS HERE";
}
}

View File

@@ -0,0 +1,380 @@
using System;
namespace SabreTools.Data.Models.Atari7800
{
/// <summary>
/// Audio device (v4+ only)
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
[Flags]
public enum AudioDevice : ushort
{
#region POKEY location
/// <summary>
/// POKEY - none
/// </summary>
PokeyNone = 0b00000000,
/// <summary>
/// POKEY - @440
/// </summary>
Pokey440 = 0b00000001,
/// <summary>
/// POKEY - @450
/// </summary>
Pokey450 = 0b00000010,
/// <summary>
/// POKEY - @450+@440
/// </summary>
Pokey450Plus440 = 0b00000011,
/// <summary>
/// POKEY - @800
/// </summary>
Pokey800 = 0b00000100,
/// <summary>
/// POKEY - @4000
/// </summary>
Pokey4000 = 0b00000101,
#endregion
/// <summary>
/// YM2151 @460
/// </summary>
YM2151460 = 0b00001000,
/// <summary>
/// COVOX @430
/// </summary>
COVOX430 = 0b00010000,
/// <summary>
/// ADPCM Audio Stream @420
/// </summary>
ADPCMAudioStream420 = 0b00100000,
}
/// <summary>
/// Cart type specifications
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
[Flags]
public enum CartType : ushort
{
/// <summary>
/// pokey at $4000
/// </summary>
PokeyAt4000 = 0b00000000_00000001,
/// <summary>
/// supergame bank switched
/// </summary>
SupergameBankSwitched = 0b00000000_00000010,
/// <summary>
/// supergame ram at $4000
/// </summary>
SupergameRamAt4000 = 0b00000000_00000100,
/// <summary>
/// rom at $4000
/// </summary>
RomAt4000 = 0b00000000_00001000,
/// <summary>
/// bank 6 at $4000
/// </summary>
Bank6At4000 = 0b00000000_00010000,
/// <summary>
/// banked ram
/// </summary>
BankedRam = 0b00000000_00100000,
/// <summary>
/// pokey at $450
/// </summary>
PokeyAt450 = 0b00000000_01000000,
/// <summary>
/// mirror ram at $4000
/// </summary>
MirrorRamAt4000 = 0b00000000_10000000,
/// <summary>
/// activision banking
/// </summary>
ActivisionBanking = 0b00000001_00000000,
/// <summary>
/// absolute banking
/// </summary>
AbsoluteBanking = 0b00000010_00000000,
/// <summary>
/// pokey at $440
/// </summary>
PokeyAt440 = 0b00000100_00000000,
/// <summary>
/// ym2151 at $460/$461
/// </summary>
Ym2151At460461 = 0b00001000_00000000,
/// <summary>
/// souper
/// </summary>
Souper = 0b00010000_00000000,
/// <summary>
/// banksets
/// </summary>
Banksets = 0b00100000_00000000,
/// <summary>
/// halt banked ram
/// </summary>
HaltBankedRam = 0b01000000_00000000,
/// <summary>
/// pokey@800
/// </summary>
PokeyAt800 = 0b10000000_00000000,
}
/// <summary>
/// Controller type
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
public enum ControllerType : byte
{
/// <summary>
/// none
/// </summary>
None = 0,
/// <summary>
/// 7800 joystick
/// </summary>
Joystick = 1,
/// <summary>
/// lightgun
/// </summary>
Lightgun = 2,
/// <summary>
/// paddle
/// </summary>
Paddle = 3,
/// <summary>
/// trakball
/// </summary>
Trakball = 4,
/// <summary>
/// 2600 joystick
/// </summary>
VcsJoystick = 5,
/// <summary>
/// 2600 driving
/// </summary>
VcsDriving = 6,
/// <summary>
/// 2600 keypad
/// </summary>
VcsKeypad = 7,
/// <summary>
/// ST mouse
/// </summary>
STMouse = 8,
/// <summary>
/// Amiga mouse
/// </summary>
AmigaMouse = 9,
/// <summary>
/// AtariVox/SaveKey
/// </summary>
AtariVoxSaveKey = 10,
/// <summary>
/// SNES2Atari
/// </summary>
SNES2Atari = 11,
/// <summary>
/// Mega7800
/// </summary>
Mega7800 = 12,
}
/// <summary>
/// Interrupt (v4+ only)
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
[Flags]
public enum Interrupt : ushort
{
None = 0b00000000,
/// <summary>
/// POKEY 1 (@450 | @800 | @4000)
/// </summary>
Pokey1 = 0b00000001,
/// <summary>
/// POKEY 2 (@440)
/// </summary>
Pokey2 = 0b00000010,
/// <summary>
/// YM2151
/// </summary>
YM2151 = 0b00000100,
}
/// <summary>
/// Mapper (v4+ only)
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
public enum Mapper : byte
{
Linear = 0,
SuperGame = 1,
Activision = 2,
Absolute = 3,
Souper = 4,
}
/// <summary>
/// Mapper options/details (v4+ only)
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
[Flags]
public enum MapperOptions : byte
{
#region Linear
/// <summary>
/// Option at @4000 - none
/// </summary>
LinearNone = 0b00000000,
/// <summary>
/// Option at @4000 - 16K RAM
/// </summary>
Linear16KRAM = 0b00000001,
/// <summary>
/// Option at @4000 - 8K EXRAM/A8
/// </summary>
Linear8KEXRAMA8 = 0b00000010,
/// <summary>
/// Option at @4000 - 32K EXRAM/M2
/// </summary>
Linear32KEXRAMM2 = 0b00000011,
#endregion
#region SuperGame
/// <summary>
/// Option at @4000 - none
/// </summary>
SuperGameNone = 0b00000000,
/// <summary>
/// Option at @4000 - 16K RAM
/// </summary>
SuperGame16KRAM = 0b00000001,
/// <summary>
/// Option at @4000 - 8K EXRAM/A8
/// </summary>
SuperGame8KEXRAMA8 = 0b00000010,
/// <summary>
/// Option at @4000 - 32K EXRAM/M2
/// </summary>
SuperGame32KEXRAMM2 = 0b00000011,
/// <summary>
/// Option at @4000 - EXROM
/// </summary>
SuperGameEXROM = 0b00000100,
/// <summary>
/// Option at @4000 - EXFIX
/// </summary>
SuperGameEXFIX = 0b00000101,
/// <summary>
/// Option at @4000 - 32k EXRAM/X2
/// </summary>
SuperGame32KEXRAMX2 = 0b00000110,
#endregion
/// <summary>
/// Bankset ROM
/// </summary>
BanksetRom = 0b10000000,
}
/// <summary>
/// Save device
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
public enum SaveDevice : byte
{
None = 0b00000000,
/// <summary>
/// HSC
/// </summary>
HSC = 0b00000001,
/// <summary>
/// SaveKey/AtariVox
/// </summary>
SaveKeyAtariVox = 0b00000010,
}
/// <summary>
/// Slot passthrough device
/// </summary>
public enum SlotPassthroughDevice : byte
{
None = 0b00000000,
XM = 0b00000001,
}
/// <summary>
/// TV type
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
[Flags]
public enum TVType : byte
{
NTSC = 0b00000000,
PAL = 0b00000001,
Component = 0b00000000,
Composite = 0b00000010,
SingleRegion = 0b00000000,
MultiRegion = 0b00000100,
}
}

View File

@@ -0,0 +1,115 @@
namespace SabreTools.Data.Models.Atari7800
{
/// <summary>
/// Atari 7800 emulator header
/// </summary>
/// <see href="https://7800.8bitdev.org/index.php/A78_Header_Specification"/>
public class Header
{
/// <summary>
/// Header version
/// </summary>
/// <remarks>
/// Current header version is 4.
/// If no V4 features are used, this should be set to 3.
/// </remarks>
public byte HeaderVersion { get; set; }
/// <summary>
/// "ATARI7800" with 7 null bytes following
/// </summary>
public byte[] MagicText { get; set; } = new byte[16];
/// <summary>
/// Cart title, encoding not specified
/// </summary>
public byte[] CartTitle { get; set; } = new byte[32];
/// <summary>
/// ROM size without header data
/// </summary>
/// <remarks>
/// Endianness possibly varies by version?
/// Version 1 - Big-endian
/// Version 2 - ?????
/// Version 3 - Documented as little-endian (unconfirmed)
/// Version 4 - Documented as little-endian (unconfirmed)
/// </remarks>
public uint RomSizeWithoutHeader { get; set; }
/// <summary>
/// Cart type flags
/// </summary>
public CartType CartType { get; set; }
/// <summary>
/// Controller 1 type
/// </summary>
public ControllerType Controller1Type { get; set; }
/// <summary>
/// Controller 2 type
/// </summary>
public ControllerType Controller2Type { get; set; }
/// <summary>
/// TV type
/// </summary>
public TVType TVType { get; set; }
/// <summary>
/// Save device
/// </summary>
public SaveDevice SaveDevice { get; set; }
/// <summary>
/// Reserved
/// </summary>
public byte[] Reserved { get; set; } = new byte[4];
/// <summary>
/// Slot passthrough device
/// </summary>
public SlotPassthroughDevice SlotPassthroughDevice { get; set; }
#region Version 4+
/// <summary>
/// Mapper
/// </summary>
/// <remarks>v4+ only</remarks>
public Mapper Mapper { get; set; }
/// <summary>
/// Mapper options
/// </summary>
/// <remarks>v4+ only</remarks>
public MapperOptions MapperOptions { get; set; }
/// <summary>
/// Audio device(s)
/// </summary>
public AudioDevice AudioDevice { get; set; }
/// <summary>
/// Interrupt
/// </summary>
public Interrupt Interrupt { get; set; }
#endregion
/// <summary>
/// Padding from end of header data to end magic text
/// </summary>
/// <remarks>
/// 36 bytes in versions lower than 4.
/// 30 bytes in versions 4 and above.
/// </remarks>
public byte[] Padding { get; set; } = [];
/// <summary>
/// "ACTUAL CART DATA STARTS HERE"
/// </summary>
public byte[] EndMagicText { get; set; } = new byte[28];
}
}

View File

@@ -0,0 +1,20 @@
namespace SabreTools.Data.Models.AtariLynx
{
/// <summary>
/// Atari Lynx headered cart (LNX)
/// </summary>
/// <see href="https://github.com/mozzwald/handy-sdl/blob/master/src/handy-0.95/cart.h"/>
public class Cart
{
/// <summary>
/// LNX header
/// </summary>
/// <remarks>If omitted, format is technically LYX</remarks>
public Header? Header { get; set; }
/// <summary>
/// Cartridge data
/// </summary>
public byte[] Data { get; set; } = [];
}
}

View File

@@ -0,0 +1,15 @@
namespace SabreTools.Data.Models.AtariLynx
{
public static class Constants
{
/// <summary>
/// LNX magic string
/// </summary>
public static readonly byte[] MagicBytes = [0x4C, 0x59, 0x4E, 0x58];
/// <summary>
/// LNX magic string
/// </summary>
public const string MagicString = "LYNX";
}
}

View File

@@ -0,0 +1,24 @@
namespace SabreTools.Data.Models.AtariLynx
{
/// <summary>
/// Screen rotation
/// </summary>
/// <see href="https://github.com/mozzwald/handy-sdl/blob/master/src/handy-0.95/cart.h"/>
public enum Rotation : byte
{
/// <summary>
/// No rotation (horizontal, buttons right)
/// </summary>
NoRotation = 0,
/// <summary>
/// Rotate left (vertical, buttons down)
/// </summary>
RotateLeft = 1,
/// <summary>
/// Rotate right (vertical, buttons up)
/// </summary>
RotateRight = 2,
}
}

View File

@@ -0,0 +1,54 @@
namespace SabreTools.Data.Models.AtariLynx
{
/// <summary>
/// Atari Lynx emulator header
/// </summary>
/// <see href="https://github.com/mozzwald/handy-sdl/blob/master/src/handy-0.95/cart.h"/>
public class Header
{
/// <summary>
/// "LYNX"
/// </summary>
/// <remarks>4 bytes</remarks>
public byte[] Magic { get; set; } = new byte[4];
/// <summary>
/// Page size for bank 0
/// </summary>
public ushort Bank0PageSize { get; set; }
/// <summary>
/// Page size for bank 1
/// </summary>
public ushort Bank1PageSize { get; set; }
/// <summary>
/// Header version
/// </summary>
/// <remarks>Must be 0x0001</remarks>
public ushort Version { get; set; }
/// <summary>
/// Game title (Null-padded ASCII)
/// </summary>
/// <remarks>32 bytes</remarks>
public byte[] CartName { get; set; } = new byte[32];
/// <summary>
/// Publisher name
/// </summary>
/// <remarks>16 bytes</remarks>
public byte[] Manufacturer { get; set; } = new byte[16];
/// <summary>
/// Screen rotation
/// </summary>
public Rotation Rotation { get; set; }
/// <summary>
/// Padding
/// </summary>
/// <remarks>5 bytes</remarks>
public byte[] Spare { get; set; } = new byte[5];
}
}

View File

@@ -0,0 +1,13 @@
namespace SabreTools.Data.Models.AttractMode
{
/// <summary>
/// #Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons /// </summary>
/// </summary>
public class MetadataFile
{
[Required]
public string[]? Header { get; set; }
public Row[]? Row { get; set; }
}
}

View File

@@ -0,0 +1,51 @@
namespace SabreTools.Data.Models.AttractMode
{
public class Row
{
/// <remarks>Also called Romname</remarks>
[Required]
public string? Name { get; set; }
public string? Title { get; set; }
public string? Emulator { get; set; }
public string? CloneOf { get; set; }
public string? Year { get; set; }
public string? Manufacturer { get; set; }
public string? Category { get; set; }
public string? Players { get; set; }
public string? Rotation { get; set; }
public string? Control { get; set; }
public string? Status { get; set; }
public string? DisplayCount { get; set; }
public string? DisplayType { get; set; }
public string? AltRomname { get; set; }
public string? AltTitle { get; set; }
public string? Extra { get; set; }
public string? Buttons { get; set; }
public string? Favorite { get; set; }
public string? Tags { get; set; }
public string? PlayedCount { get; set; }
public string? PlayedTime { get; set; }
public bool? FileIsAvailable { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SabreTools.Data.Models.BDPlus
{
public static class Constants
{
public static readonly byte[] SignatureBytes = [0x42, 0x44, 0x53, 0x56, 0x4D, 0x5F, 0x43, 0x43];
public const string SignatureString = "BDSVM_CC";
}
}

View File

@@ -0,0 +1,50 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.BDPlus
{
/// <see href="https://github.com/mwgoldsmith/bdplus/blob/master/src/libbdplus/bdsvm/loader.c"/>
public sealed class SVM
{
/// <summary>
/// "BDSVM_CC"
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string Signature = string.Empty;
/// <summary>
/// Unknown data
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] Unknown1 = new byte[5];
/// <summary>
/// Version year
/// </summary>
public ushort Year;
/// <summary>
/// Version month
/// </summary>
public byte Month;
/// <summary>
/// Version day
/// </summary>
public byte Day;
/// <summary>
/// Unknown data
/// </summary>
public uint Unknown2;
/// <summary>
/// Length
/// </summary>
public uint Length;
/// <summary>
/// <see cref="Length"> bytes of data
/// </summary>
public byte[] Data { get; set; } = [];
}
}

View File

@@ -0,0 +1,19 @@
namespace SabreTools.Data.Models.BFPK
{
/// <summary>
/// BFPK custom archive format
/// </summary>
/// <see cref="https://forum.xentax.com/viewtopic.php?t=5102"/>
public sealed class Archive
{
/// <summary>
/// Header
/// </summary>
public Header Header { get; set; } = new();
/// <summary>
/// Files
/// </summary>
public FileEntry[] Files { get; set; } = [];
}
}

View File

@@ -0,0 +1,11 @@
namespace SabreTools.Data.Models.BFPK
{
public static class Constants
{
public static readonly byte[] SignatureBytes = [0x42, 0x46, 0x50, 0x4b];
public const string SignatureString = "BFPK";
public const uint SignatureUInt32 = 0x4b504642;
}
}

View File

@@ -0,0 +1,34 @@
namespace SabreTools.Data.Models.BFPK
{
/// <summary>
/// File entry
/// </summary>
/// <see cref="https://forum.xentax.com/viewtopic.php?t=5102"/>
public sealed class FileEntry
{
/// <summary>
/// Name size
/// </summary>
public int NameSize { get; set; }
/// <summary>
/// Name
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Uncompressed size
/// </summary>
public int UncompressedSize { get; set; }
/// <summary>
/// Offset
/// </summary>
public int Offset { get; set; }
/// <summary>
/// Compressed size
/// </summary>
public int CompressedSize { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.BFPK
{
/// <summary>
/// Header
/// </summary>
/// <see cref="https://forum.xentax.com/viewtopic.php?t=5102"/>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public sealed class Header
{
/// <summary>
/// "BFPK"
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string Magic = string.Empty;
/// <summary>
/// Version
/// </summary>
public int Version;
/// <summary>
/// Files
/// </summary>
public int Files;
}
}

View File

@@ -0,0 +1,11 @@
namespace SabreTools.Data.Models.BSP
{
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
public sealed class AmbientIndexLump : Lump
{
/// <summary>
/// Indicies
/// </summary>
public LeafAmbientIndex[] Indicies { get; set; } = [];
}
}

View File

@@ -0,0 +1,11 @@
namespace SabreTools.Data.Models.BSP
{
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
public sealed class AmbientLightingLump : Lump
{
/// <summary>
/// Lightings
/// </summary>
public LeafAmbientLighting[] Lightings { get; set; } = [];
}
}

View File

@@ -0,0 +1,33 @@
using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.BSP
{
/// <summary>
/// The brush lump (Lump 18) contains all brushes that were
/// present in the original VMF file before compiling.
/// Unlike faces, brushes are constructive solid geometry (CSG)
/// defined by planes instead of edges and vertices. It is the
/// presence of the brush and brushside lumps in Source BSP
/// files that makes decompiling them a much easier job than
/// for GoldSrc files, which lacked this info.
/// </summary>
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class Brush
{
/// <summary>
/// First brushside
/// </summary>
public int FirstSide;
/// <summary>
/// Number of brushsides
/// </summary>
public int NumSides;
/// <summary>
/// Contents flags
/// </summary>
public VbspContents Contents;
}
}

Some files were not shown because too many files have changed in this diff Show More