From 3cb3ace48aa1a1fbb0bfc9f948a5e120a6f1b31e Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Mon, 20 Nov 2023 23:46:57 +0700 Subject: [PATCH] Made FindPattern a non-inline function. This should help reduce the code size as I continue to add more patterns. --- ExplorerPatcher/dllmain.c | 2 ++ ExplorerPatcher/utility.c | 28 ++++++++++++++++++++++++++++ ExplorerPatcher/utility.h | 31 +++++-------------------------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 07ec7ca..841512f 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -1916,6 +1916,7 @@ DWORD FixTaskbarAutohide(DWORD unused) #pragma region "Allow enabling XAML sounds" +#ifdef _WIN64 void ForceEnableXamlSounds(HMODULE hWindowsUIXaml) { MODULEINFO mi; @@ -1949,6 +1950,7 @@ BOOL IsXamlSoundsEnabled() RegGetValueW(HKEY_CURRENT_USER, TEXT(REGPATH_OLD), L"XamlSounds", RRF_RT_DWORD, NULL, &dwRes, &dwSize); return dwRes != 0; } +#endif #pragma endregion diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index 1f68560..ca62a45 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -1655,3 +1655,31 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve mod->cbIndex++; return TRUE; } + +#ifdef _WIN64 +inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask) +{ + for (PBYTE value = (PBYTE)pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value) + { + if (*lpMask == 'x' && *(LPCBYTE)lpPattern != *value) + return FALSE; + } + + return TRUE; +} + +PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask) +{ + dwSize -= strlen(lpMask); + + for (SIZE_T index = 0; index < dwSize; ++index) + { + PBYTE pAddress = (PBYTE)pBase + index; + + if (MaskCompare(pAddress, lpPattern, lpMask)) + return pAddress; + } + + return NULL; +} +#endif diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index 7f082ce..ab0d3b2 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -794,31 +794,9 @@ typedef struct _MonitorOverrideData BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod); -inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask) -{ - for (PBYTE value = (PBYTE)pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value) - { - if (*lpMask == 'x' && *(LPCBYTE)lpPattern != *value) - return FALSE; - } - - return TRUE; -} - -inline PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask) -{ - dwSize -= strlen(lpMask); - - for (SIZE_T index = 0; index < dwSize; ++index) - { - PBYTE pAddress = (PBYTE)pBase + index; - - if (MaskCompare(pAddress, lpPattern, lpMask)) - return pAddress; - } - - return NULL; -} +#ifdef _WIN64 +PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask); +#endif inline HMODULE LoadGuiModule() { @@ -828,8 +806,9 @@ inline HMODULE LoadGuiModule() wcscat_s(epGuiPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\ep_gui.dll"); return LoadLibraryExW(epGuiPath, NULL, LOAD_LIBRARY_AS_DATAFILE); } -#endif #ifdef __cplusplus } #endif + +#endif