static HRESULT RunEmbedded( __in HINSTANCE hInstance, __in BURN_ENGINE_STATE* pEngineState ) { HRESULT hr = S_OK; // Disable system restore since the parent bundle may have done it. pEngineState->fDisableSystemRestore = TRUE; // Connect to parent process. hr = PipeChildConnect(&pEngineState->embeddedConnection, FALSE); ExitOnFailure(hr, "Failed to connect to parent of embedded process."); // Do not register the bundle to automatically restart if embedded. if (BOOTSTRAPPER_DISPLAY_EMBEDDED == pEngineState->command.display) { pEngineState->registration.fDisableResume = TRUE; } // Now run the application like normal. hr = RunNormal(hInstance, pEngineState); ExitOnFailure(hr, "Failed to run bootstrapper application embedded."); LExit: return hr; }
static HRESULT RunEmbedded( __in HINSTANCE hInstance, __in BURN_ENGINE_STATE* pEngineState ) { HRESULT hr = S_OK; // Connect to parent process. hr = PipeChildConnect(&pEngineState->embeddedConnection, FALSE); ExitOnFailure(hr, "Failed to connect to parent of embedded process."); // Now run the application like normal. hr = RunNormal(hInstance, pEngineState); ExitOnFailure(hr, "Failed to run bootstrapper application embedded."); LExit: return hr; }
static HRESULT RunElevated( __in HINSTANCE hInstance, __in LPCWSTR wzCommandLine, __in BURN_ENGINE_STATE* pEngineState ) { HRESULT hr = S_OK; HANDLE hLock = NULL; BOOL fDisabledAutomaticUpdates = FALSE; // If we were launched elevated implicitly, launch an unelevated copy of ourselves. if (BURN_ELEVATION_STATE_ELEVATED == pEngineState->elevationState) { Assert(!pEngineState->companionConnection.dwProcessId); Assert(!pEngineState->companionConnection.sczName); Assert(!pEngineState->companionConnection.sczSecret); hr = PipeCreateNameAndSecret(&pEngineState->companionConnection.sczName, &pEngineState->companionConnection.sczSecret); ExitOnFailure(hr, "Failed to create implicit elevated connection name and secret."); hr = PipeLaunchParentProcess(wzCommandLine, pEngineState->command.nCmdShow, pEngineState->companionConnection.sczName, pEngineState->companionConnection.sczSecret, pEngineState->fDisableUnelevate); ExitOnFailure(hr, "Failed to launch unelevated process."); } // connect to per-user process hr = PipeChildConnect(&pEngineState->companionConnection, TRUE); ExitOnFailure(hr, "Failed to connect to unelevated process."); // Set up the thread local storage to store the correct pipe to communicate logging. pEngineState->dwElevatedLoggingTlsId = ::TlsAlloc(); if (TLS_OUT_OF_INDEXES == pEngineState->dwElevatedLoggingTlsId) { ExitWithLastError(hr, "Failed to allocate thread local storage for logging."); } if (!::TlsSetValue(pEngineState->dwElevatedLoggingTlsId, pEngineState->companionConnection.hPipe)) { ExitWithLastError(hr, "Failed to set elevated pipe into thread local storage for logging."); } // Create a top-level window to prevent shutting down the elevated process. hr = UiCreateMessageWindow(hInstance, pEngineState); ExitOnFailure(hr, "Failed to create the message window."); SrpInitialize(TRUE); // Override logging to write over the pipe. LogRedirect(RedirectLoggingOverPipe, pEngineState); // Pump messages from parent process. hr = ElevationChildPumpMessages(pEngineState->dwElevatedLoggingTlsId, pEngineState->companionConnection.hPipe, pEngineState->companionConnection.hCachePipe, &pEngineState->containers, &pEngineState->packages, &pEngineState->payloads, &pEngineState->variables, &pEngineState->registration, &pEngineState->userExperience, &hLock, &fDisabledAutomaticUpdates, &pEngineState->userExperience.dwExitCode, &pEngineState->fRestart); LogRedirect(NULL, NULL); // reset logging so the next failure gets written to "log buffer" for the failure log. ExitOnFailure(hr, "Failed to pump messages from parent process."); LExit: LogRedirect(NULL, NULL); // we're done talking to the child so always reset logging now. // If the message window is still around, close it. UiCloseMessageWindow(pEngineState); if (fDisabledAutomaticUpdates) { ElevationChildResumeAutomaticUpdates(); } if (hLock) { ::ReleaseMutex(hLock); ::CloseHandle(hLock); } return hr; }