Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to hook a managed function in C# like I would a unmanaged function in C++?

Tags:

c#

.net

cil

hook

In C++ I would get the address of the function and overwrite the first few bytes to a jmp to my function, do some stuff, restore the original bytes, and call the original function.

Can I do something like this in C#?

like image 938
Avery3R Avatar asked May 29 '11 18:05

Avery3R


1 Answers

The technique you're looking for is called AOP - Aspect Oriented Programming. You can find several frameworks for C# if you goggle a little.

Update: You can find plenty of links and info in this question: Built-in AOP in C# - is it on the way?

like image 147
Dan Byström Avatar answered Oct 02 '22 22:10

Dan Byström