Beispiel #1
0
 public void Write(Block block)
 {
     address.Value = block.Current;
     block.Add(Block);
     uint padlen = Module.Align((uint)Block.Length, 4) - (uint)Block.Length;
     if (padlen > 0) block.Add(new byte[padlen]);
 }
Beispiel #2
0
 public Block ToBlock(uint vaddr)
 {
     Block ret = new Block(vaddr);
     Write(ret);
     block = ret;
     return ret;
 }
Beispiel #3
0
        public override void Write(Block block)
        {
            foreach (Library lib in libraries.Values) lib.WriteImportTable(block);
            new ImportTable().Write(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);
        }
Beispiel #4
0
 public override void Write(Block block)
 {
     foreach (FieldInfo fi in GetFields())
     {
         Object obj = fi.GetValue(this);
         if (obj is Table)
         {
             block.Add(((Table)obj).Address);
             block.Add(((Table)obj).Size);
         }
         else if (obj is byte) block.Add((byte)obj);
         else if (obj is ushort) block.Add((ushort)obj);
         else if (obj is uint) block.Add((uint)obj);
         else if (obj is long) block.Add((long)obj);
         else if (obj is char[]) block.Add((char[])obj);
         else if (obj is string) block.Add((string)obj);
         else if (obj is Val32) block.Add((Val32)obj);
         else throw new Exception("The method or operation is not implemented.");
     }
 }
Beispiel #5
0
 public void Write(Block block)
 {
     if (op1 is Val32 && relative)
     {
         block.Add(GetCodes());
     }
     else if (data != null)
     {
         block.Add(data);
         if (op2 is Addr32) (op2 as Addr32).Write(block);
         if (op1 != null)
         {
             if (op1 is byte) block.Add((byte)op1);
             else if (op1 is ushort) block.Add((ushort)op1);
             else if (op1 is Val32) block.Add((Val32)op1);
             else if (op1 is Val32) block.Add((Val32)op1);
             else throw new Exception("The method or operation is not implemented.");
         }
         if (op2 is byte) block.Add((byte)op2);
     }
 }
Beispiel #6
0
 public void Test(string mnemonic, string data)
 {
     string datastr = BitConverter.ToString(GetCodes());
     if (data != datastr)
     {
         throw new Exception(string.Format(
             "[Test 1 failed] {0}\r\n\tOK: {1}\r\n\tNG: {2}",
             mnemonic, data, datastr));
     }
     Block block = new Block();
     Write(block);
     string datastr2 = BitConverter.ToString(block.ToByteArray());
     if (data != datastr2)
     {
         throw new Exception(string.Format(
             "[Test 2 failed] {0}\r\n\tOK: {1}\r\n\tNG: {2}",
             mnemonic, data, datastr2));
     }
     //Console.WriteLine("OK: {0}: {1}", datastr, mnemonic);
 }
Beispiel #7
0
 public DataBlock()
 {
     Block = new Block();
 }
Beispiel #8
0
 public override void Write(Block block)
 {
     foreach (var ctg in data.Values)
         foreach (var db in ctg.Values)
             db.Write(block);
     if (IsEmtpy) block.Add(new byte[16]);
 }
Beispiel #9
0
 public void Write(Block block, bool lookup)
 {
     if (!lookup) importRef.Value = block.Current;
     block.Add(hintAddress);
 }
Beispiel #10
0
 public void WriteName(Block block)
 {
     table.Name = block.Current;
     block.Add(HeaderBase.Pad(NameSize, name));
 }
Beispiel #11
0
 public void WriteSymbols(Block block)
 {
     foreach (Symbol sym in symbols.Values) sym.Write(block);
 }
Beispiel #12
0
 public void WriteImportTable(Block block)
 {
     table.Write(block);
 }
Beispiel #13
0
 public void WriteImportLookupTable(Block block)
 {
     table.ImportLookupTable = block.Current;
     foreach (Symbol sym in symbols.Values) sym.Write(block, true);
     block.Add(0);
 }
Beispiel #14
0
 public void WriteImportAddressTable(Block block)
 {
     table.ImportAddressTable = block.Current;
     foreach (Symbol sym in symbols.Values) sym.Write(block, false);
     block.Add(0);
 }
Beispiel #15
0
 public void Add(Block block)
 {
     foreach (object obj in block.data)
     {
         if (obj is byte) Add((byte)obj);
         else if (obj is ushort) Add((ushort)obj);
         else if (obj is uint) Add((uint)obj);
         else if (obj is int) Add((int)obj);
         else if (obj is long) Add((long)obj);
         else if (obj is byte[]) Add((byte[])obj);
         else if (obj is char[]) Add((char[])obj);
         else if (obj is string) Add((string)obj);
         else if (obj is Block) Add((Block)obj);
         else if (obj is Val32) Add((Val32)obj);
         else throw new Exception("The method or operation is not implemented.");
     }
 }
Beispiel #16
0
 public void Write(Block block)
 {
     hintAddress.Value = block.Current;
     block.Add(Hint);
     block.Add(HeaderBase.Pad(NameSize, Name));
 }
Beispiel #17
0
 public override void Write(Block block)
 {
     block.Add(data);
 }
Beispiel #18
0
 public void Write(Block block)
 {
     if (address != null)
     {
         block.Add((byte)(0x05 + (middleBits << 3)));
         block.Add(address);
     }
     else
     {
         block.Add(GetCodes());
     }
 }
Beispiel #19
0
 public abstract void Write(Block block);
Beispiel #20
0
 public Block ToBlock()
 {
     Block ret = new Block();
     Write(ret);
     return ret;
 }