mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Modify check for ExeFS NCA sections
This commit is contained in:
parent
75dafd9cbe
commit
e9602d35da
4 changed files with 14 additions and 20 deletions
|
@ -61,19 +61,7 @@ namespace LibHac
|
||||||
NcaSection section = ParseSection(i);
|
NcaSection section = ParseSection(i);
|
||||||
if (section == null) continue;
|
if (section == null) continue;
|
||||||
Sections[i] = section;
|
Sections[i] = section;
|
||||||
ValidateMasterHash(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//foreach (NcaSection pfsSection in Sections.Where(x => x != null && x.Type == SectionType.Pfs0))
|
|
||||||
//{
|
|
||||||
// Stream sectionStream = OpenSection(pfsSection.SectionNum, false, false);
|
|
||||||
// if (sectionStream == null) continue;
|
|
||||||
|
|
||||||
// var pfs = new Pfs(sectionStream);
|
|
||||||
// if (!pfs.FileExists("main.npdm")) continue;
|
|
||||||
|
|
||||||
// pfsSection.IsExefs = true;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -379,7 +367,7 @@ namespace LibHac
|
||||||
break;
|
break;
|
||||||
case NcaHashType.Ivfc when sect.Header.EncryptionType == NcaEncryptionType.AesCtrEx:
|
case NcaHashType.Ivfc when sect.Header.EncryptionType == NcaEncryptionType.AesCtrEx:
|
||||||
CheckBktrKey(sect);
|
CheckBktrKey(sect);
|
||||||
break;
|
return;
|
||||||
case NcaHashType.Ivfc:
|
case NcaHashType.Ivfc:
|
||||||
offset = sect.Header.IvfcInfo.LevelHeaders[0].LogicalOffset;
|
offset = sect.Header.IvfcInfo.LevelHeaders[0].LogicalOffset;
|
||||||
size = 1 << sect.Header.IvfcInfo.LevelHeaders[0].BlockSizePower;
|
size = 1 << sect.Header.IvfcInfo.LevelHeaders[0].BlockSizePower;
|
||||||
|
@ -414,8 +402,6 @@ namespace LibHac
|
||||||
public long Size { get; set; }
|
public long Size { get; set; }
|
||||||
public Validity MasterHashValidity { get; set; }
|
public Validity MasterHashValidity { get; set; }
|
||||||
|
|
||||||
public bool IsExefs { get; internal set; }
|
|
||||||
|
|
||||||
public byte[] GetMasterHash()
|
public byte[] GetMasterHash()
|
||||||
{
|
{
|
||||||
var hash = new byte[Crypto.Sha256DigestSize];
|
var hash = new byte[Crypto.Sha256DigestSize];
|
||||||
|
|
|
@ -80,7 +80,13 @@ namespace hactoolnet
|
||||||
|
|
||||||
if (ctx.Options.ExefsOutDir != null || ctx.Options.ExefsOut != null)
|
if (ctx.Options.ExefsOutDir != null || ctx.Options.ExefsOut != null)
|
||||||
{
|
{
|
||||||
NcaSection section = nca.Sections.FirstOrDefault(x => x?.IsExefs == true);
|
if (nca.Header.ContentType != ContentType.Program)
|
||||||
|
{
|
||||||
|
ctx.Logger.LogMessage("NCA's content type is not \"Program\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NcaSection section = nca.Sections[(int)ProgramPartitionType.Code];
|
||||||
|
|
||||||
if (section == null)
|
if (section == null)
|
||||||
{
|
{
|
||||||
|
@ -154,10 +160,12 @@ namespace hactoolnet
|
||||||
NcaSection sect = nca.Sections[i];
|
NcaSection sect = nca.Sections[i];
|
||||||
if (sect == null) continue;
|
if (sect == null) continue;
|
||||||
|
|
||||||
|
bool isExefs = nca.Header.ContentType == ContentType.Program && i == (int)ProgramPartitionType.Code;
|
||||||
|
|
||||||
sb.AppendLine($" Section {i}:");
|
sb.AppendLine($" Section {i}:");
|
||||||
PrintItem(sb, colLen, " Offset:", $"0x{sect.Offset:x12}");
|
PrintItem(sb, colLen, " Offset:", $"0x{sect.Offset:x12}");
|
||||||
PrintItem(sb, colLen, " Size:", $"0x{sect.Size:x12}");
|
PrintItem(sb, colLen, " Size:", $"0x{sect.Size:x12}");
|
||||||
PrintItem(sb, colLen, " Partition Type:", sect.IsExefs ? "ExeFS" : sect.Type.ToString());
|
PrintItem(sb, colLen, " Partition Type:", isExefs ? "ExeFS" : sect.Type.ToString());
|
||||||
PrintItem(sb, colLen, " Section CTR:", sect.Header.Ctr);
|
PrintItem(sb, colLen, " Section CTR:", sect.Header.Ctr);
|
||||||
|
|
||||||
switch (sect.Header.HashType)
|
switch (sect.Header.HashType)
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace hactoolnet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NcaSection section = title.MainNca.Sections.FirstOrDefault(x => x.IsExefs);
|
NcaSection section = title.MainNca.Sections[(int)ProgramPartitionType.Code];
|
||||||
|
|
||||||
if (section == null)
|
if (section == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace hactoolnet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NcaSection exefsSection = mainNca.Sections.FirstOrDefault(x => x.IsExefs);
|
NcaSection exefsSection = mainNca.Sections[(int)ProgramPartitionType.Code];
|
||||||
|
|
||||||
if (exefsSection == null)
|
if (exefsSection == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue