Hell libraries (aka DLL Hell)

In my project, I use a Delphi application that dynamically loads a DLL wrapper (exports C-Style functions), which, in turn, statically links to a bunch of third-party DLLs.

It works fine on my test machines, but on my client computer it failed to initialize the error message "Could not find entry point _somefunction @ 4AKKZ in TMYlibrary.dll".

After some research with the sysinternal process monitor, I realized that Windows will first look for DLL files in windows / sytem32, so if a DLL like my DLL is present in system32, windows will select it and try to find my entry point function in it - what does not work out.

Do you know that it is possible to change DLL DLLs in search of behavior?


Additional Information

  • [ Refresh ]. The EXE file is located at the top level of the application folder tree.
  • Wrapper and third-party DLL files located in the "Subfolder / bin" folder of my applications
  • The dev platform is Windows XP / 7 using VS2008 for dlll and Delphi 2010 for the application.
+4
source share
2 answers

I found another solution:

SetDllDirectory adds an additional search path to the list of locations to look at.

From http://msdn.microsoft.com/en-us/library/ms686203%28v=VS.85%29.aspx

After calling SetDllDirectory, the DLL search path:

  • The directory from which the application was downloaded.
  • The directory specified by the lpPathName parameter.
  • System catalog Use the GetSystemDirectory function to get the path of this directory. The name of this directory is System32.
  • 16-bit system catalog. There is no function that has a path to this directory, but it is a search. The name of this directory is the system.
  • Windows directory. Use the GetWindowsDirectory function to get the path to this directory.
  • Directories listed in the PATH environment variable.

(maybe I should do my googling before I post to SO;)

+13
source

Download the DLL to your program folder. (same as exe file).

Then, Windows should first try your version.

+1
source

Source: https://habr.com/ru/post/1316501/


All Articles