diff options
author | Rama Krishnan Raghupathy <ramarag@microsoft.com> | 2015-10-22 16:19:25 -0700 |
---|---|---|
committer | Rama Krishnan Raghupathy <ramarag@microsoft.com> | 2015-10-22 16:19:25 -0700 |
commit | efde18cf37f75966ca1d27b6b5e3f5fc850b4fd5 (patch) | |
tree | 59ecec56db889b98c20fabee8660172ad8ce4211 /src/vm/dllimport.cpp | |
parent | d12f402bf8a7bf16c5665f21295580e05d77c23f (diff) | |
download | coreclr-efde18cf37f75966ca1d27b6b5e3f5fc850b4fd5.tar.gz coreclr-efde18cf37f75966ca1d27b6b5e3f5fc850b4fd5.tar.bz2 coreclr-efde18cf37f75966ca1d27b6b5e3f5fc850b4fd5.zip |
[adityam] Fix break in DllImport code for Desktop CLR.
[tfs-changeset: 1540922]
Diffstat (limited to 'src/vm/dllimport.cpp')
-rw-r--r-- | src/vm/dllimport.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/vm/dllimport.cpp b/src/vm/dllimport.cpp index 17ff7d5970..038b62e36f 100644 --- a/src/vm/dllimport.cpp +++ b/src/vm/dllimport.cpp @@ -6879,13 +6879,12 @@ HMODULE NDirect::LoadLibraryModuleViaHost(NDirectMethodDesc * pMD, AppDomain* pD #endif //defined(FEATURE_HOST_ASSEMBLY_RESOLVER) // Try to load the module alongside the assembly where the PInvoke was declared. -HMODULE NDirect::LoadFromPInvokeAssemblyDirectory(NDirectMethodDesc *pMD, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker) +HMODULE NDirect::LoadFromPInvokeAssemblyDirectory(Assembly *pAssembly, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker) { STANDARD_VM_CONTRACT; HMODULE hmod = NULL; - Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly(); SString path = pAssembly->GetManifestFile()->GetPath(); SString::Iterator lastPathSeparatorIter = path.End(); @@ -6901,6 +6900,7 @@ HMODULE NDirect::LoadFromPInvokeAssemblyDirectory(NDirectMethodDesc *pMD, LPCWST return hmod; } +#ifdef FEATURE_CORECLR // Try to load the module from the native DLL search directories HMODULE NDirect::LoadFromNativeDllSearchDirectories(AppDomain* pDomain, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker) { @@ -6924,6 +6924,7 @@ HMODULE NDirect::LoadFromNativeDllSearchDirectories(AppDomain* pDomain, LPCWSTR return hmod; } +#endif // FEATURE_CORECLR HINSTANCE NDirect::LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracker * pErrorTracker) { @@ -7100,7 +7101,8 @@ HINSTANCE NDirect::LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracke } else if (searchAssemblyDirectory) { - hmod = LoadFromPInvokeAssemblyDirectory(pMD, wszLibName, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker); + Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly(); + hmod = LoadFromPInvokeAssemblyDirectory(pAssembly, wszLibName, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker); #ifndef FEATURE_CORECLR if (hmod == NULL) @@ -7148,6 +7150,15 @@ HINSTANCE NDirect::LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracke pathFromCodebase.Append(wszLibName); + SString path = pAssembly->GetManifestFile()->GetPath(); + SString::Iterator i = path.End(); + if (PEAssembly::FindLastPathSeparator(path, i)) + { + i++; + path.Truncate(i); + path.Append(wszLibName); + } + if (!pathFromCodebase.EqualsCaseInsensitive(path, PEImage::GetFileSystemLocale())) { hmod = LocalLoadLibraryHelper(pathFromCodebase, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker); @@ -7227,7 +7238,8 @@ HINSTANCE NDirect::LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracke if (libNameIsRelativePath && searchAssemblyDirectory) { - hmod = LoadFromPInvokeAssemblyDirectory(pMD, currLibNameVariation, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker); + Assembly *pAssembly = pMD->GetMethodTable()->GetAssembly(); + hmod = LoadFromPInvokeAssemblyDirectory(pAssembly, currLibNameVariation, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker); if (hmod != NULL) break; } |