コード例 #1
0
        void LoadMetaData()
        {
            metadataRva = parent._rawHeader.MetaData.RVA;
            Section section = Section.GetSectionByRva(ntHeader._assembly, metadataRva);

            offsetConverter    = new OffsetConverter(section);
            metadataFileOffset = offsetConverter.RvaToFileOffset(metadataRva);//= (uint)new CodeOffsetConverter(header.oheader).RVirtualToFileOffset((int)metadatavirtualoffset);

            metadataHeader1 = ntHeader._assembly._peImage.ReadStructure <Structures.METADATA_HEADER_1>(metadataFileOffset);

            byte[] versionBytes = image.ReadBytes((int)metadataFileOffset + sizeof(Structures.METADATA_HEADER_1), (int)metadataHeader1.VersionLength);
            metadataVersionString = Encoding.ASCII.GetString(versionBytes).Trim();

            metadataHeader2 = ntHeader._assembly._peImage.ReadStructure <Structures.METADATA_HEADER_2>((int)metadataFileOffset + sizeof(Structures.METADATA_HEADER_1) + metadataHeader1.VersionLength);

            metadataStreamOffset = (uint)metadataFileOffset + (uint)sizeof(Structures.METADATA_HEADER_1) + (uint)metadataHeader1.VersionLength + (uint)sizeof(Structures.METADATA_HEADER_2);
            LoadMetaDataStreams();
        }
コード例 #2
0
        internal void ReadFatMethod()
        {
            peImage.SetOffset(Offset.FromRva(rva, peImage.ParentAssembly).FileOffset);

            fatsig      = BitConverter.ToInt16(peImage.ReadBytes(2), 0);
            maxstack    = BitConverter.ToInt16(peImage.ReadBytes(2), 0);
            codesize    = BitConverter.ToUInt32(peImage.ReadBytes(4), 0);
            localvarsig = BitConverter.ToUInt32(peImage.ReadBytes(4), 0);
        }
コード例 #3
0
 /// <summary>
 /// Reads the data and returns it in byte array format.
 /// </summary>
 /// <returns></returns>
 public byte[] GetContents()
 {
     return(image.ReadBytes(targetOffset, (int)Size));
 }