1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-27 17:00:59 +01:00

Taskbar10: Add support for loading ep_taskbar on Windows 10 1904x

This commit is contained in:
Amrsatrio 2024-09-01 01:30:30 +07:00
parent 3c50ea3c68
commit a8bd290977
5 changed files with 72 additions and 33 deletions

View File

@ -9944,10 +9944,6 @@ BOOL CheckExplorerSymbols(symbols_addr* symbols_PTRS)
const WCHAR* GetTaskbarDllChecked(symbols_addr* symbols_PTRS) const WCHAR* GetTaskbarDllChecked(symbols_addr* symbols_PTRS)
{ {
if (!IsWindows11Version22H2OrHigher())
{
return NULL;
}
const WCHAR* pszTaskbarDll = PickTaskbarDll(); const WCHAR* pszTaskbarDll = PickTaskbarDll();
if (!pszTaskbarDll) if (!pszTaskbarDll)
{ {
@ -10001,7 +9997,25 @@ HMODULE PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const
return NULL; return NULL;
} }
explorer_TrayUI_CreateInstanceFunc = GetProcAddress(hMyTaskbar, "EP_TrayUI_CreateInstance"); TrayUI_CreateInstance_t pfnMyTrayUICreateInstance = (TrayUI_CreateInstance_t)GetProcAddress(hMyTaskbar, "EP_TrayUI_CreateInstance");
if (IsWindows11())
{
explorer_TrayUI_CreateInstanceFunc = pfnMyTrayUICreateInstance;
}
else if (explorer_TrayUI_CreateInstanceFunc)
{
funchook_prepare(
funchook,
(void**)&explorer_TrayUI_CreateInstanceFunc,
pfnMyTrayUICreateInstance
);
}
else
{
printf("[TB] Failed to hook TrayUI_CreateInstance()\n");
FreeLibrary(hMyTaskbar);
return NULL;
}
typedef void (*CopyExplorerSymbols_t)(symbols_addr* symbols); typedef void (*CopyExplorerSymbols_t)(symbols_addr* symbols);
CopyExplorerSymbols_t CopyExplorerSymbols = (CopyExplorerSymbols_t)GetProcAddress(hMyTaskbar, "CopyExplorerSymbols"); CopyExplorerSymbols_t CopyExplorerSymbols = (CopyExplorerSymbols_t)GetProcAddress(hMyTaskbar, "CopyExplorerSymbols");
@ -10603,8 +10617,8 @@ DWORD Inject(BOOL bIsExplorer)
{ {
// Find pointers to various stuff needed to have a working Windows 10 taskbar and Windows 10 taskbar context menu on Windows 11 taskbar // Find pointers to various stuff needed to have a working Windows 10 taskbar and Windows 10 taskbar context menu on Windows 11 taskbar
#if defined(_M_X64) #if defined(_M_X64)
// 4C 8D 05 ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? 48 8B // 4C 8D 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B
// ^^^^^^^ ^^^^^^^ // ^^^^^^^^^^^ ^^^^^^^^^^^
// Ref: CTray::Init() // Ref: CTray::Init()
PBYTE match = FindPattern( PBYTE match = FindPattern(
hExplorer, hExplorer,
@ -10615,30 +10629,43 @@ DWORD Inject(BOOL bIsExplorer)
if (match) if (match)
{ {
match += 7; // Point to 48 match += 7; // Point to 48
g_pTrayUIHost = match + 7 + *(int*)(match + 3); g_pTrayUIHost = (ITrayUIHost*)(match + 7 + *(int*)(match + 3));
match += 7; // Point to E8 match += 7; // Point to E8
explorer_TrayUI_CreateInstanceFunc = match + 5 + *(int*)(match + 1); explorer_TrayUI_CreateInstanceFunc = (TrayUI_CreateInstance_t)(match + 5 + *(int*)(match + 1));
} }
#elif defined(_M_ARM64) #elif defined(_M_ARM64)
// TODO Add support for ARM64 // TODO Add support for ARM64
#endif #endif
}
else
{
#if defined(_M_X64)
// 4C 8D 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 85 C0
// ^^^^^^^^^^^ ^^^^^^^^^^^
// Ref: CTray::Init()
PBYTE match = FindPattern(
hExplorer,
miExplorer.SizeOfImage,
"\x4C\x8D\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x85\xC0",
"xxx????xxx????x????xx"
);
if (match)
{
match += 7; // Point to 48
g_pTrayUIHost = (ITrayUIHost*)(match + 7 + *(int*)(match + 3));
match += 7; // Point to E8
explorer_TrayUI_CreateInstanceFunc = (TrayUI_CreateInstance_t)(match + 5 + *(int*)(match + 1));
}
#endif
}
if (g_pTrayUIHost) if (g_pTrayUIHost)
{ {
printf("ITrayUIHost = %llX\n", (PBYTE)g_pTrayUIHost - (PBYTE)hExplorer); printf("ITrayUIHost = %llX\n", (PBYTE)g_pTrayUIHost - (PBYTE)hExplorer);
} }
else if (explorer_TrayUI_CreateInstanceFunc)
{
printf("Failed to find ITrayUIHost\n");
}
if (explorer_TrayUI_CreateInstanceFunc) // TODO This does not exist anymore in 26244+
{ {
printf("explorer.exe!TrayUI_CreateInstance() = %llX\n", (PBYTE)explorer_TrayUI_CreateInstanceFunc - (PBYTE)hExplorer); printf("explorer.exe!TrayUI_CreateInstance() = %llX\n", (PBYTE)explorer_TrayUI_CreateInstanceFunc - (PBYTE)hExplorer);
} }
else
{
printf("Failed to find explorer.exe!TrayUI_CreateInstance()\n");
}
}
// Enable Windows 10 taskbar search box on 22621+ // Enable Windows 10 taskbar search box on 22621+
if (IsWindows11Version22H2OrHigher()) if (IsWindows11Version22H2OrHigher())

View File

@ -13,6 +13,7 @@ void printf_guid(GUID guid)
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
} }
#ifdef _DEBUG
LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
if (msg == WM_CREATE) if (msg == WM_CREATE)
@ -82,7 +83,6 @@ __declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance,
return 0; return 0;
} }
#ifdef _DEBUG
const wchar_t TestToastXML[] = const wchar_t TestToastXML[] =
L"<toast scenario=\"reminder\" " L"<toast scenario=\"reminder\" "
L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"%s\">\r\n" L"activationType=\"protocol\" launch=\"https://github.com/valinet/ExplorerPatcher\" duration=\"%s\">\r\n"
@ -138,7 +138,7 @@ __declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, L
} }
#endif #endif
__declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) /*__declspec(dllexport)*/ int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{ {
Sleep(100); Sleep(100);
TCHAR wszExplorerPath[MAX_PATH + 1]; TCHAR wszExplorerPath[MAX_PATH + 1];
@ -170,14 +170,14 @@ __declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstan
return 0; return 0;
} }
__declspec(dllexport) int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) /*__declspec(dllexport)*/ int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{ {
Sleep(2000); Sleep(2000);
ZZLaunchExplorer(hWnd, hInstance, lpszCmdLine, nCmdShow); ZZLaunchExplorer(hWnd, hInstance, lpszCmdLine, nCmdShow);
return 0; return 0;
} }
__declspec(dllexport) int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) /*__declspec(dllexport)*/ int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{ {
BeginExplorerRestart(NULL); BeginExplorerRestart(NULL);
FinishExplorerRestart(); FinishExplorerRestart();

View File

@ -104,7 +104,8 @@ DEFINE_GUID(IID_ITrayUIComponent,
0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b 0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b
); );
EP_INLINE HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv); typedef HRESULT(*TrayUI_CreateInstance_t)(ITrayUIHost* host, REFIID riid, void** ppv);
EP_INLINE TrayUI_CreateInstance_t explorer_TrayUI_CreateInstanceFunc;
#pragma endregion #pragma endregion
inline int FileExistsW(wchar_t* file) inline int FileExistsW(wchar_t* file)
@ -122,19 +123,19 @@ inline int FileExistsW(wchar_t* file)
// https://stackoverflow.com/questions/1672677/print-a-guid-variable // https://stackoverflow.com/questions/1672677/print-a-guid-variable
void printf_guid(GUID guid); void printf_guid(GUID guid);
#ifdef _DEBUG
LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK BalloonWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
__declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); __declspec(dllexport) int CALLBACK ZZTestBalloon(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
#ifdef _DEBUG
__declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); __declspec(dllexport) int CALLBACK ZZTestToast(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
#endif #endif
__declspec(dllexport) int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); /*__declspec(dllexport)*/ int CALLBACK ZZLaunchExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); /*__declspec(dllexport)*/ int CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
__declspec(dllexport) int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow); /*__declspec(dllexport)*/ int CALLBACK ZZRestartExplorer(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow);
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
@ -941,6 +942,16 @@ inline const WCHAR* PickTaskbarDll()
{ {
DWORD b = global_rovi.dwBuildNumber; DWORD b = global_rovi.dwBuildNumber;
if (b >= 19041 && b <= 19045) // Windows 10 20H2, 21H2, 22H2
{
return L"ep_taskbar.0.dll";
}
if (b >= 21343 && b <= 22000) // Windows 11 21H2
{
return L"ep_taskbar.1.dll";
}
if ((b >= 22621 && b <= 22635) // 22H2-23H2 Release, Release Preview, and Beta channels if ((b >= 22621 && b <= 22635) // 22H2-23H2 Release, Release Preview, and Beta channels
|| (b >= 23403 && b <= 25197)) // Early pre-reboot Dev channel until post-reboot Dev channel || (b >= 23403 && b <= 25197)) // Early pre-reboot Dev channel until post-reboot Dev channel
{ {

View File

@ -825,6 +825,7 @@ BOOL DownloadResource(BOOL bInstall, LPCWSTR pwszURL, DWORD dwSize, LPCSTR chash
void ProcessTaskbarDlls(BOOL* bInOutOk, BOOL bInstall, BOOL bExtractMode, HINSTANCE hInstance, unzFile zipFile, WCHAR wszPath[260]) void ProcessTaskbarDlls(BOOL* bInOutOk, BOOL bInstall, BOOL bExtractMode, HINSTANCE hInstance, unzFile zipFile, WCHAR wszPath[260])
{ {
LPCWSTR pwszTaskbarDllName = bExtractMode ? NULL : PickTaskbarDll(); LPCWSTR pwszTaskbarDllName = bExtractMode ? NULL : PickTaskbarDll();
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.0.dll")), hInstance, zipFile, "ep_taskbar.0.dll", wszPath, L"ep_taskbar.0.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.2.dll")), hInstance, zipFile, "ep_taskbar.2.dll", wszPath, L"ep_taskbar.2.dll"); if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.2.dll")), hInstance, zipFile, "ep_taskbar.2.dll", wszPath, L"ep_taskbar.2.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.3.dll")), hInstance, zipFile, "ep_taskbar.3.dll", wszPath, L"ep_taskbar.3.dll"); if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.3.dll")), hInstance, zipFile, "ep_taskbar.3.dll", wszPath, L"ep_taskbar.3.dll");
if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.4.dll")), hInstance, zipFile, "ep_taskbar.4.dll", wszPath, L"ep_taskbar.4.dll"); if (*bInOutOk) *bInOutOk = InstallResource(bInstall && (bExtractMode || pwszTaskbarDllName && !wcscmp(pwszTaskbarDllName, L"ep_taskbar.4.dll")), hInstance, zipFile, "ep_taskbar.4.dll", wszPath, L"ep_taskbar.4.dll");