diff options
Diffstat (limited to 'chromium/base/process/launch_win.cc')
-rw-r--r-- | chromium/base/process/launch_win.cc | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/chromium/base/process/launch_win.cc b/chromium/base/process/launch_win.cc index 0c831cf7b4a..9e4db384ebb 100644 --- a/chromium/base/process/launch_win.cc +++ b/chromium/base/process/launch_win.cc @@ -6,6 +6,7 @@ #include <fcntl.h> #include <io.h> +#include <shellapi.h> #include <windows.h> #include <userenv.h> #include <psapi.h> @@ -22,6 +23,7 @@ #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/process/kill.h" +#include "base/strings/utf_string_conversions.h" #include "base/sys_info.h" #include "base/win/object_watcher.h" #include "base/win/scoped_handle.h" @@ -192,7 +194,8 @@ bool LaunchProcess(const string16& cmdline, &temp_process_info); DestroyEnvironmentBlock(enviroment_block); if (!launched) { - DPLOG(ERROR); + DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) + << std::endl;; return false; } } else { @@ -200,7 +203,8 @@ bool LaunchProcess(const string16& cmdline, const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL, inherit_handles, flags, NULL, NULL, startup_info, &temp_process_info)) { - DPLOG(ERROR); + DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) + << std::endl;; return false; } } @@ -239,6 +243,41 @@ bool LaunchProcess(const CommandLine& cmdline, return rv; } +bool LaunchElevatedProcess(const CommandLine& cmdline, + const LaunchOptions& options, + ProcessHandle* process_handle) { + const string16 file = cmdline.GetProgram().value(); + const string16 arguments = cmdline.GetArgumentsString(); + + SHELLEXECUTEINFO shex_info = {0}; + shex_info.cbSize = sizeof(shex_info); + shex_info.fMask = SEE_MASK_NOCLOSEPROCESS; + shex_info.hwnd = GetActiveWindow(); + shex_info.lpVerb = L"runas"; + shex_info.lpFile = file.c_str(); + shex_info.lpParameters = arguments.c_str(); + shex_info.lpDirectory = NULL; + shex_info.nShow = options.start_hidden ? SW_HIDE : SW_SHOW; + shex_info.hInstApp = NULL; + + if (!ShellExecuteEx(&shex_info)) { + DPLOG(ERROR); + return false; + } + + if (options.wait) + WaitForSingleObject(shex_info.hProcess, INFINITE); + + // If the caller wants the process handle give it to them, otherwise just + // close it. Closing it does not terminate the process. + if (process_handle) + *process_handle = shex_info.hProcess; + else + CloseHandle(shex_info.hProcess); + + return true; +} + bool SetJobObjectLimitFlags(HANDLE job_object, DWORD limit_flags) { JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info = {0}; limit_info.BasicLimitInformation.LimitFlags = limit_flags; |