path: root/src/pal/inc/pal.h
diff options
authorSwaroop Sridhar <>2018-11-12 11:56:18 -0800
committerJan Vorlicek <>2018-11-12 20:56:18 +0100
commit214c3b62d889b2ff57425ab3f4ce70adf7503be6 (patch)
tree6e58e67bf9a78bd0ade030d615bf57cbc3959baa /src/pal/inc/pal.h
parent853a01279327163b099fdd70d1c04d8aaf61f772 (diff)
LoadLibrary refactoring (#20841)
* Refactor LoadLibrary Methods This change refactors the code in DllImport in preparation for implementing the new NativeLibrary API here: dotnet/corefx#32015 The two main changes are: 1) A change in the semantics of the internal LoadLibrary helper functions. When a native library is loaded, there are two categories of callers expecting different return values: External callers like AssemblyNative::InternalLoadUnmanagedDllFromPath() and the upcoming System.Runtime.Interop.Marshall.LoadLibrary() need the raw system handle Internal callers like LoadLibraryModule() need the PAL registered handle This change modifies the internal LoadLibraryModule* methods to work in terms of native system handles, so that external callers can obrain them directly. Methods requiring PAL-handles can register them explicitly. There is no change in external signature of DllImport class, or the native Dll cache in AppDomain class. 2) Differentiate HMODULE and NATIVE_LIBRARY_HANDLE This change defines NATIVE_LIBRARY_HANDLE type to represent raw system handles to native libraries that are not registered with the PAL (On Unix systems). The types on PAL and DlImport methods are adjusted to make this semantic distinction explicit. * Fix loading LibC via PAL_LoadLibraryDirect()
Diffstat (limited to 'src/pal/inc/pal.h')
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index c4a1d64a29..45989998e8 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -68,6 +68,11 @@ extern "C" {
#include <pal_error.h>
#include <pal_mstypes.h>
+// Native system libray handle.
+// On Unix systems, NATIVE_LIBRARY_HANDLE type represents a library handle not registered with the PAL.
+// To get a HMODULE on Unix, call PAL_RegisterLibraryDirect() on a NATIVE_LIBRARY_HANDLE.
+typedef void * NATIVE_LIBRARY_HANDLE;
/******************* Processor-specific glue *****************************/
#ifndef _MSC_VER
@@ -2590,7 +2595,7 @@ LoadLibraryExW(
IN DWORD dwFlags);
-void *
IN LPCWSTR lpLibFileName);