From 7c9f5f8ab1478bda25156d9153c05008a8d36f80 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 11 Jun 2022 02:17:04 +0300 Subject: [PATCH] engine: remove LoadLibrary macros, to avoid possible misuse. Although macros moved to game_launch, it's part of it's own problem from now --- common/port.h | 6 ------ engine/common/system.c | 9 ++++++--- game_launch/game.cpp | 5 ++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/port.h b/common/port.h index 435de115..ae60122f 100644 --- a/common/port.h +++ b/common/port.h @@ -47,14 +47,8 @@ GNU General Public License for more details. #define O_BINARY 0 #define O_TEXT 0 #define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ) - #define LoadLibrary( x ) dlopen( x, RTLD_NOW ) - #define GetProcAddress( x, y ) dlsym( x, y ) - #define FreeLibrary( x ) dlclose( x ) #elif XASH_DOS4GW #define PATH_SPLITTER "\\" - #define LoadLibrary( x ) (0) - #define GetProcAddress( x, y ) (0) - #define FreeLibrary( x ) (0) #endif typedef void* HANDLE; diff --git a/engine/common/system.c b/engine/common/system.c index 6916fdd1..c41854e8 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -34,6 +34,8 @@ GNU General Public License for more details. #include "menu_int.h" // _UPDATE_PAGE macro +#include "library.h" + qboolean error_on_exit = false; // arg for exit(); #define DEBUG_BREAK @@ -272,7 +274,8 @@ qboolean Sys_LoadLibrary( dll_info_t *dll ) *func->func = NULL; } - if( !dll->link ) dll->link = LoadLibrary ( dll->name ); // environment pathes + if( !dll->link ) + dll->link = COM_LoadLibrary( dll->name, false, true ); // environment pathes // no DLL found if( !dll->link ) @@ -307,7 +310,7 @@ void* Sys_GetProcAddress( dll_info_t *dll, const char* name ) if( !dll || !dll->link ) // invalid desc return NULL; - return (void *)GetProcAddress( dll->link, name ); + return (void *)COM_GetProcAddress( dll->link, name ); } qboolean Sys_FreeLibrary( dll_info_t *dll ) @@ -324,7 +327,7 @@ qboolean Sys_FreeLibrary( dll_info_t *dll ) } else Con_Reportf( "Sys_FreeLibrary: Unloading %s\n", dll->name ); - FreeLibrary( dll->link ); + COM_FreeLibrary( dll->link ); dll->link = NULL; return true; diff --git a/game_launch/game.cpp b/game_launch/game.cpp index 347f1973..5ebac7e8 100644 --- a/game_launch/game.cpp +++ b/game_launch/game.cpp @@ -23,6 +23,9 @@ GNU General Public License for more details. #if XASH_POSIX #define XASHLIB "libxash." OS_LIB_EXT +#define LoadLibrary( x ) dlopen( x, RTLD_NOW ) +#define GetProcAddress( x, y ) dlsym( x, y ) +#define FreeLibrary( x ) dlclose( x ) #include // execve #elif XASH_WIN32 #define XASHLIB "xash.dll" @@ -46,7 +49,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; #endif #if XASH_WIN32 || XASH_POSIX -#define USE_EXECVE_FOR_CHANGE_GAME 1 +#define USE_EXECVE_FOR_CHANGE_GAME 0 #else #define USE_EXECVE_FOR_CHANGE_GAME 0 #endif