Esempio n. 1
0
        public static AFSSection load(BinaryReader reader)
        {
            var AFSection = new AFSSection
            {
                offset = reader.ReadInt32(),
                length = reader.ReadInt32(),
            };

            return(AFSection);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        private const uint VIRTUAL_ALLOCATION_ADDRESS = 0x8CB00000; // Supposed to be offset for section

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