Esempio n. 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();
        }
Esempio n. 2
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();
        }