From 962cc962f0b47dbea64f30300a6b59b3b5e5ad01 Mon Sep 17 00:00:00 2001 From: anzz1 Date: Tue, 5 Dec 2023 18:47:30 +0200 Subject: [PATCH] fix 'No One Lives Forever' dedicated server --- README.md | 2 +- dllmain.c | 3 +++ include/game_nolf.h | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 include/game_nolf.h diff --git a/README.md b/README.md index 17fb0c2..3d3313a 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e | MX vs. ATV Unleashed | (Retail) (GOG) (Steam) | `dsound.dll` | n/a | | | Need for Speed: Hot Pursuit 2 | (Retail) | `dsound.dll` | n/a | [1] Requires latest [v242 update](https://taco.cab/files/games/nfshp2/NFSHP2_patch242.zip)
[2] Requires [No-CD patch](https://taco.cab/files/games/nfshp2/NFSHP2.v242.NoCD.zip) to remove SafeDisc (V2) protection
| | Nerf Arena Blast | (Retail) | n/a | n/a | [1] No DLL, use [this configuration file](https://github.com/anzz1/openspy-client/files/12753460/NAB-OpenSpy.zip) instead
[2] Latest [v1.2 update](https://taco.cab/files/games/nerf/nerfpatch1-2.zip) is recommended
| -| No One Lives Forever | (Retail) | `dinput.dll` | n/a | | +| No One Lives Forever | (Retail) | `winmm.dll` | n/a | | | Painkiller | (Retail) (GOG) (Steam) | `dinput8.dll` | n/a | | | ParaWorld | (Retail) | `winmm.dll` | n/a | [1] Latest [v1.01 update](https://taco.cab/files/games/paraworld/paraworld_patch_1_01.zip) is recommended | | Sacrifice | (Retail) (GOG) (Steam) | `dinput.dll` | n/a | | diff --git a/dllmain.c b/dllmain.c index 76d2bac..a74943f 100644 --- a/dllmain.c +++ b/dllmain.c @@ -46,6 +46,7 @@ #include "include/game_sof2.h" #include "include/game_mua.h" #include "include/game_sacrifice.h" + #include "include/game_nolf.h" #endif // !_WIN64 #include "include/picoupnp.h" @@ -278,6 +279,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) { patch_sof2(); } else if (!__stricmp(p, "sacrifice.exe")) { // Sacrifice patch_sacrifice(); + } else if (!__stricmp(p, "nolfserv.exe")) { // No One Lives Forever (Server) + patch_nolf_srv(); } else if (!__stricmp(p, "serioussam.exe") || !__stricmp(p, "sam2.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam 1 & 2 force_bind_ip = 0; patch_sam(); diff --git a/include/game_nolf.h b/include/game_nolf.h new file mode 100644 index 0000000..6e8fc06 --- /dev/null +++ b/include/game_nolf.h @@ -0,0 +1,24 @@ +// game_nolf.h + +#ifndef __GAME_NOLF_H +#define __GAME_NOLF_H + +#include "include/global.h" +#include "iathook/iathook.h" + +int __stdcall hk_bind(SOCKET s, struct sockaddr* addr, int namelen); +LPHOSTENT __stdcall hk_gethostbyname(const char* name); + +__forceinline static void nolf_srv_hook_gs() { + HMODULE mod = GetModuleHandleA("server.dll"); + if (mod) { + HOOK_FUNC(mod, gethostbyname, hk_gethostbyname, "wsock32.dll", 52, TRUE); + HOOK_FUNC(mod, bind, hk_bind, "wsock32.dll", 2, TRUE); + } +} + +__noinline static void patch_nolf_srv() { + nolf_srv_hook_gs(); +} + +#endif // __GAME_NOLF_H