mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Move NcaUtils
This commit is contained in:
parent
7681429c97
commit
aa153980be
21 changed files with 78 additions and 74 deletions
|
@ -1,7 +1,7 @@
|
|||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ using LibHac.Fs;
|
|||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.Impl;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ using LibHac.Fs.Fsa;
|
|||
using LibHac.FsSrv.FsCreator;
|
||||
using LibHac.FsSrv.Impl;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Os;
|
||||
using LibHac.Spl;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using LibHac.Util;
|
||||
using RightsId = LibHac.Fs.RightsId;
|
||||
using Utility = LibHac.FsSystem.Utility;
|
||||
|
|
|
@ -2,41 +2,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common.FixedArrays;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
|
||||
public class TitleVersion
|
||||
{
|
||||
public uint Version { get; }
|
||||
public int Major { get; }
|
||||
public int Minor { get; }
|
||||
public int Patch { get; }
|
||||
public int Revision { get; }
|
||||
|
||||
public TitleVersion(uint version, bool isSystemTitle = false)
|
||||
{
|
||||
Version = version;
|
||||
|
||||
if (isSystemTitle)
|
||||
{
|
||||
Revision = (int)(version & ((1 << 16) - 1));
|
||||
Patch = (int)((version >> 16) & ((1 << 4) - 1));
|
||||
Minor = (int)((version >> 20) & ((1 << 6) - 1));
|
||||
Major = (int)((version >> 26) & ((1 << 6) - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Revision = (byte)version;
|
||||
Patch = (byte)(version >> 8);
|
||||
Minor = (byte)(version >> 16);
|
||||
Major = (byte)(version >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Major}.{Minor}.{Patch}.{Revision}";
|
||||
}
|
||||
}
|
||||
namespace LibHac.FsSystem;
|
||||
|
||||
public struct NcaSparseInfo
|
||||
{
|
|
@ -8,9 +8,9 @@ using LibHac.Common.Keys;
|
|||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using LibHac.Tools.FsSystem.Save;
|
||||
using LibHac.Tools.Ncm;
|
||||
using LibHac.Util;
|
||||
|
|
|
@ -9,10 +9,11 @@ using LibHac.Crypto;
|
|||
using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.RomFs;
|
||||
using LibHac.Spl;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public class Nca
|
||||
{
|
||||
|
@ -778,7 +779,7 @@ public class Nca
|
|||
return Header.VerifySignature1(KeySet.NcaHeaderSigningKeyParams[0].Modulus);
|
||||
}
|
||||
|
||||
internal void GenerateAesCounter(int sectionIndex, Ncm.ContentType type, int minorVersion)
|
||||
internal void GenerateAesCounter(int sectionIndex, LibHac.Ncm.ContentType type, int minorVersion)
|
||||
{
|
||||
int counterType;
|
||||
int counterVersion;
|
||||
|
@ -789,14 +790,14 @@ public class Nca
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case Ncm.ContentType.Program:
|
||||
case LibHac.Ncm.ContentType.Program:
|
||||
counterType = sectionIndex + 1;
|
||||
break;
|
||||
case Ncm.ContentType.HtmlDocument:
|
||||
counterType = (int)Ncm.ContentType.HtmlDocument;
|
||||
case LibHac.Ncm.ContentType.HtmlDocument:
|
||||
counterType = (int)LibHac.Ncm.ContentType.HtmlDocument;
|
||||
break;
|
||||
case Ncm.ContentType.LegalInformation:
|
||||
counterType = (int)Ncm.ContentType.LegalInformation;
|
||||
case LibHac.Ncm.ContentType.LegalInformation:
|
||||
counterType = (int)LibHac.Ncm.ContentType.LegalInformation;
|
||||
break;
|
||||
default:
|
||||
counterType = 0;
|
|
@ -4,8 +4,9 @@ using System.Diagnostics;
|
|||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public static class NcaExtensions
|
||||
{
|
|
@ -1,10 +1,11 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
// ReSharper disable ImpureMethodCallOnReadonlyValueField
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public struct NcaFsHeader
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public struct NcaFsIntegrityInfoIvfc
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public struct NcaFsIntegrityInfoSha256
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public struct NcaFsPatchInfo
|
||||
{
|
|
@ -7,9 +7,10 @@ using LibHac.Common.Keys;
|
|||
using LibHac.Crypto;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public struct NcaHeader
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace LibHac.FsSystem.NcaUtils;
|
||||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
internal enum NcaKeyType
|
||||
{
|
35
src/LibHac/Tools/FsSystem/NcaUtils/NcaStructs.cs
Normal file
35
src/LibHac/Tools/FsSystem/NcaUtils/NcaStructs.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
namespace LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
public class TitleVersion
|
||||
{
|
||||
public uint Version { get; }
|
||||
public int Major { get; }
|
||||
public int Minor { get; }
|
||||
public int Patch { get; }
|
||||
public int Revision { get; }
|
||||
|
||||
public TitleVersion(uint version, bool isSystemTitle = false)
|
||||
{
|
||||
Version = version;
|
||||
|
||||
if (isSystemTitle)
|
||||
{
|
||||
Revision = (int)(version & ((1 << 16) - 1));
|
||||
Patch = (int)((version >> 16) & ((1 << 4) - 1));
|
||||
Minor = (int)((version >> 20) & ((1 << 6) - 1));
|
||||
Major = (int)((version >> 26) & ((1 << 6) - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Revision = (byte)version;
|
||||
Patch = (byte)(version >> 8);
|
||||
Minor = (byte)(version >> 16);
|
||||
Major = (byte)(version >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Major}.{Minor}.{Patch}.{Revision}";
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using ContentType = LibHac.Ncm.ContentType;
|
||||
|
||||
namespace LibHac.Tools.Ncm;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Tools.Fs;
|
||||
using ContentType = LibHac.Ncm.ContentType;
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Buffers.Binary;
|
|||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
namespace hactoolnet;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ using LibHac.Common;
|
|||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using static hactoolnet.Print;
|
||||
|
||||
namespace hactoolnet;
|
||||
|
|
|
@ -6,8 +6,8 @@ using LibHac.Fs;
|
|||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Impl;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Npdm;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using static hactoolnet.Print;
|
||||
|
||||
namespace hactoolnet;
|
||||
|
|
|
@ -8,7 +8,6 @@ using LibHac;
|
|||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.Fs;
|
||||
using LibHac.Tools.FsSystem.Save;
|
||||
|
|
|
@ -4,8 +4,8 @@ using System.Text;
|
|||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Tools.Fs;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using static hactoolnet.Print;
|
||||
|
||||
namespace hactoolnet;
|
||||
|
|
Loading…
Reference in a new issue