detours-redirecting-csharp-methods-at-runtime #16
Replies: 4 comments 2 replies
|
Ideas for wrapping the function:
|
|
It's a very interesting approach, but I'm wondering, instead of doing all of this - wouldn't it be simpler to just create a small program that runs something like reflexil (or another weaver), and then make every method public virtual? (I used to do it like that manually using JustDecompile if I wanted to patch something specific) After that you can replace the objects with a Castle DynamicProxy of the object - (especially if the project is already using dependency injection) and then add an IInterceptor to the methods that you want to "Detour". You can skip the invocation completely, or you can use the IInterceptor as a decorator to add behavior or re-write the return objects |
|
I just noticed that my post has made it to Reddit (thanks!), and somebody mentioned a list of .NET detouring libraries that they maintain. Anyway, I'll just leave this here: https://github.com/jzabroski/Home/tree/master/TechRadar#function-detouring--function-hooking |
|
Hi. I wondered what is difference between your solution and this solution. Can you explain? |
Uh oh!
There was an error while loading. Please reload this page.
detours-redirecting-csharp-methods-at-runtime
Detours are a way to replace the implementation of a C# method. Basically, you take a method (typically from some assembly you don’t have the source for) and overwrite it with a jmp to your own implementation.
https://tryfinally.dev/detours-redirecting-csharp-methods-at-runtime
All reactions