Giter Site home page Giter Site logo

x64dbg / dotx64dbg Goto Github PK

View Code? Open in Web Editor NEW
192.0 21.0 22.0 2.62 MB

x64Dbg plugin that enables C# plugins with hot-loading support and scripting.

License: MIT License

C++ 52.26% C# 47.74%
x64dbg x64dbg-plugin scripting managed-plugins plugins hot-reload csharp dotnet

dotx64dbg's Introduction

DotX64Dbg (EARLY ALPHA)

Plugins and Scripting with C# for x64Dbg.

Create Plugins for X64Dbg with ease

DotX64Dbg aims to provide a seamless way to write and test plugins for X64Dbg using .Net 6.0 and C#.

You can create/edit/debug plugins without ever restarting x64Dbg. Live Coding

This gif showcases how you debug and edit your plugin at the same time, this also showcases how you can register custom commands for x64Dbg on the fly, the same works also for expressions.

No more binaries

DotX64Dbg does not load the plugins as binaries instead it will automatically compile your plugin code as soon something changes and reloads it, this also means all plugins will be shipped as pure code which means its a lot harder to hide malicious code in there.

Installing

There is currently no official release. You can grab the latest artifacts from the CI to try it out or build it yourself. Also older versions of x64dbg are not supported by this plugin, we recommend to use the latest builds.

Your first Plugin

Creating new plugins is as easy as creating a new folder with two new files. By default the DotX64Dbg plugins are located in the root directory of X64Dbg called dotplugins this can be however configured via dotx64dbg.json.

Simply create a new folder in dotplugins called SamplePlugin, plugins are required to have a file called plugin.json which should look like following:

{
  "Name": "Sample Plugin",
  "Description": "My awesome plugin",
  "Version": "1.0.0",
  "Author": "Bob",
  "Website": "http://github.com/[youruser]/yourplugin",
}

Without the plugin.json file plugins will not load. The last thing you need is some code that defines the plugin entry class, this is done by deriving from IPlugin, you can have only one class that derives from this interface. Create a file named SamplePlugin.cs, you can choose any filename you like. To bootstrap the plugin you need at least following minimal example:

using System;
using Dotx64Dbg;

public class SamplePlugin : IPlugin
{
    public SamplePlugin()
    {
        // Constructor, only called during first load
    }
    
    // Called as soon the plugin is fully initialized, this is called after
    // the constructor and only once the for the initial plugin load.
    public void Startup()
    {
        Console.WriteLine("Startup time!");
    }
    
    // Called before the plugin is about to be unloaded.
    public void Shutdown()
    {
        Console.WriteLine("We are about to go offline");
    }
}

After the two files are created DotX64Dbg will detect the changes and immediately starts compiling/(re-)loading the plugin. DotX64Dbg will also automatically generate a .csproj file with the correct assembly references being setup. If you want to debug your plugins simply attach Visual Studio to x64Dbg and place the breakpoints where you would like to stop, its as simple as that.

There is also a comprehensive example plugin available here

Scripting

DotX64Dbg also provides a scripting interface, unlike plugins a script will be without state and only executes once. Scripts can use the same APIs as plugins. To execute scripts use following command:

dotscript <path to script file>

You can find an example script here

Building

Requirements

  • Net 6.0 SDK.
  • Visual Studio 2019 Community or greater.

Building

After everything is setup you should be open Dotx64Dbg.sln and be able to build the entire solution.

Documentation

The plan is to document all public API which also makes the documentation available to Intellisense. A good starting point is to check the plugin example, a lot of functions and classes already have minimal documentation, the best way to find out whats there is to explore the Assembly in Visual Studio with the Object Explorer. Object Explorer

dotx64dbg's People

Contributors

guila767 avatar mrexodia avatar zehmatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotx64dbg's Issues

Potential race condition on menu registration

One thing that I noticed is the dictionary used in the menu system should probably be a ConcurrentDictionary (not sure) because sometimes when calling ReloadPlugin here:

ReloadPlugin(plugin, plugin.AssemblyPath, token);
It can throw an exception like ArgumentException or NullReferenceException like:

image

or even deadlock the application at startup. I also, for testing, added a Thread.Sleep(100) before calling ReloadPlugin, and seems to "solve" the problem. That's why I think I could be a concurrency problem

Originally posted by @Guila767 in #48 (comment)

Dependencies are not loaded

When I use the command the first time I run x64dbg, I get an error:

Exception: System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray`1<Microsoft.Diagnostics.Runtime.ClrInfo> Microsoft.Diagnostics.Runtime.DataTarget.get_ClrVersions()'. 
   at DotInfo.Plugin.Init(String[] args) 
   at Dotx64Dbg.Plugins.<>c__DisplayClass44_0.<RegisterPluginCommand>b__0(String[] args) 
   at Dotx64Dbg.Commands.CommandHandler(String cmd, Int32 argc, IntPtr ptr) 
   at Dotx64Dbg.Commands.<>c__DisplayClass8_0.<Register>b__0(Int32 argc, IntPtr argv)

The error disappears if you add a couple of spaces in the source code to run hotreload.
After reloading x64dbg, the error reappears until you run hotreload through adding spaces...
P.S "Microsoft.Diagnostics.Runtime.DataTarget.get_ClrVersions" is a method from the nuget package.

Setup - Missing Dependancies

Excited about this project.

Installed both of the requirements linked to in the log, but still getting this error message.

Unable to load Dotx64Dbg, make sure you have following installed:
- .NET 6.0 Runtime (https://dotnet.microsoft.com/download/dotnet/6.0)
- Visual Studio 2019 Runtime (https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0)

I've also clone the repo and was able to successfully build it.

Both x86 and x64
Screenshot from 2023-03-10 17-56-02
Screenshot from 2023-03-10 17-55-22

Running x64dbg version snapshot_2023-03-04_02-26

Here is my placement of the plugin files:

Screenshot from 2023-03-10 17-51-39
Screenshot from 2023-03-10 17-51-26

Am I missing something?

Add more examples

  • 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

Cache plugin builds

Currently each plugin is built every startup, it should instead use a cached build when available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.