简体   繁体   English

Easyhook引发System.NotSupportedException

[英]Easyhook raises a System.NotSupportedException

I'm still trying to fully understand hooking and how easyhook works. 我仍在尝试完全了解挂钩以及easyhook的工作原理。 I've now written a simple example: a form that contains a webbrowser element, and i'm trying to hook recv calls made from that. 现在,我写了一个简单的示例:包含webbrowser元素的表单,而我试图挂接由此产生的recv调用。 When compiling, the program returns this error: 编译时,程序返回以下错误:

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

at line 46, I've this code: 在第46行,我有以下代码:

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

I can't really see where the problem is, can somebody help me out? 我真的看不出问题出在哪里,有人可以帮我吗?

In the documentation for the Inject method of the RemoteHooking class it says: 在RemoteHooking类的Inject方法的文档中说:

Even if it would technically be possible to inject a library for debugging purposes into the current process, it will throw an exception. 即使从技术上来说可以将用于调试目的的库注入当前进程,也将引发异常。 This is because it heavily depends on your injected library whether the current process will be damaged. 这是因为在很大程度上取决于您注入的库是否会破坏当前进程。 Any kind of communication may lead into deadlocks if you hook the wrong APIs. 如果您钩错了API,则任何形式的通信都可能导致死锁。 Just use the capability of Visual Studio to debug more than one process simultanously which will allow you to debug your library as if it would be injected into the current process without running into any side-effects. 只需使用Visual Studio的功能即可同时调试多个进程,这将使您可以调试库,就像将库注入到当前进程中一样,而不会产生任何副作用。

It seems that this is by design. 看来这是设计使然。 You may need to split your project into two apps, or else use shell or threading to launch instances (at least) of things outside of the current process. 您可能需要将项目分成两个应用程序,或者使用外壳程序或线程启动(至少)启动当前流程之外的事物实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM