1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-23 23:21:08 +01:00

Made FindPattern a non-inline function.

This should help reduce the code size as I continue to add more patterns.
This commit is contained in:
Amrsatrio 2023-11-20 23:46:57 +07:00
parent 2450a5d284
commit 3cb3ace48a
3 changed files with 35 additions and 26 deletions

View File

@ -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

View File

@ -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

View File

@ -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