Resume automatic updates as part of ApplyUninitialize.
Fixes first half of 6870
Sean Hall committed
Aug 19, 2022 at 13:47 UTC
1c4dc6b1cd2aa3ecd05fdb22f9889ed87e61cc68
3 files changed
+20
-13
src/burn/engine/elevation.cpp
+19
-5
@@ -189,7 +189,8 @@ static HRESULT ElevatedProcessDetect(
189
);
190
static HRESULT OnApplyUninitialize(
191
__in HANDLE* phLock,
192
- __in BOOL* pfApplying
192
+ __in BOOL* pfApplying,
193
+ __in BOOL* pfDisabledAutomaticUpdates
194
);
195
static HRESULT OnSessionBegin(
196
__in BURN_CACHE* pCache,
@@ -1543,7 +1544,6 @@ extern "C" HRESULT ElevationChildPumpMessages(
1544
__in BURN_REGISTRATION* pRegistration,
1545
__in BURN_USER_EXPERIENCE* pUserExperience,
1546
__out HANDLE* phLock,
1546
- __out BOOL* pfDisabledAutomaticUpdates,
1547
__out DWORD* pdwChildExitCode,
1548
__out BOOL* pfRestart,
1549
__out BOOL* pfApplying
@@ -1554,6 +1554,7 @@ extern "C" HRESULT ElevationChildPumpMessages(
1554
BURN_ELEVATION_CHILD_MESSAGE_CONTEXT context = { };
1555
HANDLE hCacheThread = NULL;
1556
BURN_PIPE_RESULT result = { };
1557
+ BOOL fDisabledAutomaticUpdates = FALSE;
1558
1559
cacheContext.dwLoggingTlsId = dwLoggingTlsId;
1560
cacheContext.hPipe = hCachePipe;
@@ -1568,7 +1569,7 @@ extern "C" HRESULT ElevationChildPumpMessages(
1569
context.dwLoggingTlsId = dwLoggingTlsId;
1570
context.hPipe = hPipe;
1571
context.phLock = phLock;
1571
- context.pfDisabledAutomaticUpdates = pfDisabledAutomaticUpdates;
1572
+ context.pfDisabledAutomaticUpdates = &fDisabledAutomaticUpdates;
1573
context.pfApplying = pfApplying;
1574
context.pApprovedExes = pApprovedExes;
1575
context.pCache = pCache;
@@ -1595,6 +1596,11 @@ extern "C" HRESULT ElevationChildPumpMessages(
1596
LExit:
1597
ReleaseHandle(hCacheThread);
1598
1599
+ if (fDisabledAutomaticUpdates)
1600
+ {
1601
+ ElevationChildResumeAutomaticUpdates();
1602
+ }
1603
+
1604
return hr;
1605
}
1606
@@ -2128,7 +2134,7 @@ static HRESULT ProcessElevatedChildMessage(
2134
break;
2135
2136
case BURN_ELEVATION_MESSAGE_TYPE_APPLY_UNINITIALIZE:
2131
- hrResult = OnApplyUninitialize(pContext->phLock, pContext->pfApplying);
2137
+ hrResult = OnApplyUninitialize(pContext->phLock, pContext->pfApplying, pContext->pfDisabledAutomaticUpdates);
2138
break;
2139
2140
case BURN_ELEVATION_MESSAGE_TYPE_SESSION_BEGIN:
@@ -2433,7 +2439,8 @@ LExit:
2439
2440
static HRESULT OnApplyUninitialize(
2441
__in HANDLE* phLock,
2436
- __in BOOL* pfApplying
2442
+ __in BOOL* pfApplying,
2443
+ __in BOOL* pfDisabledAutomaticUpdates
2444
)
2445
{
2446
Assert(phLock);
@@ -2442,6 +2449,13 @@ static HRESULT OnApplyUninitialize(
2449
2450
*pfApplying = FALSE;
2451
2452
+ if (*pfDisabledAutomaticUpdates)
2453
+ {
2454
+ *pfDisabledAutomaticUpdates = FALSE;
2455
+
2456
+ ElevationChildResumeAutomaticUpdates();
2457
+ }
2458
+
2459
if (*phLock)
2460
{
2461
::ReleaseMutex(*phLock);
src/burn/engine/elevation.h
-1
@@ -178,7 +178,6 @@ HRESULT ElevationChildPumpMessages(
178
__in BURN_REGISTRATION* pRegistration,
179
__in BURN_USER_EXPERIENCE* pUserExperience,
180
__out HANDLE* phLock,
181
- __out BOOL* pfDisabledAutomaticUpdates,
181
__out DWORD* pdwChildExitCode,
182
__out BOOL* pfRestart,
183
__out BOOL* pfApplying
src/burn/engine/engine.cpp
+1
-7
@@ -638,7 +638,6 @@ static HRESULT RunElevated(
638
{
639
HRESULT hr = S_OK;
640
HANDLE hLock = NULL;
641
- BOOL fDisabledAutomaticUpdates = FALSE;
641
642
// connect to per-user process
643
hr = PipeChildConnect(&pEngineState->companionConnection, TRUE);
@@ -666,7 +665,7 @@ static HRESULT RunElevated(
665
SrpInitialize(TRUE);
666
667
// Pump messages from parent process.
669
- hr = ElevationChildPumpMessages(pEngineState->dwElevatedLoggingTlsId, pEngineState->companionConnection.hPipe, pEngineState->companionConnection.hCachePipe, &pEngineState->approvedExes, &pEngineState->cache, &pEngineState->containers, &pEngineState->packages, &pEngineState->payloads, &pEngineState->variables, &pEngineState->registration, &pEngineState->userExperience, &hLock, &fDisabledAutomaticUpdates, &pEngineState->userExperience.dwExitCode, &pEngineState->fRestart, &pEngineState->plan.fApplying);
668
+ hr = ElevationChildPumpMessages(pEngineState->dwElevatedLoggingTlsId, pEngineState->companionConnection.hPipe, pEngineState->companionConnection.hCachePipe, &pEngineState->approvedExes, &pEngineState->cache, &pEngineState->containers, &pEngineState->packages, &pEngineState->payloads, &pEngineState->variables, &pEngineState->registration, &pEngineState->userExperience, &hLock, &pEngineState->userExperience.dwExitCode, &pEngineState->fRestart, &pEngineState->plan.fApplying);
669
LogRedirect(NULL, NULL); // reset logging so the next failure gets written to "log buffer" for the failure log.
670
ExitOnFailure(hr, "Failed to pump messages from parent process.");
671
@@ -676,11 +675,6 @@ LExit:
675
// If the message window is still around, close it.
676
UiCloseMessageWindow(pEngineState);
677
679
- if (fDisabledAutomaticUpdates)
680
- {
681
- ElevationChildResumeAutomaticUpdates();
682
- }
683
-
678
if (hLock)
679
{
680
::ReleaseMutex(hLock);