Exemple #1
0
        public Acid(Stream stream, int offset, KeySet keySet)
        {
            stream.Seek(offset, SeekOrigin.Begin);

            var reader = new BinaryReader(stream);

            Rsa2048Signature = reader.ReadBytes(0x100);
            Rsa2048Modulus   = reader.ReadBytes(0x100);

            Magic = reader.ReadAscii(0x4);
            if (Magic != "ACID")
            {
                throw new Exception("ACID Stream doesn't contain ACID section!");
            }

            Size = reader.ReadInt32();

            if (keySet != null)
            {
                reader.BaseStream.Position = offset + 0x100;
                byte[] signatureData = reader.ReadBytes(Size);
                SignatureValidity =
                    CryptoOld.Rsa2048PssVerify(signatureData, Rsa2048Signature, keySet.AcidSigningKeyParams[0].Modulus);
            }

            reader.BaseStream.Position = offset + 0x208;
            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();

            int fsAccessControlOffset      = reader.ReadInt32();
            int fsAccessControlSize        = reader.ReadInt32();
            int serviceAccessControlOffset = reader.ReadInt32();
            int serviceAccessControlSize   = reader.ReadInt32();
            int kernelAccessControlOffset  = reader.ReadInt32();
            int kernelAccessControlSize    = reader.ReadInt32();

            FsAccess = new FsAccessControl(stream, offset + fsAccessControlOffset);

            ServiceAccess = new ServiceAccessControl(stream, offset + serviceAccessControlOffset, serviceAccessControlSize);

            KernelAccess = new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
        }
Exemple #2
0
        public Aci0(Stream stream, int offset)
        {
            stream.Seek(offset, SeekOrigin.Begin);

            var reader = new BinaryReader(stream);

            Magic = reader.ReadAscii(0x4);

            if (Magic != "ACI0")
            {
                throw new Exception("ACI0 Stream doesn't contain ACI0 section!");
            }

            stream.Seek(0xc, SeekOrigin.Current);

            TitleId = reader.ReadInt64();

            //Reserved.
            stream.Seek(8, SeekOrigin.Current);

            int fsAccessHeaderOffset       = reader.ReadInt32();
            int fsAccessHeaderSize         = reader.ReadInt32();
            int serviceAccessControlOffset = reader.ReadInt32();
            int serviceAccessControlSize   = reader.ReadInt32();
            int kernelAccessControlOffset  = reader.ReadInt32();
            int kernelAccessControlSize    = reader.ReadInt32();

            if (fsAccessHeaderSize > 0)
            {
                var accessHeader = new FsAccessHeader(stream, offset + fsAccessHeaderOffset);

                FsVersion            = accessHeader.Version;
                FsPermissionsBitmask = accessHeader.PermissionsBitmask;
            }

            if (serviceAccessControlSize > 0)
            {
                ServiceAccess = new ServiceAccessControl(stream, offset + serviceAccessControlOffset,
                                                         serviceAccessControlSize);
            }

            if (kernelAccessControlSize > 0)
            {
                KernelAccess =
                    new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
            }
        }