Mono.Cecil.PE.ImageReader.ReadMetadata C# (CSharp) Method

ReadMetadata() private method

private ReadMetadata ( ) : void
return void
        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.TableHeap != null)
                ReadTableHeap ();

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

Usage Example

Example #1
0
 public static Image ReadPortablePdb(Disposable <Stream> stream, string file_name)
 {
     try
     {
         ImageReader imageReader = new ImageReader(stream, file_name);
         uint        num         = (uint)stream.value.Length;
         imageReader.image.Sections = new Section[1]
         {
             new Section
             {
                 PointerToRawData = 0,
                 SizeOfRawData    = num,
                 VirtualAddress   = 0,
                 VirtualSize      = num
             }
         };
         imageReader.metadata = new DataDirectory(0u, num);
         imageReader.ReadMetadata();
         return(imageReader.image);
     }
     catch (EndOfStreamException inner)
     {
         throw new BadImageFormatException(stream.value.GetFileName(), inner);
     }
 }
All Usage Examples Of Mono.Cecil.PE.ImageReader::ReadMetadata