Browse Source

Made FindPattern a non-inline function.

This should help reduce the code size as I continue to add more patterns.
pull/2488/head
Amrsatrio 2 years ago
parent
commit
3cb3ace48a
  1. 2
      ExplorerPatcher/dllmain.c
  2. 28
      ExplorerPatcher/utility.c
  3. 31
      ExplorerPatcher/utility.h

2
ExplorerPatcher/dllmain.c

@ -1916,6 +1916,7 @@ DWORD FixTaskbarAutohide(DWORD unused)
#pragma region "Allow enabling XAML sounds" #pragma region "Allow enabling XAML sounds"
#ifdef _WIN64
void ForceEnableXamlSounds(HMODULE hWindowsUIXaml) void ForceEnableXamlSounds(HMODULE hWindowsUIXaml)
{ {
MODULEINFO mi; MODULEINFO mi;
@ -1949,6 +1950,7 @@ BOOL IsXamlSoundsEnabled()
RegGetValueW(HKEY_CURRENT_USER, TEXT(REGPATH_OLD), L"XamlSounds", RRF_RT_DWORD, NULL, &dwRes, &dwSize); RegGetValueW(HKEY_CURRENT_USER, TEXT(REGPATH_OLD), L"XamlSounds", RRF_RT_DWORD, NULL, &dwRes, &dwSize);
return dwRes != 0; return dwRes != 0;
} }
#endif
#pragma endregion #pragma endregion

28
ExplorerPatcher/utility.c

@ -1655,3 +1655,31 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve
mod->cbIndex++; mod->cbIndex++;
return TRUE; 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

31
ExplorerPatcher/utility.h

@ -794,31 +794,9 @@ typedef struct _MonitorOverrideData
BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod); BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod);
inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask) #ifdef _WIN64
{ PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask);
for (PBYTE value = (PBYTE)pBuffer; *lpMask; ++lpPattern, ++lpMask, ++value) #endif
{
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;
}
inline HMODULE LoadGuiModule() inline HMODULE LoadGuiModule()
{ {
@ -828,8 +806,9 @@ inline HMODULE LoadGuiModule()
wcscat_s(epGuiPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\ep_gui.dll"); wcscat_s(epGuiPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\ep_gui.dll");
return LoadLibraryExW(epGuiPath, NULL, LOAD_LIBRARY_AS_DATAFILE); return LoadLibraryExW(epGuiPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
} }
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif

Loading…
Cancel
Save