Browse Source

Taskbar10: Centered taskbar works in remote sessions and when animations are turned off system-wide

pull/1080/head
Valentin Radu 4 years ago
parent
commit
a7ab5287c6
  1. 5
      ExplorerPatcher/ExplorerPatcher.vcxproj
  2. 28
      ExplorerPatcher/TaskbarCenter.c
  3. 2
      ExplorerPatcher/TaskbarCenter.h
  4. 15
      ExplorerPatcher/dllmain.c

5
ExplorerPatcher/ExplorerPatcher.vcxproj

@ -259,7 +259,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="lvt.c" /> <ClCompile Include="lvt.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="SettingsMonitor.c" /> <ClCompile Include="SettingsMonitor.c" />
<ClCompile Include="StartMenu.c"> <ClCompile Include="StartMenu.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>

28
ExplorerPatcher/TaskbarCenter.c

@ -1,11 +1,14 @@
#include "TaskbarCenter.h" #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 HWND PeopleButton_LastHWND;
extern DWORD dwWeatherToLeft; extern DWORD dwWeatherToLeft;
extern DWORD dwOldTaskbarAl; extern DWORD dwOldTaskbarAl;
extern DWORD dwMMOldTaskbarAl; extern DWORD dwMMOldTaskbarAl;
extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME; extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME;
#define EP_TASKBAR_LENGTH_TOO_SMALL 20 #define EP_TASKBAR_LENGTH_TOO_SMALL 20
BOOL bTaskbarCenterHasPatchedSHWindowsPolicy = FALSE;
HRESULT TaskbarCenter_Center(HWND hWnd, HWND hWndTaskbar, RECT rc, BOOL bIsTaskbarHorizontal) 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; if (bWasCalled) return bWasCalled;
return GetClientRect(hWnd, lpRect); 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);
} }

2
ExplorerPatcher/TaskbarCenter.h

@ -39,4 +39,6 @@ inline BOOL TaskbarCenter_ShouldLeftAlignWhenSpaceConstrained(DWORD dwSetting)
} }
BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect); BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect);
BOOL TaskbarCenter_SHWindowsPolicy(REFIID riid);
#endif #endif

15
ExplorerPatcher/dllmain.c

@ -147,6 +147,7 @@ int Code = 0;
HRESULT InjectStartFromExplorer(); HRESULT InjectStartFromExplorer();
void InvokeClockFlyout(); void InvokeClockFlyout();
void WINAPI Explorer_RefreshUI(int unused); void WINAPI Explorer_RefreshUI(int unused);
int (*SHWindowsPolicy)(REFIID);
#define ORB_STYLE_WINDOWS10 0 #define ORB_STYLE_WINDOWS10 0
#define ORB_STYLE_WINDOWS11 1 #define ORB_STYLE_WINDOWS11 1
@ -9164,8 +9165,9 @@ DWORD Inject(BOOL bIsExplorer)
} }
#ifdef USE_PRIVATE_INTERFACES
HANDLE hShcore = LoadLibraryW(L"shcore.dll"); HANDLE hShcore = LoadLibraryW(L"shcore.dll");
SHWindowsPolicy = GetProcAddress(hShcore, (LPCSTR)190);
#ifdef USE_PRIVATE_INTERFACES
explorer_SHCreateStreamOnModuleResourceWFunc = GetProcAddress(hShcore, (LPCSTR)109); explorer_SHCreateStreamOnModuleResourceWFunc = GetProcAddress(hShcore, (LPCSTR)109);
VnPatchIAT(hExplorer, "shcore.dll", (LPCSTR)0x6D, explorer_SHCreateStreamOnModuleResourceWHook); VnPatchIAT(hExplorer, "shcore.dll", (LPCSTR)0x6D, explorer_SHCreateStreamOnModuleResourceWHook);
#endif #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)) 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"); printf("Initialized taskbar centering module.\n");
}
else
{
printf("Failed to initialize taskbar centering module.\n");
}

Loading…
Cancel
Save