summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGaurav Khanna <gkhanna@microsoft.com>2015-02-07 09:15:45 -0800
committerGaurav Khanna <gkhanna@microsoft.com>2015-02-07 09:15:45 -0800
commit0b58e4ea50b657e7c204ffa3f5f82cfe30426ba6 (patch)
treed9b3eee6435a49dca63affd40a6fc2deef24e627 /src
parent1947a5c318f362e042550cd548b774761546c4db (diff)
parente1579b610d91441f22454c5657d2f01da8c395b7 (diff)
downloadcoreclr-0b58e4ea50b657e7c204ffa3f5f82cfe30426ba6.tar.gz
coreclr-0b58e4ea50b657e7c204ffa3f5f82cfe30426ba6.tar.bz2
coreclr-0b58e4ea50b657e7c204ffa3f5f82cfe30426ba6.zip
Merge pull request #108 from jkotas/master
Fix Windows x64 corerun.exe to run anycpu 32-bit preferred exe
Diffstat (limited to 'src')
-rw-r--r--src/coreclr/hosts/coreconsole/coreconsole.cpp19
-rw-r--r--src/coreclr/hosts/corerun/corerun.cpp23
2 files changed, 12 insertions, 30 deletions
diff --git a/src/coreclr/hosts/coreconsole/coreconsole.cpp b/src/coreclr/hosts/coreconsole/coreconsole.cpp
index 0b6a912c5f..eeb3e04c88 100644
--- a/src/coreclr/hosts/coreconsole/coreconsole.cpp
+++ b/src/coreclr/hosts/coreconsole/coreconsole.cpp
@@ -372,27 +372,20 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
wchar_t appNiPath[MAX_PATH * 2] = W("");
wchar_t managedAssemblyFullName[MAX_PATH] = W("");
- HMODULE managedExeModule = nullptr;
-
- // Have the OS loader discover the location of the managed exe
- managedExeModule = ::LoadLibraryExW(programPath, NULL, 0);
+ wchar_t* filePart = NULL;
- if (!managedExeModule) {
- log << W("Failed to load: ") << programPath << Logger::endl;
+ if (!::GetFullPathName(programPath, MAX_PATH, appPath, &filePart)) {
+ log << W("Failed to get full path: ") << programPath << Logger::endl;
log << W("Error code: ") << GetLastError() << Logger::endl;
return false;
}
- // If the module was successfully loaded, get the path to where it was found.
- ::GetModuleFileNameW(managedExeModule, managedAssemblyFullName, MAX_PATH);
-
- log << W("Loaded: ") << managedAssemblyFullName << Logger::endl;
+ wcscpy_s(managedAssemblyFullName, appPath);
- wchar_t* filePart = NULL;
-
- ::GetFullPathName(managedAssemblyFullName, MAX_PATH, appPath, &filePart);
*(filePart) = W('\0');
+ log << W("Loading: ") << managedAssemblyFullName << Logger::endl;
+
wcscpy_s(appNiPath, appPath);
wcscat_s(appNiPath, MAX_PATH * 2, W(";"));
wcscat_s(appNiPath, MAX_PATH * 2, appPath);
diff --git a/src/coreclr/hosts/corerun/corerun.cpp b/src/coreclr/hosts/corerun/corerun.cpp
index 42f2773b41..cfae1b1b73 100644
--- a/src/coreclr/hosts/corerun/corerun.cpp
+++ b/src/coreclr/hosts/corerun/corerun.cpp
@@ -399,31 +399,20 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
wchar_t appNiPath[MAX_PATH * 2] = W("");
wchar_t managedAssemblyFullName[MAX_PATH] = W("");
wchar_t appLocalWinmetadata[MAX_PATH] = W("");
-
- HMODULE managedExeModule = nullptr;
-
- wchar_t fullExePath[MAX_PATH];
- ::GetFullPathName(exeName, MAX_PATH, fullExePath, NULL); // Bizarrely, loading a relative path is failing on Phone OS
-
- // Have the OS loader discover the location of the managed exe
- managedExeModule = ::LoadLibraryExW(fullExePath, NULL, 0);
- if (!managedExeModule) {
- log << W("Failed to load: ") << fullExePath << Logger::endl;
+ wchar_t* filePart = NULL;
+
+ if (!::GetFullPathName(exeName, MAX_PATH, appPath, &filePart)) {
+ log << W("Failed to get full path: ") << exeName << Logger::endl;
log << W("Error code: ") << GetLastError() << Logger::endl;
return false;
}
- // If the module was successfully loaded, get the path to where it was found.
- ::GetModuleFileNameW(managedExeModule, managedAssemblyFullName, MAX_PATH);
-
- log << W("Loaded: ") << managedAssemblyFullName << Logger::endl;
+ wcscpy_s(managedAssemblyFullName, appPath);
- wchar_t* filePart = NULL;
-
- ::GetFullPathName(managedAssemblyFullName, MAX_PATH, appPath, &filePart);
*(filePart) = W('\0');
+ log << W("Loading: ") << managedAssemblyFullName << Logger::endl;
wcscpy_s(appLocalWinmetadata, appPath);
wcscat(appLocalWinmetadata, W("\\WinMetadata"));