Add RomFS building to hactoolnet

This commit is contained in:
Alex Barney 2019-02-03 19:27:09 -06:00
parent e111805702
commit f8e724fe0b
5 changed files with 57 additions and 7 deletions

View file

@ -18,9 +18,10 @@ Options:
-y, --verify Verify all hashes in the input file. -y, --verify Verify all hashes in the input file.
-h, --enablehash Enable hash checks when reading the input file. -h, --enablehash Enable hash checks when reading the input file.
-k, --keyset Load keys from an external file. -k, --keyset Load keys from an external file.
-t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, keygen] -t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild]
--titlekeys <file> Load title keys from an external file. --titlekeys <file> Load title keys from an external file.
NCA options: NCA options:
--plaintext <file> Specify file path for saving a decrypted copy of the NCA.
--section0 <file> Specify Section 0 file path. --section0 <file> Specify Section 0 file path.
--section1 <file> Specify Section 1 file path. --section1 <file> Specify Section 1 file path.
--section2 <file> Specify Section 2 file path. --section2 <file> Specify Section 2 file path.
@ -29,15 +30,18 @@ NCA options:
--section1dir <dir> Specify Section 1 directory path. --section1dir <dir> Specify Section 1 directory path.
--section2dir <dir> Specify Section 2 directory path. --section2dir <dir> Specify Section 2 directory path.
--section3dir <dir> Specify Section 3 directory path. --section3dir <dir> Specify Section 3 directory path.
--exefs <file> Specify ExeFS directory path. --exefs <file> Specify ExeFS file path.
--exefsdir <dir> Specify ExeFS directory path. --exefsdir <dir> Specify ExeFS directory path.
--romfs <file> Specify RomFS directory path. --romfs <file> Specify RomFS file path.
--romfsdir <dir> Specify RomFS directory path. --romfsdir <dir> Specify RomFS directory path.
--listromfs List files in RomFS. --listromfs List files in RomFS.
--basenca Set Base NCA to use with update partitions. --basenca Set Base NCA to use with update partitions.
RomFS options: RomFS options:
--romfsdir <dir> Specify RomFS directory path. --romfsdir <dir> Specify RomFS directory path.
--listromfs List files in RomFS. --listromfs List files in RomFS.
RomFS creation options:
Input path must be a directory
--outfile <file> Specify created RomFS file path.
XCI options: XCI options:
--rootdir <dir> Specify root XCI directory path. --rootdir <dir> Specify root XCI directory path.
--updatedir <dir> Specify update XCI directory path. --updatedir <dir> Specify update XCI directory path.
@ -60,6 +64,7 @@ Switch FS options:
--sdseed <seed> Set console unique seed for SD card NAX0 encryption. --sdseed <seed> Set console unique seed for SD card NAX0 encryption.
--listapps List application info. --listapps List application info.
--listtitles List title info for all titles. --listtitles List title info for all titles.
--listncas List info for all NCAs.
--title <title id> Specify title ID to use. --title <title id> Specify title ID to use.
--outdir <dir> Specify directory path to save title NCAs to. (--title must be specified) --outdir <dir> Specify directory path to save title NCAs to. (--title must be specified)
--exefs <file> Specify ExeFS directory path. (--title must be specified) --exefs <file> Specify ExeFS directory path. (--title must be specified)
@ -68,10 +73,16 @@ Switch FS options:
--romfsdir <dir> 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. --savedir <dir> Specify save file directory path.
-y, --verify Verify all titles, or verify a single title if --title is set. -y, --verify Verify all titles, or verify a single title if --title is set.
Savefile options: Save data options:
--outdir <dir> Specify directory path to save contents to. --outdir <dir> Specify directory path to save contents to.
--debugoutdir <dir> Specify directory path to save intermediate data to for debugging. --debugoutdir <dir> Specify directory path to save intermediate data to for debugging.
--sign Sign the save file. (Requires device_key in key file) --sign Sign the save file. (Requires device_key in key file)
--listfiles List files in save file.
--replacefile <filename in save> <file> Replaces a file in the save data
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: Keygen options:
--outdir <dir> Specify directory path to save key files to. --outdir <dir> Specify directory path to save key files to.
``` ```

View file

@ -162,7 +162,7 @@ namespace hactoolnet
sb.AppendLine(" -y, --verify Verify all hashes in the input file."); sb.AppendLine(" -y, --verify Verify all hashes in the input file.");
sb.AppendLine(" -h, --enablehash Enable hash checks when reading the input file."); sb.AppendLine(" -h, --enablehash Enable hash checks when reading the input file.");
sb.AppendLine(" -k, --keyset Load keys from an external file."); sb.AppendLine(" -k, --keyset Load keys from an external file.");
sb.AppendLine(" -t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen]"); sb.AppendLine(" -t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild]");
sb.AppendLine(" --titlekeys <file> Load title keys from an external file."); sb.AppendLine(" --titlekeys <file> Load title keys from an external file.");
sb.AppendLine("NCA options:"); sb.AppendLine("NCA options:");
sb.AppendLine(" --plaintext <file> Specify file path for saving a decrypted copy of the NCA."); sb.AppendLine(" --plaintext <file> Specify file path for saving a decrypted copy of the NCA.");
@ -174,15 +174,18 @@ namespace hactoolnet
sb.AppendLine(" --section1dir <dir> Specify Section 1 directory path."); sb.AppendLine(" --section1dir <dir> Specify Section 1 directory path.");
sb.AppendLine(" --section2dir <dir> Specify Section 2 directory path."); sb.AppendLine(" --section2dir <dir> Specify Section 2 directory path.");
sb.AppendLine(" --section3dir <dir> Specify Section 3 directory path."); sb.AppendLine(" --section3dir <dir> Specify Section 3 directory path.");
sb.AppendLine(" --exefs <file> Specify ExeFS directory path."); sb.AppendLine(" --exefs <file> Specify ExeFS file path.");
sb.AppendLine(" --exefsdir <dir> Specify ExeFS directory path."); sb.AppendLine(" --exefsdir <dir> Specify ExeFS directory path.");
sb.AppendLine(" --romfs <file> Specify RomFS directory path."); sb.AppendLine(" --romfs <file> Specify RomFS file path.");
sb.AppendLine(" --romfsdir <dir> Specify RomFS directory path."); sb.AppendLine(" --romfsdir <dir> Specify RomFS directory path.");
sb.AppendLine(" --listromfs List files in RomFS."); sb.AppendLine(" --listromfs List files in RomFS.");
sb.AppendLine(" --basenca Set Base NCA to use with update partitions."); sb.AppendLine(" --basenca Set Base NCA to use with update partitions.");
sb.AppendLine("RomFS options:"); sb.AppendLine("RomFS options:");
sb.AppendLine(" --romfsdir <dir> Specify RomFS directory path."); sb.AppendLine(" --romfsdir <dir> Specify RomFS directory path.");
sb.AppendLine(" --listromfs List files in RomFS."); sb.AppendLine(" --listromfs List files in RomFS.");
sb.AppendLine("RomFS creation options:");
sb.AppendLine(" Input path must be a directory");
sb.AppendLine(" --outfile <file> Specify created RomFS file path.");
sb.AppendLine("XCI options:"); sb.AppendLine("XCI options:");
sb.AppendLine(" --rootdir <dir> Specify root XCI directory path."); sb.AppendLine(" --rootdir <dir> Specify root XCI directory path.");
sb.AppendLine(" --updatedir <dir> Specify update XCI directory path."); sb.AppendLine(" --updatedir <dir> Specify update XCI directory path.");

View file

@ -64,6 +64,7 @@ namespace hactoolnet
Pfs0, Pfs0,
Nsp, Nsp,
Romfs, Romfs,
RomfsBuild,
Nax0, Nax0,
Xci, Xci,
SwitchFs, SwitchFs,

View file

@ -0,0 +1,32 @@
using System.IO;
using LibHac.IO;
using LibHac.IO.RomFs;
namespace hactoolnet
{
internal static class ProcessRomFsBuild
{
public static void Process(Context ctx)
{
if (ctx.Options.OutFile == null)
{
ctx.Logger.LogMessage("Output file must be specified.");
return;
}
var localFs = new LocalFileSystem(ctx.Options.InFile);
var builder = new RomFsBuilder(localFs);
IStorage romfs = builder.Build();
ctx.Logger.LogMessage($"Building RomFS as {ctx.Options.OutFile}");
using (var outFile = new FileStream(ctx.Options.OutFile, FileMode.Create, FileAccess.ReadWrite))
{
romfs.CopyToStream(outFile, romfs.Length, ctx.Logger);
}
ctx.Logger.LogMessage($"Finished writing {ctx.Options.OutFile}");
}
}
}

View file

@ -64,6 +64,9 @@ namespace hactoolnet
case FileType.Romfs: case FileType.Romfs:
ProcessRomfs.Process(ctx); ProcessRomfs.Process(ctx);
break; break;
case FileType.RomfsBuild:
ProcessRomFsBuild.Process(ctx);
break;
case FileType.Nax0: case FileType.Nax0:
break; break;
case FileType.SwitchFs: case FileType.SwitchFs: