f.verrini
f.verrini

Reputation: 1

Why my exe is looking for version.dll locally?

I have an issue with the executable I generate in Lazarus ( I have the same problem with any project in the example folder found in Lazarus installation folder) and the windows dll version.dll. I know windows has an order https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order in which the OS search for the librarys,

I tried using the option LOAD_WITH_ALTERED_SEARCH_PATH but I fear I have to static link the library and no dinamically. How can I have my exe to look for the version.dll library only on the windows system directory?

In the process monitor app i can see that first the dll is searched locally and then on Windows system

Upvotes: 0

Views: 307

Answers (2)

Michael McCarthy
Michael McCarthy

Reputation: 1

I also have this issue with a .Net framework application. When the application starts it searches for VERSION.dll starting with the Application directory. This is before any of the application code has run.

I would love to know why it is searching for VERSION.dll in my apps directory. I was able to stop this search by adding the following line in the app.manifest file:

<file name="version.dll" loadFrom="%SystemRoot%\system32\" />

When added version.dll was no longer loaded at startup. I would love to know what is going on here during load.

I got the solution from this article: How do I avoid dll hijacking in Delphi application that uses WinApi.Windows

Upvotes: 0

Fernando Rizzato
Fernando Rizzato

Reputation: 112

Not sure if you can define a custom manifest in Lazarus, but for Delphi the solution can be found here:

How do I avoid dll hijacking in Delphi application that uses WinApi.Windows

Ps: to create a manifest that is compatible with the recent versions of Delphi, please see this resource: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Customizing_the_Windows_Application_Manifest_File

Upvotes: 0

Related Questions