Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
imp - Stop early when load fails
Browse files Browse the repository at this point in the history
---

We need to stop early when loading fails.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Jul 11, 2024
1 parent cfebb0d commit 0b71e48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NativeLand/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ internal void LoadNixLibrary(string path)
_logger?.LogWarning($"libdl.so may not be found. Trying with libdl.so.2... {ex.Message}");
var result = dlopen_new(path, RTLD_LAZY | RTLD_GLOBAL);
_logger?.LogInformation(result == IntPtr.Zero ? "FAILED!" : "Success");
if (result == IntPtr.Zero)
throw new FileLoadException("Can't load library by this name", path);
}
}

Expand All @@ -124,6 +126,8 @@ internal void LoadWindowsLibrary(string path)
var cookie = AddDllDirectory(folder);
var result = LoadLibraryEx(path, IntPtr.Zero, LoadLibraryFlags.LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LoadLibraryFlags.LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LoadLibraryFlags.LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LoadLibraryFlags.LOAD_LIBRARY_SEARCH_SYSTEM32 | LoadLibraryFlags.LOAD_LIBRARY_SEARCH_USER_DIRS);
_logger?.LogInformation(result == IntPtr.Zero ? "FAILED!" : "Success");
if (result == IntPtr.Zero)
throw new FileLoadException("Can't load library by this name", path);
}

#region dlopen
Expand Down

0 comments on commit 0b71e48

Please sign in to comment.