1

我仍在尝试完全理解 hooking 以及 easyhook 的工作原理。我现在写了一个简单的例子:一个包含 webbrowser 元素的表单,我正在尝试挂钩由它进行的 recv 调用。编译时,程序返回此错误:

A first chance exception of type 'System.NotSupportedException' occurred in EasyHook.dll
System.NotSupportedException: STATUS_NOT_SUPPORTED:  (Code: 0)
   at EasyHook.NativeAPI.Force(Int32 InErrorCode)
   at EasyHook.RemoteHooking.InjectEx(Int32 InHostPID, Int32 InTargetPID, Int32 InWakeUpTID, Int32 InNativeOptions, String InLibraryPath_x86, String InLibraryPath_x64, Boolean InCanBypassWOW64, Boolean InCanCreateService, Object[] InPassThruArgs)
   at EasyHook.RemoteHooking.Inject(Int32 InTargetPID, InjectionOptions InOptions, String InLibraryPath_x86, String InLibraryPath_x64, Object[] InPassThruArgs)
   at Hook_Test.Form1.Run() in I:\Documents and Settings\Meme\Desktop\SimpleHook\Hook Test\Hook Test\Form1.cs:line 46

在第 46 行,我有以下代码:

            RemoteHooking.Inject(
                Process.GetCurrentProcess().Id,
                InjectionOptions.Default,
                "TestInject.dll",
                "TestInject.dll",
                ChannelName);

我真的看不出问题出在哪里,有人可以帮助我吗?

4

1 回答 1

2

在 RemoteHooking 类的 Inject 方法的文档中,它说:

即使技术上可以将用于调试目的的库注入当前进程,它也会抛出异常。这是因为它在很大程度上取决于您注入的库是否会损坏当前进程。如果挂钩错误的 API,任何类型的通信都可能导致死锁。只需使用 Visual Studio 的功能同时调试多个进程,这将允许您调试您的库,就好像它会被注入到当前进程中一样,而不会遇到任何副作用。

似乎这是设计使然。您可能需要将项目拆分为两个应用程序,或者使用 shell 或线程来启动(至少)当前进程之外的事物的实例。

于 2011-01-25T09:50:57.007 回答