Skip to content

Commit d7d2680

Browse files
committed
preliminary Worldshift support
1 parent e75a959 commit d7d2680

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/bin
2+
/build
3+
.DS_Store
4+
.DS_Store?
5+
Thumbs.db

dllmain.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "include/game_nolf.h"
5151
#include "include/game_bf2142.h"
5252
#include "include/game_stlegacy.h"
53+
#include "include/game_worldshift.h"
5354
#endif // !_WIN64
5455

5556
#include "include/picoupnp.h"
@@ -290,6 +291,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) {
290291
patch_bf2142();
291292
} else if (!__stricmp(p, "legacy.exe")) { // Star Trek: Legacy
292293
patch_stlegacy();
294+
} else if (!__stricmp(p, "worldshift.exe")) { // Worldshift
295+
patch_worldshift();
293296
} else if (!__stricmp(p, "serioussam.exe") || !__stricmp(p, "sam2.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam 1 & 2
294297
force_bind_ip = 0;
295298
patch_sam();

include/game_worldshift.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// game_worldshift.h
2+
3+
#ifndef __GAME_WORLDSHIFT_H
4+
#define __GAME_WORLDSHIFT_H
5+
6+
#include "include/global.h"
7+
#include "iathook/iathook.h"
8+
9+
LPHOSTENT __stdcall hk_gethostbyname(const char* name);
10+
11+
LPHOSTENT __stdcall worldshift_hk_gethostbyname(const char* name) {
12+
if (name && !__strcmp(name, "worldshift-game.com"))
13+
return ogethostbyname("motd.openspy.net");
14+
else
15+
return hk_gethostbyname(name);
16+
}
17+
18+
// Disable HTTPS
19+
__forceinline static void worldshift_disable_https() {
20+
BYTE* ptr = 0;
21+
BYTE search[] = {0xC7,0x46,0x28,0x01,0x00,0x00,0x00,0x83,0xC7,0x08};
22+
23+
ptr = find_pattern_mem(0, search, search + 9, TRUE);
24+
if (ptr)
25+
write_mem(ptr+3, "\0", 1);
26+
}
27+
28+
__noinline static void patch_worldshift() {
29+
HOOK_FUNC(0, gethostbyname, worldshift_hk_gethostbyname, "ws2_32.dll", 52, TRUE);
30+
worldshift_disable_https();
31+
gs_replace_pubkey(0);
32+
}
33+
34+
#endif // __GAME_WORLDSHIFT_H

0 commit comments

Comments
 (0)