libhac - LibHac 0.20.0-alpha.57+80273103

A library that reimplements select portions of the Nintendo Switch operating system and allows reading content formats used by the OS.

PM> Install-Package LibHac -Version 0.20.0-alpha.57 -Source https://www.myget.org/F/libhac/api/v3/index.json

Copy to clipboard

> nuget.exe install LibHac -Version 0.20.0-alpha.57 -Source https://www.myget.org/F/libhac/api/v3/index.json

Copy to clipboard

> dotnet add package LibHac --version 0.20.0-alpha.57 --source https://www.myget.org/F/libhac/api/v3/index.json

Copy to clipboard
<PackageReference Include="LibHac" Version="0.20.0-alpha.57" />
Copy to clipboard
source https://www.myget.org/F/libhac/api/v3/index.json

nuget LibHac  ~> 0.20.0-alpha.57
Copy to clipboard

> choco install LibHac --version 0.20.0-alpha.57 --source https://www.myget.org/F/libhac/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "libhac" -SourceLocation "https://www.myget.org/F/libhac/api/v2"
Install-Module -Name "LibHac" -RequiredVersion "0.20.0-alpha.57" -Repository "libhac" -AllowPreRelease
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following symbol server URL: https://www.myget.org/F/libhac/api/v2/symbolpackage/


LibHac

NuGet MyGet AppVeyor Build Status

LibHac is a .NET library that reimplements some parts of the Nintendo Switch operating system, also known as Horizon OS.

One of the other main functions of the library is opening, decrypting and extracting common content file formats used by Horizon.

Most content is imported and exported using a standard IStorage interface. This means that reading nested file types and encryptions can easily be done by linking different file readers together.
For example, the files from a title stored on the external SD card can be read or extracted in this way.
NAX0 Reader -> NCA Reader -> RomFS Reader -> Individual Files

Getting Started

Handling Content Files

Todo: Document usage of the Horizon and HorizonClient objects.

hactoolnet

hactoolnet is an example program that uses LibHac. It is used in a similar manner to hactool.

Usage

Usage: hactoolnet.exe [options...] <path>
Options:
  -r, --raw            Keep raw data, don't unpack.
  -y, --verify         Verify all hashes in the input file.
  -h, --enablehash     Enable hash checks when reading the input file.
  -d, --dev            Decrypt with development keys instead of retail.
  -k, --keyset         Load keys from an external file.
  -t, --intype=type    Specify input file type [nca, xci, romfs, pfs0, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild, pfsbuild]
  --titlekeys <file>   Load title keys from an external file.
  --accesslog <file>   Specify the access log file path.
  --disablekeywarns    Disables warning output when loading external keys.
  --version            Display version information and exit.
  --help               Display this help and exit.
NCA options:
  --plaintext <file>   Specify file path for saving a decrypted copy of the NCA.
  --ciphertext <file>  Specify file path for saving an encrypted copy of the NCA.
  --header <file>      Specify Header file path.
  --section0 <file>    Specify Section 0 file path.
  --section1 <file>    Specify Section 1 file path.
  --section2 <file>    Specify Section 2 file path.
  --section3 <file>    Specify Section 3 file path.
  --section0dir <dir>  Specify Section 0 directory path.
  --section1dir <dir>  Specify Section 1 directory path.
  --section2dir <dir>  Specify Section 2 directory path.
  --section3dir <dir>  Specify Section 3 directory path.
  --exefs <file>       Specify ExeFS file path.
  --exefsdir <dir>     Specify ExeFS directory path.
  --romfs <file>       Specify RomFS file path.
  --romfsdir <dir>     Specify RomFS directory path.
  --listromfs          List files in RomFS.
  --basenca            Set Base NCA to use with update partitions.
  --basetitlekey       Specify single (encrypted) titlekey for the base NCA.
  --titlekey           Specify single (encrypted) titlekey.
  --suppresskeys       Suppress output of decrypted keys.
KIP1 options:
  --uncompressed <f>   Specify file path for saving uncompressed KIP1.
RomFS options:
  --romfsdir <dir>     Specify RomFS directory path.
  --listromfs          List files in RomFS.
RomFS creation options:
                       Input path must be a directory
  --outfile <file>     Specify created RomFS file path.
Partition FS options:
  --outdir <dir>       Specify extracted FS directory path.
Partition FS creation options:
                       Input path must be a directory
  --outfile <file>     Specify created Partition FS file path.
  --hashedfs           Create a hashed Partition FS (HFS0).
XCI options:
  --rootdir <dir>      Specify root XCI directory path.
  --updatedir <dir>    Specify update XCI directory path.
  --normaldir <dir>    Specify normal XCI directory path.
  --securedir <dir>    Specify secure XCI directory path.
  --logodir <dir>      Specify logo XCI directory path.
  --outdir <dir>       Specify XCI directory path.
  --nspout <file>      Specify file for the created NSP.
Partition FS and XCI options:
  --exefs <file>       Specify main ExeFS file path.
  --exefsdir <dir>     Specify main ExeFS directory path.
  --romfs <file>       Specify main RomFS file path.
  --romfsdir <dir>     Specify main RomFS directory path.
  --listapps           List application info.
  --listtitles         List title info for all titles.
  --listncas           List info for all NCAs.
  --title <title id>   Specify title ID to use.
Package1 options:
  --outdir <dir>       Specify Package1 directory path.
Package2 options:
  --outdir <dir>       Specify Package2 directory path.
  --extractini1        Enable INI1 extraction to default directory (redundant with --ini1dir set).
  --ini1dir <dir>      Specify INI1 directory path. Overrides default path, if present.
INI1 options:
  --outdir <dir>       Specify INI1 directory path.
Switch FS options:
  --sdseed <seed>      Set console unique seed for SD card NAX0 encryption.
  --listapps           List application info.
  --listtitles         List title info for all titles.
  --listncas           List info for all NCAs.
  --title <title id>   Specify title ID to use.
  --outdir <dir>       Specify directory path to save title NCAs to. (--title must be specified)
  --exefs <file>       Specify ExeFS directory path. (--title must be specified)
  --exefsdir <dir>     Specify ExeFS directory path. (--title must be specified)
  --romfs <file>       Specify RomFS directory path. (--title must be specified)
  --romfsdir <dir>     Specify RomFS directory path. (--title must be specified)
  --savedir <dir>      Specify save file directory path.
  -y, --verify         Verify all titles, or verify a single title if --title is set.
Save data options:
  --outdir <dir>       Specify directory path to save contents to.
  --debugoutdir <dir>  Specify directory path to save intermediate data to for debugging.
  --sign               Sign the save file. (Requires device_key in key file)
  --trim               Trim garbage data in the save file. (Requires device_key in key file)
  --listfiles          List files in save file.
  --repack <dir>       Replaces the contents of the save data with the specified directory.
  --replacefile <filename in save> <file> Replaces a file in the save data
NAX0 options:
  --sdseed <seed>      Set console unique seed for SD card NAX0 encryption.
  --sdpath <path>      Set relative path for NAX0 key derivation (ex: /registered/000000FF/cafebabecafebabecafebabecafebabe.nca).
  --plaintext          Specify file path to save decrypted contents.
NDV0 (Delta) options:
                       Input delta patch can be a delta NCA file or a delta fragment file.
  --basefile <file>    Specify base file path.
  --outfile            Specify patched file path.
Keygen options:
  --outdir <dir>       Specify directory path to save key files to.

Examples

List applications on a Switch SD card or NAND

hactoolnet -t switchfs --sdseed <sd_seed> --listapps <sd_root_path>

Extract a title from an SD card or NAND as NCA files

hactoolnet -t switchfs --sdseed <sd_seed> --title <title_id> --outdir output <sd_root_path>

Extract the RomFS from a title from an SD card or NAND

hactoolnet -t switchfs --sdseed <sd_seed> --title <title_id> --romfsdir romfs <sd_root_path>

Specifying the base title ID will extract the unpatched title.
Specifying the patch title ID will extract the patched title.

External Keys

For more detailed information on keyset files, see KEYS.md.

Keys can be loaded from a text file by specifying a filename with the -k argument. The file should be in the same format read by hactool:
"Keyset files are text files containing one key per line, in the form "key_name = HEXADECIMALKEY". Case shouldn't matter, nor should whitespace."

Console-unique keys can be loaded from a text file by specifying a filename with the --consolekeys argument. The file format is the same as the main keyset file.

Title keys can be loaded from a text file by specifying a filename with the --titlekeys argument. The file should contain one key per line in the form rights_id,HEXADECIMALKEY.

If a keyfile is not set at the command line, hactoolnet will search for and load keyfiles in $HOME/.switch/prod.keys, $HOME/.switch/console.keys and $HOME/.switch/title.keys.

Special Thanks

This project uses NDepend for static code analysis.

NDepend link

  • .NETFramework 8.0
  • .NETFramework 8.0: 8.0.0.0

Owners

TheAlexBarney

Authors

Alex Barney

Project URL

https://github.com/Thealexbarney/LibHac

License

MIT

Info

178 total downloads
2 downloads for version 0.20.0-alpha.57+80273103
Download (672.36 KB)
Download symbols (321.47 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
0.20.0-alpha.57+80273103 672.36 KB Mon, 01 Apr 2024 03:52:34 GMT 2
0.20.0-alpha.51+257cf57d 665.56 KB Sat, 10 Feb 2024 23:56:05 GMT 2
0.20.0-alpha.45+908c2ca8 620.94 KB Sat, 30 Dec 2023 00:43:42 GMT 2
0.20.0--save-skeleton.51+257cf57d 665.58 KB Sun, 04 Feb 2024 07:27:45 GMT 1
0.20.0--save-skeleton.49+b713bb69 663.32 KB Wed, 31 Jan 2024 05:30:49 GMT 1
0.20.0--save-skeleton.46+2fca4019 656.29 KB Tue, 02 Jan 2024 08:19:40 GMT 1
0.20.0--save-service-impl.57+80273103 672.4 KB Mon, 18 Mar 2024 06:19:49 GMT 1
0.20.0--save-service-impl.53+2501cd24 667.77 KB Tue, 20 Feb 2024 06:09:28 GMT 2
0.20.0--save-service-impl.52+164382f9 667.66 KB Mon, 19 Feb 2024 02:50:12 GMT 2
0.20.0--net8.45+908c2ca8 620.93 KB Sun, 17 Dec 2023 06:38:14 GMT 2
0.20.0--net8.44+7a8f0de6 620.94 KB Mon, 11 Dec 2023 00:10:13 GMT 0
0.20.0--dependabot-nuget-build-NuGet-CommandLine-6-8-1.52+3b70497d 665.71 KB Tue, 13 Feb 2024 21:33:25 GMT 0
0.19.0 624.62 KB Fri, 20 Oct 2023 05:20:18 GMT 4
0.19.0-alpha.39+f28e7a7d 624.64 KB Thu, 16 Nov 2023 02:49:08 GMT 1
0.19.0-alpha.37+300fa877 624.65 KB Thu, 16 Nov 2023 02:25:44 GMT 2
0.19.0-alpha.36+dd478db7 624.64 KB Wed, 18 Oct 2023 15:50:44 GMT 2
0.19.0-alpha.34+c03e4d3f 624.53 KB Mon, 16 Oct 2023 06:57:37 GMT 1
0.19.0-alpha.33+279f86d9 624.53 KB Sat, 14 Oct 2023 21:11:31 GMT 4
0.19.0-alpha.32+655fed16 624.52 KB Fri, 13 Oct 2023 15:29:25 GMT 2
0.19.0-alpha.31+d54bea84 624.44 KB Wed, 11 Oct 2023 16:32:08 GMT 1
0.19.0--net8.43+32dff54c 620.94 KB Sun, 10 Dec 2023 06:35:33 GMT 1
0.19.0--keys-17.32+f53aff7d 624.53 KB Fri, 13 Oct 2023 05:42:01 GMT 0
0.19.0--hactoolnet-stuff.36+cd4004af 624.69 KB Wed, 18 Oct 2023 05:22:27 GMT 0
0.19.0--get-common-path-fix.33+ee09fd86 624.58 KB Sat, 14 Oct 2023 06:59:14 GMT 1
0.19.0--build-0-19-0.31+e6fc8e31 624.46 KB Wed, 11 Oct 2023 06:00:07 GMT 2
0.19.0--build-0-19-0.30+7beb1384 624.46 KB Mon, 09 Oct 2023 07:46:51 GMT 0
0.19.0--build-0-19-0.29+ee21bd28 624.47 KB Mon, 09 Oct 2023 04:54:45 GMT 2
0.19.0--17-updates.38+8f60693c 624.79 KB Thu, 02 Nov 2023 07:13:32 GMT 1
0.18.1-alpha.27+934f81da 624.42 KB Thu, 05 Oct 2023 14:33:39 GMT 2
0.18.1-alpha.26+809cecd1 622.65 KB Thu, 05 Oct 2023 14:18:38 GMT 2
0.18.1-alpha.24+2b69ec6c 622.68 KB Mon, 18 Sep 2023 04:38:07 GMT 1
0.18.1-alpha.1+1e421a36 594.31 KB Sun, 04 Jun 2023 03:03:08 GMT 3
0.18.1--sdmmcsrv.22+5672f804 622.59 KB Sun, 17 Sep 2023 15:23:39 GMT 3
0.18.1--misc-fixes.26+50c9661a 622.68 KB Thu, 28 Sep 2023 00:52:07 GMT 1
0.18.1--misc-fixes.25+ed71ab4f 622.72 KB Mon, 18 Sep 2023 07:37:59 GMT 2
0.18.1--keys-17.28+719355b4 624.52 KB Fri, 13 Oct 2023 05:29:17 GMT 1
0.18.1--fs-attribute.25+6f076e93 624.38 KB Thu, 05 Oct 2023 07:27:51 GMT 2
0.18.1--dependabot-nuget-build-NuGet-CommandLine-6-4-2.2+1b0beaf4 594.44 KB Wed, 14 Jun 2023 16:49:41 GMT 0
0.18.0 594.23 KB Sat, 11 Feb 2023 22:41:29 GMT 3
0.18.0-alpha.29+6f6836c3 594.27 KB Tue, 07 Feb 2023 04:23:13 GMT 1
0.17.1-alpha.25+c667de11 594.23 KB Fri, 03 Feb 2023 06:20:39 GMT 1
0.17.1-alpha.20+a1439a26 594.06 KB Wed, 01 Feb 2023 01:02:12 GMT 2
0.17.1-alpha.18+c6127972 592.58 KB Fri, 27 Jan 2023 04:27:00 GMT 2
0.17.1-alpha.16+fe2549cb 592.53 KB Wed, 14 Dec 2022 06:03:14 GMT 3
0.17.1-alpha.2+fe8699e8 881.46 KB Wed, 23 Nov 2022 21:34:21 GMT 1
0.17.1-alpha.1+eccd91bc 881.38 KB Wed, 23 Nov 2022 06:09:28 GMT 3
0.17.0 881.28 KB Sun, 20 Nov 2022 20:46:55 GMT 2
0.16.1 818.94 KB Thu, 07 Apr 2022 17:38:43 GMT 2
0.15.0 770.69 KB Mon, 10 Jan 2022 01:52:48 GMT 2
0.14.3 772.29 KB Sat, 18 Dec 2021 21:01:33 GMT 2
0.14.2 772.04 KB Fri, 17 Dec 2021 02:58:18 GMT 2
0.14.1 513.36 KB Wed, 15 Dec 2021 23:22:36 GMT 2
0.14.0 507.73 KB Sat, 27 Nov 2021 03:51:07 GMT 2
0.13.3 495.7 KB Sat, 21 Aug 2021 00:35:05 GMT 3
0.13.2 495.73 KB Thu, 12 Aug 2021 00:57:08 GMT 4
0.13.1 495.58 KB Thu, 01 Jul 2021 16:49:39 GMT 3
0.13.0 495.58 KB Wed, 16 Jun 2021 08:03:43 GMT 4
0.12.0 575.07 KB Tue, 18 Aug 2020 02:30:22 GMT 4
0.11.3 512.17 KB Sat, 06 Jun 2020 07:04:37 GMT 4
0.11.2 511.42 KB Wed, 13 May 2020 03:03:13 GMT 3
0.11.1 505.69 KB Sun, 03 May 2020 18:47:34 GMT 3
0.11.0 504.87 KB Wed, 29 Apr 2020 21:36:07 GMT 3
0.10.0 468.91 KB Mon, 23 Mar 2020 23:28:59 GMT 5
0.9.1 451.8 KB Wed, 04 Mar 2020 04:46:37 GMT 4
0.9.0 450.59 KB Sat, 29 Feb 2020 08:44:55 GMT 5
0.8.2 412.26 KB Tue, 14 Jan 2020 04:51:49 GMT 4
0.8.1 408.01 KB Sat, 04 Jan 2020 20:59:03 GMT 4
0.8.0 408.02 KB Wed, 01 Jan 2020 22:13:34 GMT 4
0.7.0 596.68 KB Thu, 28 Nov 2019 04:38:50 GMT 4
0.6.0 535.05 KB Mon, 14 Oct 2019 17:37:18 GMT 4
0.5.1 436.16 KB Sun, 11 Aug 2019 21:52:18 GMT 2
0.5.0 290.19 KB Wed, 10 Jul 2019 02:46:43 GMT 5
0.4.1 267.74 KB Wed, 05 Jun 2019 05:35:02 GMT 3
0.4.0 257.93 KB Fri, 31 May 2019 02:09:32 GMT 3
0.3.1 226.66 KB Sat, 23 Feb 2019 02:58:35 GMT 6
0.3.0 225.2 KB Sun, 17 Feb 2019 02:52:57 GMT 3
0.2.1-alpha.58+632d508e 225.32 KB Sun, 17 Feb 2019 02:51:58 GMT 2
0.2.1-alpha.56+199dbf75 225.33 KB Sun, 17 Feb 2019 02:35:05 GMT 2