Skip to content

Commit 17a8f39

Browse files
authored
Add workaround for all Avalonia applications (#4496)
1 parent c58a338 commit 17a8f39

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

mods/classic-theme-transparency-fix.wh.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// @id classic-theme-transparency-fix
33
// @name Classic theme transparency fix
44
// @description Fixes transparency glitches in Classic theme
5-
// @version 1.3
5+
// @version 1.4
66
// @author Anixx
77
// @github https://github.com/Anixx
88
// @include *
99
// @include dllhost.exe
10-
// @exclude UniGetUI.Avalonia.exe
1110
// ==/WindhawkMod==
1211

1312
// ==WindhawkModReadme==
@@ -28,6 +27,7 @@ shadiows, turn it off.
2827
// ==/WindhawkModSettings==
2928

3029
#include <windhawk_utils.h>
30+
#include <psapi.h>
3131

3232
// --- Structs and types for dialog transparency removal ---
3333

@@ -46,12 +46,42 @@ struct WINDOWCOMPOSITIONATTRIBDATA {
4646

4747
typedef BOOL (WINAPI* pSetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*);
4848

49+
// --- Global Avalonia flag ---
50+
// -1 = not checked yet, 0 = not Avalonia, 1 = Avalonia
51+
int g_isAvaloniaProcess = -1;
52+
4953
// --- DWM / composition hooks ---
5054

5155
typedef HRESULT (WINAPI *DwmIsCompositionEnabled_t)(BOOL *);
5256
DwmIsCompositionEnabled_t DwmIsCompositionEnabled_orig;
5357
HRESULT WINAPI DwmIsCompositionEnabled_hook(BOOL *pfEnabled)
5458
{
59+
if (g_isAvaloniaProcess == -1) {
60+
g_isAvaloniaProcess = 0;
61+
HMODULE hMods[1024];
62+
DWORD cbNeeded;
63+
64+
if (EnumProcessModules(GetCurrentProcess(), hMods, sizeof(hMods), &cbNeeded)) {
65+
for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
66+
WCHAR szModName[MAX_PATH];
67+
if (GetModuleFileNameW(hMods[i], szModName, sizeof(szModName) / sizeof(WCHAR))) {
68+
WCHAR* fileName = wcsrchr(szModName, L'\\');
69+
fileName = fileName ? fileName + 1 : szModName;
70+
71+
if (_wcsnicmp(fileName, L"av_lib", 6) == 0) {
72+
Wh_Log(L"Avalonia library detected");
73+
g_isAvaloniaProcess = 1;
74+
break;
75+
}
76+
}
77+
}
78+
}
79+
}
80+
81+
if (g_isAvaloniaProcess == 1) {
82+
return DwmIsCompositionEnabled_orig(pfEnabled);
83+
}
84+
5585
*pfEnabled = FALSE;
5686
return S_OK;
5787
}
@@ -98,7 +128,7 @@ BOOL Wh_ModInit()
98128
HMODULE uxthemeModule = LoadLibraryExW(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
99129
pFunction = GetProcAddress(uxthemeModule, "IsCompositionActive");
100130
Wh_SetFunctionHook((void*)pFunction, (void*)IsCompositionActive_hook, (void**)&IsCompositionActive_orig);
101-
131+
102132
if (Wh_GetIntSetting(L"removeDialogTransparency")) {
103133
Wh_SetFunctionHook((void*)ShowWindow, (void*)ShowWindow_Hook, (void**)&ShowWindow_Original);
104134
}

0 commit comments

Comments
 (0)