Exemplo n.º 1
0
 public byte[] MakeBytes(params object[] data)
 {
     var w = new BeImageWriter();
     foreach (var o in data)
     {
         dispatcher[o.GetType()](o, w);
     }
     var bytes = w.Bytes.Take(w.Position).ToArray();
     return bytes;
 }
Exemplo n.º 2
0
 private void Rewrite(params ushort[] opcodes)
 {
     byte[] bytes = new byte[opcodes.Length * 2];
     var writer = new BeImageWriter(bytes);
     foreach (ushort opcode in opcodes)
     {
         writer.WriteBeUInt16(opcode);
     }
     image = new LoadedImage(addrBase, bytes);
 }
Exemplo n.º 3
0
 private static void WriteString(string s, BeImageWriter w)
 {
     if (s.Length <= 0)
     {
         w.WriteBeUInt32(0);
         return;
     }
     byte[] ab = enc.GetBytes(s);
     int padLength = (ab.Length + 3) & ~3;
     w.WriteBeUInt32((uint) padLength / 4);
     w.WriteBytes(ab);
     int cPad = padLength - ab.Length;
     while (--cPad >= 0)
     {
         w.WriteByte(0);
     }
 }