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