File tree Expand file tree Collapse file tree 5 files changed +37
-19
lines changed Expand file tree Collapse file tree 5 files changed +37
-19
lines changed Original file line number Diff line number Diff line change @@ -110,10 +110,22 @@ HRESULT WINAPI DynamicGetPackageGraphRevisionId();
110
110
111
111
typedef UINT32 (WINAPI* GetPackageGraphRevisionIdFunction)();
112
112
113
+ static bool MddUseOSImplementation ()
114
+ {
115
+ // Use the Win11 APIs if available (instead of Detour'ing to our own implementation)
116
+ return MddCore::Win11::IsSupported ();
117
+ }
118
+
119
+ bool MddNeedsDetours () noexcept
120
+ {
121
+ // Detour to our own implementation if Windows doesn't provide a sufficient implementation
122
+ return !MddUseOSImplementation ();
123
+ }
124
+
113
125
HRESULT WINAPI MddDetourPackageGraphInitialize () noexcept
114
126
{
115
127
// Use the Win11 APIs if available (instead of Detour'ing to our own implementation)
116
- if (MddCore::Win11::IsSupported ())
128
+ if (MddUseOSImplementation ())
117
129
{
118
130
RETURN_IF_FAILED (MddWin11Initialize ());
119
131
return S_OK;
Original file line number Diff line number Diff line change 6
6
7
7
#include "appmodel_msixdynamicdependency.h"
8
8
9
+ bool MddNeedsDetours () noexcept ;
10
+
9
11
HRESULT WINAPI MddDetourPackageGraphInitialize () noexcept ;
10
12
11
13
void WINAPI MddDetourPackageGraphShutdown () noexcept ;
Original file line number Diff line number Diff line change @@ -405,29 +405,25 @@ HRESULT ExtRoLoadCatalog()
405
405
return S_OK;
406
406
}
407
407
408
- HRESULT UrfwInitialize () noexcept
408
+ static bool UrfwUseOSImplementation () noexcept
409
409
{
410
- #if defined(TODO_URFW_DELEGATE_TO_OS_19H1PLUS)
411
- // Windows' Reg-Free WinRT first appeared in Windows 10 Version 1903, May 2019 Update (aka 19H1)
412
- // https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/
413
- // Delegate to the OS' implementation when available
414
- if (WindowsVersion::IsWindows10_19H1OrGreater ())
415
- {
416
- return S_OK;
417
- }
418
- #elif defined(TODO_SEEME_PRODUCT_TARGET)
419
- // Delegate to the OS' implementation on >= Windows 11 24H1
420
- if (WindowsVersion::IsWindows11_22H2OrGreater ())
421
- {
422
- return S_OK;
423
- }
424
- #else
425
410
// Delegate to the OS' implementation on >= Windows 11 24H1
426
- if (WindowsVersion::IsWindows11_24H1OrGreater ())
411
+ return WindowsVersion::IsWindows11_24H1OrGreater ();
412
+ }
413
+
414
+ bool UrfwNeedsDetours () noexcept
415
+ {
416
+ // Detour to our own implementation if Windows doesn't provide a sufficient implementation
417
+ return !UrfwUseOSImplementation ();
418
+ }
419
+
420
+ HRESULT UrfwInitialize () noexcept
421
+ {
422
+ // Delegate to the OS' implementation if we can
423
+ if (UrfwUseOSImplementation ())
427
424
{
428
425
return S_OK;
429
426
}
430
- #endif
431
427
432
428
// OS Reg-Free WinRT isn't available so let's do it ourselves...
433
429
DetourAttach (&(PVOID&)TrueRoActivateInstance, RoActivateInstanceDetour);
Original file line number Diff line number Diff line change 4
4
#if !defined(URFW_H )
5
5
#define URFW_H
6
6
7
+ bool UrfwNeedsDetours () noexcept ;
8
+
7
9
HRESULT UrfwInitialize () noexcept ;
8
10
9
11
void UrfwShutdown () noexcept ;
Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ static HRESULT DetoursInitialize()
22
22
}
23
23
24
24
// Do we need to detour APIs?
25
+ if (!MddNeedsDetours () && !UrfwNeedsDetours ())
26
+ {
27
+ return S_OK;
28
+ }
29
+
30
+ // No detours needed in a 'detours helper process'
25
31
if (DetourIsHelperProcess ())
26
32
{
27
33
return S_OK;
You can’t perform that action at this time.
0 commit comments