1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

avoid exceptions with obfuscated binaries in debug build

This commit is contained in:
FunkyFr3sh 2023-10-05 01:47:43 +02:00
parent b0e8acc03c
commit cbeffa867f

View File

@ -323,6 +323,23 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks, BOOL is_loc
if (!is_local && (hooks[i].data[x].flags & HOOK_LOCAL_ONLY))
continue;
/* avoid exceptions with obfuscated binaries in debug build */
#if defined(_DEBUG)
MEMORY_BASIC_INFORMATION mbi = { 0 };
if (VirtualQuery((void*)import->Name, & mbi, sizeof(mbi)))
{
DWORD mask = (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);
BOOL b = !(mbi.Protect & mask);
// check the page is not a guard page
if (mbi.Protect & (PAGE_GUARD | PAGE_NOACCESS)) b = TRUE;
if (b)
continue;
}
else
continue;
#endif
if (_stricmp((const char*)import->Name, hooks[i].data[x].function_name) == 0)
{
DWORD op;