mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-06 04:05:11 +08:00
engine: platform: win32: use widechar versions of LoadLibrary, which fixes loading engine if path contains non-latin characters
This commit is contained in:
@@ -370,7 +370,7 @@ static void WIN_SetDPIAwareness( void )
|
||||
BOOL ( __stdcall *pSetProcessDPIAware )( void );
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
if( ( hModule = LoadLibrary( "shcore.dll" ) ) )
|
||||
if( ( hModule = LoadLibraryW( L"shcore.dll" ) ) )
|
||||
{
|
||||
if( ( pSetProcessDpiAwareness = (void*)GetProcAddress( hModule, "SetProcessDpiAwareness" ) ) )
|
||||
{
|
||||
@@ -395,7 +395,7 @@ static void WIN_SetDPIAwareness( void )
|
||||
{
|
||||
Con_Reportf( "%s: Trying SetProcessDPIAware...\n", __func__ );
|
||||
|
||||
if( ( hModule = LoadLibrary( "user32.dll" ) ) )
|
||||
if( ( hModule = LoadLibraryW( L"user32.dll" ) ) )
|
||||
{
|
||||
if( ( pSetProcessDPIAware = ( void* )GetProcAddress( hModule, "SetProcessDPIAware" ) ) )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,14 @@ GNU General Public License for more details.
|
||||
#if XASH_LIB == LIB_WIN32
|
||||
#include "lib_win.h"
|
||||
|
||||
static const wchar_t *FS_PathToWideChar( const char *path )
|
||||
{
|
||||
static wchar_t pathBuffer[MAX_PATH];
|
||||
MultiByteToWideChar( CP_UTF8, 0, path, -1, pathBuffer, MAX_PATH );
|
||||
return pathBuffer;
|
||||
}
|
||||
|
||||
|
||||
static DWORD GetOffsetByRVA( DWORD rva, PIMAGE_NT_HEADERS nt_header )
|
||||
{
|
||||
int i = 0;
|
||||
@@ -375,7 +383,7 @@ static void ListMissingModules( dll_user_t *hInst )
|
||||
HMODULE hMod;
|
||||
const char *importName = (const char *)CALCULATE_ADDRESS( data, GetOffsetByRVA( importDesc->Name, peHeader ) );
|
||||
|
||||
hMod = LoadLibraryEx( importName, NULL, LOAD_LIBRARY_AS_DATAFILE );
|
||||
hMod = LoadLibraryExW( FS_PathToWideChar( importName ), NULL, LOAD_LIBRARY_AS_DATAFILE );
|
||||
if ( !hMod )
|
||||
{
|
||||
Q_snprintf( buf, sizeof( buf ), "%s not found!", importName );
|
||||
@@ -470,7 +478,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d
|
||||
else
|
||||
#endif
|
||||
{
|
||||
hInst->hInstance = LoadLibrary( hInst->fullPath );
|
||||
hInst->hInstance = LoadLibraryW( FS_PathToWideChar( hInst->fullPath ));
|
||||
}
|
||||
|
||||
if( !hInst->hInstance )
|
||||
|
||||
Reference in New Issue
Block a user