From 4236047aaeec89163557c1f1e678a51bc4b79921 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Mon, 24 Jan 2022 19:58:39 +0000 Subject: [PATCH] use datamodel struct for jobid and use reinterpret_cast for std::string offset --- PolygonClientUtilities/Config.h | 41 ++++++++++++++++++++--- PolygonClientUtilities/RobloxMFCClasses.h | 8 ++--- PolygonClientUtilities/RobloxMFCHooks.cpp | 25 +++++++------- PolygonClientUtilities/RobloxMFCHooks.h | 4 +-- 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/PolygonClientUtilities/Config.h b/PolygonClientUtilities/Config.h index b4b5458..1b23376 100644 --- a/PolygonClientUtilities/Config.h +++ b/PolygonClientUtilities/Config.h @@ -16,9 +16,9 @@ #define CLASSLOCATION_CAPP 0x00405D20 #define CLASSPADDING_CROBLOXDOC__WORKSPACE 40 -#define CLASSPADDING_DATAMODEL__JOBID 730 +#define CLASSPADDING_DATAMODEL__JOBID 729 // when compiled as debug, this must be 728 -#define STRUCTOFFSET_DATAMODEL__JOBID 2912 +// #define STRUCTOFFSET_DATAMODEL__JOBID 2912 #define ADDRESS_DATAMODEL__GETJOBID 0x005CACC0 #define ADDRESS_STANDARDOUT__PRINT 0x0059F340 @@ -40,8 +40,9 @@ #define CLASSLOCATION_CAPP 0x00406D80 #define CLASSPADDING_CROBLOXDOC__WORKSPACE 45 +#define CLASSPADDING_DATAMODEL__JOBID 740 // when compiled as debug, this must be 739 -#define STRUCTOFFSET_DATAMODEL__JOBID 2956 +// #define STRUCTOFFSET_DATAMODEL__JOBID 2956 #define ADDRESS_DATAMODEL__GETJOBID 0x005E70C0 #define ADDRESS_STANDARDOUT__PRINT 0x005B25E0 @@ -55,4 +56,36 @@ #define ADDRESS_CWORKSPACE__EXECURLSCRIPT 0x0049FC90 #define ADDRESS_CROBLOXCOMMANDLINEINFO__PARSEPARAM 0x0045EE50 #define ADDRESS_CCOMMANDLINEINFO__PARSELAST 0x0081354A -#endif \ No newline at end of file +#endif + + +// RakNet definitions +// these are extracted from the 2016 source, but they're probably shifted 2 up compared to 2010 and 2011 +// some of these probably dont even exist in 2010 and 2011 +// i'll check later + +#define ID_TEACH_DESCRIPTOR_DICTIONARIES 130 +#define ID_DATA 131 +#define ID_REQUEST_MARKER 132 +#define ID_PHYSICS 133 +#define ID_PHYSICS_TOUCHES 134 +#define ID_CHAT_ALL 135 +#define ID_CHAT_TEAM 136 +#define ID_REPORT_ABUSE 137 +#define ID_SUBMIT_TICKET 138 +#define ID_CHAT_GAME 139 +#define ID_CHAT_PLAYER 140 +#define ID_CLUSTER 141 +#define ID_PROTOCAL_MISMATCH 142 +#define ID_SPAWN_NAME 143 +#define ID_PROTOCOL_SYNC 144 +#define ID_SCHEMA_SYNC 145 +#define ID_PLACEID_VERIFICATION 146 +#define ID_DICTIONARY_FORMAT 147 +#define ID_HASH_MISMATCH 148 +#define ID_SECURITYKEY_MISMATCH 149 +#define ID_REQUEST_STATS 150 + +#define RR_STOP_PROCESSING_AND_DEALLOCATE 0 +#define RR_CONTINUE_PROCESSING 1 +#define RR_STOP_PROCESSING 2 \ No newline at end of file diff --git a/PolygonClientUtilities/RobloxMFCClasses.h b/PolygonClientUtilities/RobloxMFCClasses.h index 7e6ea09..0fcaf35 100644 --- a/PolygonClientUtilities/RobloxMFCClasses.h +++ b/PolygonClientUtilities/RobloxMFCClasses.h @@ -4,13 +4,13 @@ #include -/* struct DataModel +struct DataModel { void* padding1[CLASSPADDING_DATAMODEL__JOBID]; - std::string* jobId; -}; */ + std::string jobId; +}; -class DataModel; +// class DataModel; #if defined(MFC2010) || defined(MFC2011) class CWorkspace; diff --git a/PolygonClientUtilities/RobloxMFCHooks.cpp b/PolygonClientUtilities/RobloxMFCHooks.cpp index 107b0e5..2dd6625 100644 --- a/PolygonClientUtilities/RobloxMFCHooks.cpp +++ b/PolygonClientUtilities/RobloxMFCHooks.cpp @@ -82,13 +82,7 @@ int __fastcall DataModel__getJobId_hook(DataModel* _this, void*, int a2) if (!setJobId && hasJobId && !jobId.empty()) { - int jobIdPtr = (int)_this + STRUCTOFFSET_DATAMODEL__JOBID; -#ifdef NDEBUG - jobIdPtr += 4; -#endif - - ((std::string*)jobIdPtr)->assign(jobId); - + _this->jobId = jobId; setJobId = true; } @@ -102,10 +96,9 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* if (Logger::handle) { #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 + // i have absolutely no clue why but the location of the message pointer is offset 4 bytes when the dll compiled as release int messagePtr = (int)message + 4; - std::string* message = (std::string*)messagePtr; + std::string* message = reinterpret_cast(messagePtr); #endif switch (type) @@ -132,10 +125,9 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* } } -// std::string __fastcall Network__RakNetAddressToString_hook(int raknetAddress, bool writePort, char portDelineator) +// std::string __fastcall Network__RakNetAddressToString_hook(const int raknetAddress, char portDelineator) // { -// Network__RakNetAddressToString(raknetAddress, writePort, portDelineator); -// return std::string("hi"); +// return Network__RakNetAddressToString(raknetAddress, portDelineator); // } #endif @@ -163,6 +155,13 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this) { // TODO: use CApp__CreateGame instead CRobloxDoc* document = CRobloxApp__CreateDocument(_this); + + printf("address of document: %p\n", document); + printf("\n"); + printf("address of &document->workspace: %p\n", &document->workspace); + printf("address of document->workspace: %p\n", document->workspace); + printf("\n"); + CWorkspace__ExecUrlScript(document->workspace, joinScriptUrl.c_str(), VARIANTARG(), VARIANTARG(), VARIANTARG(), VARIANTARG(), nullptr); } catch (std::runtime_error& exception) diff --git a/PolygonClientUtilities/RobloxMFCHooks.h b/PolygonClientUtilities/RobloxMFCHooks.h index e73c72f..ca1258e 100644 --- a/PolygonClientUtilities/RobloxMFCHooks.h +++ b/PolygonClientUtilities/RobloxMFCHooks.h @@ -9,7 +9,7 @@ typedef void(__thiscall* Crypt__verifySignatureBase64_t)(HCRYPTPROV* _this, char #ifdef ARBITERBUILD typedef INT(__thiscall* DataModel__getJobId_t)(DataModel* _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); +// typedef std::string(__thiscall* Network__RakNetAddressToString_t)(const int raknetAddress, char portDelineator); #endif #if defined(MFC2010) || defined(MFC2011) // typedef INT(__thiscall* CApp__CreateGame_t)(CApp* _this, int a2, LPCWSTR a3); @@ -39,7 +39,7 @@ void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, char #ifdef ARBITERBUILD INT __fastcall DataModel__getJobId_hook(DataModel* _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); +// std::string __fastcall Network__RakNetAddressToString_hook(const int raknetAddress, char portDelineator); #endif #if defined(MFC2010) || defined(MFC2011) // INT __fastcall CApp__CreateGame_hook(CApp* _this, void*, int a2, LPCWSTR a3);