diff --git a/README.md b/README.md index 497cb56..20e6644 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e | Crysis 2 | not working | | Men of War: Assault Squad | coming soon™ | | Rise Of Nations: Rise Of Legends | coming soon™, see [issue #2](https://github.com/anzz1/openspy-client/issues/2) | +| Soldier of Fortune 2: Double Helix | not working | | Test Drive Unlimited | not working | | [report unsupported game](https://github.com/anzz1/openspy-client/issues/new?assignees=&labels=game+request&projects=&template=request-for-game-support.yml&title=%5Bgame-request%5D+GAME+NAME) | diff --git a/dllmain.c b/dllmain.c index ecee3ae..918829f 100644 --- a/dllmain.c +++ b/dllmain.c @@ -42,6 +42,7 @@ #include "include/game_xml2.h" #include "include/game_ts.h" #include "include/game_gt.h" + #include "include/game_sof2.h" #endif // !_WIN64 #include "include/picoupnp.h" @@ -277,6 +278,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) { patch_ts(); } else if (!__stricmp(p, "gt.exe")) { // Gene Troopers patch_gt(); + } else if (!__stricmp(p, "sof2mp.exe")) { // Soldier of Fortune 2 + patch_sof2(); } 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 diff --git a/include/game_sof2.h b/include/game_sof2.h new file mode 100644 index 0000000..9d2ecdd --- /dev/null +++ b/include/game_sof2.h @@ -0,0 +1,33 @@ +// game_sof2.h + +#ifndef __GAME_SOF2_H +#define __GAME_SOF2_H + +#include "include/global.h" +#include "iathook/iathook.h" + +LPHOSTENT __stdcall hk_gethostbyname(const char* name); + +LPHOSTENT __stdcall sof2_hk_gethostbyname(const char* name) { + if (name && !__strcmp(name, "master.sof2.ravensoft.com")) + return ogethostbyname("master.openspy.net"); + else + return hk_gethostbyname(name); +} + +__forceinline static void sof2_hook_gs() { + HOOK_FUNC(0, gethostbyname, sof2_hk_gethostbyname, "ws2_32.dll", 52, TRUE); + HOOK_FUNC(0, gethostbyname, sof2_hk_gethostbyname, "wsock32.dll", 52, TRUE); +} + +// GOG v1.3 extra patch +__forceinline static void sof2_patch_gog() { + patch_if_match((void*)0x0055A9AC, "localhost 2.ravensoft.com", "master.openspy.net", 25, 19); +} + +__noinline static void patch_sof2() { + sof2_hook_gs(); + sof2_patch_gog(); +} + +#endif // __GAME_SOF2_H