[PATCH v2 0/2] MR10102: win32u: Support real handles to the current process in NtUserGetProcessDpiAwarenessContext(), NtUserGetSystemDpiForProcess().
I have a WPF application which calls `GetProcessDpiAwareness()` using a real handle to the current process. -- v2: win32u: Support real handles to the current process in NtUserGetSystemDpiForProcess(). win32u: Support real handles to the current process in NtUserGetProcessDpiAwarenessContext(). https://gitlab.winehq.org/wine/wine/-/merge_requests/10102
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/user32/tests/sysparams.c | 7 +++++++ dlls/win32u/sysparams.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index 501d9afe5ea..ebf4bf7ca9e 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -4329,6 +4329,7 @@ static void test_dpi_context(void) DPI_AWARENESS_CONTEXT context; BOOL ret; UINT dpi; + HANDLE process; HDC hdc = GetDC( 0 ); context = pGetThreadDpiAwarenessContext(); @@ -4375,6 +4376,12 @@ static void test_dpi_context(void) ret = pGetProcessDpiAwarenessInternal( GetCurrentProcess(), &awareness ); ok( ret, "got %d\n", ret ); ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness ); + process = OpenProcess( PROCESS_QUERY_LIMITED_INFORMATION, FALSE, GetCurrentProcessId() ); + ret = pGetProcessDpiAwarenessInternal( process, &awareness ); + ok( ret, "got %d\n", ret ); + ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness ); + CloseHandle(process); + SetLastError(0xdeadbeef); ret = pGetProcessDpiAwarenessInternal( (HANDLE)0xdeadbeef, &awareness ); todo_wine diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index ea477939eba..a5b7e6adbe6 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -7387,7 +7387,7 @@ ULONG WINAPI NtUserGetProcessDpiAwarenessContext( HANDLE process ) { ULONG context; - if (process && process != GetCurrentProcess()) + if (process && process != GetCurrentProcess() && NtCompareObjects( GetCurrentProcess(), process )) { WARN( "not supported on other process %p\n", process ); return NTUSER_DPI_UNAWARE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10102
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/win32u/sysparams.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index a5b7e6adbe6..85e5df8e188 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -4765,7 +4765,7 @@ MONITORINFO monitor_info_from_window( HWND hwnd, UINT flags ) */ ULONG WINAPI NtUserGetSystemDpiForProcess( HANDLE process ) { - if (process && process != GetCurrentProcess()) + if (process && process != GetCurrentProcess() && NtCompareObjects( GetCurrentProcess(), process )) { FIXME( "not supported on other process %p\n", process ); return 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10102
On Fri Feb 13 20:15:19 2026 +0000, Brendan Shanks wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/10102/diffs?diff_id=244918&start_sha=ba5ca5864f8ec4da8bae2530a2c66eae5cbd5231#85770a8b187bd82db4dbb9a2b8a5f34616049d0f_7390_7390) Ah yes thanks, that is much clearer.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10102#note_129654
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10102
participants (3)
-
Brendan Shanks -
Brendan Shanks (@bshanks) -
Rémi Bernon (@rbernon)