From 99a652ed3eff91df653085d258efe3916bbfffb0 Mon Sep 17 00:00:00 2001 From: rjindael Date: Fri, 28 Jul 2023 03:17:54 -0700 Subject: [PATCH] chore: merge 9305c29 -> 024e60a from prod --- Kiseki.Patcher/Resource/Information.h | 2 +- Kiseki.Patcher/Source/Helpers.cpp | 19 ++++++++---- Kiseki.Patcher/Source/Hooks/CRoblox.cpp | 30 +++++++++---------- .../Source/Hooks/ServerReplicator.cpp | 2 ++ Kiseki.Patcher/Source/main.cpp | 2 +- 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/Kiseki.Patcher/Resource/Information.h b/Kiseki.Patcher/Resource/Information.h index 35a20c0..7ceb66e 100644 --- a/Kiseki.Patcher/Resource/Information.h +++ b/Kiseki.Patcher/Resource/Information.h @@ -9,4 +9,4 @@ #define APP_NAME "Kiseki.Patcher" #define APP_DESCRIPTION "Client Functionality Library" #define APP_ORGANIZATION "Kiseki" -#define APP_COPYRIGHT "Copyright (c) Kiseki 2023" +#define APP_COPYRIGHT "Copyright (c) Kiseki 2022-2023" diff --git a/Kiseki.Patcher/Source/Helpers.cpp b/Kiseki.Patcher/Source/Helpers.cpp index e906eca..9e3ca33 100644 --- a/Kiseki.Patcher/Source/Helpers.cpp +++ b/Kiseki.Patcher/Source/Helpers.cpp @@ -144,8 +144,15 @@ std::string Helpers::getISOTimestamp() std::pair> Helpers::parseURL(const std::string url) { + // This is an ugly hack to url-encode the query before CURL actually parses the URL. + // We do this because CURL throws a fit if the query is not properly URL encoded; so URLs such as "/Error/Dmp.ashx?filename=C:/Users/..." won't parse correctly. + char* encodedQuery = curl_escape(url.substr(url.find("?") + 1).c_str(), url.substr(url.find("?") + 1).length()); + std::string encodedUrl = url.substr(0, url.find("?")) + encodedQuery; + curl_free(encodedQuery); + CURLU* curl = curl_url(); CURLUcode result = curl_url_set(curl, CURLUPART_URL, url.c_str(), 0); + CURLUcode result = curl_url_set(curl, CURLUPART_URL, encodedUrl.c_str(), 0); std::map map; bool success = false; @@ -154,20 +161,22 @@ std::pair> Helpers::parseURL(const std: { success = true; + char* scheme; char* path; char* host; char* query; + curl_url_get(curl, CURLUPART_SCHEME, &scheme, 0); curl_url_get(curl, CURLUPART_PATH, &path, 0); curl_url_get(curl, CURLUPART_HOST, &host, 0); curl_url_get(curl, CURLUPART_QUERY, &query, 0); curl_url_cleanup(curl); - map = { - { "path", std::string(path) }, - { "host", std::string(host) }, - { "query", std::string(query) } - }; + // ugly ternaries to prevent edge-case access violations + map["scheme"] = scheme ? std::string(scheme) : ""; + map["path"] = path ? std::string(path) : ""; + map["host"] = host ? std::string(host) : ""; + map["query"] = query ? std::string(query) : ""; curl_free(path); curl_free(host); diff --git a/Kiseki.Patcher/Source/Hooks/CRoblox.cpp b/Kiseki.Patcher/Source/Hooks/CRoblox.cpp index d87422d..c3ebc6d 100644 --- a/Kiseki.Patcher/Source/Hooks/CRoblox.cpp +++ b/Kiseki.Patcher/Source/Hooks/CRoblox.cpp @@ -20,6 +20,21 @@ CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobl BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this) { +#ifdef PLAYER + if (!hasAuthenticationUrl || !hasAuthenticationTicket || !hasJoinScriptUrl) + { + ShellExecute(0, 0, L"https://kiseki.lol/games", 0, 0, SW_SHOW); + return FALSE; + } +#endif + +#ifdef SERVER + if (!hasJobId) + { + return FALSE; + } +#endif + if (!CRobloxApp__InitInstance(_this)) { return FALSE; @@ -45,21 +60,6 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this) } } -#ifdef SERVER - if (!hasJobId) - { - return FALSE; - } -#endif - -#ifdef PLAYER - if (!hasAuthenticationUrl || !hasAuthenticationTicket || !hasJoinScriptUrl) - { - ShellExecute(0, 0, L"https://kiseki.lol/games", 0, 0, SW_SHOW); - return FALSE; - } -#endif - return TRUE; } diff --git a/Kiseki.Patcher/Source/Hooks/ServerReplicator.cpp b/Kiseki.Patcher/Source/Hooks/ServerReplicator.cpp index ede9516..535280e 100644 --- a/Kiseki.Patcher/Source/Hooks/ServerReplicator.cpp +++ b/Kiseki.Patcher/Source/Hooks/ServerReplicator.cpp @@ -1,5 +1,7 @@ #ifdef SERVER +#include + #include "Hooks/ServerReplicator.hpp" static std::map rakPeers; diff --git a/Kiseki.Patcher/Source/main.cpp b/Kiseki.Patcher/Source/main.cpp index 4863812..e2cf590 100644 --- a/Kiseki.Patcher/Source/main.cpp +++ b/Kiseki.Patcher/Source/main.cpp @@ -29,7 +29,7 @@ ADD_PATCH(Http__trustCheck, Http__trustCheck_hook) ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook) -#if defined(PLAYER) or defined(SERVER) +#if defined(PLAYER) || defined(SERVER) ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook) ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook) #endif