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)
Valentin Radu 4 years ago
parent
commit
d79dfcd8b9
  1. 8
      ExplorerPatcher/ExplorerPatcher.rc
  2. 161
      ExplorerPatcher/dllmain.c
  3. 36
      configs/22000.168/settings.ini

8
ExplorerPatcher/ExplorerPatcher.rc

@ -51,8 +51,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 22000,168,0,14 FILEVERSION 22000,168,0,15
PRODUCTVERSION 22000,168,0,14 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.14" 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.14" VALUE "ProductVersion", "22000.168.0.15"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

161
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,
@ -1090,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
{ {
@ -1117,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);
@ -1132,14 +1134,36 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight)
); );
ptCursor.x = 0; ptCursor.x = 0;
ptCursor.y = 0; ptCursor.y = 0;
if (lpMi)
{
GetMonitorInfo( GetMonitorInfo(
MonitorFromPoint( MonitorFromPoint(
ptCursor, ptCursor,
MONITOR_DEFAULTTOPRIMARY dwFlags
), ),
&mi 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;
@ -1217,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
@ -1653,11 +1723,16 @@ DWORD PlayStartupSound(DWORD unused)
return 0; return 0;
} }
DWORD SignalShellReady(DWORD unused) DWORD SignalShellReady(DWORD wait)
{ {
if (wait)
{
Sleep(wait);
}
printf("Started \"Signal shell ready\" thread.\n"); printf("Started \"Signal shell ready\" thread.\n");
while (TRUE) while (!wait && TRUE)
{ {
HWND hWnd = FindWindowEx( HWND hWnd = FindWindowEx(
NULL, NULL,
@ -1684,7 +1759,10 @@ DWORD SignalShellReady(DWORD unused)
Sleep(100); Sleep(100);
} }
Sleep(300); if (!wait)
{
Sleep(600);
}
HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent"); HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent");
if (hEvent) if (hEvent)
@ -1993,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
);
@ -2630,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),
@ -3212,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");
@ -3335,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
); );

36
configs/22000.168/settings.ini

@ -1,36 +0,0 @@
[explorer]
CTray::_HandleGlobalHotkey=6992
CTray::v_WndProc=62144
CTray::_FireDesktopSwitchIfReady=160304
CTray::Init=186208
Dirty=0
Offset=472
OffsetStrat=1
OffsetOK=1
[twinui.pcshell]
CImmersiveContextMenuOwnerDrawHelper::s_ContextMenuWndProc=2183030
CLauncherTipContextMenu::GetMenuItemsAsync=6072240
ImmersiveContextMenuHelper::ApplyOwnerDrawToMenu=6242504
ImmersiveContextMenuHelper::RemoveOwnerDrawFromMenu=6244560
CLauncherTipContextMenu::_ExecuteShutdownCommand=6131272
CLauncherTipContextMenu::_ExecuteCommand=6130436
CLauncherTipContextMenu::ShowLauncherTipContextMenu=6077440
[twinui]
CImmersiveHotkeyNotification::_GetMonitorForHotkeyNotification=2411916
IsDesktopInputContext=43992
CImmersiveHotkeyNotification::OnMessage=410208
[stobject]
SysTrayWndProc=19808
HotPlugButtonClick=96336
[Windows.UI.FileExplorer]
ContextMenuPresenter::DoContextMenu=265520
[StartDocked]
Windows::UI::Core::IVisibilityChangedEventArgs::Visible::get=402004
StartDocked::LauncherFrame::ShowAllApps=1609404
StartDocked::LauncherFrame::OnVisibilityChanged=1601824
StartDocked::SystemListPolicyProvider::GetMaximumFrequentApps=15376
StartDocked::StartSizingFrame::StartSizingFrame=1444588
[Windows.UI.Xaml]
CJupiterWindow::StaticCoreWindowSubclassProc=2038048
[OS]
Build=10.0.22000.168
Loading…
Cancel
Save