开发者

DLL not loaded from documented search path

I have a process which is loading a DLL from a place not listed in the documented search order (docs linked below). I want to know why.

Here's the description of my setup:

  1. I have a folder 'c:\foo' containing a.dll and b.dll.
  2. I have a python script also stored in c:\foo.
  3. The python script does a LoadLibrary('c:/foo/a.dll') (via ctypes)
  4. a.dll is linked against the import library for b.dll (ie using implicit linking).
  5. I run the python script with a current directory of, say, c:. It could be anything.
  6. b.dll is loaded from c:\foo, even though that isn't on the search path.
  7. Looking at the process monitor trace, I can see that all the documented search paths were tried first, and all failed. Then the python process tried and failed to open "C:\WINDOWS\as开发者_运维知识库sembly\GAC\Microsoft.VC80.CRT.mui\8.0.50727.4053_en-US_1fc8b3b9a1e18e3b\Microsoft.VC80.CRT.mui.DLL", then it opened c:\foo\b.dll.

So, it seems to be that the a.dll's directory is being searched for b.dll even though the docs don't say it should be. Also, this happens after looking on the system path, which is mad. Can anyone shed any light on this?

The same thing happens with a MatLab script that also uses a.dll.

I'm running Windows XP SP 3.

This MSDN article explains the default search order. I quote:

  1. The directory specified by lpFileName.
  2. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  3. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  5. The current directory.
  6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.


a.dll is probably using runtime dynamic linking as a last resort http://msdn.microsoft.com/en-us/library/ms686944%28VS.85%29.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜