Browse Source

Taskbar notification: Hardened event name, proper detection of existing instance

pull/51/head
Valentin Radu 4 years ago
parent
commit
9e9f958057
  1. 10
      ExplorerPatcher/TaskbarCenter.c
  2. 2
      ExplorerPatcher/TaskbarCenter.h

10
ExplorerPatcher/TaskbarCenter.c

@ -17,7 +17,7 @@ BOOL GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -17,7 +17,7 @@ BOOL GetClientRectHook(HWND hWnd, LPRECT lpRect)
wchar_t wszClassName[100];
ZeroMemory(wszClassName, 100);
GetClassNameW(hWnd, wszClassName, 100);
if (!wcscmp(wszClassName, L"Shell_TrayWnd") || !wcscmp(wszClassName, L"Shell_SecondaryTrayWnd"))
if (!wcscmp(wszClassName, L"MSTaskListWClass"))
{
TaskbarCenter_Notify();
}
@ -26,16 +26,16 @@ BOOL GetClientRectHook(HWND hWnd, LPRECT lpRect) @@ -26,16 +26,16 @@ BOOL GetClientRectHook(HWND hWnd, LPRECT lpRect)
HRESULT TaskbarCenter_Initialize(HMODULE hExplorer)
{
// This is one of the methods called by explorer!CTaskListWnd::_RecomputeLayout
if (!VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "GetClientRect", GetClientRectHook))
if (!(hEvent = CreateEventW(NULL, TRUE, FALSE, TASKBAR_CHANGED_NOTIFICATION)))
{
return E_NOTIMPL;
}
if (!(hEvent = CreateEventW(NULL, TRUE, FALSE, TASKBAR_CHANGED_NOTIFICATION)))
if (FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL))
{
return E_NOTIMPL;
}
if (GetLastError() == ERROR_ALREADY_EXISTS)
// This is one of the methods called by explorer!CTaskListWnd::_RecomputeLayout
if (!VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "GetClientRect", GetClientRectHook))
{
return E_NOTIMPL;
}

2
ExplorerPatcher/TaskbarCenter.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#include <Windows.h>
#include <valinet/hooking/iatpatch.h>
#define TASKBAR_CHANGED_NOTIFICATION L"Global\\ExplorerPatcher_TaskbarChangedNotification"
#define TASKBAR_CHANGED_NOTIFICATION L"Global\\ExplorerPatcher_TaskbarChangedNotification_{B37553B7-425C-44F6-A04A-126849EE59CB}"
HRESULT TaskbarCenter_Initialize(HMODULE);
#endif
Loading…
Cancel
Save