c# - 使用 Easyhook 和一个函数将信息从 dll 发送到我的 C# 代码后,外部应用程序崩溃

标签 c# dll crash easyhook

我正在使用 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/

相关文章:

c# - 在 C# Web API Web 服务中使用 Process() 调用 GhostScript

c# - 将列表分割为多个列表时 System.Linq 的性能问题

iOS 应用程序崩溃,终止原因为 : Namespace SPRINGBOARD, 代码 0x8badf00d

javascript - Angular 和 ASP.NET MVC - 后端收到时参数为空

c# - OnCheckedChanged 事件未触发

windows - 在 Windows Server 2008 R2 上注册 DLL 文件

windows - 如何在没有 regsvr32 的情况下注册 glut32.dll?

c# - 如何从 C++ dll 中删除 C# dll

objective-c - IOS - Mapkit 崩溃 - 这是 xcode 4.2 和自动引用计数 (ARC) 中的错误吗?

java - 由于 android Studio 中的 nullpointerException,应用程序崩溃