Skip to content

Commit

Permalink
add Deer Hunter 2004/2005 support
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 authored Aug 16, 2023
1 parent 94dfe81 commit b3f58f7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| Civilization IV | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/sid_meiers_civilization_iv_the_complete_edition"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a> | `dsound.dll` | n/a | |
| Colin McRae Rally 2005 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/colin_mcrae_rally_2005"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a> | `dinput8.dll` | n/a | |
| Crysis | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/crysis"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/17300/Crysis/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dinput8.dll` | `dinput8.dll` | |
| Deer Hunter 2004 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput8.dll` | n/a | |
| Deer Hunter 2005 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput8.dll` | n/a | |
| FEAR | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/game/fear_platinum"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/21090/FEAR/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `version.dll` | n/a | <sub><sup>[1]</sup> Requires a No-CD patch to remove SecuROM (V7) protection<br><sup>[2]</sup> Compatible also with the free multiplayer release "FEAR Combat"</sub> |
| FEAR 2 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/fear_2_project_origin_reborn"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/16450/FEAR_2_Project_Origin/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `version.dll` | n/a | |
| FlatOut 2 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/flatout_2"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/2990/FlatOut_2/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dinput8.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 @@ -25,6 +25,7 @@
#include "include/game_fear.h"
#include "include/game_sam.h"
#include "include/game_bond.h"
#include "include/game_dh2k.h"
#endif // !_WIN64

#include "include/picoupnp.h"
Expand Down Expand Up @@ -226,6 +227,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) {
patch_halo();
} else if (!__stricmp(p, "actofwar_hightreason.exe")) { // Act of War - High Treason
patch_aowht();
} else if (!__stricmp(p, "dh2004.exe") || !__stricmp(p, "dh2005.exe")) { // Deer Hunter 2004 / 2005
patch_dh2k();
} 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
31 changes: 31 additions & 0 deletions include/game_dh2k.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// game_dh2k.h

#ifndef __GAME_DH2K_H
#define __GAME_DH2K_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 dh2k_hook_gs() {
HMODULE aspen = GetModuleHandleA("Aspen.dll");
if (aspen) {
if (ogethostbyname)
detour_iat_func(aspen, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);
else
ogethostbyname = (gethostbyname_fn)detour_iat_func(aspen, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);

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

static void patch_dh2k() {
dh2k_hook_gs();
}

#endif // __GAME_DH2K_H

0 comments on commit b3f58f7

Please sign in to comment.