static EncryptionVersion getHeaderOffsetAndVersion(MyPEImage peImage, out uint headerOffset) { headerOffset = 0; var version = getVersion(peImage, headerOffset); if (version != EncryptionVersion.Unknown) { return(version); } var section = peImage.findSection(".rsrc"); if (section == null) { return(EncryptionVersion.Unknown); } headerOffset = section.PointerToRawData; uint end = section.PointerToRawData + section.SizeOfRawData - 0x1000 + 1; while (headerOffset < end) { version = getVersion(peImage, headerOffset); if (version != EncryptionVersion.Unknown) { return(version); } headerOffset++; } return(EncryptionVersion.Unknown); }
static ImageSectionHeader getLastOf(MyPEImage peImage, string[] sections) { ImageSectionHeader sect = null; foreach (var name in sections) { var sect2 = peImage.findSection(name); if (sect2 == null) { continue; } if (sect == null || sect2.VirtualAddress > sect.VirtualAddress) { sect = sect2; } } return(sect); }
static ImageSectionHeader getLastOf(MyPEImage peImage, string[] sections) { ImageSectionHeader sect = null; foreach (var name in sections) { var sect2 = peImage.findSection(name); if (sect2 == null) continue; if (sect == null || sect2.VirtualAddress > sect.VirtualAddress) sect = sect2; } return sect; }