2018-11-29 03:01:19 +01:00
|
|
|
using Ryujinx.HLE.Exceptions;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.Loaders.Npdm
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
class Aci0
|
2018-11-29 03:01:19 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
private const int Aci0Magic = 'A' << 0 | 'C' << 8 | 'I' << 16 | '0' << 24;
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2019-09-02 18:03:57 +02:00
|
|
|
public ulong TitleId { get; set; }
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
public int FsVersion { get; private set; }
|
|
|
|
public ulong FsPermissionsBitmask { get; private set; }
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
public ServiceAccessControl ServiceAccessControl { get; private set; }
|
|
|
|
public KernelAccessControl KernelAccessControl { get; private set; }
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public Aci0(Stream stream, int offset)
|
2018-11-29 03:01:19 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
stream.Seek(offset, SeekOrigin.Begin);
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
BinaryReader reader = new BinaryReader(stream);
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (reader.ReadInt32() != Aci0Magic)
|
2018-11-29 03:01:19 +01:00
|
|
|
{
|
|
|
|
throw new InvalidNpdmException("ACI0 Stream doesn't contain ACI0 section!");
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
stream.Seek(0xc, SeekOrigin.Current);
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2019-09-02 18:03:57 +02:00
|
|
|
TitleId = reader.ReadUInt64();
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2019-07-02 04:39:22 +02:00
|
|
|
// Reserved.
|
2018-12-06 12:16:24 +01:00
|
|
|
stream.Seek(8, SeekOrigin.Current);
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
int fsAccessHeaderOffset = reader.ReadInt32();
|
|
|
|
int fsAccessHeaderSize = reader.ReadInt32();
|
|
|
|
int serviceAccessControlOffset = reader.ReadInt32();
|
|
|
|
int serviceAccessControlSize = reader.ReadInt32();
|
|
|
|
int kernelAccessControlOffset = reader.ReadInt32();
|
|
|
|
int kernelAccessControlSize = reader.ReadInt32();
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
FsAccessHeader fsAccessHeader = new FsAccessHeader(stream, offset + fsAccessHeaderOffset, fsAccessHeaderSize);
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
FsVersion = fsAccessHeader.Version;
|
|
|
|
FsPermissionsBitmask = fsAccessHeader.PermissionsBitmask;
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
ServiceAccessControl = new ServiceAccessControl(stream, offset + serviceAccessControlOffset, serviceAccessControlSize);
|
2018-11-29 03:01:19 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
KernelAccessControl = new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
|
2018-11-29 03:01:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|