Skip to content

Commit

Permalink
add 'Serious Sam 2' support
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 authored Aug 15, 2023
1 parent 9515ccc commit 8e8b00f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| 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 | |
| Serious Sam: The First Encounter | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/serious_sam_the_first_encounter"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a> | `dsound.dll` | n/a | |
| Serious Sam: The Second Encounter | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/serious_sam_the_second_encounter"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a> | `dsound.dll` | n/a | |
| Serious Sam 2 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dsound.dll` | n/a | <sub><sup>[1]</sup> Not compatible with the [Steam](https://store.steampowered.com/app/204340/Serious_Sam_2/) version, but it does have working multiplayer based on Steamworks</sub> |
| Sniper Elite | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/sniper_elite_berlin_1945"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/3700/Sniper_Elite/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `dinput8.dll` | n/a | |
| Star Wars: Republic Commando | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture>&nbsp;<a href="https://www.gog.com/en/game/star_wars_republic_commando"><img src="./.github/img/gog.png" title="GOG" alt="(GOG)" /></a>&nbsp;<a href="https://store.steampowered.com/app/6000/STAR_WARS_Republic_Commando/"><img src="./.github/img/steam.png" title="Steam" alt="(Steam)" /></a> | `version.dll` | n/a | |
| Tony Hawk's Pro Skater 4 | <picture><img src="./.github/img/disc.png" title="Retail" alt="(Retail)" /></picture> | `dinput8.dll` | n/a | |
Expand Down
2 changes: 1 addition & 1 deletion dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ 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, "serioussam.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam
} else if (!__stricmp(p, "serioussam.exe") || !__stricmp(p, "sam2.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam 1 & 2
force_bind_ip = 0;
patch_sam();
} else if (!__stricmp(p, "swrepubliccommando.exe")) { // Star Wars - Republic Commando
Expand Down
29 changes: 23 additions & 6 deletions include/game_sam.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,34 @@ int __stdcall hk_bind(SOCKET s, struct sockaddr* addr, int namelen);
LPHOSTENT __stdcall hk_gethostbyname(const char* name);

__forceinline static void sam_hook_gs() {
HMODULE engine = GetModuleHandleA("Engine.dll");
if (engine) {
HMODULE hmod = GetModuleHandleA("Engine.dll");
if (hmod) {
if (ogethostbyname)
detour_iat_func(engine, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);
detour_iat_func(hmod, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);
else
ogethostbyname = (gethostbyname_fn)detour_iat_func(engine, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);
ogethostbyname = (gethostbyname_fn)detour_iat_func(hmod, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);

if (obind)
detour_iat_func(engine, "bind", (void*)hk_bind, "wsock32.dll", 2, TRUE);
detour_iat_func(hmod, "bind", (void*)hk_bind, "wsock32.dll", 2, TRUE);
else
obind = (bind_fn)detour_iat_func(engine, "bind", (void*)hk_bind, "wsock32.dll", 2, TRUE);
obind = (bind_fn)detour_iat_func(hmod, "bind", (void*)hk_bind, "wsock32.dll", 2, TRUE);
}
hmod = GetModuleHandleA("Core.dll");
if (hmod) {
hmod = GetModuleHandleA("OnlineGS.dll");
if (!hmod)
hmod = LoadLibraryA("OnlineGS.dll");
if (hmod) {
if (ogethostbyname)
detour_iat_func(hmod, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);
else
ogethostbyname = (gethostbyname_fn)detour_iat_func(hmod, "gethostbyname", (void*)hk_gethostbyname, "wsock32.dll", 52, TRUE);

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

Expand Down

0 comments on commit 8e8b00f

Please sign in to comment.