Skip to content
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

wil/resource.h conditionally enables unique_key using different logic than winreg.h #470

Open
ChrisGuzak opened this issue Aug 28, 2024 · 1 comment
Labels
improvement Something that would improve the repo in some way

Comments

@ChrisGuzak
Copy link
Member

The support for wil::unique_hkey in wil/resource.h is conditionally enabled based on WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) here.

This is out of sync with what protects RegCloseKey() and HKEY. See line 237 in winreg.h in the Windows SDK.

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)

This means if you don't build with WINAPI_FAMILY defined as WINAPI_FAMILY_DESKTOP_APP you don't get wil::uniquey_hkey.

This caused problems for a shared library that wil::unique_hkey that needs to be consumed by UWP style apps.

@dunhor
Copy link
Member

dunhor commented Dec 17, 2024

I wonder if it's been long enough since we did the WACK update to unconditionally change the API partition. Otherwise, the way we've solved this in the past is to try and detect the installed SDK version to determine how we do these checks. E.g.

// GetModuleHandleExW was added to the app partition in version 22000 of the SDK
#if defined(NTDDI_WIN10_CO) ? WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES) \
                            : WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)

@dunhor dunhor added the improvement Something that would improve the repo in some way label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something that would improve the repo in some way
Projects
None yet
Development

No branches or pull requests

2 participants