Fix bot crashes (hopefully)

This commit is contained in:
BenCat07 2023-02-25 13:16:40 +01:00
parent 50cadc15aa
commit 329a0fafe8
2 changed files with 12 additions and 4 deletions

View File

@ -2,21 +2,25 @@
// This is specifically for preload, and removes the source lock from the launcher. The only other way is bytepatching hl2_linux directly... // This is specifically for preload, and removes the source lock from the launcher. The only other way is bytepatching hl2_linux directly...
typedef void *(*dlopen_t)(const char *__file, int __mode); typedef void *(*dlopen_t)(const char *__file, int __mode);
void *dlopen(const char *__file, int __mode) noexcept(true) void *dlopen(const char *__file, int __mode) __THROWNL
{ {
dlopen_t dlopen_fn = (dlopen_t) dlsym(RTLD_NEXT, "dlopen"); dlopen_t dlopen_fn = (dlopen_t) dlsym(RTLD_NEXT, "dlopen");
auto ret = dlopen_fn(__file, __mode);
auto ret = dlopen_fn(__file, __mode);
if (!__file)
return ret;
if (!strcmp(__file, "bin/launcher.so")) if (!strcmp(__file, "bin/launcher.so"))
{ {
logging::Info("Intercepted launcher.so"); logging::Info("Intercepted launcher.so");
logging::Info("Waiting for cathook to load Launcher symbols..."); logging::Info("Waiting for cathook to load Launcher symbols...");
while (sharedobj::launcher().lmap == nullptr) while (sharedobj::launcher().lmap == nullptr)
usleep(10); usleep(1);
logging::Info("Loaded Launcher symbols"); logging::Info("Loaded Launcher symbols");
static uintptr_t launcher_sig = gSignatures.GetLauncherSignature("55 89 E5 56 53 8D 9D ? ? ? ? 81 EC A0 00 00 00"); static uintptr_t launcher_sig = gSignatures.GetLauncherSignature("55 89 E5 56 53 8D 9D ? ? ? ? 81 EC A0 00 00 00");
static BytePatch LauncherBytePatch = BytePatch(launcher_sig, { 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3 }); static BytePatch LauncherBytePatch = BytePatch(launcher_sig, { 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3 });
LauncherBytePatch.Patch(); LauncherBytePatch.Patch();
logging::Info("Removed source lock"); logging::Info("Removed source lock %d", errno);
} }
return ret; return ret;
} }

View File

@ -319,6 +319,10 @@ free(logname);*/
#if ENABLE_TEXTMODE #if ENABLE_TEXTMODE
static BytePatch patch(gSignatures.GetEngineSignature, "74 ? 89 5C 24 ? 8D 9D ? ? ? ? 89 74 24", 0, { 0x71 }); static BytePatch patch(gSignatures.GetEngineSignature, "74 ? 89 5C 24 ? 8D 9D ? ? ? ? 89 74 24", 0, { 0x71 });
patch.Patch(); patch.Patch();
// Remove intro video which also causes some crashes
static BytePatch patch_intro_video(gSignatures.GetEngineSignature, "55 89 E5 57 56 53 83 EC 5C 8B 5D ? 8B 55", 0x9, { 0x83, 0xc4, 0x5c, 0x5b, 0x5e, 0x5f, 0x5d, 0xc3 });
patch_intro_video.Patch();
#endif #endif
CreateEarlyInterfaces(); CreateEarlyInterfaces();