From 6cc6725e3486cf7b34fa7260d66c765ad404516b Mon Sep 17 00:00:00 2001 From: lightbulblighter Date: Fri, 12 Aug 2022 02:04:06 -0700 Subject: [PATCH] split studio dll + realistic discord rpc checking --- Tadah.DLL/Discord.cpp | 25 +++++++-------- Tadah.DLL/Hooks/CRoblox.cpp | 52 ++++++++++++++++++------------- Tadah.DLL/Include/Configuration.h | 1 + Tadah.DLL/Include/Discord.h | 2 +- Tadah.DLL/dllmain.cpp | 2 +- 5 files changed, 44 insertions(+), 38 deletions(-) diff --git a/Tadah.DLL/Discord.cpp b/Tadah.DLL/Discord.cpp index 354aba4..2d9e275 100644 --- a/Tadah.DLL/Discord.cpp +++ b/Tadah.DLL/Discord.cpp @@ -2,7 +2,7 @@ #include "Discord.h" -#ifndef SERVER +#ifdef PLAYER bool isRunning = false; std::string username; @@ -10,19 +10,6 @@ int placeId; void Discord::Initialize(const std::string joinScriptUrl) { - // Check if Discord should be enabled by checking if the binary is the client as well as if the binary's containing folder contains a ".nodiscord" file - std::string path = Helpers::getModulePath(); - - if (fs::path(path).stem() != "TadahPlayer") - { - return; - } - - if (fs::exists(fs::path(path).parent_path() / ".nodiscord")) - { - return; - } - std::pair> parsed = Helpers::parseURL(joinScriptUrl); if (!parsed.first) @@ -42,11 +29,21 @@ void Discord::Initialize(const std::string joinScriptUrl) return; } + if (query.find("discord") == query.end()) + { + return; + } + if (query["ticket"].empty()) { return; } + if (query["discord"] == "0") + { + return; + } + // Get the username and placeId std::pair response = Helpers::httpGet(BASE_URL + std::string("/api/places/information?ticket=" + query["ticket"])); if (!response.first) diff --git a/Tadah.DLL/Hooks/CRoblox.cpp b/Tadah.DLL/Hooks/CRoblox.cpp index f0101aa..8cc1c11 100644 --- a/Tadah.DLL/Hooks/CRoblox.cpp +++ b/Tadah.DLL/Hooks/CRoblox.cpp @@ -6,10 +6,10 @@ #include "Server.h" #endif -bool hasAuthUrlArg = false; -bool hasAuthTicketArg = false; -bool hasJoinArg = false; -bool hasJobIdArg = false; +bool hasAuthenticationUrl = false; +bool hasAuthenticationTicket = false; +bool hasJoinScriptUrl = false; +bool hasJobId = false; std::wstring authenticationUrl; std::wstring authenticationTicket; @@ -28,19 +28,17 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this) CApp* app = reinterpret_cast(CLASSLOCATION_CAPP); -#ifndef SERVER - if (hasAuthUrlArg && hasAuthTicketArg && !authenticationUrl.empty() && !authenticationTicket.empty()) + if (hasAuthenticationUrl && hasAuthenticationTicket && !authenticationUrl.empty() && !authenticationTicket.empty()) { CApp__RobloxAuthenticate(app, nullptr, authenticationUrl.c_str(), authenticationTicket.c_str()); } -#endif - if (hasJoinArg && !joinScriptUrl.empty()) + if (hasJoinScriptUrl && !joinScriptUrl.empty()) { try { CRobloxDoc* document = CRobloxApp__CreateDocument(_this); - CWorkspace__ExecUrlScript(document->workspace, joinScriptUrl.c_str(), VARIANTARG(), VARIANTARG(), VARIANTARG(), VARIANTARG(), nullptr); + CWorkspace__ExecUrlScript(document->workspace, joinScriptUrl.c_str(), VARIANT(), VARIANT(), VARIANT(), VARIANT(), nullptr); } catch (std::runtime_error) { @@ -48,12 +46,26 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this) } } +#ifdef PLAYER + if (!hasAuthUrl || !hasAuthTicket || !hasJoinScriptUrl) + { + return FALSE; + } +#endif + +#ifdef SERVER + if (!hasAuthUrl || !hasAuthTicket || !hasJobId) + { + return FALSE; + } +#endif + return TRUE; } void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* _this, void*, const char* pszParam, BOOL bFlag, BOOL bLast) { - if (hasJoinArg && joinScriptUrl.empty()) + if (hasJoinScriptUrl && joinScriptUrl.empty()) { int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0); joinScriptUrl.resize(size); @@ -63,13 +75,12 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* CCommandLineInfo__ParseLast(_this, bLast); -#ifndef SERVER +#ifdef PLAYER Discord::Initialize(Helpers::ws2s(joinScriptUrl)); #endif } -#ifndef SERVER - if (hasAuthUrlArg && authenticationUrl.empty()) + if (hasAuthenticationUrl && authenticationUrl.empty()) { int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0); authenticationUrl.resize(size); @@ -79,7 +90,7 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* return; } - if (hasAuthTicketArg && authenticationTicket.empty()) + if (hasAuthenticationTicket && authenticationTicket.empty()) { int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0); authenticationTicket.resize(size); @@ -88,10 +99,9 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* CCommandLineInfo__ParseLast(_this, bLast); return; } -#endif #ifdef SERVER - if (hasJobIdArg && jobId.empty()) + if (hasJobId && jobId.empty()) { int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0); jobId.resize(size); @@ -102,25 +112,23 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* } #endif -#ifndef SERVER if (bFlag && _stricmp(pszParam, "a") == 0) { - hasAuthUrlArg = true; + hasAuthenticationUrl = true; CCommandLineInfo__ParseLast(_this, bLast); return; } if (bFlag && _stricmp(pszParam, "t") == 0) { - hasAuthTicketArg = true; + hasAuthenticationTicket = true; CCommandLineInfo__ParseLast(_this, bLast); return; } -#endif if (bFlag && _stricmp(pszParam, "j") == 0) { - hasJoinArg = true; + hasJoinScriptUrl = true; CCommandLineInfo__ParseLast(_this, bLast); return; } @@ -128,7 +136,7 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* #ifdef SERVER if (bFlag && _stricmp(pszParam, "jobId") == 0) { - hasJobIdArg = true; + hasJobId = true; CCommandLineInfo__ParseLast(_this, bLast); Server::Initialize(jobId); diff --git a/Tadah.DLL/Include/Configuration.h b/Tadah.DLL/Include/Configuration.h index 75aa7e1..07ea944 100644 --- a/Tadah.DLL/Include/Configuration.h +++ b/Tadah.DLL/Include/Configuration.h @@ -2,6 +2,7 @@ // This is commented out since our CI defines this automatically // #define SERVER +// #define PLAYER #define BASE_URL "https://tadah.rocks" #define DISCORD_APP_ID 923705431543668736 diff --git a/Tadah.DLL/Include/Discord.h b/Tadah.DLL/Include/Discord.h index b4f282e..928fb92 100644 --- a/Tadah.DLL/Include/Discord.h +++ b/Tadah.DLL/Include/Discord.h @@ -7,7 +7,7 @@ #include "Configuration.h" #include "Hooks/CRoblox.h" -#ifndef SERVER +#ifdef PLAYER class Discord { public: diff --git a/Tadah.DLL/dllmain.cpp b/Tadah.DLL/dllmain.cpp index 956bc44..5210929 100644 --- a/Tadah.DLL/dllmain.cpp +++ b/Tadah.DLL/dllmain.cpp @@ -83,7 +83,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv { curl_global_cleanup(); -#ifndef SERVER +#ifdef PLAYER Discord::Cleanup(); #endif