From: divverent Date: Fri, 27 May 2011 16:58:46 +0000 (+0000) Subject: call SetDllDirectory on Win32 too X-Git-Tag: xonotic-v0.6.0~163^2~378 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fc8e8ca74dbb1cf8729e193ae25652daea9416a8;p=xonotic%2Fdarkplaces.git call SetDllDirectory on Win32 too Usage: put DLLs in a bin32/ subdir for that If not done, binaries work as before. This is the only way to have a 32bit and 64bit executable version in the same directory! Otherwise Windows will abort DLL search at the 32bit DLL, which fails to load into a 64bit process. NOTE: this requires WinXP SP1 and above. To compile with this functionality disabled, compile with -DDONT_USE_SETDLLDIRECTORY added to the CFLAGS. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11168 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/sys_shared.c b/sys_shared.c index 4ed624e4..298de87d 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -1,14 +1,14 @@ +#ifdef WIN32 +# ifndef DONT_USE_SETDLLDIRECTORY +# define _WIN32_WINNT 0x0502 +# endif +#endif + #include "quakedef.h" #define SUPPORTDLL #ifdef WIN32 -# ifdef _WIN64 -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0502 -# endif - // for SetDllDirectory -# endif # include # include // timeGetTime # include // localtime @@ -133,13 +133,15 @@ notfound: { Con_DPrintf (" \"%s\"", dllnames[i]); #ifdef WIN32 -# ifdef _WIN64 +# ifndef DONT_USE_SETDLLDIRECTORY +# ifdef _WIN64 SetDllDirectory("bin64"); +# else + SetDllDirectory("bin32"); +# endif # endif dllhandle = LoadLibrary (dllnames[i]); -# ifdef _WIN64 - SetDllDirectory(NULL); -# endif + // no need to unset this - we want ALL dlls to be loaded from there, anyway #else dllhandle = dlopen (dllnames[i], RTLD_LAZY | RTLD_GLOBAL); #endif