问题描述
我试图钩住其他应用程序的ExtTextOut和DrawTextExt GDI方法调用。
I am trying to hook the ExtTextOut and DrawTextExt GDI method calls of another application.
我知道我需要使用GetProcAddress的找到这些方法的地址GDI32.DLL,并覆盖在我想用我的函数的地址挂钩过程中的地址。然后在我的功能,我做什么,我需要,然后调用原有的功能。
I know that I need to Use GetProcAddress to find the address of those methods in gdi32.dll, and overwrite the address in the process I want to hook with the address of my function. Then in my function I do what I need, then call the original function.
我要提供给.NET应用这个钩子的功能,显然这是做 - 可以通过创建一个中间非托管的DLL,做的挂钩,并能在.NET方面烧成活动,使新的功能可以打赌写在托管环境中。我只是不知道如何实现这一点。没有人有任何示例代码或链接信息?
I want to make this hook functionality available to .net applications, and apparently this is do-able by creating an 'intermediate' unmanaged dll that does the hooking, and is capable of firing a event on the .net side, so that the new function can bet written in the managed environment. I'm just not sure how to implement this. Does anyone have any code samples or links to information?
推荐答案
我建议微软走弯路(C ++仅适用于x86)或EasyHook(C ++ &安培; C#中,在x86 / x64)
I would recommend Microsoft's Detours (C++ x86 only) or EasyHook (C++ & C#, x86/x64).
我以前使用过,效果很好。你必须通过一个函数或地址,你希望它重定向到,你可以将所有电话(所有进程或特定的一个)发送到您的功能。本教程涵盖大部分的基础知识,但我可以编辑代码到这个答案,如果你愿意的话。
I've used it before, works pretty well. You have to pass a function or address and where you want it redirected to, and you can have all calls (for all processes or a specific one) sent into your function. The tutorials cover most of the basics, but I can edit code into this answer if you'd like.
琐事的一点是,它也可以其他方式。一个指针传递给你的功能,你可以重定向呼叫到外部代码。使得旧的应用程序或封闭源代码的人一些有趣的融合。
A bit of trivia is that it also works the other way. Pass a pointer to your function and you can redirect calls into external code. Makes for some interesting integration with old apps or closed-source ones.
这篇关于如何挂钩的另一个应用程序的API调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!