示例#1
0
 static void ReadSectionHeader(BinaryStreamReader reader, SectionHeader section)
 {
     section.Name = reader.ReadFixedZeroFilledAsciiString(SectionHeader.MaximumNameSize);
     section.VirtualSize = reader.ReadUInt32();
     section.VirtualAddress = reader.ReadUInt32();
     section.SizeOfRawData = reader.ReadUInt32();
     section.PointerToRawData = reader.ReadUInt32();
     section.PointerToRelocations = reader.ReadUInt32();
     section.PointerToLinenumbers = reader.ReadUInt32();
     section.NumberOfRelocations = reader.ReadUInt16();
     section.NumberOfLinenumbers = reader.ReadUInt16();
     section.Characteristics = (SectionCharacteristics)reader.ReadUInt32();
 }
示例#2
0
        public void ReadFrom(BinaryStreamReader reader)
        {
            ReadDosHeader(reader);

            reader.Position = this.DosHeader.lfanew;
            ReadPEHeader(reader);
            ReadOptionalHeader(reader);

            this.SectionHeaders = new SectionHeader[this.PEHeader.NumberOfSections];

            for (int i = 0; i < this.SectionHeaders.Length; i++)
            {
                var sectionHeader = new SectionHeader();
                ReadSectionHeader(reader, sectionHeader);
                this.SectionHeaders[i] = sectionHeader;
            }
        }
示例#3
0
 static void WriteSectionHeader(BinaryStreamWriter writer, SectionHeader section)
 {
     writer.WriteFixedZeroFilledAsciiString(section.Name, SectionHeader.MaximumNameSize);
     writer.WriteUInt32(section.VirtualSize);
     writer.WriteUInt32(section.VirtualAddress);
     writer.WriteUInt32(section.SizeOfRawData);
     writer.WriteUInt32(section.PointerToRawData);
     writer.WriteUInt32(section.PointerToRelocations);
     writer.WriteUInt32(section.PointerToLinenumbers);
     writer.WriteUInt16(section.NumberOfRelocations);
     writer.WriteUInt16(section.NumberOfLinenumbers);
     writer.WriteUInt32((uint)section.Characteristics);
 }
示例#4
0
 public SectionHeaderModel(SectionHeader sectionHeader)
 {
     this.sectionHeader = sectionHeader;
 }
示例#5
0
        public void Section()
        {
            var sh = new SectionHeader();

            sh.Name = "Dummy";
            sh.PointerToRawData = 0x14e;
            sh.SizeOfRawData = 0x1aff0;
            sh.VirtualAddress = 0x1234c0;
            sh.VirtualSize = 0x320ff;

            Assert.AreEqual("Dummy [14E:1AFF0h]=>Virtual[1234C0:320FFh]", sh.ToString());
        }