Git Product home page Git Product logo

dotnetdetour's Introduction

DotNetDetour

DotNetDetour是一个用于.net方法hook的类库 ##特点

  • 支持32bit和64bit的.net程序
  • 支持.net framework 2.0以上的所有版本
  • 支持静态方法,实例方法、属性方法、泛型方法的hook
  • 支持.net基础类库方法的hook
  • 无任何性能影响

##快速示例 1.安装:Install-Package DotNetDetour

2.新建一个类并继承IMethodMonitor接口

public class CustomMonitor : IMethodMonitor //自定义一个类并继承IMethodMonitor接口
{
    [Monitor("TargetNamespace","TargetClass")] //目标方法的名称空间,类名
    public string Get() //方法签名要与目标方法一致
    {
        return "B" + Ori();
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    [Original] //原函数标记
    public string Ori() //方法签名要与目标方法一致
    {
        return null; //这里写什么无所谓,能编译过即可
    }
}

3.定义目标函数,例如:

public string Get()
{
    return "A"
}

4.安装监视器

Console.WrtieLine(Get());
Monitor.Install()
Console.WrtieLine(Get());

第一次调用Get输出的值是"A",第二次是"BA"

dotnetdetour's People

Contributors

bigbaldy1128 avatar

Watchers

 avatar  avatar

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.