2018-11-28 21:01:19 -05:00
|
|
|
using Ryujinx.HLE.Exceptions;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.Loaders.Npdm
|
|
|
|
{
|
2019-11-28 23:32:51 -05:00
|
|
|
public class Acid
|
2018-11-28 21:01:19 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
private const int AcidMagic = 'A' << 0 | 'C' << 8 | 'I' << 16 | 'D' << 24;
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
public byte[] Rsa2048Signature { get; private set; }
|
|
|
|
public byte[] Rsa2048Modulus { get; private set; }
|
2018-12-04 19:52:39 -05:00
|
|
|
public int Unknown1 { get; private set; }
|
|
|
|
public int Flags { get; private set; }
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
public long TitleIdRangeMin { get; private set; }
|
|
|
|
public long TitleIdRangeMax { get; private set; }
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-04 19:52:39 -05:00
|
|
|
public FsAccessControl FsAccessControl { get; private set; }
|
|
|
|
public ServiceAccessControl ServiceAccessControl { get; private set; }
|
|
|
|
public KernelAccessControl KernelAccessControl { get; private set; }
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
public Acid(Stream stream, int offset)
|
2018-11-28 21:01:19 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
stream.Seek(offset, SeekOrigin.Begin);
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
BinaryReader reader = new BinaryReader(stream);
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
Rsa2048Signature = reader.ReadBytes(0x100);
|
|
|
|
Rsa2048Modulus = reader.ReadBytes(0x100);
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
if (reader.ReadInt32() != AcidMagic)
|
2018-11-28 21:01:19 -05:00
|
|
|
{
|
|
|
|
throw new InvalidNpdmException("ACID Stream doesn't contain ACID section!");
|
|
|
|
}
|
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Size field used with the above signature (?).
|
2018-12-06 06:16:24 -05:00
|
|
|
Unknown1 = reader.ReadInt32();
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
reader.ReadInt32();
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Bit0 must be 1 on retail, on devunit 0 is also allowed. Bit1 is unknown.
|
2018-12-06 06:16:24 -05:00
|
|
|
Flags = reader.ReadInt32();
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
TitleIdRangeMin = reader.ReadInt64();
|
|
|
|
TitleIdRangeMax = reader.ReadInt64();
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05: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-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
FsAccessControl = new FsAccessControl(stream, offset + fsAccessControlOffset, fsAccessControlSize);
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
ServiceAccessControl = new ServiceAccessControl(stream, offset + serviceAccessControlOffset, serviceAccessControlSize);
|
2018-11-28 21:01:19 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
KernelAccessControl = new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
|
2018-11-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|