Click or drag to resize

IEntryPoint Interface

EasyHook will search in the injected user library for a class which implements this interface. You should only have one class exposing this interface, otherwise it is undefined which one will be chosen. See remarks for more details on how you should create this class.

Namespace:  EasyHook
Assembly:  EasyHook (in EasyHook.dll) Version: 2.7.6684.0 (2.7.6684.0)
Syntax
public interface IEntryPoint
Remarks

To implement this interface is not the only thing to do. The related class shall implement two methods. The first one is a constructor ctor(IContext, ...) which will let you initialize your library. You should immediately complete this call and only connect to your host application for further error reporting. This initialization method allows you to redirect all unhandled exceptions to your host application automatically. So even if all things in your library initialization would fail, you may still report exceptions! Such unhandled exceptions will be thrown by Inject(Int32, InjectionOptions, String, String, Object) in your host. But make sure that you are using serializable exception objects only as all standard NET ones are, but not all custom ones. Otherwise you will only intercept a general exception with no specific information attached.

The second one is Run(IContext, ...) and should only exit/return when you want to unload your injected library. Unhandled exceptions WON'T be redirected automatically and are likely to crash the target process. As you are expected to connect to your host in the ctor(), you are now also expected to report errors by yourself.

The parameter list described by (IContext, ...) will always contain a RemoteHookingIContext instance as the first parameter. All further parameters will depend on the arguments passed to Inject(Int32, InjectionOptions, String, String, Object) at your injection host. ctor() and Run() must have the same custom parameter list as composed by the one passed to Inject(). Otherwise an exception will be thrown. For example if you call Inject(Int32, InjectionOptions, String, String, Object) with Inject(..., ..., ..., ..., "MyString1", "MyString2"), you have supplied a custom argument list of the format String, String to Inject. This list will be converted to an object array and serialized. The injected library stub will later deserialize this array and pass it to ctor() and Run(), both expected to have a signature of IContext, String, String in our case. So Run will now be called with (IContext, "MyString1", "MyString2").

You should avoid using static fields or properties within such a class, as this might lead to bugs in your code when multiple library instances are injected into the same target!

See Also