예제 #1
0
        public static InterfacesChunk Parse(BytecodeReader reader, uint sizeInBytes)
        {
            var headerReader = reader.CopyAtCurrentPosition();

            var result = new InterfacesChunk();

            var classInstanceCount       = headerReader.ReadUInt32();
            var classTypeCount           = headerReader.ReadUInt32();
            var interfaceSlotRecordCount = headerReader.ReadUInt32();

            // Will be same as interfaceSlotRecordCount unless there are interface arrays.
            result.InterfaceSlotCount = headerReader.ReadUInt32();

            // Think this is offset to start of interface slot info, but we
            // don't need it because it is also contained in the InterfaceSlot class
            var typeIDsOffset = headerReader.ReadUInt32();

            var classTypeOffset      = headerReader.ReadUInt32();
            var availableClassReader = reader.CopyAtOffset((int)classTypeOffset);

            var interfaceSlotOffset = headerReader.ReadUInt32();
            var interfaceSlotReader = reader.CopyAtOffset((int)interfaceSlotOffset);

            var unknown1 = headerReader.ReadUInt32();

            Debug.Assert(unknown1.ToFourCcString() == "OSGN");
            var unknown2 = headerReader.ReadUInt16();

            Debug.Assert(unknown2 == 32);
            var unknown3 = headerReader.ReadUInt16();

            Debug.Assert(unknown3 == 16);

            for (uint i = 0; i < classTypeCount; i++)
            {
                var classType = ClassType.Parse(reader, availableClassReader);
                classType.ID = i;                 // Really??
                result.AvailableClassTypes.Add(classType);
            }

            for (uint i = 0; i < classInstanceCount; i++)
            {
                var classInstance = ClassInstance.Parse(reader, availableClassReader);
                result.AvailableClassInstances.Add(classInstance);
            }

            uint startSlot = 0;

            for (uint i = 0; i < interfaceSlotRecordCount; i++)
            {
                var interfaceSlot = InterfaceSlot.Parse(reader, interfaceSlotReader);
                interfaceSlot.StartSlot = startSlot;                 // Really??
                result.InterfaceSlots.Add(interfaceSlot);

                startSlot += interfaceSlot.SlotSpan;
            }

            return(result);
        }
예제 #2
0
        public static InterfacesChunk Parse(BytecodeReader reader, uint sizeInBytes)
        {
            var headerReader = reader.CopyAtCurrentPosition();

            var result = new InterfacesChunk();

            var classInstanceCount       = headerReader.ReadUInt32();
            var classTypeCount           = headerReader.ReadUInt32();
            var interfaceSlotRecordCount = headerReader.ReadUInt32();

            // Will be same as interfaceSlotRecordCount unless there are interface arrays.
            result.InterfaceSlotCount = headerReader.ReadUInt32();

            headerReader.ReadUInt32();             // Think this is offset to start of interface slot info, but we don't need it.

            var classTypeOffset      = headerReader.ReadUInt32();
            var availableClassReader = reader.CopyAtOffset((int)classTypeOffset);

            var interfaceSlotOffset = headerReader.ReadUInt32();
            var interfaceSlotReader = reader.CopyAtOffset((int)interfaceSlotOffset);

            for (uint i = 0; i < classTypeCount; i++)
            {
                var classType = ClassType.Parse(reader, availableClassReader);
                classType.ID = i;                 // Really??
                result.AvailableClassTypes.Add(classType);
            }

            for (uint i = 0; i < classInstanceCount; i++)
            {
                var classInstance = ClassInstance.Parse(reader, availableClassReader);
                result.AvailableClassInstances.Add(classInstance);
            }

            uint startSlot = 0;

            for (uint i = 0; i < interfaceSlotRecordCount; i++)
            {
                var interfaceSlot = InterfaceSlot.Parse(reader, interfaceSlotReader);
                interfaceSlot.StartSlot = startSlot;                 // Really??
                result.InterfaceSlots.Add(interfaceSlot);

                startSlot += interfaceSlot.SlotSpan;
            }

            return(result);
        }