Browse Source

Implements #6 (option to revert to classic context menu)

pull/20/head 22000.168.0.9
Valentin Radu 4 years ago
parent
commit
583440d489
  1. 9
      CHANGELOG.md
  2. 8
      ExplorerPatcher/ExplorerPatcher.rc
  3. 8
      ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc
  4. 125
      ExplorerPatcherLibrary/dllmain.c

9
CHANGELOG.md

@ -2,6 +2,15 @@ @@ -2,6 +2,15 @@
This document includes the same release notes as in the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section on GitHub.
## 22000.168.0.9
Implements [#6](https://github.com/valinet/ExplorerPatcher/issues/6) (option to revert to classic context menu). To disable this feature, add this to the settings.ini file:
```
[General]
AllowImmersiveContextMenus=1
```
## 22000.168.0.8
The popup menu for "Safe to Remove Hardware" is now skinned in the same style as the Win+X menu and the taskbar context menus, in order to improve UI consistency.

8
ExplorerPatcher/ExplorerPatcher.rc

@ -51,8 +51,8 @@ END @@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 22000,168,0,8
PRODUCTVERSION 22000,168,0,8
FILEVERSION 22000,168,0,9
PRODUCTVERSION 22000,168,0,9
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "VALINET Solutions SRL"
VALUE "FileDescription", "ExplorerPatcher Daemon"
VALUE "FileVersion", "22000.168.0.8"
VALUE "FileVersion", "22000.168.0.9"
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.168.0.8"
VALUE "ProductVersion", "22000.168.0.9"
END
END
BLOCK "VarFileInfo"

8
ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc

@ -51,8 +51,8 @@ END @@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 22000,168,0,8
PRODUCTVERSION 22000,168,0,8
FILEVERSION 22000,168,0,9
PRODUCTVERSION 22000,168,0,9
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "VALINET Solutions SRL"
VALUE "FileDescription", "ExplorerPatcher Library"
VALUE "FileVersion", "22000.168.0.8"
VALUE "FileVersion", "22000.168.0.9"
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.168.0.8"
VALUE "ProductVersion", "22000.168.0.9"
END
END
BLOCK "VarFileInfo"

125
ExplorerPatcherLibrary/dllmain.c

@ -64,6 +64,9 @@ DEFINE_GUID(__uuidof_IAuthUILogonSound, @@ -64,6 +64,9 @@ DEFINE_GUID(__uuidof_IAuthUILogonSound,
#define STOBJECT_SB_0 "SysTrayWndProc"
#define STOBJECT_SB_1 "HotPlugButtonClick"
#define STOBJECT_SB_CNT 2
#define WINDOWSUIFILEEXPLORER_SB_NAME "Windows.UI.FileExplorer"
#define WINDOWSUIFILEEXPLORER_SB_0 "ContextMenuPresenter::DoContextMenu"
#define WINDOWSUIFILEEXPLORER_SB_CNT 1
const char* explorer_SN[EXPLORER_SB_CNT] = {
EXPLORER_SB_0,
EXPLORER_SB_1,
@ -87,6 +90,9 @@ const char* stobject_SN[STOBJECT_SB_CNT] = { @@ -87,6 +90,9 @@ const char* stobject_SN[STOBJECT_SB_CNT] = {
STOBJECT_SB_0,
STOBJECT_SB_1
};
const char* windowsuifileexplorer_SN[WINDOWSUIFILEEXPLORER_SB_CNT] = {
WINDOWSUIFILEEXPLORER_SB_0
};
#pragma pack(push, 1)
typedef struct symbols_addr
{
@ -94,6 +100,7 @@ typedef struct symbols_addr @@ -94,6 +100,7 @@ typedef struct symbols_addr
DWORD twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT];
DWORD twinui_PTRS[TWINUI_SB_CNT];
DWORD stobject_PTRS[STOBJECT_SB_CNT];
DWORD windowsuifileexplorer_PTRS[WINDOWSUIFILEEXPLORER_SB_CNT];
} symbols_addr;
#pragma pack(pop)
@ -289,6 +296,31 @@ static BOOL(*TrackPopupMenuFunc)( @@ -289,6 +296,31 @@ static BOOL(*TrackPopupMenuFunc)(
static char(*ContextMenuPresenter_DoContextMenuFunc)(
char* _this,
INT64 a2,
INT a3,
void* a4
);
char ContextMenuPresenter_DoContextMenuHook(
char* _this,
INT64 a2,
INT a3,
void* a4
)
{
*(((char*)_this + 156)) = 0;
ContextMenuPresenter_DoContextMenuFunc(
_this,
a2,
a3,
a4
);
return 1;
}
DEFINE_GUID(CLSID_ImmersiveShell,
0xc2f03a33,
@ -1562,6 +1594,13 @@ __declspec(dllexport) DWORD WINAPI main( @@ -1562,6 +1594,13 @@ __declspec(dllexport) DWORD WINAPI main(
wszSettingsPath
);
symbols_PTRS.windowsuifileexplorer_PTRS[0] = VnGetUInt(
TEXT(WINDOWSUIFILEEXPLORER_SB_NAME),
TEXT(WINDOWSUIFILEEXPLORER_SB_0),
0,
wszSettingsPath
);
BOOL bNeedToDownload = FALSE;
for (UINT i = 0; i < sizeof(symbols_addr) / sizeof(DWORD); ++i)
{
@ -1978,6 +2017,65 @@ __declspec(dllexport) DWORD WINAPI main( @@ -1978,6 +2017,65 @@ __declspec(dllexport) DWORD WINAPI main(
wszSettingsPath
);
char windowsuifileexplorer_sb_dll[MAX_PATH];
ZeroMemory(
windowsuifileexplorer_sb_dll,
(MAX_PATH) * sizeof(char)
);
GetSystemDirectoryA(
windowsuifileexplorer_sb_dll,
MAX_PATH
);
strcat_s(
windowsuifileexplorer_sb_dll,
MAX_PATH,
"\\"
);
strcat_s(
windowsuifileexplorer_sb_dll,
MAX_PATH,
WINDOWSUIFILEEXPLORER_SB_NAME
);
strcat_s(
windowsuifileexplorer_sb_dll,
MAX_PATH,
".dll"
);
printf("Downloading symbols for %s.\n", windowsuifileexplorer_sb_dll);
if (VnDownloadSymbols(
NULL,
windowsuifileexplorer_sb_dll,
szSettingsPath,
MAX_PATH
))
{
FreeLibraryAndExitThread(
hModule,
6
);
return 6;
}
printf("Reading symbols.\n");
if (VnGetSymbols(
szSettingsPath,
symbols_PTRS.windowsuifileexplorer_PTRS,
windowsuifileexplorer_SN,
WINDOWSUIFILEEXPLORER_SB_CNT
))
{
FreeLibraryAndExitThread(
hModule,
7
);
return 7;
}
VnWriteUInt(
TEXT(WINDOWSUIFILEEXPLORER_SB_NAME),
TEXT(WINDOWSUIFILEEXPLORER_SB_0),
symbols_PTRS.windowsuifileexplorer_PTRS[0],
wszSettingsPath
);
VnWriteString(
TEXT("OS"),
TEXT("Build"),
@ -2131,6 +2229,33 @@ __declspec(dllexport) DWORD WINAPI main( @@ -2131,6 +2229,33 @@ __declspec(dllexport) DWORD WINAPI main(
}
LoadLibrary(L"Windows.UI.FileExplorer.dll");
HANDLE hWindowsUIFileExplorer = GetModuleHandle(L"Windows.UI.FileExplorer.dll");
ContextMenuPresenter_DoContextMenuFunc = (char(*)(void*))
((uintptr_t)hWindowsUIFileExplorer + symbols_PTRS.windowsuifileexplorer_PTRS[0]);
UINT archive_plugin = VnGetUInt(
L"ArchiveMenu",
L"Enabled",
0,
wszSettingsPath
);
if (archive_plugin)
{
rv = funchook_prepare(
funchook,
(void**)&ContextMenuPresenter_DoContextMenuFunc,
ContextMenuPresenter_DoContextMenuHook
);
if (rv != 0)
{
FreeLibraryAndExitThread(hModule, rv);
return rv;
}
}
rv = funchook_install(funchook, 0);
if (rv != 0)
{

Loading…
Cancel
Save