From 4816b70355a5cbd5025c0f55fd291c01404b2bd9 Mon Sep 17 00:00:00 2001 From: ssparach <128866445+ssparach@users.noreply.github.com> Date: Tue, 8 Jul 2025 13:49:48 -0700 Subject: [PATCH 1/5] bug fix --- dev/WindowsAppRuntime_DLL/dllmain.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dev/WindowsAppRuntime_DLL/dllmain.cpp b/dev/WindowsAppRuntime_DLL/dllmain.cpp index 60c61157c6..cc2e3890cd 100644 --- a/dev/WindowsAppRuntime_DLL/dllmain.cpp +++ b/dev/WindowsAppRuntime_DLL/dllmain.cpp @@ -13,10 +13,13 @@ #include <../Detours/detours.h> +static bool isPackaged = AppModel::Identity::IsPackagedProcess(); +static bool is19H1OrGreater = WindowsVersion::IsWindows10_19H1OrGreater(); + static HRESULT DetoursInitialize() { // Only detour APIs for not-packaged processes - if (AppModel::Identity::IsPackagedProcess()) + if (isPackaged && is19H1OrGreater) { return S_OK; } @@ -30,8 +33,11 @@ static HRESULT DetoursInitialize() // Detour APIs to our implementation DetourRestoreAfterWith(); FAIL_FAST_IF_WIN32_ERROR(DetourTransactionBegin()); - FAIL_FAST_IF_FAILED(MddDetourPackageGraphInitialize()); - FAIL_FAST_IF_FAILED(UrfwInitialize()); + if (!isPackaged && !is19H1OrGreater) + { + FAIL_FAST_IF_FAILED(MddDetourPackageGraphInitialize()); + FAIL_FAST_IF_FAILED(UrfwInitialize()); + } FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit()); return S_OK; } @@ -39,7 +45,7 @@ static HRESULT DetoursInitialize() static HRESULT DetoursShutdown() { // Only detour APIs for not-packaged processes - if (AppModel::Identity::IsPackagedProcess()) + if (isPackaged && is19H1OrGreater) { return S_OK; } @@ -53,8 +59,11 @@ static HRESULT DetoursShutdown() // Stop Detour'ing APIs to our implementation FAIL_FAST_IF_WIN32_ERROR(DetourTransactionBegin()); FAIL_FAST_IF_WIN32_ERROR(DetourUpdateThread(GetCurrentThread())); - UrfwShutdown(); - MddDetourPackageGraphShutdown(); + if (!isPackaged && !is19H1OrGreater) + { + UrfwShutdown(); + MddDetourPackageGraphShutdown(); + } FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit()); return S_OK; } From 90de757525ec84184d629aef8e8e6fdd0b8a4c95 Mon Sep 17 00:00:00 2001 From: ssparach <128866445+ssparach@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:30:48 -0700 Subject: [PATCH 2/5] Update dev/WindowsAppRuntime_DLL/dllmain.cpp Co-authored-by: Scott Jones --- dev/WindowsAppRuntime_DLL/dllmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/WindowsAppRuntime_DLL/dllmain.cpp b/dev/WindowsAppRuntime_DLL/dllmain.cpp index cc2e3890cd..97ab5a062a 100644 --- a/dev/WindowsAppRuntime_DLL/dllmain.cpp +++ b/dev/WindowsAppRuntime_DLL/dllmain.cpp @@ -18,7 +18,7 @@ static bool is19H1OrGreater = WindowsVersion::IsWindows10_19H1OrGreater(); static HRESULT DetoursInitialize() { - // Only detour APIs for not-packaged processes + // Detours needed for Lifted Reg-Free WinRT Activation before 19H1, and Dynamic Dependencies in unpackaged apps if (isPackaged && is19H1OrGreater) { return S_OK; From 1ca87df3423ce83632d8f7363855dac49e6cab4e Mon Sep 17 00:00:00 2001 From: ssparach <128866445+ssparach@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:30:57 -0700 Subject: [PATCH 3/5] Update dev/WindowsAppRuntime_DLL/dllmain.cpp Co-authored-by: Scott Jones --- dev/WindowsAppRuntime_DLL/dllmain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/WindowsAppRuntime_DLL/dllmain.cpp b/dev/WindowsAppRuntime_DLL/dllmain.cpp index 97ab5a062a..b066c9567c 100644 --- a/dev/WindowsAppRuntime_DLL/dllmain.cpp +++ b/dev/WindowsAppRuntime_DLL/dllmain.cpp @@ -33,9 +33,12 @@ static HRESULT DetoursInitialize() // Detour APIs to our implementation DetourRestoreAfterWith(); FAIL_FAST_IF_WIN32_ERROR(DetourTransactionBegin()); - if (!isPackaged && !is19H1OrGreater) + if (!isPackaged) { FAIL_FAST_IF_FAILED(MddDetourPackageGraphInitialize()); + } + if (!is19H1OrGreater) + { FAIL_FAST_IF_FAILED(UrfwInitialize()); } FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit()); From 6baa1797c92034ea65816ce278f8864d67390f0a Mon Sep 17 00:00:00 2001 From: ssparach <128866445+ssparach@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:31:04 -0700 Subject: [PATCH 4/5] Update dev/WindowsAppRuntime_DLL/dllmain.cpp Co-authored-by: Scott Jones --- dev/WindowsAppRuntime_DLL/dllmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/WindowsAppRuntime_DLL/dllmain.cpp b/dev/WindowsAppRuntime_DLL/dllmain.cpp index b066c9567c..48348845a8 100644 --- a/dev/WindowsAppRuntime_DLL/dllmain.cpp +++ b/dev/WindowsAppRuntime_DLL/dllmain.cpp @@ -47,7 +47,7 @@ static HRESULT DetoursInitialize() static HRESULT DetoursShutdown() { - // Only detour APIs for not-packaged processes + // Detours needed for Lifted Reg-Free WinRT Activation before 19H1, and Dynamic Dependencies in unpackaged apps if (isPackaged && is19H1OrGreater) { return S_OK; From d1e14358c2e659d3548786401f8e267ba109558c Mon Sep 17 00:00:00 2001 From: ssparach <128866445+ssparach@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:31:13 -0700 Subject: [PATCH 5/5] Update dev/WindowsAppRuntime_DLL/dllmain.cpp Co-authored-by: Scott Jones --- dev/WindowsAppRuntime_DLL/dllmain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/WindowsAppRuntime_DLL/dllmain.cpp b/dev/WindowsAppRuntime_DLL/dllmain.cpp index 48348845a8..210cccf7b2 100644 --- a/dev/WindowsAppRuntime_DLL/dllmain.cpp +++ b/dev/WindowsAppRuntime_DLL/dllmain.cpp @@ -62,9 +62,12 @@ static HRESULT DetoursShutdown() // Stop Detour'ing APIs to our implementation FAIL_FAST_IF_WIN32_ERROR(DetourTransactionBegin()); FAIL_FAST_IF_WIN32_ERROR(DetourUpdateThread(GetCurrentThread())); - if (!isPackaged && !is19H1OrGreater) + if (!is19H1OrGreater) { UrfwShutdown(); + } + if (!isPackaged) + { MddDetourPackageGraphShutdown(); } FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit());