public void SectionTable_Is_Has_Expected_Sections(string fileName, string[] expectedSections) { var file = TestingUtils.GetFileFromResources(fileName); using (var image = PortableExecutableImage.FromStream(file)) { var sections = image.SectionTable.Select(s => s.Name) .OrderBy(s => s) .ToArray(); var sortedExpectedSections = expectedSections.OrderBy(s => s) .ToArray(); sections.Should().BeEquivalentTo(sortedExpectedSections); } }
public void SectionTable_Entry_Has_Expected_Values(string sectionName, uint virtualSize, uint rva, uint sizeRaw, uint pointerRaw, uint characteristics) { var file = TestingUtils.GetFileFromResources("nativetest.x86.dll"); using (var image = PortableExecutableImage.FromStream(file)) { var section = image.SectionTable.FirstOrDefault(s => string.Compare(sectionName, s.Name, StringComparison.OrdinalIgnoreCase) == 0); section.Should().NotBeNull(); section.VirtualSizeOrPhysicalAddress.Should().Be(virtualSize); section.VirtualAddress.Should().Be(rva); section.SizeOfRawData.Should().Be(sizeRaw); section.PointerToRawData.Should().Be(pointerRaw); section.Characteristics.Should().Be(characteristics); } }
public void SetUp() { _image = PortableExecutableImage.FromStream(TestingUtils.GetFileFromResources("nativetest.x64.dll")); _calc = _image.GetCalculator(); }