Browse Source

Split twinui.pcshell.dll patches into their own file

pull/3551/head 22621.3880.66.3_23b44a2
Amrsatrio 1 year ago
parent
commit
23b44a2f23
  1. 8
      ExplorerPatcher/ArchiveMenu.h
  2. 36
      ExplorerPatcher/StartMenu.h
  3. 2415
      ExplorerPatcher/TwinUIPatches.cpp
  4. 2784
      ExplorerPatcher/dllmain.c
  5. 2
      ExplorerPatcher/updates.cpp
  6. 51
      ExplorerPatcher/utility.h
  7. 2
      libs/libvalinet

8
ExplorerPatcher/ArchiveMenu.h

@ -4,6 +4,10 @@
#include <Windows.h> #include <Windows.h>
#include <Shlobj_core.h> #include <Shlobj_core.h>
#ifdef __cplusplus
extern "C" {
#endif
#define OPEN_NAME L"&Open archive" #define OPEN_NAME L"&Open archive"
#define EXTRACT_NAME L"&Extract to \"%s\\\"" #define EXTRACT_NAME L"&Extract to \"%s\\\""
#define OPEN_CMD L"\"C:\\Program Files\\7-Zip\\7zFM.exe\" %s" #define OPEN_CMD L"\"C:\\Program Files\\7-Zip\\7zFM.exe\" %s"
@ -51,4 +55,8 @@ LRESULT CALLBACK ArchiveMenuWndProc(
void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(HMENU hMenu, HWND hWnd) void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(HMENU hMenu, HWND hWnd)
); );
#ifdef __cplusplus
}
#endif
#endif #endif

36
ExplorerPatcher/StartMenu.h

@ -179,42 +179,6 @@ interface IImmersiveLauncher10RS
CONST_VTBL struct IImmersiveLauncher10RSVtbl* lpVtbl; CONST_VTBL struct IImmersiveLauncher10RSVtbl* lpVtbl;
}; };
DEFINE_GUID(IID_ILauncherTipContextMenu,
0xb8c1db5f,
0xcbb3, 0x48bc, 0xaf, 0xd9,
0xce, 0x6b, 0x88, 0x0c, 0x79, 0xed
);
typedef interface ILauncherTipContextMenu ILauncherTipContextMenu;
typedef struct ILauncherTipContextMenuVtbl
{
BEGIN_INTERFACE
HRESULT(STDMETHODCALLTYPE* QueryInterface)(
ILauncherTipContextMenu* This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void** ppvObject);
ULONG(STDMETHODCALLTYPE* AddRef)(
ILauncherTipContextMenu* This);
ULONG(STDMETHODCALLTYPE* Release)(
ILauncherTipContextMenu* This);
HRESULT(STDMETHODCALLTYPE* ShowLauncherTipContextMenu)(
ILauncherTipContextMenu* This,
/* [in] */ POINT* pt);
END_INTERFACE
} ILauncherTipContextMenuVtbl;
interface ILauncherTipContextMenu
{
CONST_VTBL struct ILauncherTipContextMenuVtbl* lpVtbl;
};
void OpenStartOnMonitor(HMONITOR monitor); void OpenStartOnMonitor(HMONITOR monitor);
// Slightly tweaked version of function available in Open Shell // Slightly tweaked version of function available in Open Shell

2415
ExplorerPatcher/TwinUIPatches.cpp

File diff suppressed because it is too large Load Diff

2784
ExplorerPatcher/dllmain.c

File diff suppressed because it is too large Load Diff

2
ExplorerPatcher/updates.cpp

@ -275,7 +275,7 @@ BOOL IsUpdateAvailableHelper(
jsonStr.c_str(), jsonStr.c_str(),
-1, -1,
pszJsonStr, pszJsonStr,
jsonStr.size() + 1 (int)(jsonStr.size() + 1)
); );
} }
} }

51
ExplorerPatcher/utility.h

@ -406,7 +406,7 @@ inline RM_UNIQUE_PROCESS GetExplorerApplication()
DWORD pid = 0; DWORD pid = 0;
GetWindowThreadProcessId(hwnd, &pid); GetWindowThreadProcessId(hwnd, &pid);
RM_UNIQUE_PROCESS out = { 0, { -1, -1 } }; RM_UNIQUE_PROCESS out = { 0, { (DWORD)-1, (DWORD)-1 } };
DWORD bytesReturned; DWORD bytesReturned;
WCHAR imageName[MAX_PATH]; // process image name buffer WCHAR imageName[MAX_PATH]; // process image name buffer
DWORD processIds[2048]; // max 2048 processes (more than enough) DWORD processIds[2048]; // max 2048 processes (more than enough)
@ -604,6 +604,27 @@ inline BOOL IncrementDLLReferenceCount(HINSTANCE hinst)
PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask); PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask);
#if _M_X64
inline BOOL FollowJnz(PBYTE pJnz, PBYTE* pTarget, DWORD* pJnzSize)
{
// Check big jnz
if (pJnz[0] == 0x0F && pJnz[1] == 0x85)
{
*pTarget = pJnz + 6 + *(int*)(pJnz + 2);
*pJnzSize = 6;
return TRUE;
}
// Check small jnz
if (pJnz[0] == 0x75)
{
*pTarget = pJnz + 2 + *(char*)(pJnz + 1);
*pJnzSize = 2;
return TRUE;
}
return FALSE;
}
#endif
#if _M_ARM64 #if _M_ARM64
// https://github.com/CAS-Atlantic/AArch64-Encoding // https://github.com/CAS-Atlantic/AArch64-Encoding
@ -700,7 +721,7 @@ __forceinline DWORD ARM64_DecodeLDRBIMM(DWORD insnLDRBIMM)
inline UINT_PTR ARM64_DecodeADRL(UINT_PTR offset, DWORD insnADRP, DWORD insnADD) inline UINT_PTR ARM64_DecodeADRL(UINT_PTR offset, DWORD insnADRP, DWORD insnADD)
{ {
if (!ARM64_IsADRP(insnADRP)) if (!ARM64_IsADRP(insnADRP))
return NULL; return 0;
UINT_PTR page = ARM64_Align(offset, 0x1000); UINT_PTR page = ARM64_Align(offset, 0x1000);
@ -857,6 +878,32 @@ inline PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lp
return FindPatternHelper(pBase, dwSize, lpPattern, lpMask); return FindPatternHelper(pBase, dwSize, lpPattern, lpMask);
} }
inline UINT_PTR FileOffsetToRVA(PBYTE pBase, UINT_PTR offset)
{
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)pBase;
PIMAGE_NT_HEADERS pNtHeaders = (PIMAGE_NT_HEADERS)(pBase + pDosHeader->e_lfanew);
PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pNtHeaders);
for (int i = 0; i < pNtHeaders->FileHeader.NumberOfSections; i++, pSection++)
{
if (offset >= pSection->PointerToRawData && offset < pSection->PointerToRawData + pSection->SizeOfRawData)
return offset - pSection->PointerToRawData + pSection->VirtualAddress;
}
return 0;
}
inline UINT_PTR RVAToFileOffset(PBYTE pBase, UINT_PTR rva)
{
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)pBase;
PIMAGE_NT_HEADERS pNtHeaders = (PIMAGE_NT_HEADERS)(pBase + pDosHeader->e_lfanew);
PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pNtHeaders);
for (int i = 0; i < pNtHeaders->FileHeader.NumberOfSections; i++, pSection++)
{
if (rva >= pSection->VirtualAddress && rva < pSection->VirtualAddress + pSection->Misc.VirtualSize)
return rva - pSection->VirtualAddress + pSection->PointerToRawData;
}
return 0;
}
inline HMODULE LoadGuiModule() inline HMODULE LoadGuiModule()
{ {
wchar_t epGuiPath[MAX_PATH]; wchar_t epGuiPath[MAX_PATH];

2
libs/libvalinet

@ -1 +1 @@
Subproject commit 126a8d6d8f0d5dd49f873999a81db5a49d19aae9 Subproject commit 6a8b474fa96bfd2a7db40dc37fcae9b80105028c
Loading…
Cancel
Save