mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Extract main RomFS from XCIs
This commit is contained in:
parent
1e813818c0
commit
86741d3c92
2 changed files with 45 additions and 0 deletions
|
@ -165,6 +165,7 @@ namespace hactoolnet
|
|||
sb.AppendLine(" --securedir <dir> Specify secure XCI directory path.");
|
||||
sb.AppendLine(" --logodir <dir> Specify logo XCI directory path.");
|
||||
sb.AppendLine(" --outdir <dir> Specify XCI directory path.");
|
||||
sb.AppendLine(" --romfsdir <dir> Specify main RomFS directory path.");
|
||||
sb.AppendLine("Switch FS options:");
|
||||
sb.AppendLine(" --sdseed <seed> Set console unique seed for SD card NAX0 encryption.");
|
||||
sb.AppendLine(" --listapps List application info.");
|
||||
|
|
|
@ -221,6 +221,11 @@ namespace hactoolnet
|
|||
if (ctx.Options.OutDir != null && xci.RootPartition != null)
|
||||
{
|
||||
var root = xci.RootPartition;
|
||||
if (root == null)
|
||||
{
|
||||
ctx.Logger.LogMessage("Could not find root partition");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var sub in root.Files)
|
||||
{
|
||||
|
@ -230,6 +235,45 @@ namespace hactoolnet
|
|||
subPfs.Extract(subDir, ctx.Logger);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.Options.RomfsOutDir != null)
|
||||
{
|
||||
if (xci.SecurePartition == null)
|
||||
{
|
||||
ctx.Logger.LogMessage("Could not find secure partition");
|
||||
return;
|
||||
}
|
||||
|
||||
Nca mainNca = null;
|
||||
|
||||
foreach (var fileEntry in xci.SecurePartition.Files.Where(x => x.Name.EndsWith(".nca")))
|
||||
{
|
||||
var ncaStream = xci.SecurePartition.OpenFile(fileEntry);
|
||||
var nca = new Nca(ctx.Keyset, ncaStream, true);
|
||||
|
||||
if (nca.Header.ContentType == ContentType.Program)
|
||||
{
|
||||
mainNca = nca;
|
||||
}
|
||||
}
|
||||
|
||||
if (mainNca == null)
|
||||
{
|
||||
ctx.Logger.LogMessage("Could not find Program NCA");
|
||||
return;
|
||||
}
|
||||
|
||||
var romfsSection = mainNca.Sections.FirstOrDefault(x => x.Type == SectionType.Romfs);
|
||||
|
||||
if (romfsSection == null)
|
||||
{
|
||||
ctx.Logger.LogMessage("NCA has no RomFS section");
|
||||
return;
|
||||
}
|
||||
|
||||
var romfs = new Romfs(mainNca.OpenSection(romfsSection.SectionNum, false));
|
||||
romfs.Extract(ctx.Options.RomfsOutDir, ctx.Logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue