Skip to content

Commit

Permalink
Implements #6 (option to revert to classic context menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
valinet committed Aug 30, 2021
1 parent 34a7fd0 commit 583440d
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions ExplorerPatcher/ExplorerPatcher.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions ExplorerPatcherLibrary/ExplorerPatcherLibrary.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
125 changes: 125 additions & 0 deletions ExplorerPatcherLibrary/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -87,13 +90,17 @@ 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
{
DWORD explorer_PTRS[EXPLORER_SB_CNT];
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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 583440d

Please sign in to comment.