diff --git a/PolygonClientUtilities/Config.h b/PolygonClientUtilities/Config.h index fcf3676..aefe947 100644 --- a/PolygonClientUtilities/Config.h +++ b/PolygonClientUtilities/Config.h @@ -5,6 +5,9 @@ // RobloxApp (2010) #ifdef MFC2010 +#define STRUCTOFFSET_DATAMODEL__JOBID 2912 + +#define ADDRESS_DATAMODEL__GETJOBID 0x005CACC0 #define ADDRESS_STANDARDOUT__PRINT 0x0059F340 #define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x004FC1A0 #define ADDRESS_HTTP__TRUSTCHECK 0x005A2680 @@ -20,10 +23,13 @@ // RobloxApp (2011) #ifdef MFC2011 +#define STRUCTOFFSET_DATAMODEL__JOBID 2956 + +#define ADDRESS_DATAMODEL__GETJOBID 0x005E70C0 #define ADDRESS_STANDARDOUT__PRINT 0x005B25E0 #define ADDRESS_NETWORK__RAKNETADDRESSTOSTRING 0x0 #define ADDRESS_HTTP__TRUSTCHECK 0x005B7050 -#define ADDRESS_HTTP__VERIFYSIGNATUREBASE64 0x00809EC0 +#define ADDRESS_CRYPT__VERIFYSIGNATUREBASE64 0x00809EC0 #define ADDRESS_CAPP__CREATEGAME 0x0 #define ADDRESS_CAPP__ROBLOXAUTHENTICATE 0x0 #define ADDRESS_CROBLOXAPP__INITINSTANCE 0x004613C0 diff --git a/PolygonClientUtilities/Debug/PolygonClientUtilities.ilk b/PolygonClientUtilities/Debug/PolygonClientUtilities.ilk index b0b964a..ede2fbd 100644 Binary files a/PolygonClientUtilities/Debug/PolygonClientUtilities.ilk and b/PolygonClientUtilities/Debug/PolygonClientUtilities.ilk differ diff --git a/PolygonClientUtilities/Logger.cpp b/PolygonClientUtilities/Logger.cpp index 55a2c49..f44205b 100644 --- a/PolygonClientUtilities/Logger.cpp +++ b/PolygonClientUtilities/Logger.cpp @@ -14,12 +14,16 @@ void Logger::Initialize(const std::string jobId) Logger::handle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); SetStdHandle(STD_OUTPUT_HANDLE, Logger::handle); +#ifndef NDEBUG + printf("[[[ DLL COMPILED AS DEBUG ]]]\n"); +#endif + // lol - printf("Access key read: \n"); - printf("Current Access key: \n"); - printf("Service starting...\n"); - printf("Intializing Roblox Web Service\n"); - printf("Service Started on port 64989\n"); + // printf("Access key read: \n"); + // printf("Current Access key: \n"); + // printf("Service starting...\n"); + // printf("Intializing Roblox Web Service\n"); + // printf("Service Started on port 64989\n"); Logger::outputLog = std::ofstream(jobId + std::string("-Output.txt")); Logger::httpLog = std::ofstream(jobId + std::string("-Http.txt")); diff --git a/PolygonClientUtilities/PolygonClientUtilities.vcxproj b/PolygonClientUtilities/PolygonClientUtilities.vcxproj index 8a75c4f..24c8515 100644 --- a/PolygonClientUtilities/PolygonClientUtilities.vcxproj +++ b/PolygonClientUtilities/PolygonClientUtilities.vcxproj @@ -167,6 +167,7 @@ + @@ -183,6 +184,7 @@ Create + diff --git a/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters b/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters index 078da28..1d43609 100644 --- a/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters +++ b/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters @@ -36,6 +36,9 @@ Header Files + + Header Files + @@ -56,5 +59,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/PolygonClientUtilities/RobloxMFCHooks.cpp b/PolygonClientUtilities/RobloxMFCHooks.cpp index 6969100..30545cb 100644 --- a/PolygonClientUtilities/RobloxMFCHooks.cpp +++ b/PolygonClientUtilities/RobloxMFCHooks.cpp @@ -1,13 +1,15 @@ #include "pch.h" #include "RobloxMFCHooks.h" -#include "Logger.h" #include "Config.h" +#include "Util.h" +#include "Logger.h" #include "LUrlParser.h" static bool hasAuthUrlArg = false; static bool hasAuthTicketArg = false; static bool hasJoinArg = false; static bool hasJobId = false; +static bool setJobId = false; static std::wstring authenticationUrl; static std::wstring authenticationTicket; @@ -19,6 +21,7 @@ static std::string jobId; Http__trustCheck_t Http__trustCheck = (Http__trustCheck_t)ADDRESS_HTTP__TRUSTCHECK; Crypt__verifySignatureBase64_t Crypt__verifySignatureBase64 = (Crypt__verifySignatureBase64_t)ADDRESS_CRYPT__VERIFYSIGNATUREBASE64; #ifdef ARBITERBUILD +DataModel__getJobId_t DataModel__getJobId = (DataModel__getJobId_t)ADDRESS_DATAMODEL__GETJOBID; StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT; // Network__RakNetAddressToString_t Network__RakNetAddressToString = (Network__RakNetAddressToString_t)ADDRESS_NETWORK__RAKNETADDRESSTOSTRING; #endif @@ -31,34 +34,6 @@ CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobl BOOL __fastcall Http__trustCheck_hook(const char* url) { - const std::vector allowedHosts - { - "polygon.pizzaboxer.xyz", - "polygondev.pizzaboxer.xyz", - "polygonapi.pizzaboxer.xyz", - - "roblox.com", - "www.roblox.com", - "assetdelivery.roblox.com", - - "tadah.rocks", - "www.tadah.rocks" - }; - - const std::vector allowedSchemes - { - "http", - "https", - "ftp", - }; - - const std::vector allowedEmbeddedSchemes - { - "javascript", - "jscript", - "res", - }; - LUrlParser::ParseURL parsedUrl = LUrlParser::ParseURL::parseURL(url); if (!parsedUrl.isValid()) @@ -71,10 +46,10 @@ BOOL __fastcall Http__trustCheck_hook(const char* url) if (std::string("about:blank") == url) return true; - if (std::find(allowedSchemes.begin(), allowedSchemes.end(), parsedUrl.scheme_) != allowedSchemes.end()) - return std::find(allowedHosts.begin(), allowedHosts.end(), parsedUrl.host_) != allowedHosts.end(); + if (std::find(Util::allowedSchemes.begin(), Util::allowedSchemes.end(), parsedUrl.scheme_) != Util::allowedSchemes.end()) + return std::find(Util::allowedHosts.begin(), Util::allowedHosts.end(), parsedUrl.host_) != Util::allowedHosts.end(); - if (std::find(allowedEmbeddedSchemes.begin(), allowedEmbeddedSchemes.end(), parsedUrl.scheme_) != allowedEmbeddedSchemes.end()) + if (std::find(Util::allowedEmbeddedSchemes.begin(), Util::allowedEmbeddedSchemes.end(), parsedUrl.scheme_) != Util::allowedEmbeddedSchemes.end()) return true; return false; @@ -98,6 +73,28 @@ void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, char } #ifdef ARBITERBUILD +int __fastcall DataModel__getJobId_hook(char* _this, void*, int a2) +{ + // this only sets the job id when game.jobId is called by lua + // so the gameserver script must call game.jobId at the beginning for this to take effect + // also, this only applies to the first datamodel that is created + + if (!setJobId && hasJobId && !jobId.empty()) + { + int jobIdPtr = (int)_this + STRUCTOFFSET_DATAMODEL__JOBID; +#ifdef NDEBUG + jobIdPtr += 4; +#endif + + std::string* jobIdValue = (std::string*)jobIdPtr; + jobIdValue->assign(jobId); + + setJobId = true; + } + + return DataModel__getJobId(_this, a2); +} + void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message) { StandardOut__print(_this, type, message); @@ -107,11 +104,10 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* #ifdef NDEBUG // for some reason, the location of the message pointer is offset 4 bytes when compiled as release // i assume doing this is safe? most of the examples ive seen use reinterpret_cast but this seems to work fine - int messagePtr = (int)message; - messagePtr += 4; + int messagePtr = (int)message + 4; std::string* message = (std::string*)messagePtr; - #endif + switch (type) { case 1: // RBX::MESSAGE_OUTPUT: @@ -131,7 +127,6 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_INTENSITY); break; } - printf("%s\n", message->c_str()); SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); } diff --git a/PolygonClientUtilities/RobloxMFCHooks.h b/PolygonClientUtilities/RobloxMFCHooks.h index 425c248..92db71a 100644 --- a/PolygonClientUtilities/RobloxMFCHooks.h +++ b/PolygonClientUtilities/RobloxMFCHooks.h @@ -4,9 +4,10 @@ // Type Definitions // -typedef void(__thiscall* Http__trustCheck_t)(const char* url); +typedef BOOL(__thiscall* Http__trustCheck_t)(const char* url); typedef void(__thiscall* Crypt__verifySignatureBase64_t)(HCRYPTPROV* _this, char a2, int a3, int a4, int a5, int a6, int a7, int a8, char a9, int a10, int a11, int a12, int a13, int a14, int a15); #ifdef ARBITERBUILD +typedef INT(__thiscall* DataModel__getJobId_t)(char* _this, int a2); typedef void(__thiscall* StandardOut__print_t)(int _this, int type, std::string* message); // typedef void(__thiscall* Network__RakNetAddressToString_t)(int raknetAddress, bool writePort, char portDelineator); #endif @@ -20,6 +21,7 @@ typedef void(__thiscall* CRobloxCommandLineInfo__ParseParam_t)(CRobloxCommandLin extern Http__trustCheck_t Http__trustCheck; extern Crypt__verifySignatureBase64_t Crypt__verifySignatureBase64; #ifdef ARBITERBUILD +extern DataModel__getJobId_t DataModel__getJobId; extern StandardOut__print_t StandardOut__print; // extern Network__RakNetAddressToString_t Network__RakNetAddressToString; #endif @@ -33,6 +35,7 @@ extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam; BOOL __fastcall Http__trustCheck_hook(const char* url); void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, char a2, int a3, int a4, int a5, int a6, int a7, int a8, char a9, int a10, int a11, int a12, int a13, int a14, int a15); #ifdef ARBITERBUILD +INT __fastcall DataModel__getJobId_hook(char* _this, void*, int a2); void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message); // std::string __fastcall Network__RakNetAddressToString_hook(int raknetAddress, bool writePort, char portDelineator); #endif diff --git a/PolygonClientUtilities/Util.cpp b/PolygonClientUtilities/Util.cpp new file mode 100644 index 0000000..2872425 --- /dev/null +++ b/PolygonClientUtilities/Util.cpp @@ -0,0 +1,30 @@ +#include "pch.h" +#include "Util.h" + +const std::vector Util::allowedHosts +{ + "polygon.pizzaboxer.xyz", + "polygondev.pizzaboxer.xyz", + "polygonapi.pizzaboxer.xyz", + + "roblox.com", + "www.roblox.com", + "assetdelivery.roblox.com", + + "tadah.rocks", + "www.tadah.rocks" +}; + +const std::vector Util::allowedSchemes +{ + "http", + "https", + "ftp" +}; + +const std::vector Util::allowedEmbeddedSchemes +{ + "javascript", + "jscript", + "res" +}; \ No newline at end of file diff --git a/PolygonClientUtilities/Util.h b/PolygonClientUtilities/Util.h new file mode 100644 index 0000000..ff252fa --- /dev/null +++ b/PolygonClientUtilities/Util.h @@ -0,0 +1,11 @@ +#pragma once + +#include "pch.h" + +class Util +{ +public: + static const std::vector allowedHosts; + static const std::vector allowedSchemes; + static const std::vector allowedEmbeddedSchemes; +}; \ No newline at end of file diff --git a/PolygonClientUtilities/dllmain.cpp b/PolygonClientUtilities/dllmain.cpp index cdb4d3b..13aeb40 100644 --- a/PolygonClientUtilities/dllmain.cpp +++ b/PolygonClientUtilities/dllmain.cpp @@ -7,6 +7,7 @@ START_PATCH_LIST() ADD_PATCH(Http__trustCheck, Http__trustCheck_hook) ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook) #if defined(MFC2010) || defined(MFC2011) +ADD_PATCH(DataModel__getJobId, DataModel__getJobId_hook) ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook) ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook) #endif