2018-08-17 01:47:36 +02:00
|
|
|
using Ryujinx.HLE.Exceptions;
|
2018-06-18 04:28:11 +02:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.Loaders.Npdm
|
|
|
|
{
|
|
|
|
class ACID
|
|
|
|
{
|
2018-08-17 01:47:36 +02:00
|
|
|
private const int ACIDMagic = 'A' << 0 | 'C' << 8 | 'I' << 16 | 'D' << 24;
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
public byte[] RSA2048Signature { get; private set; }
|
|
|
|
public byte[] RSA2048Modulus { get; private set; }
|
|
|
|
public int Unknown1 { get; private set; }
|
|
|
|
public int Flags { get; private set; }
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
public long TitleIdRangeMin { get; private set; }
|
|
|
|
public long TitleIdRangeMax { get; private set; }
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
public FsAccessControl FsAccessControl { get; private set; }
|
|
|
|
public ServiceAccessControl ServiceAccessControl { get; private set; }
|
|
|
|
public KernelAccessControl KernelAccessControl { get; private set; }
|
2018-06-24 02:39:25 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
public ACID(Stream Stream, int Offset)
|
2018-06-18 04:28:11 +02:00
|
|
|
{
|
2018-08-17 01:47:36 +02:00
|
|
|
Stream.Seek(Offset, SeekOrigin.Begin);
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
BinaryReader Reader = new BinaryReader(Stream);
|
2018-06-18 04:28:11 +02:00
|
|
|
|
|
|
|
RSA2048Signature = Reader.ReadBytes(0x100);
|
|
|
|
RSA2048Modulus = Reader.ReadBytes(0x100);
|
|
|
|
|
|
|
|
if (Reader.ReadInt32() != ACIDMagic)
|
|
|
|
{
|
|
|
|
throw new InvalidNpdmException("ACID Stream doesn't contain ACID section!");
|
|
|
|
}
|
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
//Size field used with the above signature (?).
|
|
|
|
Unknown1 = Reader.ReadInt32();
|
|
|
|
|
|
|
|
Reader.ReadInt32();
|
|
|
|
|
|
|
|
//Bit0 must be 1 on retail, on devunit 0 is also allowed. Bit1 is unknown.
|
|
|
|
Flags = Reader.ReadInt32();
|
|
|
|
|
|
|
|
TitleIdRangeMin = Reader.ReadInt64();
|
|
|
|
TitleIdRangeMax = Reader.ReadInt64();
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
int FsAccessControlOffset = Reader.ReadInt32();
|
|
|
|
int FsAccessControlSize = Reader.ReadInt32();
|
|
|
|
int ServiceAccessControlOffset = Reader.ReadInt32();
|
|
|
|
int ServiceAccessControlSize = Reader.ReadInt32();
|
|
|
|
int KernelAccessControlOffset = Reader.ReadInt32();
|
|
|
|
int KernelAccessControlSize = Reader.ReadInt32();
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
FsAccessControl = new FsAccessControl(Stream, Offset + FsAccessControlOffset, FsAccessControlSize);
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
ServiceAccessControl = new ServiceAccessControl(Stream, Offset + ServiceAccessControlOffset, ServiceAccessControlSize);
|
2018-06-18 04:28:11 +02:00
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
KernelAccessControl = new KernelAccessControl(Stream, Offset + KernelAccessControlOffset, KernelAccessControlSize);
|
2018-06-18 04:28:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|