1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-27 17:00:59 +01:00

Fixes #1 (the menu is now skinned) (v22000.1.0.2)

This commit is contained in:
Valentin Radu 2021-08-12 23:46:48 +03:00
parent c2fa263b11
commit 256008981f
4 changed files with 136 additions and 21 deletions

View File

@ -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"

View File

@ -9,6 +9,9 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include <Shlwapi.h>
#pragma comment(lib, "Shlwapi.lib")
#define DEBUG
#undef DEBUG
#define CLASS_NAME TEXT("ExplorerPatcher")
#define APP_NAME TEXT("Windows Explorer")
#define NOP 0x90

View File

@ -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"

View File

@ -6,8 +6,11 @@
#pragma comment(lib, "Psapi.lib") // required by funchook
#include <Shlwapi.h>
#pragma comment(lib, "Shlwapi.lib")
#include <dwmapi.h>
#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);
@ -371,6 +480,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);