Skip to content

Commit 40b378e

Browse files
authored
Merge pull request godotengine#96235 from bruvzg/win_open_dll
[Windows] Fix OS.open_dynamic_library
2 parents 622393c + d528f28 commit 40b378e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

modules/mono/editor/hostfxr_resolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ bool get_dotnet_self_registered_dir(String &r_dotnet_root) {
260260
return false;
261261
}
262262

263-
r_dotnet_root = String::utf16((const char16_t *)buffer.ptr());
263+
r_dotnet_root = String::utf16((const char16_t *)buffer.ptr()).replace("\\", "/");
264264
RegCloseKey(hkey);
265265
return true;
266266
#else

platform/windows/os_windows.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ Error OS_Windows::open_dynamic_library(const String &p_path, void *&p_library_ha
430430
bool has_dll_directory_api = ((add_dll_directory != nullptr) && (remove_dll_directory != nullptr));
431431
DLL_DIRECTORY_COOKIE cookie = nullptr;
432432

433-
String dll_dir = ProjectSettings::get_singleton()->globalize_path(load_path.get_base_dir());
434-
String wpath = fix_path(dll_dir);
433+
String dll_path = fix_path(load_path);
434+
String dll_dir = fix_path(ProjectSettings::get_singleton()->globalize_path(load_path.get_base_dir()));
435435
if (p_data != nullptr && p_data->also_set_library_path && has_dll_directory_api) {
436-
cookie = add_dll_directory((LPCWSTR)(wpath.get_base_dir().utf16().get_data()));
436+
cookie = add_dll_directory((LPCWSTR)(dll_dir.utf16().get_data()));
437437
}
438438

439-
p_library_handle = (void *)LoadLibraryExW((LPCWSTR)(wpath.utf16().get_data()), nullptr, (p_data != nullptr && p_data->also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0);
439+
p_library_handle = (void *)LoadLibraryExW((LPCWSTR)(dll_path.utf16().get_data()), nullptr, (p_data != nullptr && p_data->also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0);
440440
if (!p_library_handle) {
441441
if (p_data != nullptr && p_data->generate_temp_files) {
442442
DirAccess::remove_absolute(load_path);
@@ -447,7 +447,7 @@ Error OS_Windows::open_dynamic_library(const String &p_path, void *&p_library_ha
447447

448448
HashSet<String> checked_libs;
449449
HashSet<String> missing_libs;
450-
debug_dynamic_library_check_dependencies(wpath, checked_libs, missing_libs);
450+
debug_dynamic_library_check_dependencies(dll_path, checked_libs, missing_libs);
451451
if (!missing_libs.is_empty()) {
452452
String missing;
453453
for (const String &E : missing_libs) {

0 commit comments

Comments
 (0)