Skip to content

Commit ea09225

Browse files
author
swaroop-sridhar
committed
Add Per-assembly Load Native Library callbacks
This Change implements the Native Library resolution Call-backs proposed in https://github.com/dotnet/corefx/issues/32015 public static bool RegisterDllImportResolver( Assembly assembly, Func<string, Assembly, DllImportSearchPath, IntPtr> callback ); This API is not yet approved, and the API contracts in CoreFX will not be added until the API approval is complete. In the meantime, we want to have the code reviewed, tested, and avaiable in CoreCLR.
1 parent ca65764 commit ea09225

19 files changed

+546
-213
lines changed

src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs

+81-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public static partial class Marshal
3232
internal static Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
3333
#endif //FEATURE_COMINTEROP
3434

35+
static Marshal()
36+
{
37+
nativeDllResolveMap = new ConditionalWeakTable<Assembly, Func<string, Assembly, DllImportSearchPath?, IntPtr>>();
38+
}
39+
3540
private const int LMEM_FIXED = 0;
3641
private const int LMEM_MOVEABLE = 2;
3742
#if !FEATURE_PAL
@@ -1805,6 +1810,7 @@ public static bool TryLoadLibrary(string libraryPath, out IntPtr handle)
18051810
/// calling assembly (if any) are used.
18061811
/// This LoadLibrary() method does not invoke the managed call-backs for native library resolution:
18071812
/// * AssemblyLoadContext.LoadUnmanagedDll()
1813+
/// * The per-assembly registered callback
18081814
/// </summary>
18091815
/// <param name="libraryName">The name of the native library to be loaded</param>
18101816
/// <param name="assembly">The assembly loading the native library</param>
@@ -1907,13 +1913,87 @@ public static bool TryGetLibraryExport(IntPtr handle, string name, out IntPtr ad
19071913
return address != IntPtr.Zero;
19081914
}
19091915

1916+
/// <summary>
1917+
/// Map from assembly to native-library-resolution-callback.
1918+
/// Generally interop specific fields and properties are not added to assembly.
1919+
/// Therefore, this table uses weak assembly pointers to indirectly achieve
1920+
/// similar behavior.
1921+
/// </summary>
1922+
public static ConditionalWeakTable<Assembly, Func<string, Assembly, DllImportSearchPath?, IntPtr>> nativeDllResolveMap;
1923+
1924+
/// <summary>
1925+
/// Register a callback for resolving native library imports from an assembly
1926+
/// This per-assembly callback is the first attempt to resolve native library loads
1927+
/// initiated by this assembly.
1928+
///
1929+
/// Only one callback can be registered per assembly. Trying to register a second
1930+
/// callback fails (with the return value false).
1931+
///
1932+
/// The callback method itself takes the following parameters
1933+
/// - The name of the library to be loaded (string)
1934+
/// - The assembly initiating the native library load
1935+
/// - The DllImportSearchPath flags from the attributes on the PInvoke, if any (null otherwise).
1936+
/// This argument doesn't include the flags from any attributes on the assembly itself.
1937+
/// and returns
1938+
/// - The handle to the loaded native library (on success) or null (on failure)
1939+
/// The parameters on this callback are such that they can be directly passed to
1940+
/// Marhall.LoadLibrary(libraryName, assembly, dllImportSearchPath) to approximately achieve
1941+
/// the default load behavior.
1942+
///
1943+
/// </summary>
1944+
/// <param name="assembly">The assembly for which the callback is registered</param>
1945+
/// <param name="callBack">The callback to register</param>
1946+
/// <exception cref="System.ArgumentNullException">If assembly or callback is null</exception>
1947+
/// <returns>True on success, false otherwise</returns>
1948+
public static bool RegisterDllImportResolver(Assembly assembly, Func<string, Assembly, DllImportSearchPath?, IntPtr> callBack)
1949+
{
1950+
if (assembly == null)
1951+
throw new ArgumentNullException(nameof(assembly));
1952+
if (callBack == null)
1953+
throw new ArgumentNullException(nameof(callBack));
1954+
if (!(assembly is RuntimeAssembly))
1955+
throw new ArgumentException(SR.Argument_MustBeRuntimeAssembly);
1956+
1957+
Func<string, Assembly, DllImportSearchPath?, IntPtr> existingCallback;
1958+
if (nativeDllResolveMap.TryGetValue(assembly, out existingCallback))
1959+
{
1960+
return false;
1961+
}
1962+
1963+
nativeDllResolveMap.Add(assembly, callBack);
1964+
return true;
1965+
}
1966+
1967+
/// <summary>
1968+
/// The helper function that calls the per-assembly native-library resolver
1969+
/// if one is registered for this assembly.
1970+
/// </summary>
1971+
/// <param name="libraryName">The native library to load</param>
1972+
/// <param name="assembly">The assembly trying load the native library</param>
1973+
/// <param name="hasDllImportSearchPathFlags">If the pInvoke has DefaultDllImportSearchPathAttribute</param>
1974+
/// <param name="dllImportSearchPathFlags">If hasdllImportSearchPathFlags is true, the flags in
1975+
/// DefaultDllImportSearchPathAttribute; meaningless otherwise </param>
1976+
/// <returns>The handle for the loaded library on success. Null on failure.</returns>
1977+
internal static IntPtr LoadLibraryCallbackStub(string libraryName, Assembly assembly,
1978+
bool hasDllImportSearchPathFlags, uint dllImportSearchPathFlags)
1979+
{
1980+
Func<string, Assembly, DllImportSearchPath?, IntPtr> callBack;
1981+
1982+
if (!nativeDllResolveMap.TryGetValue(assembly, out callBack))
1983+
{
1984+
return IntPtr.Zero;
1985+
}
1986+
1987+
return callBack(libraryName, assembly, hasDllImportSearchPathFlags? (DllImportSearchPath?)dllImportSearchPathFlags : null);
1988+
}
1989+
19101990
/// External functions that implement the NativeLibrary interface
19111991

19121992
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
19131993
internal static extern IntPtr LoadLibraryFromPath(string libraryName, bool throwOnError);
19141994
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
19151995
internal static extern IntPtr LoadLibraryByName(string libraryName, RuntimeAssembly callingAssembly,
1916-
bool hasDllImportSearchPathFlag, uint dllImportSearchPathFlag,
1996+
bool hasDllImportSearchPathFlags, uint dllImportSearchPathFlags,
19171997
bool throwOnError);
19181998
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
19191999
internal static extern void FreeNativeLibrary(IntPtr handle);

src/vm/callhelpers.h

+1
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ enum DispatchCallSimpleFlags
566566
#define STRINGREF_TO_ARGHOLDER(x) (LPVOID)STRINGREFToObject(x)
567567
#define PTR_TO_ARGHOLDER(x) (LPVOID)x
568568
#define DWORD_TO_ARGHOLDER(x) (LPVOID)(SIZE_T)x
569+
#define BOOL_TO_ARGHOLDER(x) DWORD_TO_ARGHOLDER(x)
569570

570571
#define INIT_VARIABLES(count) \
571572
DWORD __numArgs = count; \

src/vm/dllimport.cpp

+96-28
Original file line numberDiff line numberDiff line change
@@ -6157,7 +6157,7 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryFromPath(LPCWSTR libraryPath, BOOL thr
61576157

61586158
// static
61596159
NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryByName(LPCWSTR libraryName, Assembly *callingAssembly,
6160-
BOOL hasDllImportSearchFlag, DWORD dllImportSearchFlag,
6160+
BOOL hasDllImportSearchFlags, DWORD dllImportSearchFlags,
61616161
BOOL throwOnError)
61626162
{
61636163
CONTRACTL
@@ -6170,15 +6170,15 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryByName(LPCWSTR libraryName, Assembly *
61706170

61716171
LoadLibErrorTracker errorTracker;
61726172

6173-
// First checks if a default DllImportSearchPathFlag was passed in, if so, use that value.
6173+
// First checks if a default dllImportSearchPathFlags was passed in, if so, use that value.
61746174
// Otherwise checks if the assembly has the DefaultDllImportSearchPathsAttribute attribute. If so, use that value.
61756175
BOOL searchAssemblyDirectory = TRUE;
6176-
DWORD dllImportSearchPathFlag = 0;
6176+
DWORD dllImportSearchPathFlags = 0;
61776177

6178-
if (hasDllImportSearchFlag)
6178+
if (hasDllImportSearchFlags)
61796179
{
6180-
dllImportSearchPathFlag = dllImportSearchFlag & ~DLLIMPORTSEARCHPATH_ASSEMBLYDIRECTORY;
6181-
searchAssemblyDirectory = dllImportSearchFlag & DLLIMPORTSEARCHPATH_ASSEMBLYDIRECTORY;
6180+
dllImportSearchPathFlags = dllImportSearchFlags & ~DLLIMPORTSEARCHPATH_ASSEMBLYDIRECTORY;
6181+
searchAssemblyDirectory = dllImportSearchFlags & DLLIMPORTSEARCHPATH_ASSEMBLYDIRECTORY;
61826182

61836183
}
61846184
else
@@ -6187,13 +6187,13 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryByName(LPCWSTR libraryName, Assembly *
61876187

61886188
if (pModule->HasDefaultDllImportSearchPathsAttribute())
61896189
{
6190-
dllImportSearchPathFlag = pModule->DefaultDllImportSearchPathsAttributeCachedValue();
6190+
dllImportSearchPathFlags = pModule->DefaultDllImportSearchPathsAttributeCachedValue();
61916191
searchAssemblyDirectory = pModule->DllImportSearchAssemblyDirectory();
61926192
}
61936193
}
61946194

61956195
NATIVE_LIBRARY_HANDLE hmod =
6196-
LoadLibraryModuleBySearch(callingAssembly, searchAssemblyDirectory, dllImportSearchPathFlag, &errorTracker, libraryName);
6196+
LoadLibraryModuleBySearch(callingAssembly, searchAssemblyDirectory, dllImportSearchPathFlags, &errorTracker, libraryName);
61976197

61986198
if (throwOnError && (hmod == nullptr))
61996199
{
@@ -6212,11 +6212,11 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(NDirectMethodDesc * pMD
62126212
// First checks if the method has DefaultDllImportSearchPathsAttribute. If so, use that value.
62136213
// Otherwise checks if the assembly has the attribute. If so, use that value.
62146214
BOOL searchAssemblyDirectory = TRUE;
6215-
DWORD dllImportSearchPathFlag = 0;
6215+
DWORD dllImportSearchPathFlags = 0;
62166216

62176217
if (pMD->HasDefaultDllImportSearchPathsAttribute())
62186218
{
6219-
dllImportSearchPathFlag = pMD->DefaultDllImportSearchPathsAttributeCachedValue();
6219+
dllImportSearchPathFlags = pMD->DefaultDllImportSearchPathsAttributeCachedValue();
62206220
searchAssemblyDirectory = pMD->DllImportSearchAssemblyDirectory();
62216221
}
62226222
else
@@ -6225,13 +6225,13 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(NDirectMethodDesc * pMD
62256225

62266226
if (pModule->HasDefaultDllImportSearchPathsAttribute())
62276227
{
6228-
dllImportSearchPathFlag = pModule->DefaultDllImportSearchPathsAttributeCachedValue();
6228+
dllImportSearchPathFlags = pModule->DefaultDllImportSearchPathsAttributeCachedValue();
62296229
searchAssemblyDirectory = pModule->DllImportSearchAssemblyDirectory();
62306230
}
62316231
}
62326232

62336233
Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly();
6234-
return LoadLibraryModuleBySearch(pAssembly, searchAssemblyDirectory, dllImportSearchPathFlag, pErrorTracker, wszLibName);
6234+
return LoadLibraryModuleBySearch(pAssembly, searchAssemblyDirectory, dllImportSearchPathFlags, pErrorTracker, wszLibName);
62356235
}
62366236

62376237
// static
@@ -6280,23 +6280,32 @@ INT_PTR NDirect::GetNativeLibraryExport(NATIVE_LIBRARY_HANDLE handle, LPCWSTR sy
62806280
return address;
62816281
}
62826282

6283+
#ifndef PLATFORM_UNIX
6284+
BOOL IsWindowsAPI(PCWSTR wszLibName)
6285+
{
6286+
// This is replicating quick check from the OS implementation of api sets.
6287+
return SString::_wcsnicmp(wszLibName, W("api-"), 4) == 0 ||
6288+
SString::_wcsnicmp(wszLibName, W("ext-"), 4) == 0;
6289+
}
6290+
#endif // !PLATFORM_UNIX
6291+
62836292
// static
6284-
NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleViaHost(NDirectMethodDesc * pMD, AppDomain* pDomain, PCWSTR wszLibName)
6293+
NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleViaHost(NDirectMethodDesc * pMD, PCWSTR wszLibName)
62856294
{
62866295
STANDARD_VM_CONTRACT;
62876296
//Dynamic Pinvoke Support:
62886297
//Check if we need to provide the host a chance to provide the unmanaged dll
62896298

62906299
#ifndef PLATFORM_UNIX
6291-
// Prevent Overriding of Windows API sets.
6292-
// This is replicating quick check from the OS implementation of api sets.
6293-
if (SString::_wcsnicmp(wszLibName, W("api-"), 4) == 0 || SString::_wcsnicmp(wszLibName, W("ext-"), 4) == 0)
6300+
if (IsWindowsAPI(wszLibName))
62946301
{
6302+
// Prevent Overriding of Windows API sets.
62956303
return NULL;
62966304
}
6297-
#endif
6305+
#endif // !PLATFORM_UNIX
62986306

62996307
LPVOID hmod = NULL;
6308+
AppDomain* pDomain = GetAppDomain();
63006309
CLRPrivBinderCoreCLR *pTPABinder = pDomain->GetTPABinderContext();
63016310
Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly();
63026311

@@ -6362,6 +6371,55 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleViaHost(NDirectMethodDesc * pMD,
63626371
return (NATIVE_LIBRARY_HANDLE)hmod;
63636372
}
63646373

6374+
NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleViaCallBack(NDirectMethodDesc * pMD, LPCWSTR wszLibName)
6375+
{
6376+
#ifndef PLATFORM_UNIX
6377+
if (IsWindowsAPI(wszLibName))
6378+
{
6379+
// Prevent Overriding of Windows API sets.
6380+
return NULL;
6381+
}
6382+
#endif // !PLATFORM_UNIX
6383+
6384+
DWORD dllImportSearchPathFlags = 0;
6385+
BOOL hasDllImportSearchPathFlags = pMD->HasDefaultDllImportSearchPathsAttribute();
6386+
if (hasDllImportSearchPathFlags)
6387+
{
6388+
dllImportSearchPathFlags = pMD->DefaultDllImportSearchPathsAttributeCachedValue();
6389+
if (pMD->DllImportSearchAssemblyDirectory())
6390+
dllImportSearchPathFlags |= DLLIMPORTSEARCHPATH_ASSEMBLYDIRECTORY;
6391+
}
6392+
6393+
GCX_COOP();
6394+
6395+
struct {
6396+
STRINGREF libNameRef;
6397+
OBJECTREF assemblyRef;
6398+
} protect;
6399+
6400+
6401+
Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly();
6402+
protect.libNameRef = StringObject::NewString(wszLibName);
6403+
protect.assemblyRef = pAssembly->GetExposedObject();
6404+
6405+
NATIVE_LIBRARY_HANDLE handle = NULL;
6406+
6407+
GCPROTECT_BEGIN(protect);
6408+
6409+
PREPARE_NONVIRTUAL_CALLSITE(METHOD__MARSHAL__LOADLIBRARYCALLBACKSTUB);
6410+
DECLARE_ARGHOLDER_ARRAY(args, 4);
6411+
args[ARGNUM_0] = STRINGREF_TO_ARGHOLDER(protect.libNameRef);
6412+
args[ARGNUM_1] = OBJECTREF_TO_ARGHOLDER(protect.assemblyRef);
6413+
args[ARGNUM_2] = BOOL_TO_ARGHOLDER(hasDllImportSearchPathFlags);
6414+
args[ARGNUM_3] = DWORD_TO_ARGHOLDER(dllImportSearchPathFlags);
6415+
6416+
// Make the call
6417+
CALL_MANAGED_METHOD(handle, NATIVE_LIBRARY_HANDLE, args);
6418+
GCPROTECT_END();
6419+
6420+
return handle;
6421+
}
6422+
63656423
// Try to load the module alongside the assembly where the PInvoke was declared.
63666424
NATIVE_LIBRARY_HANDLE NDirect::LoadFromPInvokeAssemblyDirectory(Assembly *pAssembly, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker)
63676425
{
@@ -6385,11 +6443,12 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadFromPInvokeAssemblyDirectory(Assembly *pAssem
63856443
}
63866444

63876445
// Try to load the module from the native DLL search directories
6388-
NATIVE_LIBRARY_HANDLE NDirect::LoadFromNativeDllSearchDirectories(AppDomain* pDomain, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker)
6446+
NATIVE_LIBRARY_HANDLE NDirect::LoadFromNativeDllSearchDirectories(LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker)
63896447
{
63906448
STANDARD_VM_CONTRACT;
63916449

63926450
NATIVE_LIBRARY_HANDLE hmod = NULL;
6451+
AppDomain* pDomain = GetAppDomain();
63936452

63946453
if (pDomain->HasNativeDllSearchDirectories())
63956454
{
@@ -6511,7 +6570,7 @@ static void DetermineLibNameVariations(const WCHAR** libNameVariations, int* num
65116570
// Search for the library and variants of its name in probing directories.
65126571
//static
65136572
NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(Assembly *callingAssembly,
6514-
BOOL searchAssemblyDirectory, DWORD dllImportSearchPathFlag,
6573+
BOOL searchAssemblyDirectory, DWORD dllImportSearchPathFlags,
65156574
LoadLibErrorTracker * pErrorTracker, LPCWSTR wszLibName)
65166575
{
65176576
STANDARD_VM_CONTRACT;
@@ -6521,7 +6580,7 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(Assembly *callingAssemb
65216580
#if defined(FEATURE_CORESYSTEM) && !defined(PLATFORM_UNIX)
65226581
// Try to go straight to System32 for Windows API sets. This is replicating quick check from
65236582
// the OS implementation of api sets.
6524-
if (SString::_wcsnicmp(wszLibName, W("api-"), 4) == 0 || SString::_wcsnicmp(wszLibName, W("ext-"), 4) == 0)
6583+
if (IsWindowsAPI(wszLibName))
65256584
{
65266585
hmod = LocalLoadLibraryHelper(wszLibName, LOAD_LIBRARY_SEARCH_SYSTEM32, pErrorTracker);
65276586
if (hmod != NULL)
@@ -6549,7 +6608,7 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(Assembly *callingAssemb
65496608
currLibNameVariation.Printf(prefixSuffixCombinations[i], PLATFORM_SHARED_LIB_PREFIX_W, wszLibName, PLATFORM_SHARED_LIB_SUFFIX_W);
65506609

65516610
// NATIVE_DLL_SEARCH_DIRECTORIES set by host is considered well known path
6552-
hmod = LoadFromNativeDllSearchDirectories(pDomain, currLibNameVariation, loadWithAlteredPathFlags, pErrorTracker);
6611+
hmod = LoadFromNativeDllSearchDirectories(currLibNameVariation, loadWithAlteredPathFlags, pErrorTracker);
65536612
if (hmod != NULL)
65546613
{
65556614
return hmod;
@@ -6558,11 +6617,11 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(Assembly *callingAssemb
65586617
if (!libNameIsRelativePath)
65596618
{
65606619
DWORD flags = loadWithAlteredPathFlags;
6561-
if ((dllImportSearchPathFlag & LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) != 0)
6620+
if ((dllImportSearchPathFlags & LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) != 0)
65626621
{
65636622
// LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR is the only flag affecting absolute path. Don't OR the flags
65646623
// unconditionally as all absolute path P/Invokes could then lose LOAD_WITH_ALTERED_SEARCH_PATH.
6565-
flags |= dllImportSearchPathFlag;
6624+
flags |= dllImportSearchPathFlags;
65666625
}
65676626

65686627
hmod = LocalLoadLibraryHelper(currLibNameVariation, flags, pErrorTracker);
@@ -6573,14 +6632,14 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(Assembly *callingAssemb
65736632
}
65746633
else if ((callingAssembly != nullptr) && searchAssemblyDirectory)
65756634
{
6576-
hmod = LoadFromPInvokeAssemblyDirectory(callingAssembly, currLibNameVariation, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker);
6635+
hmod = LoadFromPInvokeAssemblyDirectory(callingAssembly, currLibNameVariation, loadWithAlteredPathFlags | dllImportSearchPathFlags, pErrorTracker);
65776636
if (hmod != NULL)
65786637
{
65796638
return hmod;
65806639
}
65816640
}
65826641

6583-
hmod = LocalLoadLibraryHelper(currLibNameVariation, dllImportSearchPathFlag, pErrorTracker);
6642+
hmod = LocalLoadLibraryHelper(currLibNameVariation, dllImportSearchPathFlags, pErrorTracker);
65846643
if (hmod != NULL)
65856644
{
65866645
return hmod;
@@ -6610,7 +6669,7 @@ NATIVE_LIBRARY_HANDLE NDirect::LoadLibraryModuleBySearch(Assembly *callingAssemb
66106669
Assembly *pAssembly = spec.LoadAssembly(FILE_LOADED);
66116670
Module *pModule = pAssembly->FindModuleByName(szLibName);
66126671

6613-
hmod = LocalLoadLibraryHelper(pModule->GetPath(), loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker);
6672+
hmod = LocalLoadLibraryHelper(pModule->GetPath(), loadWithAlteredPathFlags | dllImportSearchPathFlags, pErrorTracker);
66146673
}
66156674
}
66166675

@@ -6631,19 +6690,28 @@ HINSTANCE NDirect::LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracke
66316690
if ( !name || !*name )
66326691
return NULL;
66336692

6634-
ModuleHandleHolder hmod;
66356693

66366694
PREFIX_ASSUME( name != NULL );
66376695
MAKE_WIDEPTR_FROMUTF8( wszLibName, name );
66386696

6697+
ModuleHandleHolder hmod = LoadLibraryModuleViaCallBack(pMD, wszLibName);
6698+
if (hmod != NULL)
6699+
{
6700+
#ifdef FEATURE_PAL
6701+
// Register the system library handle with PAL and get a PAL library handle
6702+
hmod = PAL_RegisterLibraryDirect(hmod, wszLibName);
6703+
#endif // FEATURE_PAL
6704+
return hmod.Extract();
6705+
}
6706+
66396707
AppDomain* pDomain = GetAppDomain();
66406708

66416709
// AssemblyLoadContext is not supported in AppX mode and thus,
66426710
// we should not perform PInvoke resolution via it when operating in
66436711
// AppX mode.
66446712
if (!AppX::IsAppXProcess())
66456713
{
6646-
hmod = LoadLibraryModuleViaHost(pMD, pDomain, wszLibName);
6714+
hmod = LoadLibraryModuleViaHost(pMD, wszLibName);
66476715
if (hmod != NULL)
66486716
{
66496717
#ifdef FEATURE_PAL

0 commit comments

Comments
 (0)