Hi, in order to learn something more about hooks, I'm trying to write a simple application: a form containing a webbrowser component, and i'm going to make a local hook oon recv to see the packets received by it.
I wrote the program looking at the easyhook tutorial, but when i try to run it, i get a

A first chance exception of type 'System.NotSupportedException' occurred in EasyHook.dll
There was an error while connecting to target:
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()

and, the line who generates the error is

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

What am I missing? Here http://www.mediafire.com/?29qkq0vvzz9bkyt you can find the full solution source, just in case somebody needs it ...
Thansk everybody for your help!

Don't use Process.GetCurrentProcess().Id instead find it by process name in case you are not sure about process id.

RemoteHooking.Inject(
 Process.GetProcessesByName("Hook Test.vshost")[0].Id ,
 InjectionOptions.Default,
 "TestInject.dll",
 "TestInject.dll",
 ChannelName);

First of all, thank you for your reply. I tryed what you suggested, without success. I even tried replacing the string with the process ID ( obtained using spystudio), without success : the error is still the same.
After editing a little bit the source, I'm now getting a different error, "System.ApplicationException: Unable to install assembly in the GAC. This usually indicates either an invalid assembly path or you are not admin.", thing that already happened when the assembly wasn't signed ... but once I'll solve this problem, I'm quite sure the old "System.NotSupportedException: STATUS_NOT_SUPPORTED" will be back.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.