MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / BeforeUpdate

Method BeforeUpdate

LegacyUpdate/LegacyUpdateCtrl.cpp:635–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635STDMETHODIMP CLegacyUpdateCtrl::BeforeUpdate(void) {
636 DoIsPermittedCheck();
637
638 IElevationHelper *elevatedHelper;
639 HRESULT hr = GetElevatedHelper(&elevatedHelper);
640 CHECK_HR_OR_RETURN(L"GetElevatedHelper");
641
642 // Allow IUpdateInstaller->RunWizard() dialog to come to foreground while this process is in foreground.
643 // Without this, Windows will see it as a disruption and ignore the request.
644 DWORD pid;
645 hr = elevatedHelper->GetProcessId(&pid);
646 if (SUCCEEDED(hr)) {
647 HWND hwnd = NULL;
648 GetIEWindowHWND(&hwnd);
649
650 // Do some thread magic to execute in the thread context of the top-level IE process
651 BOOL attached = FALSE;
652 DWORD brokerThread = 0;
653 DWORD currentThread = GetCurrentThreadId();
654 if (hwnd) {
655 brokerThread = GetWindowThreadProcessId(hwnd, NULL);
656
657 if (brokerThread != 0 && brokerThread != currentThread) {
658 attached = AttachThreadInput(currentThread, brokerThread, TRUE);
659 }
660 }
661
662 AllowSetForegroundWindow(pid);
663
664 if (attached) {
665 AttachThreadInput(currentThread, brokerThread, FALSE);
666 }
667 }
668
669 return elevatedHelper->BeforeUpdate();
670}
671
672STDMETHODIMP CLegacyUpdateCtrl::AfterUpdate(void) {
673 DoIsPermittedCheck();

Callers

nothing calls this directly

Calls 1

GetProcessIdMethod · 0.80

Tested by

no test coverage detected