コード例 #1
0
        public static AFSSection load(BinaryReader reader)
        {
            var AFSection = new AFSSection
            {
                offset = reader.ReadInt32(),
                length = reader.ReadInt32(),
            };

            return(AFSection);
        }
コード例 #2
0
        public AFSSection[] sections;    // sections are relative to file base

        public static AFSFile load(BinaryReader reader)
        {
            var head = reader.ReadInt32();

            if (head != AFS_HEAD)
            {
                throw new InvalidDataException($"AFSFile.load expected 0x{AFS_HEAD:X} 'AFS\\x00', got {head:X}");
            }
            var AFS = new AFSFile();

            AFS.sectionCount = reader.ReadInt32();
            AFS.sections     = new AFSSection[AFS.sectionCount];

            for (int i = 0; i < AFS.sectionCount; i++)
            {
                AFS.sections[i] = AFSSection.load(reader);
            }

            for (int i = 0; i < AFS.sectionCount; i++)
            {
                reader.BaseStream.Position = AFS.sections[i].offset;
                //Console.WriteLine($"{reader.BaseStream.Position:X}, {AFS.sections[i].length:X} ");
                AFS.sections[i].data = reader.ReadBytes(AFS.sections[i].length);
            }
            // we're at the end anchor of the second section

            /*
             * // locate filetable offset
             * // there's probably better way to do this
             * Console.WriteLine("Finding filetable...");
             * while ((reader.ReadByte()) == 0) ;
             *
             * reader.BaseStream.Position -= 1; // Dec one pos.
             * //NNGHGHGNGHH
             */
            reader.BaseStream.Position = AFS.sections[0].offset - 0x10;
            reader.ReadUInt64();
            var filetable_offset = reader.ReadUInt32();

            // Console.WriteLine($"{filetable_offset:X}");
            reader.BaseStream.Position = filetable_offset;

            for (int i = 0; i < AFS.sectionCount; i++)
            {
                AFS.sections[i].descriptor = AFSSectionDescriptor.load(reader);
            }

            return(AFS);
        }
コード例 #3
0
ファイル: JSRSceneBin.cs プロジェクト: XAYRGA/ArfAFS
        private const uint VIRTUAL_ALLOCATION_ADDRESS = 0x8CB00000; // Supposed to be offset for section

        public JSRSceneBin(AFSSection sect)
        {
            reader = new BinaryReader(new MemoryStream(sect.data));
        }