开发者

How to use Easyhook with non managed executable

I am trying to do some hooking in c# (I'd rat开发者_如何学Goher not use Detours or c++) so i have been using EasyHook.

https://easyhook.github.io/

However When i'm doing this

Config.Register( "This description can be anything.", @"SomePathToAnExecutable.exe", "MyInjectionDll.dll");

I get the error:

There was an error while connecting to target: System.BadImageFormatException: Unable to load given assembly [SomePathToAnExecutable.exe] for reflection.

Is this a valid NET assembly? ---> System.BadImageFormatException: Could not load file or assembly [SomePathToAnExecutable.exe] or one of its dependencies. The module was expected to contain an assembly manifest.

Question 1) Am I right in thinking that SomePathToAnExecutable is the process that you want to hook into???

Question 2) Does the executable have to be managed code then??

I've also asked at on the codeplex project site, but no response.

http://easyhook.codeplex.com/Thread/View.aspx?ThreadId=235616


Answer 1) No. Config.Register registers managed assemblies with the GAC. Thus you register all assemblies participating from your code. This includes the dll you want to inject and the assembly that provides the common interface for the IPCServer. For my it looks like this one for example:

        Config.Register("MyHook",
            Path.Combine(startupPath, "HookManager.dll"), 
            Path.Combine(startupPath, "NetworkIncomingHook.dll"),
            Path.Combine(startupPath, "NetworkOutgoingHook.dll")
        );

The HookManager.dll contains the interface I use to create the IPCServer (and where all messages are send to from the hooked functions). The NetworkIncomingHook.dll and NetworkOutgoingHook.dll are both dlls I inject into my programm. This is done by RemoteHooking.Inject.

2) No. You can hook unmanaged assemblies aswell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜