diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-04-22 14:38:05 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-21 19:40:40 +0000 |
commit | 7f6785f36336671b01ba9944cf7101a7c2c487bd (patch) | |
tree | ac6642369407ac31fb10d07edc4e0fbee252a874 /video/out/w32_common.c | |
parent | 704afb89681bc6d7fb87cce0a389444de3fac2a0 (diff) | |
download | mpv-7f6785f36336671b01ba9944cf7101a7c2c487bd.tar.bz2 mpv-7f6785f36336671b01ba9944cf7101a7c2c487bd.tar.xz |
win32: explicitly guard dark mode calls by Windows version
Fixes: #11610
Fixes: 9feeb324eddd9ed73ae667e10275f663d70f7544
Diffstat (limited to 'video/out/w32_common.c')
-rw-r--r-- | video/out/w32_common.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index b6da8223c4..b3ad949794 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1552,8 +1552,20 @@ static void w32_api_load(struct vo_w32_state *w32) w32->api.pImmDisableIME = !imm32_dll ? NULL : (void *)GetProcAddress(imm32_dll, "ImmDisableIME"); - // Dark mode related functions, avaliable since a Win10 update - HMODULE uxtheme_dll = GetModuleHandle(L"uxtheme.dll"); + // Dark mode related functions, available since the 1809 Windows 10 update + // Check the Windows build version as on previous versions used ordinals + // may point to unexpected code/data. Alternatively could check uxtheme.dll + // version directly, but it is little bit more boilerplate code, and build + // number is good enough check. + void (WINAPI *pRtlGetNtVersionNumbers)(LPDWORD, LPDWORD, LPDWORD) = + (void *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetNtVersionNumbers"); + + DWORD major, build; + pRtlGetNtVersionNumbers(&major, NULL, &build); + build &= ~0xF0000000; + + HMODULE uxtheme_dll = (major < 10 || build < 17763) ? NULL : + GetModuleHandle(L"uxtheme.dll"); w32->api.pShouldAppsUseDarkMode = !uxtheme_dll ? NULL : (void *)GetProcAddress(uxtheme_dll, MAKEINTRESOURCEA(132)); w32->api.pSetPreferredAppMode = !uxtheme_dll ? NULL : |