diff --git a/ExplorerPatcher/ExplorerPatcher.rc b/ExplorerPatcher/ExplorerPatcher.rc index 63dedf0..1af2499 100644 --- a/ExplorerPatcher/ExplorerPatcher.rc +++ b/ExplorerPatcher/ExplorerPatcher.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 22000,168,0,12 - PRODUCTVERSION 22000,168,0,12 + FILEVERSION 22000,168,0,15 + PRODUCTVERSION 22000,168,0,15 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "VALINET Solutions SRL" VALUE "FileDescription", "ExplorerPatcher" - VALUE "FileVersion", "22000.168.0.12" + VALUE "FileVersion", "22000.168.0.15" VALUE "InternalName", "ExplorerPatcher.dll" VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved." VALUE "OriginalFilename", "ExplorerPatcher.dll" VALUE "ProductName", "ExplorerPatcher" - VALUE "ProductVersion", "22000.168.0.12" + VALUE "ProductVersion", "22000.168.0.15" END END BLOCK "VarFileInfo" diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 5c49e03..fb051d8 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -70,7 +70,8 @@ DEFINE_GUID(__uuidof_IAuthUILogonSound, #define TWINUI_PCSHELL_SB_4 "CLauncherTipContextMenu::_ExecuteShutdownCommand" #define TWINUI_PCSHELL_SB_5 "CLauncherTipContextMenu::_ExecuteCommand" #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_0 "CImmersiveHotkeyNotification::_GetMonitorForHotkeyNotification" #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_4, TWINUI_PCSHELL_SB_5, - TWINUI_PCSHELL_SB_6 + TWINUI_PCSHELL_SB_6, + TWINUI_PCSHELL_SB_7 }; const char* twinui_SN[TWINUI_SB_CNT] = { 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)( void* _this, @@ -505,28 +512,27 @@ static BOOL(*TrackPopupMenuFunc)( -static char(*ContextMenuPresenter_DoContextMenuFunc)( - char* _this, +static INT64(*ContextMenuPresenter_DoContextMenuFunc)( + void* _this, INT64 a2, INT a3, void* a4 ); -char ContextMenuPresenter_DoContextMenuHook( - char* _this, +INT64 ContextMenuPresenter_DoContextMenuHook( + void* _this, INT64 a2, INT a3, void* a4 ) { *(((char*)_this + 156)) = 0; - ContextMenuPresenter_DoContextMenuFunc( + return ContextMenuPresenter_DoContextMenuFunc( _this, a2, a3, a4 ); - return 1; } @@ -1091,24 +1097,9 @@ DWORD ShowLauncherTipContextMenu( return 0; } -POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight) +HWND GetMonitorInfoFromPointForTaskbarFlyoutActivation(POINT ptCursor, DWORD dwFlags, LPMONITORINFO lpMi) { - if (lpBottom) *lpBottom = FALSE; - 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 - ); + HMONITOR hMonitor = MonitorFromPoint(ptCursor, dwFlags); HWND hWnd = NULL; do { @@ -1118,8 +1109,18 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight) L"Shell_SecondaryTrayWnd", NULL ); - if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == hMonitor) + if (MonitorFromWindow(hWnd, dwFlags) == hMonitor) { + if (lpMi) + { + GetMonitorInfo( + MonitorFromPoint( + ptCursor, + dwFlags + ), + lpMi + ); + } break; } } while (hWnd); @@ -1133,14 +1134,36 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight) ); ptCursor.x = 0; ptCursor.y = 0; - GetMonitorInfo( - MonitorFromPoint( - ptCursor, - MONITOR_DEFAULTTOPRIMARY - ), - &mi - ); + if (lpMi) + { + GetMonitorInfo( + MonitorFromPoint( + ptCursor, + 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) { RECT rc; @@ -1218,6 +1241,52 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight) 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( void* _this, POINT* pt @@ -1654,11 +1723,47 @@ DWORD PlayStartupSound(DWORD unused) return 0; } -DWORD SignalShellReady(DWORD unused) +DWORD SignalShellReady(DWORD wait) { - Sleep(2000); + if (wait) + { + Sleep(wait); + } + 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"); if (hEvent) { @@ -1966,6 +2071,12 @@ DWORD DownloadSymbols(TCHAR* wszSettingsPath) symbols_PTRS.twinui_pcshell_PTRS[6], 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, 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( TEXT(TWINUI_SB_NAME), @@ -3185,6 +3302,19 @@ __declspec(dllexport) DWORD WINAPI main( FreeLibraryAndExitThread(hModule, 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"); @@ -3244,7 +3374,7 @@ __declspec(dllexport) DWORD WINAPI main( LoadLibraryW(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]); UINT bAllowImmersiveContextMenus = VnGetUInt( L"General", @@ -3308,11 +3438,17 @@ __declspec(dllexport) DWORD WINAPI main( + UINT delay = VnGetUInt( + TEXT("General"), + TEXT("ExplorerReadyDelay"), + 0, + wszSettingsPath + ); CreateThread( 0, 0, SignalShellReady, - 0, + delay, 0, 0 );