mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
try to use hook=3 by default
This commit is contained in:
parent
b42c3e1d49
commit
97a81b67b5
11
src/config.c
11
src/config.c
@ -323,11 +323,6 @@ static void cfg_create_ini()
|
|||||||
"; Note: Usually one of the following values will work: 60 / 30 / 25 / 20 / 15 (lower value = slower game speed)\n"
|
"; Note: Usually one of the following values will work: 60 / 30 / 25 / 20 / 15 (lower value = slower game speed)\n"
|
||||||
"maxgameticks=0\n"
|
"maxgameticks=0\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Windows API Hooking, Possible values: 0 = disabled, 1 = IAT Hooking, 2 = Microsoft Detours, 3 = IAT+GetProcAddress hook (All Modules), 4 = IAT Hooking (All Modules)\n"
|
|
||||||
"; Note: Change this value if windowed mode or upscaling isn't working properly\n"
|
|
||||||
"; Note: 'hook=3' will usually work for problematic games, if it doesn't then try 'hook=2' + 'renderer=gdi'\n"
|
|
||||||
"hook=4\n"
|
|
||||||
"\n"
|
|
||||||
"; Force minimum FPS, possible values: 0 = disabled, -1 = use 'maxfps=' value, -2 = same as -1 but force full redraw, 1-1000 = custom FPS\n"
|
"; Force minimum FPS, possible values: 0 = disabled, -1 = use 'maxfps=' value, -2 = same as -1 but force full redraw, 1-1000 = custom FPS\n"
|
||||||
"; Note: Set this to a low value such as 5 or 10 if some parts of the game are not being displayed (e.g. menus or loading screens)\n"
|
"; Note: Set this to a low value such as 5 or 10 if some parts of the game are not being displayed (e.g. menus or loading screens)\n"
|
||||||
"minfps=0\n"
|
"minfps=0\n"
|
||||||
@ -356,6 +351,7 @@ static void cfg_create_ini()
|
|||||||
"releasealt=false\n"
|
"releasealt=false\n"
|
||||||
"game_handles_close=false\n"
|
"game_handles_close=false\n"
|
||||||
"fixnotresponding=false\n"
|
"fixnotresponding=false\n"
|
||||||
|
"hook=4\n"
|
||||||
"guard_lines=200\n"
|
"guard_lines=200\n"
|
||||||
"max_resolutions=0\n"
|
"max_resolutions=0\n"
|
||||||
"limit_bltfast=false\n"
|
"limit_bltfast=false\n"
|
||||||
@ -866,7 +862,6 @@ static void cfg_create_ini()
|
|||||||
"; KKND2: Krossfire\n"
|
"; KKND2: Krossfire\n"
|
||||||
"[KKND2]\n"
|
"[KKND2]\n"
|
||||||
"noactivateapp=true\n"
|
"noactivateapp=true\n"
|
||||||
"hook=3\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"; Lionheart\n"
|
"; Lionheart\n"
|
||||||
"[Lionheart]\n"
|
"[Lionheart]\n"
|
||||||
@ -1064,10 +1059,6 @@ static void cfg_create_ini()
|
|||||||
"height=0\n"
|
"height=0\n"
|
||||||
"resizable=false\n"
|
"resizable=false\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Wizards and Warriors\n"
|
|
||||||
"[deep6]\n"
|
|
||||||
"hook=3\n"
|
|
||||||
"\n"
|
|
||||||
"; War Wind\n"
|
"; War Wind\n"
|
||||||
"[WW]\n"
|
"[WW]\n"
|
||||||
"renderer=opengl\n"
|
"renderer=opengl\n"
|
||||||
|
@ -105,7 +105,6 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeBeginPeriod(1);
|
timeBeginPeriod(1);
|
||||||
g_hook_method = cfg_get_int("hook", 4);
|
|
||||||
hook_init(TRUE);
|
hook_init(TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
50
src/hook.c
50
src/hook.c
@ -364,6 +364,45 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL hook_got_ddraw_import()
|
||||||
|
{
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
HMODULE hmod = GetModuleHandleA(NULL);
|
||||||
|
|
||||||
|
PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)hmod;
|
||||||
|
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew);
|
||||||
|
if (nt_headers->Signature != IMAGE_NT_SIGNATURE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
PIMAGE_IMPORT_DESCRIPTOR import_desc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)dos_header +
|
||||||
|
(DWORD)(nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress));
|
||||||
|
|
||||||
|
if (import_desc == (PIMAGE_IMPORT_DESCRIPTOR)nt_headers)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
while (import_desc->FirstThunk)
|
||||||
|
{
|
||||||
|
char* imp_module_name = (char*)((DWORD)dos_header + (DWORD)(import_desc->Name));
|
||||||
|
|
||||||
|
if (_stricmp(imp_module_name, "ddraw.dll") == 0)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
import_desc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void hook_create(HOOKLIST* hooks, BOOL initial_hook)
|
void hook_create(HOOKLIST* hooks, BOOL initial_hook)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -525,6 +564,17 @@ void hook_revert(HOOKLIST* hooks)
|
|||||||
|
|
||||||
void hook_init(BOOL initial_hook)
|
void hook_init(BOOL initial_hook)
|
||||||
{
|
{
|
||||||
|
if (initial_hook)
|
||||||
|
{
|
||||||
|
g_hook_method = cfg_get_int("hook", 4);
|
||||||
|
|
||||||
|
if (g_hook_method == 4 && hook_got_ddraw_import())
|
||||||
|
{
|
||||||
|
/* Switch to 3 if we can be sure that ddraw.dll will not be unloaded from the process */
|
||||||
|
g_hook_method = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_hook_active || g_hook_method == 3 || g_hook_method == 4)
|
if (!g_hook_active || g_hook_method == 3 || g_hook_method == 4)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) && defined(_MSC_VER)
|
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user