win-app icon indicating copy to clipboard operation
win-app copied to clipboard

Replace SetDefaultDllDirectories call with Assembly attribute

Open ejstrunz opened this issue 3 weeks ago • 0 comments

Currently ProtonVPN.Service sets the DLL import search path to LOAD_LIBRARY_SEARCH_DEFAULT_DIRS using a P/Invoke call to kernel32.dll. I believe the intention is to prevent DLLs being loaded from PATH?

In that case, it is possible to do this with an Assembly attribute instead:

[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)]

This should be identical in behaviour, since SafeDirectories and LOAD_LIBRARY_SEARCH_DEFAULT_DIRS both have the value 0x1000.

The ProtonVPN.Native module becomes redundant this way, since it only contained the P/Invoke binding. Therefore I have removed it.

ejstrunz avatar Dec 04 '25 09:12 ejstrunz