|
| 1 | +// game_stlegacy.h |
| 2 | + |
| 3 | +#ifndef __GAME_STLEGACY_H |
| 4 | +#define __GAME_STLEGACY_H |
| 5 | + |
| 6 | +#include "include/global.h" |
| 7 | +#include "iathook/iathook.h" |
| 8 | + |
| 9 | +int __stdcall hk_bind(SOCKET s, struct sockaddr* addr, int namelen); |
| 10 | +LPHOSTENT __stdcall hk_gethostbyname(const char* name); |
| 11 | + |
| 12 | +__forceinline static void stlegacy_hook_gs(HMODULE mod) { |
| 13 | + HOOK_FUNC(0, gethostbyname, hk_gethostbyname, "ws2_32.dll", 52, TRUE); |
| 14 | + HOOK_FUNC(mod, gethostbyname, hk_gethostbyname, "ws2_32.dll", 52, TRUE); |
| 15 | + HOOK_FUNC(mod, bind, hk_bind, "ws2_32.dll", 2, TRUE); |
| 16 | +} |
| 17 | + |
| 18 | +// net voice init crashes game - disable it |
| 19 | +__forceinline static void stlegacy_disable_net_voice(HMODULE mod) { |
| 20 | + BYTE search1[] = {0x83,0xC4,0x04,0x8B,0x46,0x08,0x05,0xD4,0x00,0x00,0x00,0x50}; |
| 21 | + BYTE patch1[] = {0xE9,0xBE,0x00,0x00,0x00,0x90,0x90,0x90}; |
| 22 | + WORD search2[] = {0x64,0x89,0x25,0x00,0x00,0x00,0x00,0x51,0xA1,_ANY,_ANY,_ANY,_ANY,0x85,0xC0,0x75,0x47,0x56,0x6A,0x44}; |
| 23 | + BYTE patch2[] = {0xEB,0x3F}; |
| 24 | + WORD search3[] = {0x83,0xC4,0x10,0xC3,0x33,0xC0,0xA3,_ANY,_ANY,_ANY,_ANY,0x5E,0x8B,0x4C,0x24,0x04}; |
| 25 | + |
| 26 | + BYTE* ptr = find_pattern_mem((ULONG_PTR)mod, search1, search1 + 11, TRUE); |
| 27 | + if (ptr) |
| 28 | + write_mem(ptr+3, patch1, 8); |
| 29 | + |
| 30 | + ptr = find_pattern_mem_wildcard((ULONG_PTR)mod, search2, search2 + 19, TRUE); |
| 31 | + if (ptr) { |
| 32 | + write_mem(ptr+15, patch2, 2); |
| 33 | + ptr = find_pattern_mem_wildcard((ULONG_PTR)mod, search3, search3 + 15, TRUE); |
| 34 | + if (ptr) |
| 35 | + nop_mem(ptr+11, 1); |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +__noinline static void patch_stlegacy() { |
| 40 | + HMODULE mod = GetModuleHandleA("NetworkManager.dll"); |
| 41 | + if (mod) { |
| 42 | + stlegacy_hook_gs(mod); |
| 43 | + stlegacy_disable_net_voice(mod); |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +#endif // __GAME_STLEGACY_H |
0 commit comments