vlc | branch: master | Jean-Baptiste Kempf <[email protected]> | Fri Jul 1 13:26:19 2016 +0200| [c220ddc927d1a97f72a0c5bf86de56301e3483ad] | committer: Jean-Baptiste Kempf
Win32: modify the LoadLibrary PATHS used We used to load system libraries without the full path, notably for DirectX-related libraries. This is a bad idea if someone puts a similarly-named DLL in the VLC folder, because they would be loaded. Indeed, even if we don't load from CWD, we still load from the application, which could be an issue, if you install a DLL next to libvlccore.dll. Therefore, on modern Windows systems, now LoadLibrary calls are completely limited to SYSTEM32; except when loading vlc modules, where they are limited to the application folder. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c220ddc927d1a97f72a0c5bf86de56301e3483ad --- src/win32/plugin.c | 4 +++- src/win32/specific.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/win32/plugin.c b/src/win32/plugin.c index db3b61b..8dd30eb 100644 --- a/src/win32/plugin.c +++ b/src/win32/plugin.c @@ -33,6 +33,8 @@ #include <windows.h> #include <wchar.h> +extern DWORD LoadLibraryFlags; + #if (_WIN32_WINNT < 0x601) static BOOL WINAPI SetThreadErrorModeFallback(DWORD mode, DWORD *oldmode) { @@ -107,7 +109,7 @@ int module_Load( vlc_object_t *p_this, const char *psz_file, if (SetThreadErrorMode (SEM_FAILCRITICALERRORS, &mode) != 0) #endif { - handle = LoadLibraryW (wfile); + handle = LoadLibraryExW (wfile, NULL, LoadLibraryFlags ); #if !VLC_WINSTORE_APP SetThreadErrorMode (mode, NULL); #endif diff --git a/src/win32/specific.c b/src/win32/specific.c index fdcb9f4..fd1a21d 100644 --- a/src/win32/specific.c +++ b/src/win32/specific.c @@ -34,6 +34,7 @@ #include <mmsystem.h> #include <winsock.h> +DWORD LoadLibraryFlags = 0; static int system_InitWSA(int hi, int lo) { @@ -60,6 +61,21 @@ void system_Init(void) if (system_InitWSA(2, 2) && system_InitWSA(1, 1)) fputs("Error: cannot initialize Winsocks\n", stderr); + +#if !VLC_WINSTORE_APP + typedef BOOL (WINAPI *SetDefaultDllDirectoriesFunc)( DWORD DirectoryFlags); + SetDefaultDllDirectoriesFunc pf_SetDefDllDir = (SetDefaultDllDirectoriesFunc) + GetProcAddress( GetModuleHandleW(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); + + if( pf_SetDefDllDir ) { + pf_SetDefDllDir( LOAD_LIBRARY_SEARCH_SYSTEM32 ); + LoadLibraryFlags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | + LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR; + } +#else + LoadLibraryFlags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | + LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR; +#endif } /***************************************************************************** _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
