示例#1
0
        public void SectionTable_Is_Not_Null()
        {
            var file = TestingUtils.GetFileFromResources(TestingUtils.GetRandomTestFilename());

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.SectionTable.Should().NotBeNull();
            }
        }
示例#2
0
        public void IsCLR_With_CLR_Image_Returns_True()
        {
            var file = TestingUtils.GetFileFromResources("clrtest.any.dll");

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.IsCLR.Should().BeTrue();
            }
        }
示例#3
0
        public void IsSigned_Returns_False()
        {
            var file = TestingUtils.GetFileFromResources(TestingUtils.GetRandomTestFilename());

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.IsSigned.Should().BeFalse();
            }
        }
示例#4
0
文件: SectionTests.cs 项目: zzfeed/pe
        public void Sections_Is_Not_Null(string fileName)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.Sections.Should().NotBeNull();
            }
        }
示例#5
0
        public void IsCLR_With_Native_Image_Returns_False()
        {
            var file = TestingUtils.GetFileFromResources("nativetest.x86.dll");

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.IsCLR.Should().BeFalse();
            }
        }
示例#6
0
        public void SectionTable_Is_Has_Correct_Sections_Count(string fileName, string[] expectedSections)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.SectionTable.Count.Should().Be(expectedSections.Length);
            }
        }
示例#7
0
文件: SectionTests.cs 项目: zzfeed/pe
        public void Sections_Has_Expected_Count(string fileName)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.Sections.Count.Should().Be(image.SectionTable.Count);
            }
        }
示例#8
0
        public void DataDirectory_Is_Not_Empty()
        {
            var file = TestingUtils.GetFileFromResources(TestingUtils.GetRandomTestFilename());

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.NTHeaders.DataDirectories.Count.Should().BeGreaterThan(0);
            }
        }
示例#9
0
        public void DataDirectory_Is_Not_Null()
        {
            var file = TestingUtils.GetFileFromResources(TestingUtils.GetRandomTestFilename());

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.NTHeaders.DataDirectories.Should().NotBeNull();
            }
        }
示例#10
0
        public void Is64Bit_With_32Bit_Image_Returns_False()
        {
            var file = TestingUtils.GetFileFromResources("clrtest.x86.dll");

            using (var image = PortableExecutableImage.FromStream(file))
            {
                image.Is64Bit.Should().BeFalse();
            }
        }
示例#11
0
        public void GetCalculator_Returns_Successfully()
        {
            var file = TestingUtils.GetFileFromResources("clrtest.any.dll");

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var calc = image.GetCalculator();

                calc.Should().NotBeNull();
            }
        }
示例#12
0
        public void Characteristics_Is_Correct(string fileName, long expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.FileHeader.Characteristics;

                value.Should().Be(Convert.ToUInt16(expectedValue));
            }
        }
示例#13
0
        public void File_Address_New_Header_Is_Correct(string fileName, int expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.DOSHeader.FileAddressNewHeader;

                value.Should().Be(expectedValue);
            }
        }
示例#14
0
        public void MinorLinkerVersion_Is_Correct(string fileName, int expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.OptionalHeader.MinorLinkerVersion;

                value.Should().Be(Convert.ToByte(expectedValue));
            }
        }
示例#15
0
        private static void DataDirectory_Exists(string fileName, DataDirectoryType type, bool expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.DataDirectories.ExistsAndNotEmpty(type);

                value.Should().Be(expectedValue);
            }
        }
示例#16
0
        public void SizeOfCode_Is_Correct(string fileName, int expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.OptionalHeader.SizeOfCode;

                value.Should().Be(Convert.ToUInt32(expectedValue));
            }
        }
示例#17
0
        public void File_Address_Relocation_Table_Is_Correct(string fileName, int expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.DOSHeader.FileAddressRelocationTable;

                value.Should().Be(Convert.ToUInt16(expectedValue));
            }
        }
示例#18
0
        public void Bytes_On_Last_Page_Of_File_Is_Correct(string fileName, int expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.DOSHeader.BytesOnLastPage;

                value.Should().Be(Convert.ToUInt16(expectedValue));
            }
        }
示例#19
0
        public void Type_Is_Correct(string fileName, Type type)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.OptionalHeader;

                value.Should().BeOfType(type);
            }
        }
示例#20
0
        public void FileAlignment_Is_Correct(string fileName, uint expectedValue)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.OptionalHeader.FileAlignment;

                value.Should().Be(expectedValue);
            }
        }
示例#21
0
文件: SectionTests.cs 项目: zzfeed/pe
        public void Section_Has_Expected_Offset(string fileName)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                foreach (var section in image.Sections)
                {
                    section.Location.FileOffset.Should().Be(section.TableEntry.PointerToRawData);
                }
            }
        }
示例#22
0
        public void NumberOfRVA_Is_Correct()
        {
            var fileName = TestingUtils.GetRandomTestFilename();
            var file     = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var value = image.NTHeaders.OptionalHeader.NumberOfRvaAndSizes;

                value.Should().Be(16);
            }
        }
示例#23
0
        public void DataDirectory_DelayImportDescriptors_RVA_And_Size_Is_Correct()
        {
            var file = TestingUtils.GetFileFromResources("nativetest.x64.dll");

            using (var image = PortableExecutableImage.FromStream(file))
            {
                var directory = image.NTHeaders.DataDirectories.FirstOrDefault(e => e.DirectoryType == DataDirectoryType.DelayImportDescriptor);

                directory.Should().NotBeNull();
                directory.VirtualAddress.Should().Be(0x00018000U);
                directory.Size.Should().Be(0x00000180U);
            }
        }
示例#24
0
文件: SectionTests.cs 项目: zzfeed/pe
        public void Section_Has_Expected_Size(string fileName)
        {
            var file = TestingUtils.GetFileFromResources(fileName);

            using (var image = PortableExecutableImage.FromStream(file))
            {
                foreach (var section in image.Sections)
                {
                    var buffer = section.GetBytes();

                    buffer.LongLength.Should().Be(Convert.ToInt64(section.TableEntry.SizeOfRawData));
                }
            }
        }
示例#25
0
        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);
            }
        }
示例#26
0
        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);
            }
        }
示例#27
0
 public void SetUp()
 {
     _image = PortableExecutableImage.FromStream(TestingUtils.GetFileFromResources("nativetest.x64.dll"));
     _calc  = _image.GetCalculator();
 }