Skip to content

Commit

Permalink
add 'James Bond 007: Nightfire' support
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 authored Aug 15, 2023
1 parent de85150 commit f307211
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| GangLand | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/gangland"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a> | `dinput8.dll` | n/a | |
| Halo: Combat Evolved | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `version.dll` | n/a | |
| IGI 2: Covert Strike | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/i_g_i_2_covert_strike"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a> | `version.dll` | n/a | |
| James Bond 007: Nightfire | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `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 | |
| 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> | `version.dll` | n/a | |
| Saints Row 2 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/saints_row_2"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/9480/Saints_Row_2/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dinput8.dll` | n/a | |
Expand Down
6 changes: 5 additions & 1 deletion dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include "include/game_swrc.h"
#include "include/game_fear.h"
#include "include/game_sam.h"
#endif // _WIN64
#include "include/game_bond.h"
#endif // !_WIN64

#include "include/picoupnp.h"
#include "iathook/iathook.h"
Expand Down Expand Up @@ -247,6 +248,9 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) {
} else if (!__stricmp(p, "fearmp.exe") || !__stricmp(p, "fearserver.exe")) { // FEAR
force_bind_ip = 0;
patch_fear();
} else if (!__stricmp(p, "bond.exe") || !__stricmp(p, "bond_ded.exe")) { // James Bond - Nightfire
force_bind_ip = 0;
patch_bond();
} else if (!__stricmp(p, "fear2.exe")) { // FEAR 2
gs_replace_pubkey(0);
}
Expand Down
33 changes: 33 additions & 0 deletions include/game_bond.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// game_bond.h

#ifndef __GAME_BOND_H
#define __GAME_BOND_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 bond_hook_gs() {
HMODULE engine = GetModuleHandleA("engine.dll");
if (!engine)
engine = LoadLibraryA("engine.dll");
if (engine) {
if (ogethostbyname)
detour_iat_func(engine, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);
else
ogethostbyname = (gethostbyname_fn)detour_iat_func(engine, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);

if (obind)
detour_iat_func(engine, "bind", (void*)hk_bind, "wsock32.dll", 2, TRUE);
else
obind = (bind_fn)detour_iat_func(engine, "bind", (void*)hk_bind, "wsock32.dll", 2, TRUE);
}
}

static void patch_bond() {
bond_hook_gs();
}

#endif // __GAME_BOND_H

0 comments on commit f307211

Please sign in to comment.