示例#1
0
        internal void Read(BinaryReader br)
        {
            msdos.signature = br.ReadUInt16();
            br.BaseStream.Seek(58, SeekOrigin.Current);
            msdos.peSignatureOffset = br.ReadUInt32();
            if (msdos.signature != MSDOS_HEADER.IMAGE_DOS_SIGNATURE)
            {
                throw new BadImageFormatException();
            }
            br.BaseStream.Seek(msdos.peSignatureOffset, SeekOrigin.Begin);
            headers.Read(br);
            sections = new IMAGE_SECTION_HEADER[headers.FileHeader.NumberOfSections];
            for (int i = 0; i < sections.Length; i++)
            {
                sections[i] = new IMAGE_SECTION_HEADER();
                sections[i].Read(br);
            }
            var virtualAddress = GetComDescriptorVirtualAddress();

            if (virtualAddress > 0)
            {
                br.BaseStream.Seek(RvaToFileOffset(virtualAddress), SeekOrigin.Begin);
                cliHeader.Read(br);
                _CliHeaderWasRead = true;
            }
        }
示例#2
0
 internal void Read(BinaryReader br)
 {
     msdos.signature = br.ReadUInt16();
     br.BaseStream.Seek(58, SeekOrigin.Current);
     msdos.peSignatureOffset = br.ReadUInt32();
     if (msdos.signature != MSDOS_HEADER.IMAGE_DOS_SIGNATURE)
     {
         throw new BadImageFormatException();
     }
     br.BaseStream.Seek(msdos.peSignatureOffset, SeekOrigin.Begin);
     headers.Read(br);
     sections = new IMAGE_SECTION_HEADER[headers.FileHeader.NumberOfSections];
     for (int i = 0; i < sections.Length; i++)
     {
         sections[i] = new IMAGE_SECTION_HEADER();
         sections[i].Read(br);
     }
     var virtualAddress = GetComDescriptorVirtualAddress();
     if (virtualAddress > 0)
     {
         br.BaseStream.Seek(RvaToFileOffset(virtualAddress), SeekOrigin.Begin);
         cliHeader.Read(br);
         _CliHeaderWasRead = true;
     }
 }