Browse Source

Taskbar10: Allow search box (without highlights) on Windows 11

pull/2940/merge
Amrsatrio 2 years ago
parent
commit
0157ecc330
  1. 12
      ExplorerPatcher/TaskbarCenter.c
  2. 57
      ExplorerPatcher/dllmain.c
  3. 37
      ExplorerPatcher/utility.c
  4. 2
      ExplorerPatcher/utility.h
  5. 5
      ep_gui/resources/settings.reg

12
ExplorerPatcher/TaskbarCenter.c

@ -146,7 +146,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -146,7 +146,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
GetClientRect(hWndStart, &rcStart);
HWND hTrayButton = NULL;
wchar_t* pCn = L"TrayButton";
if (!IsWindows11() && dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
{
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;
@ -188,7 +188,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -188,7 +188,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
DWORD dwDim = (rcTrayButton.right - rcTrayButton.left);
HWND hTrayButton = NULL;
wchar_t* pCn = L"TrayButton";
if (!IsWindows11() && dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
{
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;
@ -210,7 +210,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -210,7 +210,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
DWORD dwDim = (rcTrayButton.bottom - rcTrayButton.top);
HWND hTrayButton = NULL;
wchar_t* pCn = L"TrayButton";
if (!IsWindows11() && dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
{
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;
@ -330,7 +330,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -330,7 +330,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
DWORD dwDim = (rcTrayButton.right - rcTrayButton.left);
HWND hTrayButton = NULL;
wchar_t* pCn = L"TrayButton";
if (!IsWindows11() && dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
{
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;
@ -352,7 +352,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -352,7 +352,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
DWORD dwDim = (rcTrayButton.bottom - rcTrayButton.top);
HWND hTrayButton = NULL;
wchar_t* pCn = L"TrayButton";
if (!IsWindows11() && dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
{
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;
@ -474,7 +474,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -474,7 +474,7 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
DWORD dwDim = bIsTaskbarHorizontal ? (rcTrayButton.right - rcTrayButton.left) : (rcTrayButton.bottom - rcTrayButton.top);
HWND hTrayButton = NULL;
wchar_t* pCn = L"TrayButton";
if (!IsWindows11() && dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
if (/*!IsWindows11() &&*/ dwSearchboxTaskbarMode == 2) pCn = L"TrayDummySearchControl";
while (hTrayButton = FindWindowExW(hWndTaskbar, hTrayButton, pCn, NULL))
{
if (pCn == L"TrayButton" && !IsWindowVisible(hTrayButton)) continue;

57
ExplorerPatcher/dllmain.c

@ -3837,7 +3837,6 @@ BOOL WINAPI DisableImmersiveMenus_SystemParametersInfoW( @@ -3837,7 +3837,6 @@ BOOL WINAPI DisableImmersiveMenus_SystemParametersInfoW(
{
if (bDisableImmersiveContextMenu && uiAction == SPI_GETSCREENREADER)
{
printf("SystemParametersInfoW\n");
*(BOOL*)pvParam = TRUE;
return TRUE;
}
@ -7399,6 +7398,43 @@ void Explorer_RefreshClock(int unused) @@ -7399,6 +7398,43 @@ void Explorer_RefreshClock(int unused)
} while (hWnd);
}
void* TrayUI__UpdatePearlSizeFunc;
void UpdateSearchBox()
{
#ifdef _WIN64
if (!IsWindows11Version22H2OrHigher())
return;
if (!TrayUI__UpdatePearlSizeFunc)
return;
PBYTE searchBegin = TrayUI__UpdatePearlSizeFunc;
// 0F 84 ?? ?? ?? ?? 48 8B 81 ?? ?? ?? ?? 48 85 C0 74 04
PBYTE match = FindPattern(
searchBegin,
256,
"\x0F\x84\x00\x00\x00\x00\x48\x8B\x81\x00\x00\x00\x00\x48\x85\xC0\x74\x04",
"xx????xxx????xxxxx"
);
if (match)
{
PBYTE overwriteBegin = match + 18;
DWORD dwOldProtect;
if (VirtualProtect(overwriteBegin, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect))
{
// Overwrite right after the pattern with
// mov byte ptr [rax+58h], 0 // C6 40 58 00
overwriteBegin[0] = 0xC6;
overwriteBegin[1] = 0x40;
overwriteBegin[2] = 0x58; // Offset to m_bEnabled
overwriteBegin[3] = dwSearchboxTaskbarMode == 2 && !dwTaskbarSmallIcons; // Enable the search box?
VirtualProtect(overwriteBegin, 4, dwOldProtect, &dwOldProtect);
}
}
#endif
}
int numTBButtons = 0;
void WINAPI Explorer_RefreshUI(int src)
{
@ -7499,6 +7535,7 @@ void WINAPI Explorer_RefreshUI(int src) @@ -7499,6 +7535,7 @@ void WINAPI Explorer_RefreshUI(int src)
{
dwSearchboxTaskbarMode = dwTemp;
dwRefreshMask |= REFRESHUI_CENTER;
UpdateSearchBox();
}
}
}
@ -9058,7 +9095,7 @@ LSTATUS explorer_RegGetValueW( @@ -9058,7 +9095,7 @@ LSTATUS explorer_RegGetValueW(
lRes = RegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
}
if (IsWindows11() && !lstrcmpW(lpValue, L"SearchboxTaskbarMode"))
/*if (IsWindows11() && !lstrcmpW(lpValue, L"SearchboxTaskbarMode"))
{
if (*(DWORD*)pvData)
{
@ -9066,7 +9103,7 @@ LSTATUS explorer_RegGetValueW( @@ -9066,7 +9103,7 @@ LSTATUS explorer_RegGetValueW(
}
lRes = ERROR_SUCCESS;
}
}*/
return lRes;
}
@ -12181,6 +12218,16 @@ DWORD Inject(BOOL bIsExplorer) @@ -12181,6 +12218,16 @@ DWORD Inject(BOOL bIsExplorer)
}
}
// Enable Windows 10 taskbar search box on 22621+
if (IsWindows11Version22H2OrHigher())
{
if (symbols_PTRS.explorer_PTRS[8] && symbols_PTRS.explorer_PTRS[8] != 0xFFFFFFFF)
{
TrayUI__UpdatePearlSizeFunc = (PBYTE)hExplorer + symbols_PTRS.explorer_PTRS[8];
}
UpdateSearchBox();
}
HANDLE hShcore = LoadLibraryW(L"shcore.dll");
SHWindowsPolicy = GetProcAddress(hShcore, (LPCSTR)190);
#ifdef USE_PRIVATE_INTERFACES
@ -12695,7 +12742,7 @@ DWORD Inject(BOOL bIsExplorer) @@ -12695,7 +12742,7 @@ DWORD Inject(BOOL bIsExplorer)
}
}
if (IsWindows11Version22H2OrHigher() && bOldTaskbar)
/*if (IsWindows11Version22H2OrHigher() && bOldTaskbar)
{
DWORD dwRes = 1;
DWORD dwSize = sizeof(DWORD);
@ -12703,7 +12750,7 @@ DWORD Inject(BOOL bIsExplorer) @@ -12703,7 +12750,7 @@ DWORD Inject(BOOL bIsExplorer)
{
RegSetKeyValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Search", L"SearchboxTaskbarMode", REG_DWORD, &dwRes, sizeof(DWORD));
}
}
}*/
/*

37
ExplorerPatcher/utility.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "utility.h"
#include <Wininet.h>
#pragma comment(lib, "Wininet.lib")
#include <TlHelp32.h>
RTL_OSVERSIONINFOW global_rovi;
DWORD32 global_ubr;
@ -1535,6 +1536,42 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve @@ -1535,6 +1536,42 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve
return TRUE;
}
DWORD GetProcessIdByExeName(LPCWSTR wszProcessName)
{
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap != INVALID_HANDLE_VALUE)
{
PROCESSENTRY32W pe;
pe.dwSize = sizeof(pe);
BOOL bRet = Process32FirstW(hSnap, &pe);
while (bRet)
{
if (!_wcsicmp(pe.szExeFile, wszProcessName))
{
CloseHandle(hSnap);
return pe.th32ProcessID;
}
bRet = Process32NextW(hSnap, &pe);
}
CloseHandle(hSnap);
}
return 0;
}
void KillProcess(LPCWSTR wszProcessName)
{
DWORD dwProcessId = GetProcessIdByExeName(wszProcessName);
if (!dwProcessId)
return;
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (hProcess)
{
TerminateProcess(hProcess, 1);
CloseHandle(hProcess);
}
}
#ifdef _WIN64
inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask)
{

2
ExplorerPatcher/utility.h

@ -666,6 +666,8 @@ typedef struct _MonitorOverrideData @@ -666,6 +666,8 @@ typedef struct _MonitorOverrideData
} MonitorOverrideData;
BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod);
DWORD GetProcessIdByExeName(LPCWSTR wszProcessName);
void KillProcess(LPCWSTR wszProcessName);
#ifdef _WIN64
PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask);

5
ep_gui/resources/settings.reg

@ -40,7 +40,10 @@ @@ -40,7 +40,10 @@
"TaskbarDa"=dword:00000000
;g Taskbar_CortanaButtonSection
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search]
;b %R:1018%
;c 3 %R:1019%
;x 0 %R:1020%
;x 1 %R:1021%
;x 2 %R:1022%
"SearchboxTaskbarMode"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
;b %R:1024%

Loading…
Cancel
Save