Provides a mechanism for assembling x86 instructions into bytes.
Exemplo n.º 1
0
 public DataSegment CreateRawMethodBody()
 {
     using (var stream = new MemoryStream())
     {
         var writer    = new BinaryStreamWriter(stream);
         var assembler = new X86Assembler(writer);
         foreach (var instruction in Instructions)
         {
             assembler.Write(instruction);
         }
         return(new DataSegment(stream.ToArray()));
     }
 }
Exemplo n.º 2
0
        private static void TestAssembler(IReadOnlyList<X86Instruction> instructions)
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.bin");
            using (var stream = File.Create(path))
            {
                var writer = new BinaryStreamWriter(stream);
                var assembler = new X86Assembler(writer);

                foreach (var instruction in instructions)
                    assembler.Write(instruction);
            }

            ValidateCode(instructions, File.ReadAllBytes(path));
        }
Exemplo n.º 3
0
 public override void Write(WritingContext context)
 {
     var assembler = new X86Assembler(context.Writer);
     foreach (var instruction in Instructions)
         assembler.Write(instruction);
 }