From 7728e34e48a4fdb710ecc92dd8dca833bff3993f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 2 Sep 2022 16:12:26 -0500 Subject: Use elevated engine to make the restart request when it is available. Fixes 6145 --- src/burn/engine/core.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/burn/engine/core.cpp') diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 3c1ed117..c8dce17b 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -2028,6 +2028,48 @@ extern "C" HRESULT DAPI CoreWaitForProcCompletion( return vpfnProcWaitForCompletion(hProcess, dwTimeout, pdwReturnCode); } +extern "C" HRESULT DAPI CoreCloseElevatedLoggingThread( + __in BURN_ENGINE_STATE* pEngineState + ) +{ + HRESULT hr = S_OK; + + if (INVALID_HANDLE_VALUE == pEngineState->elevatedLoggingContext.hThread) + { + ExitFunction(); + } + + if (!::SetEvent(pEngineState->elevatedLoggingContext.hFinishedEvent)) + { + ExitWithLastError(hr, "Failed to set log finished event."); + } + + hr = AppWaitForSingleObject(pEngineState->elevatedLoggingContext.hThread, 5 * 60 * 1000); // TODO: is 5 minutes good? + ExitOnFailure(hr, "Failed to wait for elevated logging thread."); + +LExit: + return hr; +} + +extern "C" HRESULT DAPI CoreWaitForUnelevatedLoggingThread( + __in HANDLE hUnelevatedLoggingThread + ) +{ + HRESULT hr = S_OK; + + if (INVALID_HANDLE_VALUE == hUnelevatedLoggingThread) + { + ExitFunction(); + } + + // Give the thread 15 seconds to exit. + hr = AppWaitForSingleObject(hUnelevatedLoggingThread, 15 * 1000); + ExitOnFailure(hr, "Failed to wait for unelevated logging thread."); + +LExit: + return hr; +} + // internal helper functions static HRESULT AppendEscapedArgumentToCommandLine( -- cgit v1.2.3-55-g6feb