确定哪个模块(DLL / EXE)加载了我的DLL [英] Determine which module(DLL/EXE) loaded my DLL

查看:69
本文介绍了确定哪个模块(DLL / EXE)加载了我的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的DLLMain()函数中,在DLL_PROCESS_ATTACH中,出于某些应用程序安全原因,我需要知道谁加载了我的DLL。如何确定哪个其他DLL或EXE加载了我的DLL?我需要加载我的
DLL的模块的完整路径。

In my DLLMain() function, in the DLL_PROCESS_ATTACH, I need to know who has loaded my DLL for some application security reasons. How do I determine which other DLL or EXE has loaded my DLL? I need the complete path to the module which is loading my DLL.

TIA,

Jy

推荐答案

您是否尝试过使用OpenProcess()后跟QueryFullProcessImageName()? 这将返回EXE。


Have you tried using OpenProcess() followed by QueryFullProcessImageName()?  This would return the EXE.

它应该是安全的从DllMain中调用这些函数,因为它们都驻留在kernel32.dll中

It should be safe to call these functions from within DllMain since they both reside in kernel32.dll

更新 -

在Win8.1的快速测试中,没有必要使用OpenProcess,我使用的是GetCurrentProcess();而是




In a quick test on Win8.1 OpenProcess wasn't necessary, I used GetCurrentProcess() instead;



这篇关于确定哪个模块(DLL / EXE)加载了我的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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