Browse Source

Win+C now opens the calendar flyout (previously it opened Cortana

but since that is gone, it just crashes Explorer, so better we map
it to something useful)
pull/20/head
Valentin Radu 4 years ago
parent
commit
40ea50e19c
  1. 8
      ExplorerPatcher/ExplorerPatcher.rc
  2. 210
      ExplorerPatcher/dllmain.c

8
ExplorerPatcher/ExplorerPatcher.rc

@ -51,8 +51,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 22000,168,0,12 FILEVERSION 22000,168,0,15
PRODUCTVERSION 22000,168,0,12 PRODUCTVERSION 22000,168,0,15
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "VALINET Solutions SRL" VALUE "CompanyName", "VALINET Solutions SRL"
VALUE "FileDescription", "ExplorerPatcher" VALUE "FileDescription", "ExplorerPatcher"
VALUE "FileVersion", "22000.168.0.12" VALUE "FileVersion", "22000.168.0.15"
VALUE "InternalName", "ExplorerPatcher.dll" VALUE "InternalName", "ExplorerPatcher.dll"
VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved." VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved."
VALUE "OriginalFilename", "ExplorerPatcher.dll" VALUE "OriginalFilename", "ExplorerPatcher.dll"
VALUE "ProductName", "ExplorerPatcher" VALUE "ProductName", "ExplorerPatcher"
VALUE "ProductVersion", "22000.168.0.12" VALUE "ProductVersion", "22000.168.0.15"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

210
ExplorerPatcher/dllmain.c

@ -70,7 +70,8 @@ DEFINE_GUID(__uuidof_IAuthUILogonSound,
#define TWINUI_PCSHELL_SB_4 "CLauncherTipContextMenu::_ExecuteShutdownCommand" #define TWINUI_PCSHELL_SB_4 "CLauncherTipContextMenu::_ExecuteShutdownCommand"
#define TWINUI_PCSHELL_SB_5 "CLauncherTipContextMenu::_ExecuteCommand" #define TWINUI_PCSHELL_SB_5 "CLauncherTipContextMenu::_ExecuteCommand"
#define TWINUI_PCSHELL_SB_6 "CLauncherTipContextMenu::ShowLauncherTipContextMenu" #define TWINUI_PCSHELL_SB_6 "CLauncherTipContextMenu::ShowLauncherTipContextMenu"
#define TWINUI_PCSHELL_SB_CNT 7 #define TWINUI_PCSHELL_SB_7 "winrt::Windows::Internal::Shell::implementation::MeetAndChatManager::OnMessage"
#define TWINUI_PCSHELL_SB_CNT 8
#define TWINUI_SB_NAME "twinui" #define TWINUI_SB_NAME "twinui"
#define TWINUI_SB_0 "CImmersiveHotkeyNotification::_GetMonitorForHotkeyNotification" #define TWINUI_SB_0 "CImmersiveHotkeyNotification::_GetMonitorForHotkeyNotification"
#define TWINUI_SB_1 "IsDesktopInputContext" #define TWINUI_SB_1 "IsDesktopInputContext"
@ -106,7 +107,8 @@ const char* twinui_pcshell_SN[TWINUI_PCSHELL_SB_CNT] = {
TWINUI_PCSHELL_SB_3, TWINUI_PCSHELL_SB_3,
TWINUI_PCSHELL_SB_4, TWINUI_PCSHELL_SB_4,
TWINUI_PCSHELL_SB_5, TWINUI_PCSHELL_SB_5,
TWINUI_PCSHELL_SB_6 TWINUI_PCSHELL_SB_6,
TWINUI_PCSHELL_SB_7
}; };
const char* twinui_SN[TWINUI_SB_CNT] = { const char* twinui_SN[TWINUI_SB_CNT] = {
TWINUI_SB_0, TWINUI_SB_0,
@ -393,6 +395,11 @@ static HWND(WINAPI* CreateWindowInBand)(
); );
static INT64(*winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageFunc)(
void* _this,
INT64 a2,
INT a3
);
static INT64(*CLauncherTipContextMenu_ShowLauncherTipContextMenuFunc)( static INT64(*CLauncherTipContextMenu_ShowLauncherTipContextMenuFunc)(
void* _this, void* _this,
@ -505,28 +512,27 @@ static BOOL(*TrackPopupMenuFunc)(
static char(*ContextMenuPresenter_DoContextMenuFunc)( static INT64(*ContextMenuPresenter_DoContextMenuFunc)(
char* _this, void* _this,
INT64 a2, INT64 a2,
INT a3, INT a3,
void* a4 void* a4
); );
char ContextMenuPresenter_DoContextMenuHook( INT64 ContextMenuPresenter_DoContextMenuHook(
char* _this, void* _this,
INT64 a2, INT64 a2,
INT a3, INT a3,
void* a4 void* a4
) )
{ {
*(((char*)_this + 156)) = 0; *(((char*)_this + 156)) = 0;
ContextMenuPresenter_DoContextMenuFunc( return ContextMenuPresenter_DoContextMenuFunc(
_this, _this,
a2, a2,
a3, a3,
a4 a4
); );
return 1;
} }
@ -1091,24 +1097,9 @@ DWORD ShowLauncherTipContextMenu(
return 0; return 0;
} }
POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight) HWND GetMonitorInfoFromPointForTaskbarFlyoutActivation(POINT ptCursor, DWORD dwFlags, LPMONITORINFO lpMi)
{ {
if (lpBottom) *lpBottom = FALSE; HMONITOR hMonitor = MonitorFromPoint(ptCursor, dwFlags);
if (lpRight) *lpRight = FALSE;
POINT point, ptCursor;
point.x = 0;
point.y = 0;
GetCursorPos(&ptCursor);
HMONITOR hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi;
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(
MonitorFromPoint(
ptCursor,
MONITOR_DEFAULTTOPRIMARY
),
&mi
);
HWND hWnd = NULL; HWND hWnd = NULL;
do do
{ {
@ -1118,8 +1109,18 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight)
L"Shell_SecondaryTrayWnd", L"Shell_SecondaryTrayWnd",
NULL NULL
); );
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == hMonitor) if (MonitorFromWindow(hWnd, dwFlags) == hMonitor)
{ {
if (lpMi)
{
GetMonitorInfo(
MonitorFromPoint(
ptCursor,
dwFlags
),
lpMi
);
}
break; break;
} }
} while (hWnd); } while (hWnd);
@ -1133,14 +1134,36 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight)
); );
ptCursor.x = 0; ptCursor.x = 0;
ptCursor.y = 0; ptCursor.y = 0;
GetMonitorInfo( if (lpMi)
MonitorFromPoint( {
ptCursor, GetMonitorInfo(
MONITOR_DEFAULTTOPRIMARY MonitorFromPoint(
), ptCursor,
&mi dwFlags
); ),
lpMi
);
}
} }
return hWnd;
}
POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight)
{
if (lpBottom) *lpBottom = FALSE;
if (lpRight) *lpRight = FALSE;
POINT point;
point.x = 0;
point.y = 0;
POINT ptCursor;
GetCursorPos(&ptCursor);
MONITORINFO mi;
mi.cbSize = sizeof(MONITORINFO);
HWND hWnd = GetMonitorInfoFromPointForTaskbarFlyoutActivation(
ptCursor,
MONITOR_DEFAULTTOPRIMARY,
&mi
);
if (hWnd) if (hWnd)
{ {
RECT rc; RECT rc;
@ -1218,6 +1241,52 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight)
return point; return point;
} }
INT64 winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageHook(
void* _this,
INT64 a2,
INT a3
)
{
if (a2 == 786 && a3 == 107)
{
POINT ptCursor;
GetCursorPos(&ptCursor);
HWND hWnd = GetMonitorInfoFromPointForTaskbarFlyoutActivation(
ptCursor,
MONITOR_DEFAULTTOPRIMARY,
NULL
);
HWND prev_hWnd = hWnd;
if (hWnd)
{
hWnd = FindWindowEx(hWnd, NULL, TEXT("TrayNotifyWnd"), NULL);
if (hWnd)
{
hWnd = FindWindowEx(hWnd, NULL, TEXT("TrayClockWClass"), NULL);
}
if (!hWnd)
{
hWnd = FindWindowEx(prev_hWnd, NULL, TEXT("ClockButton"), NULL);
}
if (hWnd)
{
RECT rc;
GetWindowRect(hWnd, &rc);
HWND g_ProgWin = FindWindowEx(
NULL,
NULL,
L"Progman",
NULL
);
SetForegroundWindow(g_ProgWin);
PostMessage(hWnd, WM_LBUTTONDOWN, 0, 0);
PostMessage(hWnd, WM_LBUTTONUP, 0, 0);
}
}
}
return 0;
}
INT64 CLauncherTipContextMenu_ShowLauncherTipContextMenuHook( INT64 CLauncherTipContextMenu_ShowLauncherTipContextMenuHook(
void* _this, void* _this,
POINT* pt POINT* pt
@ -1654,11 +1723,47 @@ DWORD PlayStartupSound(DWORD unused)
return 0; return 0;
} }
DWORD SignalShellReady(DWORD unused) DWORD SignalShellReady(DWORD wait)
{ {
Sleep(2000); if (wait)
{
Sleep(wait);
}
printf("Started \"Signal shell ready\" thread.\n"); printf("Started \"Signal shell ready\" thread.\n");
while (!wait && TRUE)
{
HWND hWnd = FindWindowEx(
NULL,
NULL,
L"Shell_TrayWnd",
NULL
);
if (hWnd)
{
hWnd = FindWindowEx(
hWnd,
NULL,
L"Start",
NULL
);
if (hWnd)
{
if (IsWindowVisible(hWnd))
{
break;
}
}
}
Sleep(100);
}
if (!wait)
{
Sleep(600);
}
HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent"); HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent");
if (hEvent) if (hEvent)
{ {
@ -1966,6 +2071,12 @@ DWORD DownloadSymbols(TCHAR* wszSettingsPath)
symbols_PTRS.twinui_pcshell_PTRS[6], symbols_PTRS.twinui_pcshell_PTRS[6],
wszSettingsPath wszSettingsPath
); );
VnWriteUInt(
TEXT(TWINUI_PCSHELL_SB_NAME),
TEXT(TWINUI_PCSHELL_SB_7),
symbols_PTRS.twinui_pcshell_PTRS[7],
wszSettingsPath
);
@ -2603,6 +2714,12 @@ __declspec(dllexport) DWORD WINAPI main(
0, 0,
wszSettingsPath wszSettingsPath
); );
symbols_PTRS.twinui_pcshell_PTRS[7] = VnGetUInt(
TEXT(TWINUI_PCSHELL_SB_NAME),
TEXT(TWINUI_PCSHELL_SB_7),
0,
wszSettingsPath
);
symbols_PTRS.twinui_PTRS[0] = VnGetUInt( symbols_PTRS.twinui_PTRS[0] = VnGetUInt(
TEXT(TWINUI_SB_NAME), TEXT(TWINUI_SB_NAME),
@ -3185,6 +3302,19 @@ __declspec(dllexport) DWORD WINAPI main(
FreeLibraryAndExitThread(hModule, rv); FreeLibraryAndExitThread(hModule, rv);
return rv; return rv;
} }
winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageFunc = (INT64(*)(void*, POINT*))
((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[7]);
rv = funchook_prepare(
funchook,
(void**)&winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageFunc,
winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageHook
);
if (rv != 0)
{
FreeLibraryAndExitThread(hModule, rv);
return rv;
}
printf("Setup twinui.pcshell functions done\n"); printf("Setup twinui.pcshell functions done\n");
@ -3244,7 +3374,7 @@ __declspec(dllexport) DWORD WINAPI main(
LoadLibraryW(L"Windows.UI.FileExplorer.dll"); LoadLibraryW(L"Windows.UI.FileExplorer.dll");
HANDLE hWindowsUIFileExplorer = GetModuleHandle(L"Windows.UI.FileExplorer.dll"); HANDLE hWindowsUIFileExplorer = GetModuleHandle(L"Windows.UI.FileExplorer.dll");
ContextMenuPresenter_DoContextMenuFunc = (char(*)(void*)) ContextMenuPresenter_DoContextMenuFunc = (INT64(*)(void*, INT64, INT, void*))
((uintptr_t)hWindowsUIFileExplorer + symbols_PTRS.windowsuifileexplorer_PTRS[0]); ((uintptr_t)hWindowsUIFileExplorer + symbols_PTRS.windowsuifileexplorer_PTRS[0]);
UINT bAllowImmersiveContextMenus = VnGetUInt( UINT bAllowImmersiveContextMenus = VnGetUInt(
L"General", L"General",
@ -3308,11 +3438,17 @@ __declspec(dllexport) DWORD WINAPI main(
UINT delay = VnGetUInt(
TEXT("General"),
TEXT("ExplorerReadyDelay"),
0,
wszSettingsPath
);
CreateThread( CreateThread(
0, 0,
0, 0,
SignalShellReady, SignalShellReady,
0, delay,
0, 0,
0 0
); );

Loading…
Cancel
Save