예제 #1
0
        private void ReadMetadata()
        {
            MoveTo(metadata);
            if (ReadUInt32() != 1112167234)
            {
                throw new BadImageFormatException();
            }
            base.Advance(8);
            image.RuntimeVersion = ReadZeroTerminatedString(ReadInt32());
            base.Advance(2);
            ushort  num = ReadUInt16();
            Section sectionAtVirtualAddress = image.GetSectionAtVirtualAddress(metadata.VirtualAddress);

            if (sectionAtVirtualAddress == null)
            {
                throw new BadImageFormatException();
            }
            image.MetadataSection = sectionAtVirtualAddress;
            for (int i = 0; i < num; i++)
            {
                ReadMetadataStream(sectionAtVirtualAddress);
            }
            if (image.PdbHeap != null)
            {
                ReadPdbHeap();
            }
            if (image.TableHeap != null)
            {
                ReadTableHeap();
            }
        }
예제 #2
0
파일: ImageReader.cs 프로젝트: pureivan/XIL
        void ReadMetadata()
        {
            MoveTo(metadata);

            if (ReadUInt32() != 0x424a5342)
            {
                throw new BadImageFormatException();
            }

            // MajorVersion			2
            // MinorVersion			2
            // Reserved				4
            Advance(8);

            image.RuntimeVersion = ReadZeroTerminatedString(ReadInt32());

            // Flags		2
            Advance(2);

            var streams = ReadUInt16();

            var section = image.GetSectionAtVirtualAddress(metadata.VirtualAddress);

            if (section == null)
            {
                throw new BadImageFormatException();
            }

            image.MetadataSection = section;

            for (int i = 0; i < streams; i++)
            {
                ReadMetadataStream(section);
            }

            if (image.PdbHeap != null)
            {
                ReadPdbHeap();
            }

            if (image.TableHeap != null)
            {
                ReadTableHeap();
            }
        }