如何将 Easyhook 与非托管可执行文件一起使用
我正在尝试在 c# 中进行一些挂钩(我宁愿不使用 Detours 或 c++),所以我一直在使用 EasyHook。
但是,当我这样做时,
Config.Register( "This description can be anything.", @"SomePathToAnExecutable.exe", "MyInjectionDll.dll");
我收到错误:
连接时出错 目标: System.BadImageFormatException:无法 加载给定的程序集 [SomePathToAnExecutable.exe] 为 反思。
这是一个有效的 NET 程序集吗? ---> System.BadImageFormatException:可以 不加载文件或程序集 [SomePathToAnExecutable.exe] 或其中之一 它的依赖项。该模块是 预计包含一个程序集 明显。
问题 1)我认为 SomePathToAnExecutable 是您想要挂钩的进程是否正确?
问题 2)可执行文件必须是托管代码吗?
我也在 codeplex 项目网站上询问过,但没有回复。
http://easyhook.codeplex.com/Thread/View.aspx?ThreadId= 235616
I am trying to do some hooking in c# (I'd rather not use Detours or c++) so i have been using EasyHook.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案 1) 否。
Config.Register
使用HookManager.dll 包含我用来创建 IPCServer 的接口(并且所有消息都从挂钩函数发送到该接口)。 NetworkIncomingHook.dll 和 NetworkOutgoingHook.dll 都是我注入到程序中的 dll。这是由RemoteHooking.Inject 完成的。
2) 不。您也可以挂钩非托管程序集。
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: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.