Skip to content

Commit

Permalink
fix 'No One Lives Forever' dedicated server
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 authored Dec 5, 2023
1 parent 9db06ed commit 962cc96
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| MX vs. ATV Unleashed | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/mx_vs_atv_unleashed"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/359220/MX_vs_ATV_Unleashed/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dsound.dll` | n/a | |
| Need for Speed: Hot Pursuit 2 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dsound.dll` | n/a | <sub><sup>[1]</sup> Requires latest [v242 update](https://taco.cab/files/games/nfshp2/NFSHP2_patch242.zip)<br><sup>[2]</sup> Requires [No-CD patch](https://taco.cab/files/games/nfshp2/NFSHP2.v242.NoCD.zip) to remove SafeDisc (V2) protection</sub> |
| Nerf Arena Blast | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | n/a | n/a | <sub><sup>[1]</sup> No DLL, use [this configuration file](https://github.com/anzz1/openspy-client/files/12753460/NAB-OpenSpy.zip) instead<br><sup>[2]</sup> Latest [v1.2 update](https://taco.cab/files/games/nerf/nerfpatch1-2.zip) is recommended</sub> |
| No One Lives Forever | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput.dll` | n/a | |
| No One Lives Forever | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `winmm.dll` | n/a | |
| Painkiller | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/painkiller"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/39530/Painkiller_Black_Edition/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dinput8.dll` | n/a | |
| ParaWorld | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `winmm.dll` | n/a | <sub><sup>[1]</sup> Latest [v1.01 update](https://taco.cab/files/games/paraworld/paraworld_patch_1_01.zip) is recommended</sub> |
| Sacrifice | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/sacrifice"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/38440/Sacrifice/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dinput.dll` | n/a | |
Expand Down
3 changes: 3 additions & 0 deletions dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
24 changes: 24 additions & 0 deletions include/game_nolf.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 962cc96

Please sign in to comment.