diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 75be55a..aa6ccc4 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -4189,7 +4189,7 @@ HRESULT stobject_CoCreateInstanceHook( LPVOID* ppv ) { - if (global_rovi.dwBuildNumber >= 25000 && IsEqualGUID(rclsid, &CLSID_NetworkTraySSO) && bOldTaskbar) + if (global_rovi.dwBuildNumber >= 25236 && IsEqualGUID(rclsid, &CLSID_NetworkTraySSO) && bOldTaskbar) { wchar_t szPath[MAX_PATH]; ZeroMemory(szPath, sizeof(szPath)); @@ -6555,6 +6555,7 @@ void WINAPI LoadSettings(LPARAM lParam) if (!bWasOldTaskbarSet) { bOldTaskbar = dwTemp; + AdjustTaskbarStyleValue(&bOldTaskbar); bWasOldTaskbarSet = TRUE; } dwSize = sizeof(DWORD); @@ -9896,6 +9897,7 @@ int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* c } break; } +#if 0 case 42537950: // DisableWin10Taskbar { if (bOldTaskbar) @@ -9905,6 +9907,7 @@ int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* c } break; } +#endif case 44656322: // ID44656322 { if (bOldTaskbar) @@ -11872,7 +11875,7 @@ LSTATUS pnidui_RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD void PatchPnidui(HMODULE hPnidui) { VnPatchIAT(hPnidui, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", pnidui_CoCreateInstanceHook); - if (global_rovi.dwBuildNumber >= 25000) + if (global_rovi.dwBuildNumber >= 25236) { VnPatchIAT(hPnidui, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", pnidui_RegGetValueW); } @@ -12211,6 +12214,7 @@ DWORD Inject(BOOL bIsExplorer) if (bOldTaskbar >= 2 && !pszTaskbarDll) { bOldTaskbar = 1; + AdjustTaskbarStyleValue(&bOldTaskbar); } @@ -12238,6 +12242,7 @@ DWORD Inject(BOOL bIsExplorer) CImmersiveColor_GetColorFunc = (DWORD(*)(int))((uintptr_t)hExplorer + symbols_PTRS.explorer_PTRS[0]); } +#if 0 if (global_rovi.dwBuildNumber >= 26002) { // Please Microsoft 🙏 @@ -12267,6 +12272,7 @@ DWORD Inject(BOOL bIsExplorer) ); } } +#endif } SetChildWindowNoActivateFunc = GetProcAddress(GetModuleHandleW(L"user32.dll"), (LPCSTR)2005); @@ -12664,7 +12670,7 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hStobject, "user32.dll", "TrackPopupMenu", stobject_TrackPopupMenuHook); VnPatchIAT(hStobject, "user32.dll", "TrackPopupMenuEx", stobject_TrackPopupMenuExHook); } - if (global_rovi.dwBuildNumber >= 25000 && bOldTaskbar) + if (global_rovi.dwBuildNumber >= 25236 && bOldTaskbar) { PatchStobject(hStobject); } @@ -12690,7 +12696,7 @@ DWORD Inject(BOOL bIsExplorer) - if (global_rovi.dwBuildNumber < 25000) + if (global_rovi.dwBuildNumber < 25236) { HANDLE hPnidui = LoadLibraryW(L"pnidui.dll"); if (hPnidui) diff --git a/ExplorerPatcher/hooking.h b/ExplorerPatcher/hooking.h index 1d182da..e47dc2c 100644 --- a/ExplorerPatcher/hooking.h +++ b/ExplorerPatcher/hooking.h @@ -1,26 +1,45 @@ #ifndef _H_HOOKING_H_ #define _H_HOOKING_H_ + #define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_NOP 0 #define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_ALWAYS_JUMP 1 #define HOOK_WITH_FUNCHOOK 0 #define HOOK_WITH_DETOURS 1 #define HOW_TO_HOOK HOOK_WITH_FUNCHOOK + #if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK + #ifdef _M_ARM64 #error Cannot compile for ARM64 using funchook. Change the source to hook with Detours and try again. Compilation aborted. #endif + #include #include #pragma comment(lib, "funchook.lib") #pragma comment(lib, "Psapi.lib") // required by funchook #pragma comment(lib, "distorm.lib") + #elif HOW_TO_HOOK == HOOK_WITH_DETOURS + +#ifdef __cplusplus +extern "C" +{ +#endif + #include #pragma comment(lib, "detours.lib") + +#ifdef __cplusplus +inline +#endif void* funchook_create(void) { return 1; } + +#ifdef __cplusplus +inline +#endif int funchook_uninstall( void* _this, int flags @@ -28,10 +47,18 @@ int funchook_uninstall( { return 0; } + +#ifdef __cplusplus +inline +#endif int funchook_destroy(void* _this) { return 0; } + +#ifdef __cplusplus +inline +#endif int funchook_prepare( void* funchook, void** target_func, @@ -43,6 +70,10 @@ int funchook_prepare( DetourAttach(target_func, hook_func); return DetourTransactionCommit(); } + +#ifdef __cplusplus +inline +#endif int funchook_install( void* funchook, int flags @@ -50,10 +81,28 @@ int funchook_install( { return 0; } + +#ifdef __cplusplus +} // extern "C" #endif + +#endif + +#define HOOKING_SUCCESS 0 + +#ifdef __cplusplus +extern "C" +{ +#endif + #if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK -funchook_t* funchook = 0; +funchook_t* funchook; #elif HOW_TO_HOOK == HOOK_WITH_DETOURS -void* funchook = 0; +void* funchook; #endif + +#ifdef __cplusplus +} // extern "C" +#endif + #endif \ No newline at end of file diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index 7e22a0a..af8f5d7 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -102,6 +102,9 @@ DEFINE_GUID(IID_ITrayUIComponent, 0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b ); +#ifdef __cplusplus +inline +#endif HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv); #pragma endregion @@ -145,6 +148,9 @@ typedef LSTATUS(*t_SHRegGetValueFromHKCUHKLM)( void* pvData, DWORD* pcbData ); +#ifdef __cplusplus +inline +#endif t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc; inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt( @@ -215,6 +221,9 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt( return lRes; } +#ifdef __cplusplus +inline +#endif HWND(WINAPI* CreateWindowInBand)( _In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, @@ -231,10 +240,19 @@ HWND(WINAPI* CreateWindowInBand)( DWORD band ); +#ifdef __cplusplus +inline +#endif BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand); +#ifdef __cplusplus +inline +#endif BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand); +#ifdef __cplusplus +inline +#endif INT64(*SetWindowCompositionAttribute)(HWND, void*); static void(*SetPreferredAppMode)(BOOL bAllowDark); @@ -672,6 +690,11 @@ inline BOOL DoesWindows10StartMenuExist() return FileExistsW(szPath); } +inline BOOL IsStockWindows10TaskbarAvailable() +{ + return global_rovi.dwBuildNumber < 26002; +} + #if WITH_ALT_TASKBAR_IMPL inline const WCHAR* PickTaskbarDll() { @@ -721,6 +744,18 @@ inline BOOL DoesTaskbarDllExist() } #endif +inline void AdjustTaskbarStyleValue(DWORD* pdwValue) +{ + if (*pdwValue >= 2 && !DoesTaskbarDllExist()) + { + *pdwValue = 1; + } + if (*pdwValue == 1 && !IsStockWindows10TaskbarAvailable()) + { + *pdwValue = 0; + } +} + #ifdef __cplusplus } #endif diff --git a/ep_gui/GUI.c b/ep_gui/GUI.c index 8394f93..daca2de 100644 --- a/ep_gui/GUI.c +++ b/ep_gui/GUI.c @@ -12,7 +12,7 @@ DWORD GUI_FileSize = 0; BOOL g_darkModeEnabled = FALSE; static void(*RefreshImmersiveColorPolicyState)() = NULL; DWORD dwTaskbarPosition = 3; -BOOL gui_bOldTaskbar = TRUE; +DWORD GUI_TaskbarStyle = 1; LSTATUS SetPolicy(HKEY hKey, LPCWSTR wszPolicyPath, LPCWSTR wszPolicyName, DWORD dwVal) { @@ -632,7 +632,7 @@ LSTATUS GUI_Internal_RegQueryValueExW( if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2) { dwTaskbarPosition = srd.pvData[3]; - if (!gui_bOldTaskbar) + if (GUI_TaskbarStyle == 0) { if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it { @@ -672,7 +672,7 @@ LSTATUS GUI_Internal_RegQueryValueExW( ); if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2) { - if (!gui_bOldTaskbar) + if (GUI_TaskbarStyle == 0) { if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it { @@ -1000,14 +1000,14 @@ static void GUI_UpdateLanguages() EP_L10N_GetCurrentThreadLanguage(wszThreadLanguage, ARRAYSIZE(wszThreadLanguage)); } -DWORD GUI_GetTaskbarStyle() +DWORD GUI_GetTaskbarStyle(BOOL bAdjust) { DWORD dwRes = 1; DWORD dwSize = sizeof(DWORD); RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", RRF_RT_DWORD, NULL, &dwRes, &dwSize); - if (dwRes >= 2 && !DoesTaskbarDllExist()) + if (bAdjust) { - dwRes = 1; + AdjustTaskbarStyleValue(&dwRes); } return dwRes; } @@ -1161,19 +1161,23 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) if (!_stricmp(funcName, "DoesOSBuildSupportSpotlight") && !DoesOSBuildSupportSpotlight()) bSkipLines = TRUE; else if (!_stricmp(funcName, "IsSpotlightEnabled") && !IsSpotlightEnabled()) bSkipLines = TRUE; else if (!_stricmp(funcName, "IsSWSEnabled") && (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", L"AltTabSettings", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes != 2))) bSkipLines = TRUE; - else if (!_stricmp(funcName, "IsOldTaskbar") && GUI_GetTaskbarStyle() == 0) bSkipLines = TRUE; - else if (!_stricmp(funcName, "!IsOldTaskbar") && GUI_GetTaskbarStyle() != 0) bSkipLines = TRUE; - else if (!_stricmp(funcName, "IsStockWin10Taskbar") && GUI_GetTaskbarStyle() != 1) bSkipLines = TRUE; - else if (!_stricmp(funcName, "IsAltImplTaskbar") && GUI_GetTaskbarStyle() <= 1) bSkipLines = TRUE; + else if (!_stricmp(funcName, "IsOldTaskbar") && GUI_GetTaskbarStyle(TRUE) == 0) bSkipLines = TRUE; + else if (!_stricmp(funcName, "!IsOldTaskbar") && GUI_GetTaskbarStyle(TRUE) != 0) bSkipLines = TRUE; + else if (!_stricmp(funcName, "IsStockWin10Taskbar") && GUI_GetTaskbarStyle(TRUE) != 1) bSkipLines = TRUE; + else if (!_stricmp(funcName, "IsAltImplTaskbar") && GUI_GetTaskbarStyle(TRUE) <= 1) bSkipLines = TRUE; else if (!_stricmp(funcName, "DoesTaskbarDllExist") && !DoesTaskbarDllExist()) bSkipLines = TRUE; else if (!_stricmp(funcName, "!DoesTaskbarDllExist") && DoesTaskbarDllExist()) bSkipLines = TRUE; + else if (!_stricmp(funcName, "!IsStockWindows10TaskbarAvailable") && !(!IsStockWindows10TaskbarAvailable() && GUI_GetTaskbarStyle(FALSE) == 1)) bSkipLines = TRUE; else if (!_stricmp(funcName, "IsWindows10StartMenu") && (!DoesWindows10StartMenuExist() || (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"Start_ShowClassicMode", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes != 1)))) bSkipLines = TRUE; else if (!_stricmp(funcName, "!IsWindows10StartMenu") && (DoesWindows10StartMenuExist() && (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"Start_ShowClassicMode", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes == 1)))) bSkipLines = TRUE; else if (!_stricmp(funcName, "DoesWindows10StartMenuExist") && !DoesWindows10StartMenuExist()) bSkipLines = TRUE; else if (!_stricmp(funcName, "IsWeatherEnabled") && (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\People", L"PeopleBand", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes != 1))) bSkipLines = TRUE; else if (!_stricmp(funcName, "IsWindows11Version22H2OrHigher") && !IsWindows11Version22H2OrHigher()) bSkipLines = TRUE; else if (!_stricmp(funcName, "!IsWindows11Version22H2OrHigher") && IsWindows11Version22H2OrHigher()) bSkipLines = TRUE; - else if (!_stricmp(funcName, "!(IsWindows11Version22H2OrHigher&&!IsOldTaskbar)") && (IsWindows11Version22H2OrHigher() && GUI_GetTaskbarStyle() == 0)) bSkipLines = TRUE; + else if (!_stricmp(funcName, "!(IsWindows11Version22H2OrHigher&&!IsOldTaskbar)") && (IsWindows11Version22H2OrHigher() && GUI_GetTaskbarStyle(TRUE) == 0)) bSkipLines = TRUE; +#if 1 + else if (!_stricmp(funcName, "LogonLogoffShutdownSoundsAvailable")) bSkipLines = TRUE; +#endif if (bSkipLines) { do @@ -2485,7 +2489,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) BOOL bShouldAlterTaskbarDa = FALSE; if (!wcscmp(name, L"TaskbarDa")) { - if (!gui_bOldTaskbar) + if (GUI_TaskbarStyle == 0) { MENUITEMINFOA menuInfo; ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA)); @@ -2502,7 +2506,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } if (!wcscmp(name, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition") || !wcscmp(name, L"Virtualized_" _T(EP_CLSID) L"_MMTaskbarPosition")) { - if (!gui_bOldTaskbar) + if (GUI_TaskbarStyle == 0) { MENUITEMINFOA menuInfo; ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA)); @@ -2600,7 +2604,8 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) ); if (!wcscmp(name, L"OldTaskbar")) { - gui_bOldTaskbar = value; + GUI_TaskbarStyle = value; + AdjustTaskbarStyleValue(&GUI_TaskbarStyle); } if (hDC && bInvert) { diff --git a/ep_gui/resources/EPSettingsResources.h b/ep_gui/resources/EPSettingsResources.h index e00bd26..4d1f34f 100644 --- a/ep_gui/resources/EPSettingsResources.h +++ b/ep_gui/resources/EPSettingsResources.h @@ -50,6 +50,7 @@ #define IDS_TB_ICONSIZE_0 1046 #define IDS_TB_STYLE_2 1047 #define IDS_TB_ALTIMPL_NOTICE 1048 +#define IDS_TB_WIN10_UNAVAILABLE 1049 #define IDS_TRAY 1101 #define IDS_TRAY_SKINMENUS 1102 diff --git a/ep_gui/resources/lang/ep_gui.en-US.rc b/ep_gui/resources/lang/ep_gui.en-US.rc index e02785c..b3370cf 100644 --- a/ep_gui/resources/lang/ep_gui.en-US.rc +++ b/ep_gui/resources/lang/ep_gui.en-US.rc @@ -41,6 +41,7 @@ BEGIN IDS_TB_STYLE_0 "Windows 11 (default)" IDS_TB_STYLE_1 "Windows 10" IDS_TB_STYLE_2 "Windows 10 (ExplorerPatcher)" + IDS_TB_WIN10_UNAVAILABLE "Windows 10 taskbar is not available in this version of Windows." IDS_TB_MORE "More taskbar options in the Settings app" IDS_TB_CUSTOMIZETRAYICONS "Customize notification area icons" IDS_TB_CUSTOMIZESYSTEMICONS "Customize system icons in the notification area" diff --git a/ep_gui/resources/settings.reg b/ep_gui/resources/settings.reg index 7d72979..f1b575d 100644 --- a/ep_gui/resources/settings.reg +++ b/ep_gui/resources/settings.reg @@ -20,6 +20,9 @@ ;x 1 %R:1004% "OldTaskbar"=dword:00000001 ;g Taskbar_StyleSection2 +;s Taskbar_StockWin10Unavailable !IsStockWindows10TaskbarAvailable +;t ⚠ %R:1049% +;g Taskbar_StockWin10Unavailable ;y %R:1005% 🡕 ;ms-settings:taskbar ;y %R:1006% 🡕