diff --git a/dllmain.c b/dllmain.c index a74943f..470ba9c 100644 --- a/dllmain.c +++ b/dllmain.c @@ -308,7 +308,7 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) { } else if (!__stricmp(p, "game.dat")) { char* p2 = GetModExpName(GetModuleHandleA(0)); if (p2) { - if (!__strcmp(p2, "RTS.exe")) patch_bfme2(); // Battle for Middle-earth II + if (!__strcmp(p2, "RTS.exe")) patch_bfme2(); // Battle for Middle-earth II / Rise of the Witch King } } else if (!__stricmp(p, "game.exe")) { LPGUID pguid = GetModPdbGuid(GetModuleHandleA(0)); diff --git a/include/game_bfme2.h b/include/game_bfme2.h index 954afcc..d6d0532 100644 --- a/include/game_bfme2.h +++ b/include/game_bfme2.h @@ -33,13 +33,23 @@ __forceinline static void bfme2_hook_gs() { // missing options.ini causes crash on startup __forceinline static void bfme2_create_options() { - char path[MAX_PATH+56]; + char path[MAX_PATH+72]; HANDLE hFile = 0; - DWORD dw = 0; + DWORD dw, len; if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path) >= 0) { - __strcat(path, "\\My Battle for Middle-earth(tm) II Files"); + len = __strlen(path); + if (len > MAX_PATH) return; + __strcpy(path+len, "\\My Battle for Middle-earth(tm) II Files"); CreateDirectoryA(path, NULL); - __strcat(path, "\\options.ini"); + __strcpy(path+len+40, "\\options.ini"); + hFile = CreateFileA(path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile && hFile != INVALID_HANDLE_VALUE) { + WriteFile(hFile, bfme2_options_ini, 150, &dw, NULL); + CloseHandle(hFile); + } + __strcpy(path+len, "\\My The Lord of the Rings, The Rise of the Witch-king Files"); + CreateDirectoryA(path, NULL); + __strcpy(path+len+59, "\\options.ini"); hFile = CreateFileA(path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile && hFile != INVALID_HANDLE_VALUE) { WriteFile(hFile, bfme2_options_ini, 150, &dw, NULL);