From 453d266d7640444f619af09e0e357ed9c8f19aed Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 26 Sep 2023 01:50:58 +0200 Subject: [PATCH] add temporary game patches for testing --- src/dllmain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/dllmain.c b/src/dllmain.c index ff55417..945ee6b 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -9,6 +9,7 @@ #include "debug.h" #include "config.h" #include "hook.h" +#include "patch.h" /* export for cncnet cnc games */ @@ -38,6 +39,56 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) #endif g_ddraw_module = hDll; + + + /* Claw DVD Movie experiments */ + + /* change file extension .vob to .avi */ + HMODULE game_exe = GetModuleHandleA(NULL); + + PIMAGE_DOS_HEADER dos_hdr = (void*)game_exe; + PIMAGE_NT_HEADERS nt_hdr = (void*)((char*)game_exe + dos_hdr->e_lfanew); + + for (int i = 0; i < nt_hdr->FileHeader.NumberOfSections; i++) + { + PIMAGE_SECTION_HEADER sct_hdr = IMAGE_FIRST_SECTION(nt_hdr) + i; + + if (strcmp(".data", (char*)sct_hdr->Name) == 0) + { + char* s = (char*)((char*)game_exe + sct_hdr->VirtualAddress); + int s_len = sct_hdr->Misc.VirtualSize; + + for (int i = 0; i < s_len; i++, s++) + { + if (*s == '.' && memcmp(s, "\x2E\x76\x6F\x62\x00", 5) == 0) /* .vob */ + { + memcpy(s, "\x2E\x61\x76\x69", 4); /* .avi */ + } + } + + break; + } + sct_hdr++; + } + + /* add registry key for x264vfw */ + + HKEY hkey; + LONG status = + RegOpenKeyExA( + HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32", 0L, KEY_WRITE, &hkey); + + if (status == ERROR_SUCCESS) + { + LPCTSTR data = "x264vfw.dll"; + RegSetValueExA(hkey,"vidc.x264", 0, REG_SZ, data, strlen(data)+1); + RegCloseKey(hkey); + } + + + + + char buf[1024]; if (GetEnvironmentVariable("__COMPAT_LAYER", buf, sizeof(buf)))