ManagedHook 1.1.1
dotnet add package ManagedHook --version 1.1.1
NuGet\Install-Package ManagedHook -Version 1.1.1
<PackageReference Include="ManagedHook" Version="1.1.1" />
paket add ManagedHook --version 1.1.1
#r "nuget: ManagedHook, 1.1.1"
// Install ManagedHook as a Cake Addin
#addin nuget:?package=ManagedHook&version=1.1.1
// Install ManagedHook as a Cake Tool
#tool nuget:?package=ManagedHook&version=1.1.1
Tested with X64 architecture with non-inlined methods. (careful with optimized code with inlined methods, the pattern was not intended to be used in that case)
How to use:
1- Create a class that implements the interface IHookerHandler:
public class MyHookHandler : IHookHandler
{
public void Before(object instanceHooked, object[] parameters)
{
// do whatever you want here
}
public void After(object instanceHooked, object[] parameters)
{
// do whatever you want here
}
}
2- Get the methodInfo for the method to be hooked:
MethodInfo methodHooked = typeof(Foo).GetMethod("MethodHooked");
3- Hook the method!
HookManager.Instance.HookFunction(methodHooked, new MyHookHandler());
Or hook the method with lamdas (before call and after call)
HookManager.Instance.HookFunction(methodHooked, (t) => { ... }, (t) => { ... });
4 - (opt) When finished, you can unhook the method:
HookManager.Instance.UnHookFunction(methodHooked);
Product | Versions |
---|---|
.NET Framework | net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481 |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Use the returned value of the replaced function.