예제 #1
0
파일: DataSection.cs 프로젝트: 7shi/LLPML
 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]);
 }
예제 #2
0
파일: SectionBase.cs 프로젝트: 7shi/LLPML
 public Block32 ToBlock(uint vaddr)
 {
     Block32 ret = Block32.New(vaddr);
     Write(ret);
     block = ret;
     return ret;
 }
예제 #3
0
파일: Library.cs 프로젝트: 7shi/LLPML
 public void WriteImportLookupTable(Block32 block)
 {
     table.ImportLookupTable = block.Current;
     foreach (var sym in symbols.Values)
         (sym as Symbol).WriteLookup(block, true);
     block.AddInt(0);
 }
예제 #4
0
파일: PEHeaders.cs 프로젝트: 7shi/LLPML
 public override void WriteBlock(Block32 block)
 {
     block.AddUInt(ImportLookupTable);
     block.AddUInt(DateTimeStamp);
     block.AddUInt(ForwarderChain);
     block.AddUInt(Name);
     block.AddUInt(ImportAddressTable);
 }
예제 #5
0
파일: TextSection.cs 프로젝트: 7shi/LLPML
 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);
     }
 }
예제 #6
0
파일: PEHeaders.cs 프로젝트: 7shi/LLPML
 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);
 }
예제 #7
0
파일: ImportSection.cs 프로젝트: 7shi/LLPML
        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);
        }
예제 #8
0
파일: OpModule.cs 프로젝트: 7shi/LLPML
 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));
 }
예제 #9
0
파일: DOSHeader.cs 프로젝트: 7shi/LLPML
 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);
 }
예제 #10
0
파일: Block32.cs 프로젝트: 7shi/LLPML
 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.");
     }
 }
예제 #11
0
파일: Symbol.cs 프로젝트: 7shi/LLPML
 public void Write(Block32 block)
 {
     hintAddress.Value = block.Current;
     block.AddUShort(Hint);
     block.AddString(HeaderBase.Pad(NameSize, Name));
 }
예제 #12
0
파일: Addr32.cs 프로젝트: 7shi/LLPML
 public void Write(Block32 block)
 {
     if (address != null)
     {
         block.AddByte((byte)(0x05 + (middleBits << 3)));
         block.AddVal32(address);
     }
     else
     {
         block.AddBytes(GetCodes());
     }
 }
예제 #13
0
파일: DataSection.cs 프로젝트: 7shi/LLPML
 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]);
 }
예제 #14
0
파일: WriterBase.cs 프로젝트: 7shi/LLPML
 public Block32 ToBlock()
 {
     var ret = new Block32();
     WriteBlock(ret);
     return ret;
 }
예제 #15
0
파일: AnySection.cs 프로젝트: 7shi/LLPML
 public override void Write(Block32 block)
 {
     block.AddBytes(data);
 }
예제 #16
0
파일: Library.cs 프로젝트: 7shi/LLPML
 public void WriteSymbols(Block32 block)
 {
     foreach (var sym in symbols.Values)
         (sym as Symbol).Write(block);
 }
예제 #17
0
파일: Library.cs 프로젝트: 7shi/LLPML
 public void WriteName(Block32 block)
 {
     table.Name = block.Current;
     block.AddString(HeaderBase.Pad(NameSize, name));
 }
예제 #18
0
파일: PEHeaders.cs 프로젝트: 7shi/LLPML
 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);
 }
예제 #19
0
파일: OpModule.cs 프로젝트: 7shi/LLPML
        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;
        }
예제 #20
0
파일: PEHeaders.cs 프로젝트: 7shi/LLPML
 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);
 }
예제 #21
0
파일: PEHeaders.cs 프로젝트: 7shi/LLPML
 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);
 }
예제 #22
0
파일: PEHeaders.cs 프로젝트: 7shi/LLPML
 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);
 }
예제 #23
0
파일: SectionBase.cs 프로젝트: 7shi/LLPML
 public abstract void Write(Block32 block);
예제 #24
0
파일: Symbol.cs 프로젝트: 7shi/LLPML
 public void WriteLookup(Block32 block, bool lookup)
 {
     if (!lookup) importRef.Value = block.Current;
     block.AddVal32(hintAddress);
 }
예제 #25
0
파일: OpModule.cs 프로젝트: 7shi/LLPML
        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;
        }
예제 #26
0
파일: Library.cs 프로젝트: 7shi/LLPML
 public void WriteImportTable(Block32 block)
 {
     table.WriteBlock(block);
 }
예제 #27
0
파일: HeaderBase.cs 프로젝트: 7shi/LLPML
 public void WriteBlock(Block32 block)
 {
     block.AddUInt(Address);
     block.AddUInt(Size);
 }
예제 #28
0
파일: Block32.cs 프로젝트: 7shi/LLPML
 public static Block32 New(uint addr)
 {
     var ret = new Block32(); ret.Address = addr; return ret;
 }