mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-06 12:14:54 +01:00
UTF8 paths are now properly handled on windows.
This commit is contained in:
parent
b8eae2b709
commit
51702b898e
5 changed files with 147 additions and 96 deletions
25
dll/base.cpp
25
dll/base.cpp
|
|
@ -28,14 +28,14 @@ randombytes(char * const buf, const size_t size)
|
|||
|
||||
std::string get_env_variable(std::string name)
|
||||
{
|
||||
char env_variable[1024];
|
||||
DWORD ret = GetEnvironmentVariableA(name.c_str(), env_variable, sizeof(env_variable));
|
||||
wchar_t env_variable[1024];
|
||||
DWORD ret = GetEnvironmentVariableW(utf8_decode(name).c_str(), env_variable, _countof(env_variable));
|
||||
if (ret <= 0) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
env_variable[ret] = 0;
|
||||
return std::string(env_variable);
|
||||
return utf8_encode(env_variable);
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
@ -194,9 +194,9 @@ std::string get_full_lib_path()
|
|||
{
|
||||
std::string program_path;
|
||||
#if defined(__WINDOWS__)
|
||||
char DllPath[MAX_PATH] = {0};
|
||||
GetModuleFileName((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
|
||||
program_path = DllPath;
|
||||
wchar_t DllPath[2048] = {0};
|
||||
GetModuleFileNameW((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
|
||||
program_path = utf8_encode(DllPath);
|
||||
#else
|
||||
program_path = get_lib_path();
|
||||
#endif
|
||||
|
|
@ -240,15 +240,18 @@ std::string canonical_path(std::string path)
|
|||
{
|
||||
std::string output;
|
||||
#if defined(STEAM_WIN32)
|
||||
char *buffer = _fullpath(NULL, path.c_str(), 0);
|
||||
wchar_t *buffer = _wfullpath(NULL, utf8_decode(path).c_str(), 0);
|
||||
if (buffer) {
|
||||
output = utf8_encode(buffer);
|
||||
free(buffer);
|
||||
}
|
||||
#else
|
||||
char *buffer = canonicalize_file_name(path.c_str());
|
||||
#endif
|
||||
|
||||
if (buffer) {
|
||||
output = buffer;
|
||||
free(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -633,7 +636,7 @@ static void load_dll()
|
|||
PRINT_DEBUG("Crack file %s\n", path.c_str());
|
||||
if (file_exists(path)) {
|
||||
redirect_crackdll();
|
||||
crack_dll_handle = LoadLibraryA(path.c_str());
|
||||
crack_dll_handle = LoadLibraryW(utf8_decode(path).c_str());
|
||||
unredirect_crackdll();
|
||||
PRINT_DEBUG("Loaded crack file\n");
|
||||
}
|
||||
|
|
@ -657,7 +660,7 @@ static void load_dlls()
|
|||
if (full_path[length - 4] != '.') continue;
|
||||
|
||||
PRINT_DEBUG("Trying to load %s\n", full_path.c_str());
|
||||
if (LoadLibraryA(full_path.c_str())) {
|
||||
if (LoadLibraryW(utf8_decode(full_path).c_str())) {
|
||||
PRINT_DEBUG("LOADED %s\n", full_path.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue