Skip to content

Commit

Permalink
add 'Sacrifice' support
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 committed Dec 5, 2023
1 parent 4822d93 commit 024222d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| 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> |
| 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 | |
| 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 | |
Expand Down
3 changes: 3 additions & 0 deletions dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "include/game_gt.h"
#include "include/game_sof2.h"
#include "include/game_mua.h"
#include "include/game_sacrifice.h"
#endif // !_WIN64

#include "include/picoupnp.h"
Expand Down Expand Up @@ -275,6 +276,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) {
patch_gt();
} else if (!__stricmp(p, "sof2mp.exe")) { // Soldier of Fortune 2
patch_sof2();
} else if (!__stricmp(p, "sacrifice.exe")) { // Sacrifice
patch_sacrifice();
} 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
40 changes: 40 additions & 0 deletions include/game_sacrifice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// game_sacrifice.h

#ifndef __GAME_SACRIFICE_H
#define __GAME_SACRIFICE_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);

HMODULE __stdcall sacrifice_hk_LoadLibraryA(LPCSTR lpLibFileName) {
HMODULE mod = 0;
const char* name = __strrchr(lpLibFileName, '\\');
if (name)
name++;
else
name = lpLibFileName;

mod = oLoadLibraryA(lpLibFileName);
if (mod && (!__stricmp(name, "gamespy.dll"))) {
HOOK_FUNC(mod, gethostbyname, hk_gethostbyname, "wsock32.dll", 52, TRUE);
HOOK_FUNC(mod, bind, hk_bind, "wsock32.dll", 2, TRUE);
}

return mod;
}

__forceinline static void sacrifice_hook_gs() {
HMODULE mod = GetModuleHandleA("share.dll");
if (mod) {
HOOK_FUNC(mod, LoadLibraryA, sacrifice_hk_LoadLibraryA, "kernel32.dll", 0, FALSE);
}
}

__noinline static void patch_sacrifice() {
sacrifice_hook_gs();
}

#endif // __GAME_SACRIFICE_H

0 comments on commit 024222d

Please sign in to comment.