public override void Write(WritingContext context) { foreach (var block in Blocks) { block.Write(context); } }
public override void Write(WritingContext context) { var stream = context.Writer; stream.WriteUInt32(VirtualAddress); stream.WriteUInt32(Size); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(NameId); writer.WriteUInt32(OffsetToData); }
public override void Write(WritingContext context) { foreach (var moduleImport in ModuleImports) { moduleImport.Write(context); } new ImageModuleImport().Write(context); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(PageRva); writer.WriteUInt32(BlockSize); foreach (var entry in Entries) entry.Write(context); }
public override void Write(WritingContext context) { var rva = OffsetConverter.FileOffsetToRva(Reference.StartOffset); if (Is32Bit) context.Writer.WriteUInt32((uint)rva); else context.Writer.WriteUInt64((ulong)rva); }
public override void Write(WritingContext context) { // TODO: more elegant way of creating buffer. uint physicalLength = GetPhysicalLength(); context.Writer.Position += physicalLength; context.Writer.Position -= physicalLength; base.Write(context); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt16(Hint); writer.WriteBytes(Encoding.ASCII.GetBytes(Name)); writer.WriteByte(0); if (writer.Position % 2 != 0) writer.WriteByte(0); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(ImportLookupTableRva); writer.WriteUInt32(TimeDateStamp); writer.WriteUInt32(ForwarderChain); writer.WriteUInt32(NameRva); writer.WriteUInt32(ImportAddressTableRva); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(PageRva); writer.WriteUInt32(BlockSize); foreach (var entry in Entries) { entry.Write(context); } }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt16(Hint); writer.WriteBytes(Encoding.ASCII.GetBytes(Name)); writer.WriteByte(0); if (writer.Position % 2 != 0) { writer.WriteByte(0); } }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt16((ushort)Machine); writer.WriteUInt16(NumberOfSections); writer.WriteUInt32(TimeDateStamp); writer.WriteUInt32(PointerToSymbolTable); writer.WriteUInt32(NumberOfSymbols); writer.WriteUInt16(SizeOfOptionalHeader); writer.WriteUInt16((ushort)Characteristics); }
public override void Write(WritingContext context) { var rva = OffsetConverter.FileOffsetToRva(Reference.StartOffset); if (Is32Bit) { context.Writer.WriteUInt32((uint)rva); } else { context.Writer.WriteUInt64((ulong)rva); } }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(Characteristics); writer.WriteUInt32(TimeDateStamp); writer.WriteUInt16(MajorVersion); writer.WriteUInt16(MinorVersion); writer.WriteUInt32((uint)Type); writer.WriteUInt32(SizeOfData); writer.WriteUInt32(AddressOfRawData); writer.WriteUInt32(PointerToRawData); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(Characteristics); writer.WriteUInt32(TimeDateStamp); writer.WriteUInt16(MajorVersion); writer.WriteUInt16(MinorVersion); writer.WriteUInt32(NameRva); writer.WriteUInt32(OrdinalBase); writer.WriteUInt32(NumberOfFunctions); writer.WriteUInt32(NumberOfNames); writer.WriteUInt32(AddressOfFunctions); writer.WriteUInt32(AddressOfNames); writer.WriteUInt32(AddressOfNameOrdinals); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(Characteristics); writer.WriteUInt32(TimeDateStamp); writer.WriteUInt16(MajorVersion); writer.WriteUInt16(MinorVersion); writer.WriteUInt16(NamedEntriesCount); writer.WriteUInt16(IdEntriesCount); foreach (var entry in Entries) { entry.Write(context); } }
public override void Write(WritingContext context) { var writer = context.Writer; var nameBytes = Encoding.ASCII.GetBytes(Name ?? string.Empty); writer.WriteBytes(nameBytes); writer.WriteBytes(new byte[8 - nameBytes.Length]); writer.WriteUInt32(VirtualSize); writer.WriteUInt32(VirtualAddress); writer.WriteUInt32(SizeOfRawData); writer.WriteUInt32(PointerToRawData); writer.WriteUInt32(PointerToRelocations); writer.WriteUInt32(PointerToLinenumbers); writer.WriteUInt16(NumberOfRelocations); writer.WriteUInt16(NumberOfLinenumbers); writer.WriteUInt32((uint)Attributes); }
public override void Write(WritingContext context) { context.Writer.WriteUInt32(Signature); FileHeader.Write(context); OptionalHeader.Write(context); }
/// <summary> /// Writes the segment to a specific writing context. /// </summary> /// <param name="context">The context to use.</param> public abstract void Write(WritingContext context);
public override void Write(WritingContext context) { var writer = context.Writer; long start = writer.Position; writer.WriteUInt16((ushort)Magic); writer.WriteByte(MajorLinkerVersion); writer.WriteByte(MinorLinkerVersion); writer.WriteUInt32(SizeOfCode); writer.WriteUInt32(SizeOfInitializedData); writer.WriteUInt32(SizeOfUninitializedData); writer.WriteUInt32(AddressOfEntrypoint); writer.WriteUInt32(BaseOfCode); switch (Magic) { case OptionalHeaderMagic.Pe32: writer.WriteUInt32(BaseOfData); writer.WriteUInt32((uint)ImageBase); break; case OptionalHeaderMagic.Pe32Plus: writer.WriteUInt64(ImageBase); break; default: throw new NotSupportedException(string.Format("Unrecognized or unsupported executable format.")); } writer.WriteUInt32(SectionAlignment); writer.WriteUInt32(FileAlignment); writer.WriteUInt16(MajorOperatingSystemVersion); writer.WriteUInt16(MinorOperatingSystemVersion); writer.WriteUInt16(MajorImageVersion); writer.WriteUInt16(MinorImageVersion); writer.WriteUInt16(MajorSubsystemVersion); writer.WriteUInt16(MinorSubsystemVersion); writer.WriteUInt32(Win32VersionValue); writer.WriteUInt32(SizeOfImage); writer.WriteUInt32(SizeOfHeaders); writer.WriteUInt32(CheckSum); writer.WriteUInt16((ushort)Subsystem); writer.WriteUInt16((ushort)DllCharacteristics); if (Magic == OptionalHeaderMagic.Pe32) { writer.WriteUInt32((uint)SizeOfStackReserve); writer.WriteUInt32((uint)SizeOfStackCommit); writer.WriteUInt32((uint)SizeOfHeapReserve); writer.WriteUInt32((uint)SizeOfHeapCommit); } else { writer.WriteUInt64(SizeOfStackReserve); writer.WriteUInt64(SizeOfStackCommit); writer.WriteUInt64(SizeOfHeapReserve); writer.WriteUInt64(SizeOfHeapCommit); } writer.WriteUInt32(LoaderFlags); writer.WriteUInt32(NumberOfRvaAndSizes); foreach (var directory in DataDirectories) { directory.Write(context); } writer.WriteBytes(new byte[start + context.Assembly.NtHeaders.FileHeader.SizeOfOptionalHeader - writer.Position]); }
public override void Write(WritingContext context) { var writer = context.Writer; long start = writer.Position; writer.WriteUInt16((ushort)Magic); writer.WriteByte(MajorLinkerVersion); writer.WriteByte(MinorLinkerVersion); writer.WriteUInt32(SizeOfCode); writer.WriteUInt32(SizeOfInitializedData); writer.WriteUInt32(SizeOfUninitializedData); writer.WriteUInt32(AddressOfEntrypoint); writer.WriteUInt32(BaseOfCode); switch (Magic) { case OptionalHeaderMagic.Pe32: writer.WriteUInt32(BaseOfData); writer.WriteUInt32((uint)ImageBase); break; case OptionalHeaderMagic.Pe32Plus: writer.WriteUInt64(ImageBase); break; default: throw new NotSupportedException(string.Format("Unrecognized or unsupported executable format.")); } writer.WriteUInt32(SectionAlignment); writer.WriteUInt32(FileAlignment); writer.WriteUInt16(MajorOperatingSystemVersion); writer.WriteUInt16(MinorOperatingSystemVersion); writer.WriteUInt16(MajorImageVersion); writer.WriteUInt16(MinorImageVersion); writer.WriteUInt16(MajorSubsystemVersion); writer.WriteUInt16(MinorSubsystemVersion); writer.WriteUInt32(Win32VersionValue); writer.WriteUInt32(SizeOfImage); writer.WriteUInt32(SizeOfHeaders); writer.WriteUInt32(CheckSum); writer.WriteUInt16((ushort)Subsystem); writer.WriteUInt16((ushort)DllCharacteristics); if (Magic == OptionalHeaderMagic.Pe32) { writer.WriteUInt32((uint)SizeOfStackReserve); writer.WriteUInt32((uint)SizeOfStackCommit); writer.WriteUInt32((uint)SizeOfHeapReserve); writer.WriteUInt32((uint)SizeOfHeapCommit); } else { writer.WriteUInt64(SizeOfStackReserve); writer.WriteUInt64(SizeOfStackCommit); writer.WriteUInt64(SizeOfHeapReserve); writer.WriteUInt64(SizeOfHeapCommit); } writer.WriteUInt32(LoaderFlags); writer.WriteUInt32(NumberOfRvaAndSizes); foreach (var directory in DataDirectories) directory.Write(context); writer.WriteBytes(new byte[start + context.Assembly.NtHeaders.FileHeader.SizeOfOptionalHeader - writer.Position]); }
public override void Write(WritingContext context) { context.Writer.WriteBytes(_defaultDosHeader); }
public override void Write(WritingContext context) { foreach (var block in Blocks) block.Write(context); }
public override void Write(WritingContext context) { foreach (var moduleImport in ModuleImports) moduleImport.Write(context); new ImageModuleImport().Write(context); }
public override void Write(WritingContext context) { var writer = context.Writer; writer.WriteUInt32(Characteristics); writer.WriteUInt32(TimeDateStamp); writer.WriteUInt16(MajorVersion); writer.WriteUInt16(MinorVersion); writer.WriteUInt16(NamedEntriesCount); writer.WriteUInt16(IdEntriesCount); foreach (var entry in Entries) entry.Write(context); }
public override void Write(WritingContext context) { context.Writer.WriteBytes(Data); }