public override void ReadDirectories(PeCoffFile containingFile) { _metadata = new MetadataDirectory( containingFile, containingFile.GetAddressFromRVA(this.Header.MetaData.VirtualAddress) ); }
public void WhenNoSectionsRvaCantBeComputed_GetRva_ThrowsException() { Mock <IFileSystem> fileSystem = new Mock <IFileSystem>(); PeCoffFile coffFile = new PeCoffFile("doesnt-matter.dll", fileSystem.Object); // section headers need to be set up to be able work out the rva coffFile.SectionHeaders = new List <SectionHeader>(); Assert.Throws <InvalidOperationException>(delegate() { coffFile.GetAddressFromRVA(0x00000000); }); }
[TestCase(0x0000d000, 0x00001200)] // top of range public void WhenHeaderIsInRange_GetRva_AddressIsCalculated(int rva, int expected) { Mock <IFileSystem> fileSystem = new Mock <IFileSystem>(); PeCoffFile coffFile = new PeCoffFile("doesnt-matter.dll", fileSystem.Object); // section headers need to be set up to be able work out the rva coffFile.SectionHeaders = new List <SectionHeader>(); coffFile.SectionHeaders.Add(CreateSectionHeader(0x0000c000, 0x0000d000, 0x00000200)); uint result = coffFile.GetAddressFromRVA((uint)rva); Assert.AreEqual(expected, result); }
public void WhenHeaderStartIsInRangeButRvaIsOutside_GetRva_ThrowsException() { Mock <IFileSystem> fileSystem = new Mock <IFileSystem>(); PeCoffFile coffFile = new PeCoffFile("doesnt-matter.dll", fileSystem.Object); // section headers need to be set up to be able work out the rva coffFile.SectionHeaders = new List <SectionHeader>(); coffFile.SectionHeaders.Add(CreateSectionHeader(0x0000c000, 0x00000001, 0x0)); Assert.Throws <InvalidOperationException>(delegate() { coffFile.GetAddressFromRVA(0x00000c02); }); }
internal uint FileAddressFromRVA(uint rva) { return(_peCoffFile.GetAddressFromRVA(rva)); }