Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
Merge branch 'valinet:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
creeper-0910 authored Oct 22, 2023
2 parents 83a6ad7 + a77aff4 commit 9e860d8
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 34 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

本書には、GitHub の [Releases](https://github.com/creeper-0910/ExplorerPatcher-jp/releases) に掲載されているものと同じリリースノートが含まれています。

## 22621.2428.59

Tested on OS builds 22000.2416, 22621.2428, 23555.1000, and 23560.1000.

#### Details

##### 1

Note: After updating to this version, the symbols will be re-downloaded even if they have been downloaded before.

* Taskbar10: Fixed Control Center and Toast Center positioning on build 25951 (Canary). (dca0b3a)
* Taskbar10: Fixed start menu position when the taskbar is at the left or right side on Moment 4 builds. (a57471f)
* Taskbar10: Fixed the Windows 10 taskbar background patch to not crash anymore on build 25951 (Canary). (b52bd79)
* Taskbar10: Made taskbar fonts (when using classic theme mitigations) more accurate (thanks @aubymori). (8fc53a1)
* Start10: Fixed a bug where certain texts in the Windows 10 Start menu stayed in English. (c6a7d3f, ed251e9)
* Start10: Properly fixed start menu showing/hiding along with its original animations on builds 22000.65+. (7e2f768)
* GUI: Fixed a bug where "Remember last used section" doesn't remember the current page after being enabled. (dcf72bb)
* Symbols: Reworked how symbols are managed so that symbols don't need to be successfully downloaded in succession. (8412bd6)

## 22621.2361.58

Tested on OS builds 22000.2416, 22621.1, 22621.2134, 22621.2361, 22631.2338, and 23545.1000.
Expand Down
Binary file modified ExplorerPatcher/ExplorerPatcher.rc
Binary file not shown.
4 changes: 2 additions & 2 deletions ExplorerPatcher/ExplorerPatcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand Down Expand Up @@ -126,7 +126,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand Down
Binary file added ExplorerPatcher/RefreshedStyles.xbf
Binary file not shown.
4 changes: 2 additions & 2 deletions ExplorerPatcher/def.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _H_DEF_H_
#define _H_DEF_H_
#define APPID L"Microsoft.Windows.Explorer"
#define REGPATH "SOFTWARE\\ExplorerPatcher"
#define REGPATH_OLD "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher"
#define REGPATH "Software\\ExplorerPatcher"
#define REGPATH_OLD "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher"
#define REGPATH_STARTMENU REGPATH_OLD
#define SPECIAL_FOLDER CSIDL_PROGRAM_FILES
#define SPECIAL_FOLDER_LEGACY CSIDL_APPDATA
Expand Down
160 changes: 133 additions & 27 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4296,6 +4296,7 @@ INT64 winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageHo

#pragma region "Enable old taskbar"
#ifdef _WIN64
HRESULT(*explorer_RoGetActivationFactoryFunc)(HSTRING activatableClassId, GUID* iid, void** factory);
HRESULT explorer_RoGetActivationFactoryHook(HSTRING activatableClassId, GUID* iid, void** factory)
{
PCWSTR StringRawBuffer = WindowsGetStringRawBuffer(activatableClassId, 0);
Expand All @@ -4312,7 +4313,7 @@ HRESULT explorer_RoGetActivationFactoryHook(HSTRING activatableClassId, GUID* ii
return S_OK;
}
}
return RoGetActivationFactory(activatableClassId, iid, factory);
return explorer_RoGetActivationFactoryFunc(activatableClassId, iid, factory);
}

FARPROC explorer_GetProcAddressHook(HMODULE hModule, const CHAR* lpProcName)
Expand Down Expand Up @@ -8062,27 +8063,15 @@ HRESULT explorer_DrawThemeTextEx(
SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0);

HFONT hFont = NULL;
if (bIsActiveUnhovered)
if (bIsActiveUnhovered || bIsActiveHovered)
{
hFont = CreateFontIndirectW(&(ncm.lfCaptionFont));
}
else if (bIsInactiveUnhovered)
{
hFont = CreateFontIndirectW(&(ncm.lfMenuFont));
}
else if (bIsActiveHovered)
{
hFont = CreateFontIndirectW(&(ncm.lfCaptionFont));
}
else if (bIsInactiveHovered)
{
hFont = CreateFontIndirectW(&(ncm.lfMenuFont));
ncm.lfCaptionFont.lfWeight = FW_BOLD;
}
else
{
hFont = CreateFontIndirectW(&(ncm.lfMenuFont));
//wprintf(L"DrawThemeTextEx %d %d %s\n", iPartId, iStateId, pszText);
ncm.lfCaptionFont.lfWeight = FW_NORMAL;
}
hFont = CreateFontIndirectW(&(ncm.lfCaptionFont));

if (iPartId == 5 && iStateId == 0) // clock
{
Expand Down Expand Up @@ -11396,6 +11385,9 @@ DWORD Inject(BOOL bIsExplorer)
{
VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook);
VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW);
// A certain configuration update in 23560.1000 broke this method, this didn't get called with
// "RoGetActivationFactory" anymore. ~~We're now hooking RoGetActivationFactory directly.~~ Pulled back for now.
explorer_RoGetActivationFactoryFunc = RoGetActivationFactory;
VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook);
VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteW", explorer_ShellExecuteW);
VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteExW", explorer_ShellExecuteExW);
Expand Down Expand Up @@ -11724,11 +11716,31 @@ DWORD Inject(BOOL bIsExplorer)
printf("Setup twinui.pcshell functions done\n");


if (IsWindows11Version22H2OrHigher())
if (IsWindows11())
{
HANDLE hCombase = LoadLibraryW(L"combase.dll");
// Fixed a bug that crashed Explorer when a folder window was opened after a first one was closed on OS builds 22621+
VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", Windows11v22H2_combase_LoadLibraryExW);
/*if (bOldTaskbar) // TODO Pulled back for now, crashes on 22621.2428
{
// Hook RoGetActivationFactory() for old taskbar
explorer_RoGetActivationFactoryFunc = GetProcAddress(hCombase, "RoGetActivationFactory");
if (explorer_RoGetActivationFactoryFunc)
{
rv = funchook_prepare(
funchook,
(void**)&explorer_RoGetActivationFactoryFunc,
explorer_RoGetActivationFactoryHook
);
}
if (rv != 0)
{
printf("Failed to hook RoGetActivationFactory(). rv = %d\n", rv);
}
}*/
if (IsWindows11Version22H2OrHigher())
{
// Fixed a bug that crashed Explorer when a folder window was opened after a first one was closed on OS builds 22621+
VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", Windows11v22H2_combase_LoadLibraryExW);
}
printf("Setup combase functions done\n");
}

Expand Down Expand Up @@ -12569,6 +12581,96 @@ LSTATUS StartUI_RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD
return RegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
}

typedef enum Parser_XamlBufferType
{
XBT_Text,
XBT_Binary,
XBT_MemoryMappedResource
} Parser_XamlBufferType;

typedef struct Parser_XamlBuffer
{
unsigned int m_count;
Parser_XamlBufferType m_bufferType;
const unsigned __int8* m_buffer;
} Parser_XamlBuffer;

static BOOL StartMenu_FillParserBuffer(Parser_XamlBuffer* pBuffer, int resourceId)
{
HRSRC hRscr = FindResource(hModule, MAKEINTRESOURCE(resourceId), RT_RCDATA);
if (!hRscr)
return FALSE;

HGLOBAL hgRscr = LoadResource(hModule, hRscr);
if (!hgRscr)
return FALSE;

pBuffer->m_buffer = LockResource(hgRscr);
pBuffer->m_count = SizeofResource(hModule, hRscr);
pBuffer->m_bufferType = XBT_Binary;
return TRUE;
}

Parser_XamlBuffer g_EmptyRefreshedStylesXbfBuffer;

HRESULT(*CCoreServices_TryLoadXamlResourceHelperFunc)(void* _this, void* pUri, bool* pfHasBinaryFile, void** ppMemory, Parser_XamlBuffer* pBuffer, void** ppPhysicalUri);
HRESULT CCoreServices_TryLoadXamlResourceHelperHook(void* _this, void* pUri, bool* pfHasBinaryFile, void** ppMemory, Parser_XamlBuffer* pBuffer, void** ppPhysicalUri)
{
HRESULT(*Clone)(void* _this, void** ppUri); // index 3
HRESULT(*GetPath)(void* _this, unsigned int* pBufferLength, wchar_t* pszBuffer); // index 12
void** vtable = *(void***)pUri;
Clone = vtable[3];
GetPath = vtable[12];
wchar_t thePath[MAX_PATH];
unsigned int len = MAX_PATH;
GetPath(pUri, &len, thePath);
// OutputDebugStringW(thePath); OutputDebugStringW(L"<<<<<\n");

if (!wcscmp(thePath, L"/JumpViewUI/RefreshedStyles.xaml"))
{
*pfHasBinaryFile = true;
*pBuffer = g_EmptyRefreshedStylesXbfBuffer;
if (ppPhysicalUri)
Clone(pUri, ppPhysicalUri);
return pBuffer->m_buffer ? S_OK : E_FAIL;
}

return CCoreServices_TryLoadXamlResourceHelperFunc(_this, pUri, pfHasBinaryFile, ppMemory, pBuffer, ppPhysicalUri);
}

static BOOL StartMenu_FixContextMenuXbfHijackMethod()
{
LoadLibraryW(L"Windows.UI.Xaml.dll");
HANDLE hWindowsUIXaml = GetModuleHandleW(L"Windows.UI.Xaml.dll");
MODULEINFO mi;
GetModuleInformation(GetCurrentProcess(), hWindowsUIXaml, &mi, sizeof(mi));

if (!StartMenu_FillParserBuffer(&g_EmptyRefreshedStylesXbfBuffer, IDR_REFRESHEDSTYLES_XBF))
return FALSE;

// 49 89 43 C8 E8 ?? ?? ?? ?? 85 C0
// ^^^^^^^^^^^
// Ref: CCoreServices::LoadXamlResource()
PBYTE match = FindPattern(
mi.lpBaseOfDll,
mi.SizeOfImage,
"\x49\x89\x43\xC8\xE8\x00\x00\x00\x00\x85\xC0",
"xxxxx????xx"
);
if (!match)
return FALSE;

match += 4;
match += 5 + *(int*)(match + 1);
CCoreServices_TryLoadXamlResourceHelperFunc = match;
funchook_prepare(
funchook,
(void**)&CCoreServices_TryLoadXamlResourceHelperFunc,
CCoreServices_TryLoadXamlResourceHelperHook
);
return TRUE;
}

LSTATUS StartUI_RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
{
if (wcsstr(lpSubKey, L"$start.tilegrid$windows.data.curatedtilecollection.tilecollection\\Current"))
Expand Down Expand Up @@ -13201,13 +13303,17 @@ DWORD InjectStartMenu()
PatchAppResolver();
PatchStartTileData();

// Redirects to pri files from 22000.51 which work with the legacy menu
LoadLibraryW(L"MrmCoreR.dll");
HANDLE hMrmCoreR = GetModuleHandleW(L"MrmCoreR.dll");
VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "CreateFileW", StartUI_CreateFileW);
VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "GetFileAttributesExW", StartUI_GetFileAttributesExW);
VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "FindFirstFileW", StartUI_FindFirstFileW);
VnPatchIAT(hMrmCoreR, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", StartUI_RegGetValueW);
// Fixes context menu crashes
if (!StartMenu_FixContextMenuXbfHijackMethod()) {
// Fallback to the old method, but we'll have broken localization
// Redirects to pri files from 22000.51 which work with the legacy menu
LoadLibraryW(L"MrmCoreR.dll");
HANDLE hMrmCoreR = GetModuleHandleW(L"MrmCoreR.dll");
VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "CreateFileW", StartUI_CreateFileW);
VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "GetFileAttributesExW", StartUI_GetFileAttributesExW);
VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "FindFirstFileW", StartUI_FindFirstFileW);
VnPatchIAT(hMrmCoreR, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", StartUI_RegGetValueW);
}

// Enables "Show more tiles" setting
LoadLibraryW(L"Windows.CloudStore.dll");
Expand Down
1 change: 1 addition & 0 deletions ExplorerPatcher/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define IDS_UNINSTALL_ERROR_TEXT 112
#define IDS_OPERATION_NONE 113
#define IDR_REGISTRY2 114
#define IDR_REFRESHEDSTYLES_XBF 115
#define IDS_DRIVECATEGORY_HARDDISKDRIVES 40000
#define IDS_DRIVECATEGORY_REMOVABLESTORAGE 40001
#define IDS_DRIVECATEGORY_OTHER 40002
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define VER_MAJOR 22621
#define VER_MINOR 2361
#define VER_BUILD_HI 58
#define VER_BUILD_LO 4
#define VER_MINOR 2428
#define VER_BUILD_HI 59
#define VER_BUILD_LO 1
#define VER_FLAGS VS_FF_PRERELEASE


Expand Down

0 comments on commit 9e860d8

Please sign in to comment.