1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-16 06:18:53 +01:00

also check imported dlls for ddraw.dll import

This commit is contained in:
FunkyFr3sh 2023-11-04 04:26:19 +01:00
parent b8cef05a9c
commit d95423f5e6

@ -406,13 +406,14 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks, BOOL is_loc
} }
} }
BOOL hook_got_ddraw_import() BOOL hook_got_ddraw_import(HMODULE mod, BOOL check_imported_dlls)
{ {
if (!mod)
return FALSE;
__try __try
{ {
HMODULE hmod = GetModuleHandleA(NULL); PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)mod;
PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)hmod;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
return FALSE; return FALSE;
@ -441,6 +442,11 @@ BOOL hook_got_ddraw_import()
if (first_thunk->u1.Function) if (first_thunk->u1.Function)
return TRUE; return TRUE;
} }
else if (check_imported_dlls)
{
if (hook_got_ddraw_import(GetModuleHandleA(imp_module_name), FALSE))
return TRUE;
}
} }
import_desc++; import_desc++;
@ -596,7 +602,7 @@ void hook_init(BOOL initial_hook)
{ {
if (initial_hook) if (initial_hook)
{ {
if (g_config.hook == 4 && hook_got_ddraw_import()) if (g_config.hook == 4 && hook_got_ddraw_import(GetModuleHandleA(NULL), TRUE))
{ {
/* Switch to 3 if we can be sure that ddraw.dll will not be unloaded from the process */ /* Switch to 3 if we can be sure that ddraw.dll will not be unloaded from the process */
g_config.hook = 3; g_config.hook = 3;