diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj
index 57cc7c0..f61898c 100644
--- a/ExplorerPatcher/ExplorerPatcher.vcxproj
+++ b/ExplorerPatcher/ExplorerPatcher.vcxproj
@@ -259,7 +259,10 @@
true
true
-
+
+ true
+ true
+
true
diff --git a/ExplorerPatcher/TaskbarCenter.c b/ExplorerPatcher/TaskbarCenter.c
index 3c926c5..c6dcee2 100644
--- a/ExplorerPatcher/TaskbarCenter.c
+++ b/ExplorerPatcher/TaskbarCenter.c
@@ -1,11 +1,14 @@
#include "TaskbarCenter.h"
+DEFINE_GUID(POLID_TurnOffSPIAnimations, 0xD7AF00A, 0xB468, 0x4A39, 0xB0, 0x16, 0x33, 0x3E, 0x22, 0x77, 0xAB, 0xED);
+extern int(*SHWindowsPolicy)(REFIID);
extern HWND PeopleButton_LastHWND;
extern DWORD dwWeatherToLeft;
extern DWORD dwOldTaskbarAl;
extern DWORD dwMMOldTaskbarAl;
extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME;
#define EP_TASKBAR_LENGTH_TOO_SMALL 20
+BOOL bTaskbarCenterHasPatchedSHWindowsPolicy = FALSE;
HRESULT TaskbarCenter_Center(HWND hWnd, HWND hWndTaskbar, RECT rc, BOOL bIsTaskbarHorizontal)
{
@@ -428,4 +431,29 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
}
if (bWasCalled) return bWasCalled;
return GetClientRect(hWnd, lpRect);
+}
+
+BOOL TaskbarCenter_SHWindowsPolicy(REFIID riid)
+{
+ if (IsEqualIID(riid, &POLID_TurnOffSPIAnimations) && (TaskbarCenter_ShouldCenter(dwOldTaskbarAl) || TaskbarCenter_ShouldCenter(dwMMOldTaskbarAl)))
+ {
+ DWORD flOldProtect = 0;
+ if (!bTaskbarCenterHasPatchedSHWindowsPolicy && *((unsigned char*)_ReturnAddress() + 7) == 0x0F)
+ {
+ if (*((unsigned char*)_ReturnAddress() + 8) == 0x85 && VirtualProtect((unsigned char*)_ReturnAddress() + 9, 1, PAGE_EXECUTE_READWRITE, &flOldProtect))
+ {
+ *((unsigned char*)_ReturnAddress() + 9) += 2;
+ VirtualProtect((unsigned char*)_ReturnAddress() + 9, 1, flOldProtect, &flOldProtect);
+ }
+ else if (*((unsigned char*)_ReturnAddress() + 8) == 0x84 && VirtualProtect((unsigned char*)_ReturnAddress() + 13, 2, PAGE_EXECUTE_READWRITE, &flOldProtect))
+ {
+ *((unsigned char*)_ReturnAddress() + 13) += 0x90;
+ *((unsigned char*)_ReturnAddress() + 13) += 0x90;
+ VirtualProtect((unsigned char*)_ReturnAddress() + 13, 2, flOldProtect, &flOldProtect);
+ }
+ bTaskbarCenterHasPatchedSHWindowsPolicy = TRUE;
+ }
+ return 1;
+ }
+ return SHWindowsPolicy(riid);
}
\ No newline at end of file
diff --git a/ExplorerPatcher/TaskbarCenter.h b/ExplorerPatcher/TaskbarCenter.h
index c8b970a..3ad6edb 100644
--- a/ExplorerPatcher/TaskbarCenter.h
+++ b/ExplorerPatcher/TaskbarCenter.h
@@ -39,4 +39,6 @@ inline BOOL TaskbarCenter_ShouldLeftAlignWhenSpaceConstrained(DWORD dwSetting)
}
BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect);
+
+BOOL TaskbarCenter_SHWindowsPolicy(REFIID riid);
#endif
\ No newline at end of file
diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c
index bff2548..85cc513 100644
--- a/ExplorerPatcher/dllmain.c
+++ b/ExplorerPatcher/dllmain.c
@@ -147,6 +147,7 @@ int Code = 0;
HRESULT InjectStartFromExplorer();
void InvokeClockFlyout();
void WINAPI Explorer_RefreshUI(int unused);
+int (*SHWindowsPolicy)(REFIID);
#define ORB_STYLE_WINDOWS10 0
#define ORB_STYLE_WINDOWS11 1
@@ -9164,8 +9165,9 @@ DWORD Inject(BOOL bIsExplorer)
}
-#ifdef USE_PRIVATE_INTERFACES
HANDLE hShcore = LoadLibraryW(L"shcore.dll");
+ SHWindowsPolicy = GetProcAddress(hShcore, (LPCSTR)190);
+#ifdef USE_PRIVATE_INTERFACES
explorer_SHCreateStreamOnModuleResourceWFunc = GetProcAddress(hShcore, (LPCSTR)109);
VnPatchIAT(hExplorer, "shcore.dll", (LPCSTR)0x6D, explorer_SHCreateStreamOnModuleResourceWHook);
#endif
@@ -9620,14 +9622,9 @@ DWORD Inject(BOOL bIsExplorer)
- if (VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "GetClientRect", TaskbarCenter_GetClientRectHook))
- {
- printf("Initialized taskbar centering module.\n");
- }
- else
- {
- printf("Failed to initialize taskbar centering module.\n");
- }
+ VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "GetClientRect", TaskbarCenter_GetClientRectHook);
+ VnPatchIAT(hExplorer, "SHCORE.dll", (LPCSTR)190, TaskbarCenter_SHWindowsPolicy);
+ printf("Initialized taskbar centering module.\n");