diff --git a/include/copypasted/CSignature.h b/include/copypasted/CSignature.h index c94227bf..a6bdeffa 100644 --- a/include/copypasted/CSignature.h +++ b/include/copypasted/CSignature.h @@ -30,6 +30,7 @@ enum SharedObjects engine, steamapi, vstd, + launcher, // Whatever you do, keep this one last entry_count }; @@ -43,6 +44,7 @@ public: static uintptr_t GetSignature(const char *chPattern, sharedobj::SharedObject &obj, int idx); static uintptr_t GetClientSignature(const char *chPattern); static uintptr_t GetEngineSignature(const char *chPattern); + static uintptr_t GetLauncherSignature(const char *chaPattern); static uintptr_t GetSteamAPISignature(const char *chPattern); static uintptr_t GetVstdSignature(const char *chPattern); }; diff --git a/include/core/sharedobj.hpp b/include/core/sharedobj.hpp index 12106f42..09785c88 100644 --- a/include/core/sharedobj.hpp +++ b/include/core/sharedobj.hpp @@ -42,6 +42,7 @@ SharedObject &serverbrowser(); SharedObject &steamclient(); SharedObject &client(); SharedObject &engine(); +SharedObject &launcher(); SharedObject &steamapi(); SharedObject &vstdlib(); SharedObject &tier0(); diff --git a/src/copypasted/CSignature.cpp b/src/copypasted/CSignature.cpp index f0c74722..56139e87 100644 --- a/src/copypasted/CSignature.cpp +++ b/src/copypasted/CSignature.cpp @@ -212,6 +212,11 @@ uintptr_t CSignature::GetEngineSignature(const char *chPattern) return GetSignature(chPattern, sharedobj::engine(), CSignature_space::engine); } //=================================================================================== +uintptr_t CSignature::GetLauncherSignature(const char *chPattern) +{ + return GetSignature(chPattern, sharedobj::launcher(), CSignature_space::launcher); +} +//=================================================================================== uintptr_t CSignature::GetSteamAPISignature(const char *chPattern) { return GetSignature(chPattern, sharedobj::steamapi(), CSignature_space::steamapi); diff --git a/src/core/sharedobj.cpp b/src/core/sharedobj.cpp index e55abca8..f4952cfb 100644 --- a/src/core/sharedobj.cpp +++ b/src/core/sharedobj.cpp @@ -99,6 +99,7 @@ void LoadEarlyObjects() try { engine().Load(); + launcher().Load(); filesystem_stdio().Load(); tier0().Load(); materialsystem().Load(); @@ -146,6 +147,7 @@ void UnloadAllSharedObjects() studiorender().Unload(); libsdl().Unload(); #endif + launcher().Unload(); engine().Unload(); filesystem_stdio().Unload(); tier0().Unload(); @@ -172,6 +174,11 @@ SharedObject &engine() static SharedObject obj("engine.so", true); return obj; } +SharedObject &launcher() +{ + static SharedObject obj("launcher.so", true); + return obj; +} SharedObject &vstdlib() { static SharedObject obj("libvstdlib.so", true); diff --git a/src/hooks/nographics.cpp b/src/hooks/nographics.cpp index 95e6a139..3d4744d6 100755 --- a/src/hooks/nographics.cpp +++ b/src/hooks/nographics.cpp @@ -247,6 +247,7 @@ static void ReduceRamUsage() * cannot play on error.mdl */ } + if (g_IBaseClient) { static BytePatch playSequence{ gSignatures.GetClientSignature, "55 89 E5 57 56 53 83 EC ? 8B 75 0C 8B 5D 08 85 F6 74 ? 83 BB", 0x00, { 0xC3 } }; @@ -270,17 +271,44 @@ static void UnHookFs() if (g_IBaseClient) g_IBaseClient->InvalidateMdlCache(); } + #if ENABLE_TEXTMODE static InitRoutineEarly nullify_textmode([]() { - ReduceRamUsage(); - static auto addr1 = e8call_direct(gSignatures.GetEngineSignature("E8 ? ? ? ? 8B 93 ? ? ? ? 85 D2 0F 84 ? ? ? ?")) + 0x18; - static auto addr2 = sharedobj::materialsystem().Pointer(0x3EC08); + // SDL_CreateWindow has a "flag" parameter. We simply give it HIDDEN as a flag + static auto addr1 = gSignatures.GetLauncherSignature("C7 43 ? ? ? ? ? C7 44 24 ? ? ? ? ? C7 44 24") + 0xb; + // All of these are needed so tf2 doesn't just unhide the window + static auto addr2 = gSignatures.GetLauncherSignature("E8 ? ? ? ? C6 43 25 01 83 C4 5C"); + static auto addr3 = gSignatures.GetLauncherSignature("E8 ? ? ? ? 8B 43 14 89 04 24 E8 ? ? ? ? C6 43 25 01 83 C4 1C"); + static auto addr4 = gSignatures.GetLauncherSignature("89 14 24 E8 ? ? ? ? 8B 45 B4") + 0x3; - static BytePatch patch1(addr1, { 0x81, 0xC4, 0x6C, 0x20, 0x00, 0x00, 0x5B, 0x5E, 0x5F, 0x5D, 0xC3 }); - static BytePatch patch2(addr2, { 0x83, 0xC4, 0x50, 0x5B, 0x5E, 0x5D, 0xC3 }); + // 0x8 = SDL_HIDDEN + static BytePatch patch1(addr1, { 0x8 }); + + // all are the same size so use same patch for all + std::vector patch_arr = { 0x90, 0x90, 0x90, 0x90, 0x90 }; + + static BytePatch patch2(addr2, patch_arr); + static BytePatch patch3(addr3, patch_arr); + static BytePatch patch4(addr4, patch_arr); patch1.Patch(); patch2.Patch(); + patch3.Patch(); + patch4.Patch(); + + ReduceRamUsage(); + // CVideoMode_Common::Init SetupStartupGraphic + static auto addr5 = e8call_direct(gSignatures.GetEngineSignature("E8 ? ? ? ? 8B 93 ? ? ? ? 85 D2 0F 84")) + 0x18; + // make materials illegal + static auto addr6 = sharedobj::materialsystem().Pointer(0x3EC08); + + // Make SetupStartupGraphic instantly return + static BytePatch patch5(addr5, { 0x81, 0xC4, 0x6C, 0x20, 0x00, 0x00, 0x5B, 0x5E, 0x5F, 0x5D, 0xC3 }); + // materials are gone :crab: + static BytePatch patch6(addr6, { 0x83, 0xC4, 0x50, 0x5B, 0x5E, 0x5D, 0xC3 }); + + patch5.Patch(); + patch6.Patch(); }); #endif @@ -296,8 +324,10 @@ static InitRoutine nullifiy_textmode2([]() { UnHookFs(); }); #if ENABLE_TEXTMODE - auto addr = gSignatures.GetEngineSignature("E8 ? ? ? ? C7 04 24 ? ? ? ? E8 ? ? ? ? C7 04 24 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ?"); - addr = e8call_direct(addr); + // Catbots still hit properly, this just makes it easier to Stub stuff not needed in textmode + bool *g_bTextMode_ptr = *((bool **) (gSignatures.GetEngineSignature("A2 ? ? ? ? 8B 43 04") + 0x1)); + *g_bTextMode_ptr = true; + /*auto addr = gSignatures.GetEngineSignature("55 89 E5 57 56 53 81 EC ? ? ? ? C7 45 ? ? ? ? ? A1 ? ? ? ? C7 45 ? ? ? ? ? 8B 75 08 85 C0 0F 84 ? ? ? ? 8D 55 88 89 04 24 31 DB 89 54 24 04"); static BytePatch patch(addr, { 0x31, 0xc0, 0xc3 }); patch.Patch(); EC::Register( @@ -307,11 +337,11 @@ static InitRoutine nullifiy_textmode2([]() { return; if (CE_GOOD(LOCAL_E)) return; - static auto addr = e8call_direct(gSignatures.GetEngineSignature("E8 ? ? ? ? 8B 85 ? ? ? ? 89 C7 E9 ? ? ? ? ")); + static auto addr = e8call_direct(gSignatures.GetEngineSignature("E8 ? ? ? ? 8B 85 ? ? ? ? 89 C7 E9")); typedef void (*SendFinishedSync_t)(CBaseClientState *); static SendFinishedSync_t SendFinishedSync_fn = SendFinishedSync_t(addr); SendFinishedSync_fn(g_IBaseClientState); }, - "nographics_cm"); + "nographics_cm");*/ #endif }); diff --git a/src/reclasses/CTFPartyClient.cpp b/src/reclasses/CTFPartyClient.cpp index e17de978..180c7c60 100644 --- a/src/reclasses/CTFPartyClient.cpp +++ b/src/reclasses/CTFPartyClient.cpp @@ -106,8 +106,7 @@ bool re::CTFPartyClient::BInQueueForStandby() char re::CTFPartyClient::RequestLeaveForMatch(int type) { typedef char (*RequestLeaveForMatch_t)(re::CTFPartyClient *, int); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 45 ? 89 44 24 ? 8B 45 ? 89 04 24 E8 ? ? " - "? ? 84 C0 89 C6 75"); + static uintptr_t addr = e8call_direct(gSignatures.GetClientSignature("E8 ? ? ? ? 90 8B 45 E4")); static RequestLeaveForMatch_t RequestLeaveForMatch_fn = RequestLeaveForMatch_t(addr); return RequestLeaveForMatch_fn(this, type); @@ -115,14 +114,13 @@ char re::CTFPartyClient::RequestLeaveForMatch(int type) int re::CTFPartyClient::BInvitePlayerToParty(CSteamID steamid) { typedef int (*BInvitePlayerToParty_t)(re::CTFPartyClient *, CSteamID, bool); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? 8B 5D ? 8B 55 ? 89 85 ? ? ? ? " + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? 8B 5D ? 8B 55 ? 89 85" "65 A1 ? ? ? ? 89 45 ? 31 C0 8B 45"); static BInvitePlayerToParty_t BInvitePlayerToParty_fn = BInvitePlayerToParty_t(addr); return BInvitePlayerToParty_fn(this, steamid, false); } int re::CTFPartyClient::BRequestJoinPlayer(CSteamID steamid) { - // 55 89 E5 57 56 53 81 EC 8C 00 00 00 8B 45 14 8B 55 10 89 45 A4 8B 45 0C typedef int (*BRequestJoinPlayer_t)(re::CTFPartyClient *, CSteamID, bool); static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 14 8B 55 ? 89 45 ? 8B"); static BRequestJoinPlayer_t BRequestJoinPlayer_fn = BRequestJoinPlayer_t(addr); diff --git a/src/reclasses/C_MannVsMachineStats.cpp b/src/reclasses/C_MannVsMachineStats.cpp index 0415391c..eb93cf8b 100644 --- a/src/reclasses/C_MannVsMachineStats.cpp +++ b/src/reclasses/C_MannVsMachineStats.cpp @@ -12,7 +12,7 @@ C_MannVsMachineStats *C_MannVsMachineStats::G_MannVsMachineStats() { typedef C_MannVsMachineStats *(*G_MannVsMachineStats_t)(); static uintptr_t addr = gSignatures.GetClientSignature("55 A1 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 89 E5 53 83 EC ? 8B 5D " - "? C7 83 ? ? ? ? ? ? ? ?"); + "? C7 83"); static G_MannVsMachineStats_t G_MannVsMachineStats_fn = G_MannVsMachineStats_t(addr); return G_MannVsMachineStats_fn(); @@ -22,7 +22,7 @@ int *C_MannVsMachineStats::AddLocalPlayerUpgrade(int id, int &a3) typedef int *(*AddLocalPlayerUpgrade_t)(C_MannVsMachineStats *, int, int); static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 5D ? 8B 75 ? 8B 7D ? 8B 43 ? 8B 53 ? 83 " "C0 ? 39 D0 7E ? 29 D0 89 1C 24 89 44 24 ? E8 ? ? ? ? 8B 43 ? 83 C0 ? " - "8B 13 89 43 ? 29 F0 83 E8 ? 89 F1 C1 E1 ?"); + "8B 13 89 43 ? 29 F0 83 E8 ? 89 F1 C1 E1"); static AddLocalPlayerUpgrade_t AddLocalPlayerUpgrade_fn = AddLocalPlayerUpgrade_t(addr); return AddLocalPlayerUpgrade_fn(this, id, a3);