From a5f35b133f4352218b3138778e58d6a2bf5af865 Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sun, 18 Oct 2020 09:10:54 +0200 Subject: [PATCH] Improve compatibility with WindowBlinds `Open-Shell` hooks `SHFillRectClr` (ordinal 197) API from `shlwapi.dll` in order to be able to customize taskbar. The API is hooked even if taskbar customization is disabled in `Open-Shell` (default). `WindowBlinds` hooks the same API so this is causing clashes between both programs. In fact `Open-Shell` hooks later which makes `WindowBlinds` hook to be completely ignored. The solution would be to hook only if taskbar customization is enabled. This way `Open-Shell` should be more compatible with other customization tools in default state. Fixes #433. --- Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp | 52 +++++++++++---------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp index b77e1cb..1ae435f 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp @@ -2790,6 +2790,9 @@ static void OpenCortana( void ) static void InitStartMenuDLL( void ) { + LogToFile(STARTUP_LOG, L"StartMenu DLL: InitStartMenuDLL"); + WaitDllInitThread(); + InitializeIatHooks(); if (IsWin81Update1()) { @@ -2817,39 +2820,40 @@ static void InitStartMenuDLL( void ) } } - if (GetWinVersion()>=WIN_VER_WIN10) + if (GetSettingBool(L"CustomTaskbar")) { - HMODULE shlwapi=GetModuleHandle(L"shlwapi.dll"); - if (shlwapi) + if (GetWinVersion()>=WIN_VER_WIN10) { - g_SHFillRectClr=(tSHFillRectClr)GetProcAddress(shlwapi,MAKEINTRESOURCEA(197)); - if (g_SHFillRectClr) + HMODULE shlwapi=GetModuleHandle(L"shlwapi.dll"); + if (shlwapi) { - g_SHFillRectClrHook=SetIatHook(GetModuleHandle(NULL),"shlwapi.dll",MAKEINTRESOURCEA(197),SHFillRectClr2); - if (!g_SHFillRectClrHook) - g_SHFillRectClrHook=SetIatHook(GetModuleHandle(NULL),"api-ms-win-shlwapi-winrt-storage-l1-1-1.dll",MAKEINTRESOURCEA(197),SHFillRectClr2); + g_SHFillRectClr=(tSHFillRectClr)GetProcAddress(shlwapi,MAKEINTRESOURCEA(197)); + if (g_SHFillRectClr) + { + g_SHFillRectClrHook=SetIatHook(GetModuleHandle(NULL),"shlwapi.dll",MAKEINTRESOURCEA(197),SHFillRectClr2); + if (!g_SHFillRectClrHook) + g_SHFillRectClrHook=SetIatHook(GetModuleHandle(NULL),"api-ms-win-shlwapi-winrt-storage-l1-1-1.dll",MAKEINTRESOURCEA(197),SHFillRectClr2); + } } + g_StretchDIBitsHook=SetIatHook(GetModuleHandle(NULL),"gdi32.dll","StretchDIBits",StretchDIBits2); } - g_StretchDIBitsHook=SetIatHook(GetModuleHandle(NULL),"gdi32.dll","StretchDIBits",StretchDIBits2); - } - { - HWND dlg=CreateWindow(L"#32770",L"",WS_POPUP,0,0,0,0,NULL,0,0,0); - HWND toolbar=CreateWindow(TOOLBARCLASSNAME,L"",WS_CHILD|TBS_TOOLTIPS,0,0,0,0,dlg,0,0,0); - DestroyWindow(dlg); - } + { + HWND dlg=CreateWindow(L"#32770",L"",WS_POPUP,0,0,0,0,NULL,0,0,0); + HWND toolbar=CreateWindow(TOOLBARCLASSNAME,L"",WS_CHILD|TBS_TOOLTIPS,0,0,0,0,dlg,0,0,0); + DestroyWindow(dlg); + } - if (GetWinVersion()<=WIN_VER_WIN81) - g_DrawThemeBackgroundHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeBackground",DrawThemeBackground2); - g_DrawThemeTextHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeText",DrawThemeText2); - g_DrawThemeTextExHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeTextEx",DrawThemeTextEx2); - g_DrawThemeTextCtlHook=SetIatHook(GetModuleHandle(L"comctl32.dll"),"uxtheme.dll","DrawThemeText",DrawThemeText2); - if (GetWinVersion()>=WIN_VER_WIN10) - g_SetWindowCompositionAttributeHook=SetIatHook(GetModuleHandle(NULL),"user32.dll","SetWindowCompositionAttribute",SetWindowCompositionAttribute2); + if (GetWinVersion()<=WIN_VER_WIN81) + g_DrawThemeBackgroundHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeBackground",DrawThemeBackground2); + g_DrawThemeTextHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeText",DrawThemeText2); + g_DrawThemeTextExHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeTextEx",DrawThemeTextEx2); + g_DrawThemeTextCtlHook=SetIatHook(GetModuleHandle(L"comctl32.dll"),"uxtheme.dll","DrawThemeText",DrawThemeText2); + if (GetWinVersion()>=WIN_VER_WIN10) + g_SetWindowCompositionAttributeHook=SetIatHook(GetModuleHandle(NULL),"user32.dll","SetWindowCompositionAttribute",SetWindowCompositionAttribute2); + } g_TaskbarThreadId=GetCurrentThreadId(); - LogToFile(STARTUP_LOG,L"StartMenu DLL: InitStartMenuDLL"); - WaitDllInitThread(); g_bTrimHooks=GetWinVersion()==WIN_VER_WIN7 && (GetSettingInt(L"CompatibilityFixes")&COMPATIBILITY_TRIM_HOOKS); InitManagers(false); int level=GetSettingInt(L"CrashDump");