Assume I have a process (target.exe) which is running on my computer. I found out, that target.exe is using a DLL (target.dll). In this DLL there is a method named:
public PaintedObject GetRepaintedObject(Image img)
{
return new PaintedObject(img);
}
Is it possible to catch the method call GetRepaintedObject at runtime and execute my own code ? I just want to return my own PaintedObject.
Edit: I think target.exe loads the target.dll into his memory space and this is the point where I want to inject or modify the method GetRepaintedObject. I don't want recompile the dll or something else. Everytime target.exe is calling GetRepaintedObject I want to intercept this and return my own value.
Do you need to call
GetRepaintedObject()
from DLL at run-time?If yes, you can get the reference to methods of classes defined in DLL using Reflection.