Beispiel #1
0
        public void Df_FormatString()
        {
            var list = new List <TextSpan>();
            var df   = new DisassemblyFormatter(program, program.Architecture, null, list);

            df.WriteString("Hello");
            df.NewLine();

            Assert.AreEqual(1, list.Count);
        }
Beispiel #2
0
        public void Df_FormatAddress()
        {
            var list = new List <TextSpan>();
            var df   = new DisassemblyFormatter(program, program.Architecture, null, list);

            df.WriteAddress("foo", Address.Ptr32(0x1234));
            df.NewLine();

            Assert.AreEqual("foo", list[0].GetText());
            Assert.IsInstanceOf <Address>(list[0].Tag);
        }
        public void Df_FormatAddress_ScannedProcedure()
        {
            var list = new List <TextSpan>();

            program.Procedures.Add(Address.Ptr32(0x1234), new Procedure("fn_renamed", new Frame(PrimitiveType.Word32)));
            var df = new DisassemblyFormatter(program, null, list);

            df.WriteAddress("foo", Address.Ptr32(0x1234));
            df.NewLine();

            Assert.AreEqual("fn_renamed", list[0].GetText());
            Assert.IsInstanceOf <Address>(list[0].Tag);
        }
Beispiel #4
0
        public static LineSpan RenderAsmLine(Program program, MachineInstruction instr)
        {
            var line = new List <TextSpan>();
            var addr = instr.Address;

            line.Add(new AddressSpan(addr.ToString() + " ", addr, "link"));
            line.Add(new InstructionTextSpan(instr, BuildBytes(program, instr), "dasm-bytes"));
            var dfmt = new DisassemblyFormatter(program, instr, line);

            instr.Render(dfmt);
            dfmt.NewLine();
            return(new LineSpan(addr, line.ToArray()));
        }
Beispiel #5
0
        public static LineSpan RenderAsmLine(
            object position,
            Program program,
            IProcessorArchitecture arch,
            MachineInstruction instr,
            MachineInstructionRendererOptions options)
        {
            var line = new List <TextSpan>();
            var addr = instr.Address;

            line.Add(new AddressSpan(addr.ToString() + " ", addr, "link"));
            line.Add(new InstructionTextSpan(instr, BuildBytes(program, arch, instr), "dasm-bytes"));
            var dfmt = new DisassemblyFormatter(program, arch, instr, line);

            instr.Render(dfmt, options);
            dfmt.NewLine();
            return(new LineSpan(position, line.ToArray()));
        }
 public TextSpan[][] GetLineSpans(int count)
 {
     var lines = new List<TextSpan[]>();
     if (program.Architecture != null)
     {
         var dasm = program.CreateDisassembler(position).GetEnumerator();
         while (count != 0 && dasm.MoveNext())
         {
             var line = new List<TextSpan>();
             var addr = dasm.Current.Address;
             line.Add(new AddressSpan(addr.ToString() + " ", addr, "link"));
             line.Add(new InertTextSpan(BuildBytes(dasm.Current), "dasm-bytes"));
             var dfmt = new DisassemblyFormatter(program, line);
             dasm.Current.Render(dfmt);
             dfmt.NewLine();
             lines.Add(line.ToArray());
             --count;
         }
     }
     return lines.ToArray();
 }
Beispiel #7
0
        public TextSpan[][] GetLineSpans(int count)
        {
            var lines = new List <TextSpan[]>();

            if (program.Architecture != null)
            {
                var dasm = program.CreateDisassembler(position).GetEnumerator();
                while (count != 0 && dasm.MoveNext())
                {
                    var line = new List <TextSpan>();
                    var addr = dasm.Current.Address;
                    line.Add(new AddressSpan(addr.ToString() + " ", addr, "addr"));
                    line.Add(new InertTextSpan(BuildBytes(dasm.Current), "bytes"));
                    var dfmt = new DisassemblyFormatter(program, line);
                    dasm.Current.Render(dfmt);
                    dfmt.NewLine();
                    lines.Add(line.ToArray());
                    --count;
                }
            }
            return(lines.ToArray());
        }
        public LineSpan[] GetLineSpans(int count)
        {
            var lines = new List<LineSpan>();
            if (program.Architecture != null)
            {
                var dasm = program.CreateDisassembler(Align(position)).GetEnumerator();
                while (count != 0 && dasm.MoveNext())
                {
                    var line = new List<TextSpan>();
                    var instr = dasm.Current;
                    var addr = instr.Address;
                    line.Add(new AddressSpan(addr.ToString() + " ", addr, "link"));
                    line.Add(new InstructionTextSpan(instr, BuildBytes(instr), "dasm-bytes"));
                    var dfmt = new DisassemblyFormatter(program, instr, line);
                    instr.Render(dfmt);
                    dfmt.NewLine();
                    lines.Add(new LineSpan(addr, line.ToArray()));
                    --count;
                    position = addr + instr.Length;
                }

            }
            return lines.ToArray();
        }
Beispiel #9
0
 public static LineSpan RenderAsmLine(Program program, MachineInstruction instr)
 {
     var line = new List<TextSpan>();
     var addr = instr.Address;
     line.Add(new AddressSpan(addr.ToString() + " ", addr, "link"));
     line.Add(new InstructionTextSpan(instr, BuildBytes(program, instr), "dasm-bytes"));
     var dfmt = new DisassemblyFormatter(program, instr, line);
     instr.Render(dfmt);
     dfmt.NewLine();
     return new LineSpan(addr, line.ToArray());
 }