Ryujinx/Ryujinx.HLE/Loaders/Npdm/ACI0.cs

54 lines
1.9 KiB
C#
Raw Normal View History

2018-11-28 18:01:19 -08:00
using Ryujinx.HLE.Exceptions;
using System.IO;
namespace Ryujinx.HLE.Loaders.Npdm
{
class Aci0
2018-11-28 18:01:19 -08:00
{
private const int Aci0Magic = 'A' << 0 | 'C' << 8 | 'I' << 16 | '0' << 24;
2018-11-28 18:01:19 -08:00
public long TitleId { get; private set; }
2018-11-28 18:01:19 -08:00
public int FsVersion { get; private set; }
public ulong FsPermissionsBitmask { get; private set; }
2018-11-28 18:01:19 -08:00
public ServiceAccessControl ServiceAccessControl { get; private set; }
public KernelAccessControl KernelAccessControl { get; private set; }
2018-11-28 18:01:19 -08:00
public Aci0(Stream stream, int offset)
2018-11-28 18:01:19 -08:00
{
stream.Seek(offset, SeekOrigin.Begin);
2018-11-28 18:01:19 -08:00
BinaryReader reader = new BinaryReader(stream);
2018-11-28 18:01:19 -08:00
if (reader.ReadInt32() != Aci0Magic)
2018-11-28 18:01:19 -08:00
{
throw new InvalidNpdmException("ACI0 Stream doesn't contain ACI0 section!");
}
stream.Seek(0xc, SeekOrigin.Current);
2018-11-28 18:01:19 -08:00
TitleId = reader.ReadInt64();
2018-11-28 18:01:19 -08:00
//Reserved.
stream.Seek(8, SeekOrigin.Current);
2018-11-28 18:01:19 -08: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 18:01:19 -08:00
FsAccessHeader fsAccessHeader = new FsAccessHeader(stream, offset + fsAccessHeaderOffset, fsAccessHeaderSize);
2018-11-28 18:01:19 -08:00
FsVersion = fsAccessHeader.Version;
FsPermissionsBitmask = fsAccessHeader.PermissionsBitmask;
2018-11-28 18:01:19 -08:00
ServiceAccessControl = new ServiceAccessControl(stream, offset + serviceAccessControlOffset, serviceAccessControlSize);
2018-11-28 18:01:19 -08:00
KernelAccessControl = new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
2018-11-28 18:01:19 -08:00
}
}
}