diff options
Diffstat (limited to 'src/burn/engine/pipe.cpp')
| -rw-r--r-- | src/burn/engine/pipe.cpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/burn/engine/pipe.cpp b/src/burn/engine/pipe.cpp index a9fd24e8..48be8785 100644 --- a/src/burn/engine/pipe.cpp +++ b/src/burn/engine/pipe.cpp | |||
| @@ -314,108 +314,6 @@ LExit: | |||
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | /******************************************************************* | 316 | /******************************************************************* |
| 317 | PipeLaunchParentProcess - Called from the per-machine process to create | ||
| 318 | a per-user process and set up the | ||
| 319 | communication pipe. | ||
| 320 | |||
| 321 | *******************************************************************/ | ||
| 322 | const LPCWSTR BURN_COMMANDLINE_SWITCH_UNELEVATED = L"burn.unelevated"; | ||
| 323 | HRESULT PipeLaunchParentProcess( | ||
| 324 | __in_z LPCWSTR wzCommandLine, | ||
| 325 | __in int nCmdShow, | ||
| 326 | __in_z LPWSTR sczConnectionName, | ||
| 327 | __in_z LPWSTR sczSecret, | ||
| 328 | __in BOOL /*fDisableUnelevate*/ | ||
| 329 | ) | ||
| 330 | { | ||
| 331 | HRESULT hr = S_OK; | ||
| 332 | DWORD dwProcessId = 0; | ||
| 333 | LPWSTR sczBurnPath = NULL; | ||
| 334 | LPWSTR sczParameters = NULL; | ||
| 335 | HANDLE hProcess = NULL; | ||
| 336 | |||
| 337 | dwProcessId = ::GetCurrentProcessId(); | ||
| 338 | |||
| 339 | hr = PathForCurrentProcess(&sczBurnPath, NULL); | ||
| 340 | ExitOnFailure(hr, "Failed to get current process path."); | ||
| 341 | |||
| 342 | hr = StrAllocFormatted(&sczParameters, L"-%ls %ls %ls %u %ls", BURN_COMMANDLINE_SWITCH_UNELEVATED, sczConnectionName, sczSecret, dwProcessId, wzCommandLine); | ||
| 343 | ExitOnFailure(hr, "Failed to allocate parameters for unelevated process."); | ||
| 344 | |||
| 345 | #ifdef ENABLE_UNELEVATE | ||
| 346 | if (fDisableUnelevate) | ||
| 347 | { | ||
| 348 | hr = ProcExec(sczBurnPath, sczParameters, nCmdShow, &hProcess); | ||
| 349 | ExitOnFailure(hr, "Failed to launch parent process with unelevate disabled: %ls", sczBurnPath); | ||
| 350 | } | ||
| 351 | else | ||
| 352 | { | ||
| 353 | // Try to launch unelevated and if that fails for any reason, try launch our process normally (even though that may make it elevated). | ||
| 354 | hr = ProcExecuteAsInteractiveUser(sczBurnPath, sczParameters, &hProcess); | ||
| 355 | if (FAILED(hr)) | ||
| 356 | { | ||
| 357 | hr = ShelExecUnelevated(sczBurnPath, sczParameters, L"open", NULL, nCmdShow); | ||
| 358 | if (FAILED(hr)) | ||
| 359 | { | ||
| 360 | hr = ShelExec(sczBurnPath, sczParameters, L"open", NULL, nCmdShow, NULL, NULL); | ||
| 361 | ExitOnFailure(hr, "Failed to launch parent process: %ls", sczBurnPath); | ||
| 362 | } | ||
| 363 | } | ||
| 364 | } | ||
| 365 | #else | ||
| 366 | hr = ProcExec(sczBurnPath, sczParameters, nCmdShow, &hProcess); | ||
| 367 | ExitOnFailure(hr, "Failed to launch parent process with unelevate disabled: %ls", sczBurnPath); | ||
| 368 | #endif | ||
| 369 | |||
| 370 | LExit: | ||
| 371 | ReleaseHandle(hProcess); | ||
| 372 | ReleaseStr(sczParameters); | ||
| 373 | ReleaseStr(sczBurnPath); | ||
| 374 | |||
| 375 | return hr; | ||
| 376 | } | ||
| 377 | |||
| 378 | /******************************************************************* | ||
| 379 | PipeLaunchChildProcess - Called from the per-user process to create | ||
| 380 | the per-machine process and set up the | ||
| 381 | communication pipe. | ||
| 382 | |||
| 383 | *******************************************************************/ | ||
| 384 | extern "C" HRESULT PipeLaunchChildProcess( | ||
| 385 | __in_z LPCWSTR wzExecutablePath, | ||
| 386 | __in BURN_PIPE_CONNECTION* pConnection, | ||
| 387 | __in BOOL fElevate, | ||
| 388 | __in_opt HWND hwndParent | ||
| 389 | ) | ||
| 390 | { | ||
| 391 | HRESULT hr = S_OK; | ||
| 392 | DWORD dwCurrentProcessId = ::GetCurrentProcessId(); | ||
| 393 | LPWSTR sczParameters = NULL; | ||
| 394 | LPCWSTR wzVerb = NULL; | ||
| 395 | HANDLE hProcess = NULL; | ||
| 396 | |||
| 397 | hr = StrAllocFormatted(&sczParameters, L"-q -%ls %ls %ls %u", BURN_COMMANDLINE_SWITCH_ELEVATED, pConnection->sczName, pConnection->sczSecret, dwCurrentProcessId); | ||
| 398 | ExitOnFailure(hr, "Failed to allocate parameters for elevated process."); | ||
| 399 | |||
| 400 | wzVerb = !fElevate ? L"open" : L"runas"; | ||
| 401 | |||
| 402 | // Since ShellExecuteEx doesn't support passing inherited handles, don't bother with CoreAppendFileHandleSelfToCommandLine. | ||
| 403 | // We could fallback to using ::DuplicateHandle to inject the file handle later if necessary. | ||
| 404 | hr = ShelExec(wzExecutablePath, sczParameters, wzVerb, NULL, SW_SHOWNA, hwndParent, &hProcess); | ||
| 405 | ExitOnFailure(hr, "Failed to launch elevated child process: %ls", wzExecutablePath); | ||
| 406 | |||
| 407 | pConnection->dwProcessId = ::GetProcessId(hProcess); | ||
| 408 | pConnection->hProcess = hProcess; | ||
| 409 | hProcess = NULL; | ||
| 410 | |||
| 411 | LExit: | ||
| 412 | ReleaseHandle(hProcess); | ||
| 413 | ReleaseStr(sczParameters); | ||
| 414 | |||
| 415 | return hr; | ||
| 416 | } | ||
| 417 | |||
| 418 | /******************************************************************* | ||
| 419 | PipeWaitForChildConnect - | 317 | PipeWaitForChildConnect - |
| 420 | 318 | ||
| 421 | *******************************************************************/ | 319 | *******************************************************************/ |
