mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
hactoolnet: Add NPDM converter
This commit is contained in:
parent
6f6836c302
commit
8232ff7ed6
5 changed files with 40 additions and 2 deletions
|
@ -55,6 +55,8 @@ NCA options:
|
||||||
--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.
|
||||||
|
NPDM options:
|
||||||
|
--json <file> Specify file path for saving JSON representation of program permissions to.
|
||||||
KIP1 options:
|
KIP1 options:
|
||||||
--uncompressed <f> Specify file path for saving uncompressed KIP1.
|
--uncompressed <f> Specify file path for saving uncompressed KIP1.
|
||||||
RomFS options:
|
RomFS options:
|
||||||
|
|
|
@ -68,6 +68,7 @@ internal static class CliParser
|
||||||
new CliOption("title", 1, (o, a) => o.TitleId = ParseTitleId(o, a[0])),
|
new CliOption("title", 1, (o, a) => o.TitleId = ParseTitleId(o, a[0])),
|
||||||
new CliOption("bench", 1, (o, a) => o.BenchType = a[0]),
|
new CliOption("bench", 1, (o, a) => o.BenchType = a[0]),
|
||||||
new CliOption("cpufreq", 1, (o, a) => o.CpuFrequencyGhz = ParseDouble(o, a[0])),
|
new CliOption("cpufreq", 1, (o, a) => o.CpuFrequencyGhz = ParseDouble(o, a[0])),
|
||||||
|
new CliOption("json", 1, (o, a) => o.JsonFile = a[0]),
|
||||||
|
|
||||||
new CliOption("replacefile", 2, (o, a) =>
|
new CliOption("replacefile", 2, (o, a) =>
|
||||||
{
|
{
|
||||||
|
@ -190,6 +191,7 @@ internal static class CliParser
|
||||||
case "ini1": return FileType.Ini1;
|
case "ini1": return FileType.Ini1;
|
||||||
case "ndv0": return FileType.Ndv0;
|
case "ndv0": return FileType.Ndv0;
|
||||||
case "bench": return FileType.Bench;
|
case "bench": return FileType.Bench;
|
||||||
|
case "npdm": return FileType.Npdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.ParseErrorMessage ??= "Specified type is invalid.";
|
options.ParseErrorMessage ??= "Specified type is invalid.";
|
||||||
|
@ -274,6 +276,8 @@ internal static class CliParser
|
||||||
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("NPDM options:");
|
||||||
|
sb.AppendLine(" --json <file> Specify file path for saving JSON representation of program permissions to.");
|
||||||
sb.AppendLine("KIP1 options:");
|
sb.AppendLine("KIP1 options:");
|
||||||
sb.AppendLine(" --uncompressed <f> Specify file path for saving uncompressed KIP1.");
|
sb.AppendLine(" --uncompressed <f> Specify file path for saving uncompressed KIP1.");
|
||||||
sb.AppendLine("RomFS options:");
|
sb.AppendLine("RomFS options:");
|
||||||
|
@ -370,4 +374,4 @@ internal static class CliParser
|
||||||
public int ArgsNeeded { get; }
|
public int ArgsNeeded { get; }
|
||||||
public Action<Options, string[]> Assigner { get; }
|
public Action<Options, string[]> Assigner { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ internal class Options
|
||||||
public ulong TitleId;
|
public ulong TitleId;
|
||||||
public string BenchType;
|
public string BenchType;
|
||||||
public double CpuFrequencyGhz;
|
public double CpuFrequencyGhz;
|
||||||
|
public string JsonFile;
|
||||||
|
|
||||||
public string ParseErrorMessage;
|
public string ParseErrorMessage;
|
||||||
public bool IsParseSuccessful;
|
public bool IsParseSuccessful;
|
||||||
|
@ -99,7 +100,8 @@ internal enum FileType
|
||||||
Kip1,
|
Kip1,
|
||||||
Ini1,
|
Ini1,
|
||||||
Ndv0,
|
Ndv0,
|
||||||
Bench
|
Bench,
|
||||||
|
Npdm
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Context
|
internal class Context
|
||||||
|
|
27
src/hactoolnet/ProcessNpdm.cs
Normal file
27
src/hactoolnet/ProcessNpdm.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
using LibHac.FsSystem;
|
||||||
|
using LibHac.Tools.FsSystem;
|
||||||
|
using LibHac.Tools.Npdm;
|
||||||
|
|
||||||
|
namespace hactoolnet;
|
||||||
|
|
||||||
|
internal static class ProcessNpdm
|
||||||
|
{
|
||||||
|
public static void Process(Context ctx)
|
||||||
|
{
|
||||||
|
using (var file = new LocalStorage(ctx.Options.InFile, FileAccess.Read))
|
||||||
|
{
|
||||||
|
var npdm = new NpdmBinary(file.AsStream(), ctx.KeySet);
|
||||||
|
|
||||||
|
if(ctx.Options.JsonFile != null)
|
||||||
|
{
|
||||||
|
string json = JsonSerializer.Serialize(npdm, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true
|
||||||
|
});
|
||||||
|
File.WriteAllText(ctx.Options.JsonFile, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -182,6 +182,9 @@ public static class Program
|
||||||
case FileType.Bench:
|
case FileType.Bench:
|
||||||
ProcessBench.Process(ctx);
|
ProcessBench.Process(ctx);
|
||||||
break;
|
break;
|
||||||
|
case FileType.Npdm:
|
||||||
|
ProcessNpdm.Process(ctx);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue