通过提供DLLName查找DLL路径 [英] Locate DLL path by giving a DLLName

查看:66
本文介绍了通过提供DLLName查找DLL路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我愿意

  LoadLibrary( MyTest.dll)

Windows将从 C:\TestFolder\Test\MyTest.dll定位并加载它。,因为 C:\TestFolder\Test\ %PATH%文件夹中。 / p>

如何模拟相同的功能?我需要找到 C:\TestFolder\Test\MyTest.dll C:\TestFolder\Test\ MyTest.dll 作为函数的参数传递给%PATH%中的c $ c>。有没有这样的API?或功能?



P.S。我无法先执行LoadLibrary,然后再执行GetModuleHandle并找到Path,有时此DLL可能是恶意DLL,因此无法加载。因此,我需要找到PATH而不必加载它。

解决方案

要在不运行任何恶意代码的情况下加载DLL,请使用 LoadLibraryEx DONT_RESOLVE_DLL_REFERENCES LOAD_LIBRARY_AS_DATAFILE 标志。



然后您可以使用 GetModuleFileName



您还应该阅读有关所有其他标志,使您可以执行Windows能够执行的所有各种搜索。


If I do

LoadLibrary("MyTest.dll")

Windows will locate and load it from "C:\TestFolder\Test\MyTest.dll", because "C:\TestFolder\Test\" is in %PATH% folder.

How can I emulate same function? I need to locate C:\TestFolder\Test\MyTest.dll (C:\TestFolder\Test\ is in %PATH%) by passing MyTest.dll as an argument to a function. Is there such an API? or a function?

P.S. I can't do LoadLibrary and then GetModuleHandle and finding Path, sometimes this DLL could be malicious DLL and I can't load it. So I need to find PATH without having to load it.

解决方案

To load the DLL without running any malicious code inside, use LoadLibraryEx with the DONT_RESOLVE_DLL_REFERENCES and LOAD_LIBRARY_AS_DATAFILE flags.

Then you can use GetModuleFileName.

You should also read about all the other flags, which allow you to perform all the various searches Windows is capable of.

这篇关于通过提供DLLName查找DLL路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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