Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Fix OS.open_dynamic_library #96235

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/mono/editor/hostfxr_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ bool get_dotnet_self_registered_dir(String &r_dotnet_root) {
return false;
}

r_dotnet_root = String::utf16((const char16_t *)buffer.ptr());
r_dotnet_root = String::utf16((const char16_t *)buffer.ptr()).replace("\\", "/");
Copy link
Member Author

@bruvzg bruvzg Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this change is not necessary (everything will work without it), but makes path cleaner (had mixed \ and /).

RegCloseKey(hkey);
return true;
#else
Expand Down
10 changes: 5 additions & 5 deletions platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ Error OS_Windows::open_dynamic_library(const String &p_path, void *&p_library_ha
bool has_dll_directory_api = ((add_dll_directory != nullptr) && (remove_dll_directory != nullptr));
DLL_DIRECTORY_COOKIE cookie = nullptr;

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

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);
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);
if (!p_library_handle) {
if (p_data != nullptr && p_data->generate_temp_files) {
DirAccess::remove_absolute(load_path);
Expand All @@ -447,7 +447,7 @@ Error OS_Windows::open_dynamic_library(const String &p_path, void *&p_library_ha

HashSet<String> checked_libs;
HashSet<String> missing_libs;
debug_dynamic_library_check_dependencies(wpath, checked_libs, missing_libs);
debug_dynamic_library_check_dependencies(dll_path, checked_libs, missing_libs);
if (!missing_libs.is_empty()) {
String missing;
for (const String &E : missing_libs) {
Expand Down
Loading