diff --git a/ExplorerPatcher/ExplorerPatcher.rc b/ExplorerPatcher/ExplorerPatcher.rc index b03d29c..a75630b 100644 --- a/ExplorerPatcher/ExplorerPatcher.rc +++ b/ExplorerPatcher/ExplorerPatcher.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 22000,1,0,1 - PRODUCTVERSION 22000,1,0,1 + FILEVERSION 22000,1,0,2 + PRODUCTVERSION 22000,1,0,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "VALINET Solutions SRL" VALUE "FileDescription", "ExplorerPatcher Daemon" - VALUE "FileVersion", "22000.1.0.1" + VALUE "FileVersion", "22000.1.0.2" VALUE "InternalName", "ExplorerPatcher.exe" VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved." VALUE "OriginalFilename", "ExplorerPatcher.exe" VALUE "ProductName", "ExplorerPatcher" - VALUE "ProductVersion", "22000.1.0.1" + VALUE "ProductVersion", "22000.1.0.2" END END BLOCK "VarFileInfo" diff --git a/ExplorerPatcher/main.c b/ExplorerPatcher/main.c index 1bae286..193cbfd 100644 --- a/ExplorerPatcher/main.c +++ b/ExplorerPatcher/main.c @@ -9,6 +9,9 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #include #pragma comment(lib, "Shlwapi.lib") +#define DEBUG +#undef DEBUG + #define CLASS_NAME TEXT("ExplorerPatcher") #define APP_NAME TEXT("Windows Explorer") #define NOP 0x90 diff --git a/ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc b/ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc index 81aed48..d55a23c 100644 --- a/ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc +++ b/ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 22000,1,0,1 - PRODUCTVERSION 22000,1,0,1 + FILEVERSION 22000,1,0,2 + PRODUCTVERSION 22000,1,0,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "VALINET Solutions SRL" VALUE "FileDescription", "ExplorerPatcher Library" - VALUE "FileVersion", "22000.1.0.1" + VALUE "FileVersion", "22000.1.0.2" VALUE "InternalName", "ExplorerPatcherLibrary.dll" VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved." VALUE "OriginalFilename", "ExplorerPatcherLibrary.dll" VALUE "ProductName", "WinOverview" - VALUE "ProductVersion", "22000.1.0.1" + VALUE "ProductVersion", "22000.1.0.2" END END BLOCK "VarFileInfo" diff --git a/ExplorerPatcherLibrary/dllmain.c b/ExplorerPatcherLibrary/dllmain.c index c7add6c..d7b959f 100644 --- a/ExplorerPatcherLibrary/dllmain.c +++ b/ExplorerPatcherLibrary/dllmain.c @@ -6,8 +6,11 @@ #pragma comment(lib, "Psapi.lib") // required by funchook #include #pragma comment(lib, "Shlwapi.lib") +#include +#pragma comment(lib, "Dwmapi.lib") - +#define DEBUG +#undef DEBUG funchook_t* funchook = NULL; HMODULE hModule = NULL; @@ -61,12 +64,26 @@ static INT64(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenu)( void* data ); +static void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu)( + HMENU _this, + HMENU hWnd, + HWND a3 + ); + static INT64(*CLauncherTipContextMenu_GetMenuItemsAsync)( void* _this, void* rect, void** iunk ); +static INT64(*CImmersiveContextMenuOwnerDrawHelper_s_ContextMenuWndProc)( + HWND hWnd, + int a2, + HWND a3, + int a4, + BOOL* a5 + ); + DEFINE_GUID(IID_ILauncherTipContextMenu, 0xb8c1db5f, 0xcbb3, 0x48bc, 0xaf, 0xd9, @@ -102,6 +119,87 @@ static BOOL(*IsDesktopInputContextFunc)( HANDLE hThread; +LRESULT CALLBACK CLauncherTipContextMenu_WndProc( + _In_ HWND hWnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam +) +{ + LRESULT result; + + if (uMsg == WM_NCCREATE) + { + CREATESTRUCT* pCs = lParam; + if (pCs->lpCreateParams) + { + *((HWND*)((char*)pCs->lpCreateParams + 0x78)) = hWnd; + SetWindowLongPtr( + hWnd, + GWLP_USERDATA, + pCs->lpCreateParams + ); + result = DefWindowProc( + hWnd, + uMsg, + wParam, + lParam + ); + } + else + { + result = 0; + } + } + else + { + void* _this = GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (_this) + { + BOOL v12 = FALSE; + if ((uMsg == WM_DRAWITEM || uMsg == WM_MEASUREITEM) && + CImmersiveContextMenuOwnerDrawHelper_s_ContextMenuWndProc( + hWnd, + uMsg, + wParam, + lParam, + &v12 + )) + { + result = 0; + } + else + { + result = DefWindowProc( + hWnd, + uMsg, + wParam, + lParam + ); + } + if (uMsg == WM_NCDESTROY) + { + SetWindowLongPtrW( + hWnd, + GWLP_USERDATA, + 0 + ); + *((HWND*)((char*)_this + 0x78)) = 0; + } + } + else + { + result = DefWindowProc( + hWnd, + uMsg, + wParam, + lParam + ); + } + } + return result; +} + typedef struct { void* _this; @@ -115,7 +213,7 @@ DWORD ShowLauncherTipContextMenu( { WNDCLASS wc = { 0 }; wc.style = CS_DBLCLKS; - wc.lpfnWndProc = DefWindowProc; // CLauncherTipContextMenu_WndProc + wc.lpfnWndProc = CLauncherTipContextMenu_WndProc; wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = CLASS_NAME; @@ -134,7 +232,7 @@ DWORD ShowLauncherTipContextMenu( 0, 0, GetModuleHandle(NULL), - params->_this, + (char*)params->_this - 0x58, 7 ); ShowWindow(hWnd, SW_SHOW); @@ -149,16 +247,14 @@ DWORD ShowLauncherTipContextMenu( goto finalize; } - /* - void* v25 = 0; + INT64* unknown_array = calloc(4, sizeof(INT64)); ImmersiveContextMenuHelper_ApplyOwnerDrawToMenu( *((HMENU*)((char*)params->_this + 0xe8)), hWnd, &(params->point), 0xc, - &v25 + unknown_array ); - */ BOOL res = TrackPopupMenu( *((HMENU*)((char*)params->_this + 0xe8)), @@ -169,6 +265,14 @@ DWORD ShowLauncherTipContextMenu( hWnd, 0 ); + + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu( + *((HMENU*)((char*)params->_this + 0xe8)), + hWnd, + &(params->point) + ); + free(unknown_array); + if (res > 0) { if (res < 4000) @@ -189,8 +293,6 @@ DWORD ShowLauncherTipContextMenu( } } - // ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu - finalize: params->iunk->lpVtbl->Release(params->iunk); SendMessage( @@ -337,11 +439,16 @@ __declspec(dllexport) DWORD WINAPI main( _In_ LPVOID lpParameter ) { - /* +#ifdef DEBUG FILE* conout; AllocConsole(); - freopen_s(&conout, "CONOUT$", "w", stdout); - */ + freopen_s( + &conout, + "CONOUT$", + "w", + stdout + ); +#endif int rv; if (!funchook) @@ -349,7 +456,6 @@ __declspec(dllexport) DWORD WINAPI main( messageWindow = (HWND)lpParameter; - funchook = funchook_create(); @@ -362,6 +468,9 @@ __declspec(dllexport) DWORD WINAPI main( HANDLE hTwinuiPcshell = GetModuleHandle(L"twinui.pcshell.dll"); + CImmersiveContextMenuOwnerDrawHelper_s_ContextMenuWndProc = (INT64(*)(HWND, int, HWND, int, BOOL*)) + ((uintptr_t)hTwinuiPcshell + 0xB0E12); + InternalAddRef = (INT64(*)(void*, INT64)) ((uintptr_t)hTwinuiPcshell + 0x46650); @@ -370,6 +479,9 @@ __declspec(dllexport) DWORD WINAPI main( ImmersiveContextMenuHelper_ApplyOwnerDrawToMenu = (INT64(*)(HMENU, HMENU, HWND, unsigned int, void*)) ((uintptr_t)hTwinuiPcshell + 0x535AF8); + + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu = (void(*)(HMENU, HMENU, HWND)) + ((uintptr_t)hTwinuiPcshell + 0x536300); CLauncherTipContextMenu_ExecuteShutdownCommand = (void(*)(void*, void*)) ((uintptr_t)hTwinuiPcshell + 0x514714);