LoadLibrary来自另一个DLL [英] LoadLibrary from another DLL

查看:150
本文介绍了LoadLibrary来自另一个DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DLL查找路径,如 in MSDN 是:

The DLL lookup path, as described in MSDN is:


  1. 当前进程的可执行模块所在的目录。

  2. 当前目录。

  3. Windows系统目录。 GetSystemDirectory函数检索此目录的路径。

  4. Windows目录。 GetWindowsDirectory函数检索此目录的路径。

  5. PATH环境变量中列出的目录。

  1. The directory where the executable module for the current process is located.
  2. The current directory.
  3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
  4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
  5. The directories listed in the PATH environment variable.

这带来了以下疑问:

假设我在某个目录中有一个可执行文件,说: c:\execdir\myexe .exe ,它会加载在 PATH 中找到的DLL,它位于 c:\dlldir\mydll中。 DLL 。现在,假设 mydll.dll 尝试使用 LoadLibrary 加载另一个DLL。将首先查看哪个目录 - c:\dlldir c:\execdir

Suppose I have an executable in some directory, say: c:\execdir\myexe.exe and it loads a DLL that's found in PATH and is located in c:\dlldir\mydll.dll. Now, suppose mydll.dll tries to load another DLL with LoadLibrary. Which directory will be looked at first - c:\dlldir or c:\execdir?

我认为上面引用的查找规则说这将是 c:\execdir ,因为这被称为

I think that the lookup rules quoted above say it's going to be c:\execdir because that's allegedly "the directory where the executable module for the current process is located", but it would be nice to get a confirmation from another source.

编辑:另外,是 c:\dlldir\ 全部查看 ?毕竟,它不是.exe所在的位置,也不是当前目录(如果这是一般意义上的)。

Also, is c:\dlldir\ looked at at all? After all, it's neither where the .exe is located, nor the "current directory" (if that is meant in the general sense).

P.S。我对Windows XP和7都感兴趣。

P.S. I'm interested in both Windows XP and 7.

推荐答案

是的,这是可执行文件目录,它实现了这可能会导致安全漏洞。在该页面上有建议,以确保您的应用程序不会通过此机制受到损害。

Yes, it is the executable directory first and it was realised this could lead to a security vulnerability under certain circumstances. There is advice on that page for ensuring your application is not compromised via this mechanism.

这篇关于LoadLibrary来自另一个DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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