x64dbg/DotX64Dbg

Add more examples

mrexodia opened this issue · 1 comments

  • Evaluate an expression
  • Format a format string
  • Get/set comments/labels/bookmarks
  • Breakpoint callback plugin
  • Adding packages from NuGet
  • Adding a folder with source files
using System;
using Dotx64Dbg;

public partial class MyPlugin : IPlugin
{
    [Command("findmnemonic", DebugOnly = true)]
    public bool FindMnemonic(string[] args)
    {
        if(args.Length < 2)
        {
            Console.WriteLine("Usage: findmnemonic mnemonic, [memaddr], [memsize]");
            return false;
        }
        var mnemonic = args[1];
        Console.WriteLine(mnemonic);
        var memaddr = Expressions.Evaluate(args.Length > 2 ? args[2] : "cip");
        var memsize = args.Length > 3 ? Expressions.Evaluate(args[3]) : 0;
        if(memsize == 0)
        {
            memaddr = Memory.GetBase(memaddr);
            memsize = Memory.GetSize(memaddr);
        }
        var decoder = Decoder.Create();
        for (var ip = memaddr; ip < memaddr + memsize;)
        {
            var instr = decoder.Decode(ip);
            if(instr == null)
            {
                // Failed to decode
                ip++;
                continue;
            }
            if(instr.Id.ToString().ToLower() == mnemonic)
            {
                Dotx64Dbg.Utils.re
                Console.WriteLine($"{ip:X} {instr}");
            }
            ip += instr.Size;
        }
        return true;
    }
}