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(); }
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; } }
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); }
public SectionHeaderModel(SectionHeader sectionHeader) { this.sectionHeader = sectionHeader; }
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()); }