我正在使用 Easyhook,退出应用程序后,被 Hook 的应用程序崩溃了。我知道它发生在哪里,但不知道如何解决。我正在 Hook DrawText。我什么也没做:
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);
}
但是,如果我取消注释 Interface.Read(...)
,当我退出 C# 程序时,它会使我的 Hook 应用程序崩溃(否则它可以正常工作)。
该函数位于我的 C# 代码中,如下所示:
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);
}
}
我可以采取什么措施来防止此外部应用程序崩溃?或者如何将信息从我的 dll 发送到 C# 代码而不出现此问题?
谢谢
最佳答案
我不知道为什么会发生这种情况,经过进一步调查,我知道是什么错误后得到了答案。在完全解决之前我又问了一个问题,链接如下:
System.MissingMethodException in a dll when I shut down c# application
关于c# - 使用 Easyhook 和一个函数将信息从 dll 发送到我的 C# 代码后,外部应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31777467/