|
1 | 1 | #include <Windows.h> |
2 | 2 | #include <Shlwapi.h> |
| 3 | +#include <DbgHelp.h> |
3 | 4 | #include <new.h> |
4 | 5 | #include <stdarg.h> |
5 | 6 | #include <stdio.h> |
|
11 | 12 | #include "include/sdk/steamclientpublic.h" |
12 | 13 | #include "include/sdk/steam_gameserver.h" |
13 | 14 |
|
| 15 | +S_API ISteamClient* g_pSteamClientGameServer = nullptr; |
| 16 | + |
14 | 17 | #include "include/registfuncs.h" |
15 | 18 | #include "include/callback_dispatcher.h" |
16 | 19 | #include "include/globals.h" |
17 | | -#include "include/dll_loader.h" |
| 20 | +#include "include/uc_loader.h" |
18 | 21 | #include "include/dump_handler.h" |
| 22 | +#include "include/MinHook.h" |
19 | 23 |
|
20 | 24 | #include "include/api/api_callbacks.h" |
21 | 25 | #include "include/api/api_client.h" |
@@ -48,7 +52,6 @@ HSteamPipe g_ServerPipe = 0; |
48 | 52 | HSteamUser g_ServerUser = 0; |
49 | 53 | ISteamClient* g_ServerClient = nullptr; |
50 | 54 | ISteamClient* g_pServerClient = nullptr; |
51 | | -ISteamClient* g_pSteamClientGameServer = nullptr; |
52 | 55 | ISteamClient* g_pSteamClientGameServer_Latest = nullptr; |
53 | 56 | ISteamGameServer* g_pGameServer = nullptr; |
54 | 57 | ISteamUtils* g_pServerUtils = nullptr; |
@@ -151,26 +154,23 @@ static void UCOLogImpl(const char* fmt, va_list args) |
151 | 154 |
|
152 | 155 | void UCOLOG(const char* fmt, ...) |
153 | 156 | { |
154 | | -#ifdef _DEBUG |
155 | 157 | if (!fmt) return; |
156 | 158 | va_list args; |
157 | 159 | va_start(args, fmt); |
158 | 160 | UCOLogImpl(fmt, args); |
159 | 161 | va_end(args); |
160 | | -#endif |
161 | 162 | } |
162 | 163 |
|
163 | 164 | void UCOColor(WORD color, const char* text) |
164 | 165 | { |
165 | 166 | (void)color; |
166 | | -#ifdef _DEBUG |
167 | 167 | if (text && text[0]) |
168 | 168 | UCOLOG("%s", text); |
169 | | -#endif |
170 | 169 | } |
171 | 170 |
|
172 | 171 | // ============================================================ |
173 | | -// InitSteamClient |
| 172 | +// InitSteamClient // I seriously broke this later on in the |
| 173 | +// // releases, I am SO SORRY ya'll!! |
174 | 174 | // ============================================================ |
175 | 175 |
|
176 | 176 | void* InitSteamClient(HMODULE* phMod, bool bLocal, const char* iface) |
@@ -251,6 +251,55 @@ void* InitSteamClient(HMODULE* phMod, bool bLocal, const char* iface) |
251 | 251 | return nullptr; |
252 | 252 | } |
253 | 253 |
|
| 254 | +// ============================================================ |
| 255 | +// BIsSubscribedApp Hook - always return true |
| 256 | +// Fixes games with hardcoded AppID subscription checks |
| 257 | +// ~ credits to xinerqu ~ |
| 258 | +// ============================================================ |
| 259 | + |
| 260 | +typedef bool (S_CALLTYPE *Fn_BIsSubscribedApp)(void*, AppId_t); |
| 261 | +static Fn_BIsSubscribedApp g_pfnOriginalBIsSubscribedApp = nullptr; |
| 262 | + |
| 263 | +static bool S_CALLTYPE Hooked_BIsSubscribedApp(void* pSteamApps, AppId_t appId) |
| 264 | +{ |
| 265 | + UCOLOG("[UCOnline2] BIsSubscribedApp(%u) -> hooked, returning true", appId); |
| 266 | + return true; |
| 267 | +} |
| 268 | + |
| 269 | +void InstallBIsSubscribedAppHook() |
| 270 | +{ |
| 271 | + if (!g_bClientReady || !g_ClientCtx.SteamApps()) |
| 272 | + { |
| 273 | + UCOLOG("[UCOnline2] Cannot install BIsSubscribedApp hook: client not ready or SteamApps is null"); |
| 274 | + return; |
| 275 | + } |
| 276 | + |
| 277 | + void** vtable = *reinterpret_cast<void***>(g_ClientCtx.SteamApps()); |
| 278 | + |
| 279 | + // ISteamApps vtable layout (from isteamapps.h): |
| 280 | + // 0: BIsSubscribed, 1: BIsLowViolence, 2: BIsCybercafe, 3: BIsVACBanned, |
| 281 | + // 4: GetCurrentGameLanguage, 5: GetAvailableGameLanguages, 6: BIsSubscribedApp |
| 282 | + void* pOriginalFunc = vtable[6]; |
| 283 | + |
| 284 | + MH_STATUS mhStatus = MH_Initialize(); |
| 285 | + UCOLOG("[UCOnline2] MH_Initialize status: %d", mhStatus); |
| 286 | + |
| 287 | + mhStatus = MH_CreateHook(pOriginalFunc, &Hooked_BIsSubscribedApp, reinterpret_cast<void**>(&g_pfnOriginalBIsSubscribedApp)); |
| 288 | + if (mhStatus == MH_OK) |
| 289 | + { |
| 290 | + mhStatus = MH_EnableHook(pOriginalFunc); |
| 291 | + if (mhStatus == MH_OK) |
| 292 | + UCOLOG("[UCOnline2] BIsSubscribedApp hook installed successfully"); |
| 293 | + else |
| 294 | + UCOLOG("[UCOnline2] MH_EnableHook failed for BIsSubscribedApp: %d", mhStatus); |
| 295 | + } |
| 296 | + else |
| 297 | + { |
| 298 | + UCOLOG("[UCOnline2] MH_CreateHook failed for BIsSubscribedApp: %d", mhStatus); |
| 299 | + } |
| 300 | +} |
| 301 | + |
| 302 | + |
254 | 303 | // ============================================================ |
255 | 304 | // LoadGameOverlay |
256 | 305 | // ============================================================ |
|
0 commit comments