public void Write(Block32 block) { address.Value = block.Current; block.AddBlock(Block); uint padlen = Module.Align((uint)Block.Length, 4) - (uint)Block.Length; if (padlen > 0) block.AddBytes(new byte[padlen]); }
public Block32 ToBlock(uint vaddr) { Block32 ret = Block32.New(vaddr); Write(ret); block = ret; return ret; }
public void WriteImportLookupTable(Block32 block) { table.ImportLookupTable = block.Current; foreach (var sym in symbols.Values) (sym as Symbol).WriteLookup(block, true); block.AddInt(0); }
public override void WriteBlock(Block32 block) { block.AddUInt(ImportLookupTable); block.AddUInt(DateTimeStamp); block.AddUInt(ForwarderChain); block.AddUInt(Name); block.AddUInt(ImportAddressTable); }
public override void Write(Block32 block) { for (int i = 0; i < OpCodes.Length; i++) { var op = OpCodes[i]; op.Address.Value = block.Current; op.Write(block); } }
public override void WriteBlock(Block32 block) { block.AddUShort(Machine); block.AddUShort(NumberOfSections); block.AddUInt(TimeDateStamp); block.AddUInt(PointerToSymbolTable); block.AddUInt(NumberOfSymbols); block.AddUShort(OptionalHeaderSize); block.AddUShort(Characteristics); }
public override void Write(Block32 block) { foreach (Library lib in libraries.Values) lib.WriteImportTable(block); new ImportTable().WriteBlock(block); foreach (Library lib in libraries.Values) lib.WriteImportLookupTable(block); foreach (Library lib in libraries.Values) lib.WriteImportAddressTable(block); foreach (Library lib in libraries.Values) lib.WriteSymbols(block); foreach (Library lib in libraries.Values) lib.WriteName(block); }
public Val32 AddData(string category, string name, Val32 type, int size, int len, Block32 data) { var db = new DataBlock(); db.Block.AddVal32(type); db.Block.AddInt(1); db.Block.AddInt(size); db.Block.AddInt(len); var offset = db.Block.Length; db.Block.AddBlock(data); Module.Data.AddDataBlock(category, name, db); return Val32.New2(db.Address, Val32.New(offset)); }
public override void WriteBlock(Block32 block) { block.AddString(signature); block.AddUShort(bytes_in_last_block); block.AddUShort(blocks_in_file); block.AddUShort(num_relocs); block.AddUShort(header_paragraphs); block.AddUShort(min_extra_paragraphs); block.AddUShort(max_extra_paragraphs); block.AddUShort(ss); block.AddUShort(sp); block.AddUShort(checksum); block.AddUShort(ip); block.AddUShort(cs); block.AddUShort(reloc_table_offset); block.AddUShort(overlay_number); }
public void AddBlock(Block32 block) { for (int i = 0; i < block.data.Count; i++) { var obj = block.data[i]; if (obj is Byte) AddByte2((Byte)obj); else if (obj is UShort) AddUShort2((UShort)obj); else if (obj is UInt) AddUInt2((UInt)obj); else if (obj is Int) AddInt2((Int)obj); else if (obj is byte[]) AddBytes((byte[])obj); else if (obj is char[]) AddChars((char[])obj); else if (obj is string) AddString((string)obj); else if (obj is Block32) AddBlock((Block32)obj); else if (obj is Val32) AddVal32((Val32)obj); else throw new Exception("The method or operation is not implemented."); } }
public void Write(Block32 block) { hintAddress.Value = block.Current; block.AddUShort(Hint); block.AddString(HeaderBase.Pad(NameSize, Name)); }
public void Write(Block32 block) { if (address != null) { block.AddByte((byte)(0x05 + (middleBits << 3))); block.AddVal32(address); } else { block.AddBytes(GetCodes()); } }
public override void Write(Block32 block) { foreach (ListDictionary ctg in data.Values) foreach (var db in ctg.Values) (db as DataBlock).Write(block); if (IsEmtpy) block.AddBytes(new byte[16]); }
public Block32 ToBlock() { var ret = new Block32(); WriteBlock(ret); return ret; }
public override void Write(Block32 block) { block.AddBytes(data); }
public void WriteSymbols(Block32 block) { foreach (var sym in symbols.Values) (sym as Symbol).Write(block); }
public void WriteName(Block32 block) { table.Name = block.Current; block.AddString(HeaderBase.Pad(NameSize, name)); }
public override void WriteBlock(Block32 block) { ExportTable.WriteBlock(block); ImportTable.WriteBlock(block); ResourceTable.WriteBlock(block); ExceptionTable.WriteBlock(block); CertificateTable.WriteBlock(block); BaseRelocationTable.WriteBlock(block); Debug.WriteBlock(block); Copyright.WriteBlock(block); GlobalPtr.WriteBlock(block); TLSTable.WriteBlock(block); LoadConfigTable.WriteBlock(block); BoundImport.WriteBlock(block); IAT.WriteBlock(block); DelayImportDescriptor.WriteBlock(block); CLIHeader.WriteBlock(block); Reserved.WriteBlock(block); }
public Val32 GetString(string s) { if (strings.ContainsKey(s)) return strings.Get(s) as Val32; var block = new Block32(); block.AddBytes(Module.EncodeString(s)); var type = Val32.NewB(0, true); var ret = AddData("string_constant", s, type, 2, s.Length, block); strings.Add(s, ret); type.Reference = GetTypeObjectD(Root.GetStruct("string")); return ret; }
public override void WriteBlock(Block32 block) { block.AddUShort(Magic); block.AddByte(LMajor); block.AddByte(LMinor); block.AddUInt(CodeSize); block.AddUInt(InitializedDataSize); block.AddUInt(UninitializedDataSize); block.AddUInt(EntryPoint); block.AddUInt(BaseOfCode); block.AddUInt(BaseOfData); }
public override void WriteBlock(Block32 block) { block.AddUInt(ImageBase); block.AddUInt(SectionAlignment); block.AddUInt(FileAlignment); block.AddUShort(OSMajor); block.AddUShort(OSMinor); block.AddUShort(UserMajor); block.AddUShort(UserMinor); block.AddUShort(SubSysMajor); block.AddUShort(SubSysMinor); block.AddUInt(Reserved); block.AddUInt(ImageSize); block.AddUInt(HeaderSize); block.AddUInt(FileChecksum); block.AddUShort(SubSystem); block.AddUShort(DLLFlags); block.AddUInt(StackReserveSize); block.AddUInt(StackCommitSize); block.AddUInt(HeapReserveSize); block.AddUInt(HeapCommitSize); block.AddUInt(LoaderFlags); block.AddUInt(NumberOfDataDirectories); }
public override void WriteBlock(Block32 block) { block.AddString(name); block.AddUInt(VirtualSize); block.AddUInt(VirtualAddress); block.AddUInt(SizeOfRawData); block.AddUInt(PointerToRawData); block.AddUInt(PointerToRelocations); block.AddUInt(PointerToLinenumbers); block.AddUShort(NumberOfRelocations); block.AddUShort(NumberOfLinenumbers); block.AddUInt(Characteristics); }
public abstract void Write(Block32 block);
public void WriteLookup(Block32 block, bool lookup) { if (!lookup) importRef.Value = block.Current; block.AddVal32(hintAddress); }
public Val32 GetTypeObjectV(string name, Function dtor, int size, Val32 baseType) { if (types.ContainsKey(name)) return types.Get(name) as Val32; var block = new Block32(); var namev = Val32.NewB(0, true); block.AddVal32(namev); if (dtor == null || name == "string" || name == "Type") block.AddInt(0); else block.AddVal32(GetAddress(dtor)); block.AddInt(size); block.AddVal32(baseType); var type = Val32.NewB(0, true); var tsz = (int)block.Length; var ret = AddData("type_object", name, type, tsz, -1, block); types.Add(name, ret); namev.Reference = GetString(name); type.Reference = GetTypeObjectD(Root.GetStruct("Type")); return ret; }
public void WriteImportTable(Block32 block) { table.WriteBlock(block); }
public void WriteBlock(Block32 block) { block.AddUInt(Address); block.AddUInt(Size); }
public static Block32 New(uint addr) { var ret = new Block32(); ret.Address = addr; return ret; }