I'm using easyhook and after exiting my application, the one which was hooked crashes. I know where it happens but not how to solve it. I'm hooking DrawText. I do nothing:
int DrawText_Hooked(IntPtr hdc, [In, Out, MarshalAs(UnmanagedType.LPTStr)] string lpString, int cchText, [In, Out, MarshalAs(UnmanagedType.Struct)] ref RECT lprc, uint dwDTFormat, [In, Out, MarshalAs(UnmanagedType.Struct)] ref DRAWTEXTPARAMS dparams)
{
//Interface.Read(hdc, lpString, cchText, dwDTFormat);
return DrawTextExW(hdc, lpString, cchText, ref lprc, dwDTFormat, ref dparams);
}
But if I uncomment Interface.Read(...)
it will crash my hooked application when I quit my c# program (otherwise it works perfect).
The function is in my c# code and looks this way:
public class interfaceA : MarshalByRefObject
{
public void ReportException(Exception InInfo)
{
}
public void Ping()
{
}
public void Read(IntPtr hdc, string lpString, int cchText, uint dwDTFormat)
{
Console.WriteLine(lpString);
}
}
What can I do to prevent this external application to crash? Or how do I send information from my dll to the c# code without having this issue?
Thanks