你能从被调用者那里得到调用者 DLL 或可执行模块吗? [英] Can you get the caller DLL or executable module from the callee

查看:60
本文介绍了你能从被调用者那里得到调用者 DLL 或可执行模块吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想允许特定的 DLL 执行我在我挂钩的函数上编写的代码.如果没有执行堆栈跟踪,您如何获得调用者的模块名称?

I only want to allow specific DLLs to execute code I have written on a function I hooked. short of performing a stack trace how do you get the module name of your caller?

推荐答案

获取堆栈跟踪以查找函数的返回地址,例如使用 CaptureStackBackTrace.

Get a stack trace to find the return address of your function, for instance with CaptureStackBackTrace.

然后调用GetModuleHandleEx 传递 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 以获取包含该代码的模块句柄.

And then call GetModuleHandleEx passing GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS to obtain the module handle containing that code.

最后,调用 GetModuleFileName 查找与该模块关联的文件名.

Finally, call GetModuleFileName to find the filename associated with that module.

这篇关于你能从被调用者那里得到调用者 DLL 或可执行模块吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆