Skip to content

Commit

Permalink
add 'X-Men Legends II' support
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 committed Oct 7, 2023
1 parent 24bb6a2 commit 36bbe64
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| Worms 3D | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput8.dll` | n/a | <sub><sup>[1]</sup> Requires latest [v1.073 update](https://taco.cab/files/games/w3d/Worms3DServicePatch2.zip)<br><sup>[2]</sup> Requires [No-CD patch](https://taco.cab/files/games/w3d/W3D.Euro.v1.073.NoCD.zip) to remove SecuROM (V5) protection</sub> |
| Worms 4: Mayhem | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput8.dll` | n/a | <sub><sup>[1]</sup> Requires latest [v1.01 update](https://taco.cab/files/games/w4m/WormsMayhemPATCHv1.01.zip)<br><sup>[2]</sup> Requires [No-CD patch](https://taco.cab/files/games/w4m/W4M.Euro.v1.01.3013.NoDRM.zip) to remove StarForce (V3) protection</sub> |
| Worms 4: Mayhem Online Demo | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput8.dll` | n/a | <sub><sup>[1]</sup> [Free download](https://taco.cab/files/games/w4m/worms_4_multi_demo.zip)</sub> |
| X-Men Legends II | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput.dll` | n/a | <sub><sup>[1]</sup> Requires [No-CD patch](https://taco.cab/files/games/xml2/X-Men.Legends.II.v1.0.NoCD.zip) to remove SafeDisc (V4) protection</sub> |
| [report supported game](https://github.com/anzz1/openspy-client/issues/new?assignees=&labels=working+game&projects=&template=report-working-game.yml&title=%5Bworking-game%5D+GAME+NAME) |

## Unsupported games list
Expand Down
3 changes: 3 additions & 0 deletions dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "include/game_bfme2.h"
#include "include/game_blood2.h"
#include "include/game_dmntn.h"
#include "include/game_xml2.h"
#endif // !_WIN64

#include "include/picoupnp.h"
Expand Down Expand Up @@ -268,6 +269,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) {
patch_blood2();
} else if (!__stricmp(p, "damngame.exe")) { // Damnation
patch_dmntn();
} else if (!__stricmp(p, "xmen2.exe")) { // X-Men Legends II
patch_xml2();
} else if (!__stricmp(p, "game.dat") && p2 && !__strcmp(p2, "RTS.exe")) { // Battle for Middle-earth II
patch_bfme2();
} else if (!__stricmp(p, "serioussam.exe") || !__stricmp(p, "sam2.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam 1 & 2
Expand Down
19 changes: 19 additions & 0 deletions include/game_xml2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// game_xml2.h

#ifndef __GAME_XML2_H
#define __GAME_XML2_H

#include "include/global.h"

static char xml2_key[] = "SOFTWARE\\Activision\\X-Men Legends 2\\Settings\\Display";

// missing registry key causes crash on startup
__forceinline static void xml2_create_key() {
CreateRegKey(HKEY_CURRENT_USER, xml2_key);
}

__noinline static void patch_xml2() {
xml2_create_key();
}

#endif // __GAME_XML2_H
15 changes: 15 additions & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,19 @@ static char* GetModExpName(HMODULE hModule) {
return (img_exp_dir->Name ? (char*)((size_t)img_dos_headers + img_exp_dir->Name) : 0);
}

static BOOL CreateRegKey(HKEY hKeyRoot, char* subKey) {
HKEY hKey;
char *p = subKey;
while (*++p) {
if (*p == '\\') {
*p = 0;
if (!RegCreateKeyExA(hKeyRoot, subKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL)) RegCloseKey(hKey);
*p = '\\';
}
}
if (RegCreateKeyExA(hKeyRoot, subKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL)) return FALSE;
RegCloseKey(hKey);
return TRUE;
}

#endif // __GLOBAL_H

0 comments on commit 36bbe64

Please sign in to comment.