Skip to content

Undocked Reg-Free WinRT Activation isn’t enabled for Packaged Self-Contained apps on < 19H1 devices #5623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions dev/WindowsAppRuntime_DLL/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@Scottj1s Scottj1s Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Only detour APIs for not-packaged processes
// Detours needed for Lifted Reg-Free WinRT Activation before 19H1, and Dynamic Dependencies in unpackaged apps

if (AppModel::Identity::IsPackagedProcess())
if (isPackaged && is19H1OrGreater)
{
return S_OK;
}
Expand All @@ -30,16 +33,19 @@ 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());
}
Comment on lines +36 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isPackaged && !is19H1OrGreater)
{
FAIL_FAST_IF_FAILED(MddDetourPackageGraphInitialize());
FAIL_FAST_IF_FAILED(UrfwInitialize());
}
if (!isPackaged)
{
FAIL_FAST_IF_FAILED(MddDetourPackageGraphInitialize());
}
if (!is19H1OrGreater)
{
FAIL_FAST_IF_FAILED(UrfwInitialize());
}

FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit());
return S_OK;
}

static HRESULT DetoursShutdown()
{
// Only detour APIs for not-packaged processes
Copy link
Member

@Scottj1s Scottj1s Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Only detour APIs for not-packaged processes
// Detours needed for Lifted Reg-Free WinRT Activation before 19H1, and Dynamic Dependencies in unpackaged apps

if (AppModel::Identity::IsPackagedProcess())
if (isPackaged && is19H1OrGreater)
{
return S_OK;
}
Expand All @@ -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();
}
Comment on lines +62 to +66
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isPackaged && !is19H1OrGreater)
{
UrfwShutdown();
MddDetourPackageGraphShutdown();
}
if (!is19H1OrGreater)
{
UrfwShutdown();
}
if (!isPackaged)
{
MddDetourPackageGraphShutdown();
}

FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit());
return S_OK;
}
Expand Down