Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more examples #62

Open
6 tasks
mrexodia opened this issue Oct 4, 2022 · 1 comment
Open
6 tasks

Add more examples #62

mrexodia opened this issue Oct 4, 2022 · 1 comment

Comments

@mrexodia
Copy link
Member

mrexodia commented Oct 4, 2022

  • 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
@mrexodia
Copy link
Member Author

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;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant