[PATCH 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. -- 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..527f39cdfe8 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 527f39cdfe8..94008b5436f 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
Rémi Bernon (@rbernon) commented about dlls/win32u/sysparams.c:
{ ULONG context;
- if (process && process != GetCurrentProcess()) + if (process && !(process == GetCurrentProcess() || !NtCompareObjects( GetCurrentProcess(), process ))) It's maybe a matter of taste but wouldn't `if (process && process != GetCurrentProcess() && NtCompareObjects( GetCurrentProcess(), process ))` be more readable?
Same for the other patch. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10102#note_129651
participants (3)
-
Brendan Shanks -
Brendan Shanks (@bshanks) -
Rémi Bernon (@rbernon)