Browse Source

Main: Fixed signature of ApplyOwnerDrawToMenu and RemoveOwnerDrawFromMenu

Also fixed the pattern for preventing UpdateStartMenuPositioning from crashing, to work on 25951 (Canary)
pull/2488/head
Amrsatrio 2 years ago
parent
commit
2450a5d284
  1. 17
      ExplorerPatcher/ArchiveMenu.c
  2. 14
      ExplorerPatcher/ArchiveMenu.h
  3. 64
      ExplorerPatcher/dllmain.c

17
ExplorerPatcher/ArchiveMenu.c

@ -83,18 +83,8 @@ LRESULT CALLBACK ArchiveMenuWndProc(
_In_ UINT uMsg, _In_ UINT uMsg,
_In_ WPARAM wParam, _In_ WPARAM wParam,
_In_ LPARAM lParam, _In_ LPARAM lParam,
INT64(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)( HRESULT(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)(HMENU hMenu, HWND hWnd, POINT* pPt, unsigned int options, void* data),
HMENU h1, void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(HMENU hMenu, HWND hWnd)
HMENU h2,
HWND a3,
unsigned int a4,
void* data
),
void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(
HMENU _this,
HMENU hWnd,
HWND a3
)
) )
{ {
LRESULT result; LRESULT result;
@ -145,8 +135,7 @@ LRESULT CALLBACK ArchiveMenuWndProc(
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
free(unknown_array); free(unknown_array);
SetForegroundWindow(prevhWnd); SetForegroundWindow(prevhWnd);

14
ExplorerPatcher/ArchiveMenu.h

@ -47,18 +47,8 @@ LRESULT CALLBACK ArchiveMenuWndProc(
_In_ UINT uMsg, _In_ UINT uMsg,
_In_ WPARAM wParam, _In_ WPARAM wParam,
_In_ LPARAM lParam, _In_ LPARAM lParam,
INT64(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)( HRESULT(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)(HMENU hMenu, HWND hWnd, POINT* pPt, unsigned int options, void* data),
HMENU h1, void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(HMENU hMenu, HWND hWnd)
HMENU h2,
HWND a3,
unsigned int a4,
void* data
),
void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(
HMENU _this,
HMENU hWnd,
HWND a3
)
); );
#endif #endif

64
ExplorerPatcher/dllmain.c

@ -1109,18 +1109,10 @@ static void(*CLauncherTipContextMenu_ExecuteShutdownCommandFunc)(
void* _this, void* _this,
void* a2 void* a2
) = NULL; ) = NULL;
static INT64(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc)( typedef HRESULT(*ImmersiveContextMenuHelper_ApplyOwnerDrawToMenu_t)(HMENU hMenu, HWND hWnd, POINT* pPt, unsigned int options, void* data);
HMENU h1, static ImmersiveContextMenuHelper_ApplyOwnerDrawToMenu_t ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc;
HMENU h2, typedef void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu_t)(HMENU hMenu, HWND hWnd);
HWND a3, static ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu_t ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc;
unsigned int a4,
void* data
) = NULL;
static void(*ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc)(
HMENU _this,
HMENU hWnd,
HWND a3
) = NULL;
static INT64(*CLauncherTipContextMenu_GetMenuItemsAsyncFunc)( static INT64(*CLauncherTipContextMenu_GetMenuItemsAsyncFunc)(
void* _this, void* _this,
void* rect, void* rect,
@ -1372,8 +1364,7 @@ DWORD ShowLauncherTipContextMenu(
{ {
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
*((HMENU*)((char*)params->_this + 0xe8 + offset_in_class)), *((HMENU*)((char*)params->_this + 0xe8 + offset_in_class)),
hWinXWnd, hWinXWnd
&(params->point)
); );
} }
free(unknown_array); free(unknown_array);
@ -2695,8 +2686,7 @@ INT64 Shell_TrayWndSubclassProc(
{ {
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hSubMenu, hSubMenu,
hWnd, hWnd
&pt
); );
} }
free(unknown_array); free(unknown_array);
@ -2984,8 +2974,7 @@ BOOL TrackPopupMenuHookEx(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
#endif #endif
} }
@ -3073,8 +3062,7 @@ BOOL TrackPopupMenuHook(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
#endif #endif
} }
@ -3266,8 +3254,7 @@ BOOL explorer_TrackPopupMenuExHook(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
else else
@ -3329,8 +3316,7 @@ BOOL pnidui_TrackPopupMenuHook(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
else else
@ -3389,8 +3375,7 @@ BOOL sndvolsso_TrackPopupMenuExHook(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
else else
@ -3515,8 +3500,7 @@ BOOL stobject_TrackPopupMenuExHook(
{ {
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
free(unknown_array); free(unknown_array);
@ -3579,8 +3563,7 @@ BOOL stobject_TrackPopupMenuHook(
{ {
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
free(unknown_array); free(unknown_array);
@ -3641,8 +3624,7 @@ BOOL bthprops_TrackPopupMenuExHook(
{ {
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
free(unknown_array); free(unknown_array);
@ -3681,8 +3663,7 @@ BOOL inputswitch_TrackPopupMenuExHook(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
else else
@ -3736,8 +3717,7 @@ BOOL twinui_TrackPopupMenuHook(
pt.y = y; pt.y = y;
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc(
hMenu, hMenu,
hWnd, hWnd
&(pt)
); );
} }
else else
@ -10422,7 +10402,7 @@ BOOL Moment2PatchHardwareConfirmator(LPMODULEINFO mi)
// ^ HCH ^ bIsInLockScreen // ^ HCH ^ bIsInLockScreen
// //
// 22621.2134: 1D55D // 22621.2134: 1D55D
PBYTE match1 = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x48\x8B\x83\x00\x00\x00\x00\x8A\x80\x00\x00\x00\x00", "xxx????xx????"); PBYTE match1 = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x48\x8B\x83\x00\x00\x00\x00\x8A\x80", "xxx????xx");
printf("[HC] match1 = %llX\n", match1 - (PBYTE)mi->lpBaseOfDll); printf("[HC] match1 = %llX\n", match1 - (PBYTE)mi->lpBaseOfDll);
if (!match1) return FALSE; if (!match1) return FALSE;
g_Moment2PatchOffsets.coroInstance_pHardwareConfirmatorHost = *(int*)(match1 + 3); g_Moment2PatchOffsets.coroInstance_pHardwareConfirmatorHost = *(int*)(match1 + 3);
@ -11909,13 +11889,13 @@ DWORD Inject(BOOL bIsExplorer)
if (symbols_PTRS.twinui_pcshell_PTRS[2] && symbols_PTRS.twinui_pcshell_PTRS[2] != 0xFFFFFFFF) if (symbols_PTRS.twinui_pcshell_PTRS[2] && symbols_PTRS.twinui_pcshell_PTRS[2] != 0xFFFFFFFF)
{ {
ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc = (INT64(*)(HMENU, HMENU, HWND, unsigned int, void*)) ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc = (ImmersiveContextMenuHelper_ApplyOwnerDrawToMenu_t)
((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[2]); ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[2]);
} }
if (symbols_PTRS.twinui_pcshell_PTRS[3] && symbols_PTRS.twinui_pcshell_PTRS[3] != 0xFFFFFFFF) if (symbols_PTRS.twinui_pcshell_PTRS[3] && symbols_PTRS.twinui_pcshell_PTRS[3] != 0xFFFFFFFF)
{ {
ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc = (void(*)(HMENU, HMENU, HWND)) ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc = (ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenu_t)
((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[3]); ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[3]);
} }
@ -12290,12 +12270,12 @@ DWORD Inject(BOOL bIsExplorer)
// Fix ReportMonitorRemoved in UpdateStartMenuPositioning crashing, *for now* // Fix ReportMonitorRemoved in UpdateStartMenuPositioning crashing, *for now*
// We can't use our RtlQueryFeatureConfiguration() hook because our function didn't get called with the feature ID // We can't use our RtlQueryFeatureConfiguration() hook because our function didn't get called with the feature ID
// TODO Need to check again later after this feature flag has been removed // TODO Need to check again later after this feature flag has been removed
// E8 ?? ?? ?? ?? 48 8B 7D FF 84 C0 74 1F 48 8D 4F 08 // E8 ?? ?? ?? ?? 48 8B 7D ?? 84 C0 74 ?? 48 8D 4F 08
PBYTE match = FindPattern( PBYTE match = FindPattern(
hWindowsudkShellcommon, hWindowsudkShellcommon,
mi.SizeOfImage, mi.SizeOfImage,
"\xE8\x00\x00\x00\x00\x48\x8B\x7D\xFF\x84\xC0\x74\x1F\x48\x8D\x4F\x08", "\xE8\x00\x00\x00\x00\x48\x8B\x7D\x00\x84\xC0\x74\x00\x48\x8D\x4F\x08",
"x????xxxxxxxxxxxx" "x????xxx?xxx?xxxx"
); );
if (match) if (match)
{ {

Loading…
Cancel
Save