Browse Source

Reduced symbol dependency for Win+C hook

pull/886/head 22000.434.41.10_8119c5a
Valentin Radu 4 years ago
parent
commit
8119c5aa7c
  1. 1
      CHANGELOG.md
  2. 2
      ExplorerPatcher/ExplorerPatcher.vcxproj
  3. 100
      ExplorerPatcher/dllmain.c
  4. 4
      ExplorerPatcher/settings.reg
  5. 2
      ExplorerPatcher/symbols.h
  6. 6
      version.h

1
CHANGELOG.md

@ -25,6 +25,7 @@ Tested on OS build 22000.434.
* Windows 10 (with link to "Language Preferences") * Windows 10 (with link to "Language Preferences")
* Windows 10 * Windows 10
* Simple Window Switcher now highlights windows that require user attention (windows that have their taskbar button flash and colored in orange) (.8) * Simple Window Switcher now highlights windows that require user attention (windows that have their taskbar button flash and colored in orange) (.8)
* Reliability improvements for the option that maps the `Win`+`C` shortcut to open the clock flyout instead of Microsoft Teams (eliminated dependency on symbol data) (.10)
#### Fixes #### Fixes

2
ExplorerPatcher/ExplorerPatcher.vcxproj

@ -206,6 +206,8 @@
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_error.c"> <ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_error.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>

100
ExplorerPatcher/dllmain.c

@ -162,11 +162,13 @@ HRESULT WINAPI _DllGetClassObject(
REFIID riid, REFIID riid,
LPVOID* ppv LPVOID* ppv
); );
#ifdef _WIN64
BOOL ep_dwm_StartService(LPWSTR wszServiceName, LPWSTR wszEventName); BOOL ep_dwm_StartService(LPWSTR wszServiceName, LPWSTR wszEventName);
__declspec(dllexport) int ZZDWM(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) __declspec(dllexport) int ZZDWM(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{ {
ep_dwm_StartService(L"ep_dwm_Service_" _T(EP_CLSID), L"Global\\ep_dwm_" _T(EP_CLSID)); ep_dwm_StartService(L"ep_dwm_Service_" _T(EP_CLSID), L"Global\\ep_dwm_" _T(EP_CLSID));
} }
#endif
#pragma region "Updates" #pragma region "Updates"
#ifdef _WIN64 #ifdef _WIN64
@ -709,6 +711,77 @@ void LaunchNetworkTargets(DWORD dwTarget)
#pragma endregion #pragma endregion
#pragma region "Service Window"
#ifdef _WIN64
#define EP_SERVICE_WINDOW_CLASS_NAME L"EP_Service_Window_" _T(EP_CLSID)
LRESULT CALLBACK EP_Service_Window_WndProc(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
if (uMsg == WM_HOTKEY && (wParam == 1 || wParam == 2))
{
InvokeClockFlyout();
return 0;
}
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
DWORD EP_ServiceWindowThread(DWORD unused)
{
WNDCLASS wc = { 0 };
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = EP_Service_Window_WndProc;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = EP_SERVICE_WINDOW_CLASS_NAME;
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
RegisterClassW(&wc);
HWND hWnd = CreateWindowExW(
0,
EP_SERVICE_WINDOW_CLASS_NAME,
0,
WS_POPUP,
0,
0,
0,
0,
0,
0,
GetModuleHandle(NULL),
NULL
);
if (hWnd)
{
if (bClockFlyoutOnWinC)
{
RegisterHotKey(hWnd, 1, MOD_WIN | MOD_NOREPEAT, 'C');
}
RegisterHotKey(hWnd, 2, MOD_WIN | MOD_ALT, 'D');
MSG msg;
BOOL bRet;
while ((bRet = GetMessageW(&msg, NULL, 0, 0)) != 0)
{
if (bRet == -1)
{
break;
}
else
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
DestroyWindow(hWnd);
}
SetEvent(hCanStartSws);
}
#endif
#pragma endregion
#pragma region "Toggle shell features" #pragma region "Toggle shell features"
BOOL CALLBACK ToggleImmersiveCallback(HWND hWnd, LPARAM lParam) BOOL CALLBACK ToggleImmersiveCallback(HWND hWnd, LPARAM lParam)
{ {
@ -1655,7 +1728,6 @@ INT64 Shell_TrayWndSubclassProc(
if (bIsPrimaryTaskbar) if (bIsPrimaryTaskbar)
{ {
UnhookWindowsHookEx(Shell_TrayWndMouseHook); UnhookWindowsHookEx(Shell_TrayWndMouseHook);
UnregisterHotKey(hWnd, 'VNEP');
} }
RemoveWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc); RemoveWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc);
} }
@ -1677,11 +1749,6 @@ INT64 Shell_TrayWndSubclassProc(
ToggleTaskbarAutohide(); ToggleTaskbarAutohide();
return 0; return 0;
} }
else if (uMsg == WM_HOTKEY && lParam == MAKELPARAM(MOD_WIN | MOD_ALT, 0x44))
{
InvokeClockFlyout();
return 0;
}
else if (uMsg == WM_HOTKEY && wParam == 500 && lParam == MAKELPARAM(MOD_WIN, 0x41)) else if (uMsg == WM_HOTKEY && wParam == 500 && lParam == MAKELPARAM(MOD_WIN, 0x41))
{ {
InvokeActionCenter(); InvokeActionCenter();
@ -3105,7 +3172,7 @@ HRESULT pnidui_CoCreateInstanceHook(
#pragma endregion #pragma endregion
#pragma region "Show Clock flyout on Win+C and Win+Alt+D" #pragma region "Clock flyout helper"
#ifdef _WIN64 #ifdef _WIN64
typedef struct _ClockButton_ToggleFlyoutCallback_Params typedef struct _ClockButton_ToggleFlyoutCallback_Params
{ {
@ -4914,7 +4981,6 @@ HWND CreateWindowExWHook(
else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_TrayWnd")) else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
{ {
SetWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc, TRUE); SetWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc, TRUE);
RegisterHotKey(hWnd, 'VNEP', MOD_WIN | MOD_ALT, 0x44);
Shell_TrayWndMouseHook = SetWindowsHookExW(WH_MOUSE, Shell_TrayWndMouseProc, NULL, GetCurrentThreadId()); Shell_TrayWndMouseHook = SetWindowsHookExW(WH_MOUSE, Shell_TrayWndMouseProc, NULL, GetCurrentThreadId());
} }
else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_SecondaryTrayWnd")) else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_SecondaryTrayWnd"))
@ -6885,7 +6951,7 @@ DWORD Inject(BOOL bIsExplorer)
} }
} }
if (symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1] && symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1] != 0xFFFFFFFF) /*if (symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1] && symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1] != 0xFFFFFFFF)
{ {
winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageFunc = (INT64(*)(void*, POINT*)) winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageFunc = (INT64(*)(void*, POINT*))
((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1]); ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1]);
@ -6899,7 +6965,7 @@ DWORD Inject(BOOL bIsExplorer)
FreeLibraryAndExitThread(hModule, rv); FreeLibraryAndExitThread(hModule, rv);
return rv; return rv;
} }
} }*/
VnPatchIAT(hTwinuiPcshell, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", twinuipcshell_RegGetValueW); VnPatchIAT(hTwinuiPcshell, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", twinuipcshell_RegGetValueW);
//VnPatchIAT(hTwinuiPcshell, "api-ms-win-core-debug-l1-1-0.dll", "IsDebuggerPresent", IsDebuggerPresentHook); //VnPatchIAT(hTwinuiPcshell, "api-ms-win-core-debug-l1-1-0.dll", "IsDebuggerPresent", IsDebuggerPresentHook);
printf("Setup twinui.pcshell functions done\n"); printf("Setup twinui.pcshell functions done\n");
@ -7093,6 +7159,7 @@ DWORD Inject(BOOL bIsExplorer)
} }
CreateThread( CreateThread(
0, 0,
0, 0,
@ -7104,6 +7171,19 @@ DWORD Inject(BOOL bIsExplorer)
printf("Open Start on monitor thread\n"); printf("Open Start on monitor thread\n");
CreateThread(
0,
0,
EP_ServiceWindowThread,
0,
0,
0
);
printf("EP Service Window thread\n");
if (bDisableOfficeHotkeys) if (bDisableOfficeHotkeys)
{ {
VnPatchIAT(hExplorer, "user32.dll", "RegisterHotKey", explorer_RegisterHotkeyHook); VnPatchIAT(hExplorer, "user32.dll", "RegisterHotKey", explorer_RegisterHotkeyHook);

4
ExplorerPatcher/settings.reg

@ -350,7 +350,7 @@
[HKEY_CURRENT_USER\Software\ExplorerPatcher] [HKEY_CURRENT_USER\Software\ExplorerPatcher]
;b Remember last used section in this window ;b Remember last used section in this window
"LastSectionInProperties"=dword:00000000 "LastSectionInProperties"=dword:00000000
;b Open clock flyout when pressing Win+C instead of Microsoft Teams ;b Open clock flyout when pressing Win+C instead of Microsoft Teams *
"ClockFlyoutOnWinC"=dword:00000000 "ClockFlyoutOnWinC"=dword:00000000
;b Show separators between taskbar toolbars * ;b Show separators between taskbar toolbars *
"ToolbarSeparators"=dword:00000000 "ToolbarSeparators"=dword:00000000
@ -433,7 +433,7 @@
;d Enable SysListView32 for Explorer views * ;d Enable SysListView32 for Explorer views *
@="" @=""
[HKEY_CURRENT_USER\Software\ExplorerPatcher] [HKEY_CURRENT_USER\Software\ExplorerPatcher]
;b Do not show the program settings item ("Properties") in the taskbar context menu ;b Hide the program settings item ("Properties") from the taskbar context menu
"NoPropertiesInContextMenu"=dword:00000000 "NoPropertiesInContextMenu"=dword:00000000
;b Enable symbols download * ;b Enable symbols download *
"EnableSymbolDownload"=dword:00000001 "EnableSymbolDownload"=dword:00000001

2
ExplorerPatcher/symbols.h

@ -18,7 +18,7 @@
#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_7 "IsUndockedAssetAvailable" #define TWINUI_PCSHELL_SB_7 "IsUndockedAssetAvailable"
#define TWINUI_PCSHELL_SB_8 "winrt::Windows::Internal::Shell::implementation::MeetAndChatManager::OnMessage" // should be always last #define TWINUI_PCSHELL_SB_8 "CLauncherTipContextMenu::ShowLauncherTipContextMenu" //"winrt::Windows::Internal::Shell::implementation::MeetAndChatManager::OnMessage" // should be always last
#define TWINUI_PCSHELL_SB_CNT 9 #define TWINUI_PCSHELL_SB_CNT 9
#define STARTDOCKED_SB_NAME "StartDocked" #define STARTDOCKED_SB_NAME "StartDocked"
#define STARTDOCKED_SB_0 "StartDocked::LauncherFrame::ShowAllApps" // UNUSED #define STARTDOCKED_SB_0 "StartDocked::LauncherFrame::ShowAllApps" // UNUSED

6
version.h

@ -1,7 +1,7 @@
#define VER_MAJOR 22000 #define VER_MAJOR 22000
#define VER_MINOR 434 #define VER_MINOR 434
#define VER_BUILD_HI 41 #define VER_BUILD_HI 41
#define VER_BUILD_LO 9 #define VER_BUILD_LO 10
#define VER_FLAGS VS_FF_PRERELEASE #define VER_FLAGS VS_FF_PRERELEASE
@ -12,5 +12,5 @@
#define VER_STR(arg) #arg #define VER_STR(arg) #arg
// The String form of the version numbers // The String form of the version numbers
#define VER_FILE_STRING VALUE "FileVersion", "22000.434.41.9" #define VER_FILE_STRING VALUE "FileVersion", "22000.434.41.10"
#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.434.41.9" #define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.434.41.10"

Loading…
Cancel
Save