2011-01-05 74 views
0

我仍然試圖完全理解鉤子和easyhook的工作方式。 我現在寫了一個簡單的例子:一個包含webbrowser元素的表單,並且我試圖掛接那個recv調用。編譯時,程序返回此錯誤:Easyhook引發System.NotSupportedException

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); 

我實在看不出是哪裏的問題,有人可以幫我嗎?

+2

一次機會例外並不意味着太多。按F5。它實際上是否在未處理的異常上彈出? – 2011-01-05 16:28:28

+0

不,當我運行該程序時,瀏覽器工作正常,但我無法掛鉤任何東西。 – kaharas 2011-01-06 13:19:24

回答

1

在爲RemoteHooking類,它說的進樣方法的文檔:

即使它在技術上是可能的注入庫調試目的到當前的過程中,它會拋出異常。這是因爲它很大程度上取決於您的注入庫是否會損壞當前進程。如果您鉤住錯誤的API,任何類型的通信都可能導致死鎖。只需使用Visual Studio的功能同時調試多個進程,這將允許您調試庫,就好像它將被注入當前進程而不會遇到任何副作用。

看來這是設計。您可能需要將項目分成兩個應用程序,或者使用shell或線程來啓動當前進程之外的實例(至少)。

相關問題