MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / LoadViewService

Method LoadViewService

ExplorerHooks/taskviewvisibilitymonitor.cpp:42–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42TaskViewVisibilityMonitor::unique_view_service TaskViewVisibilityMonitor::LoadViewService() noexcept
43{
44 // if we get injected at process creation, it's possible the immersive shell isn't ready yet.
45 // try until it is ready. if after 10 seconds the class is still not registered, it's most likely
46 // an issue other than process init not being done.
47 wil::com_ptr_failfast<IServiceProvider> servProv;
48 uint8_t attempts = 0;
49 HRESULT hr = S_OK;
50 do
51 {
52 hr = CoCreateInstance(CLSID_ImmersiveShell, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(servProv.put()));
53 if (SUCCEEDED(hr))
54 {
55 break;
56 }
57 else
58 {
59 ++attempts;
60 Sleep(500);
61 }
62 }
63 while (hr == REGDB_E_CLASSNOTREG && attempts < 20);
64 FAIL_FAST_IF_FAILED(hr);
65
66 // on Windows 11, we frequently get not implemented if this is done too early, so apply the same treatment for the QueryService call.
67 attempts = 0;
68 hr = S_OK;
69 do
70 {
71 hr = servProv->QueryService(SID_MultitaskingViewVisibilityService, s_ViewService.put());
72 if (SUCCEEDED(hr))
73 {
74 return unique_view_service();
75 }
76 else
77 {
78 ++attempts;
79 Sleep(500);
80 }
81 }
82 while (hr == E_NOTIMPL && attempts < 20);
83 FAIL_FAST_HR(hr);
84}
85
86TaskViewVisibilityMonitor::unique_multitasking_view_visibility_token TaskViewVisibilityMonitor::RegisterSink() noexcept
87{

Callers

nothing calls this directly

Calls 1

putMethod · 0.80

Tested by

no test coverage detected