diff --git a/PolygonClientUtilities/Config.h b/PolygonClientUtilities/Config.h index ed60efc..14ace0f 100644 --- a/PolygonClientUtilities/Config.h +++ b/PolygonClientUtilities/Config.h @@ -4,6 +4,9 @@ #define PLAYERBUILD #define ARBITERBUILD +// when PLAYERBUILD is defined, the following changes occur for 2010 and 2012 only: +// the -jobId arg is parsed + // when ARBITERBUILD is defined, the following changes occur: // DataModel->getJobId is hooked // StandardOut->print is hooked @@ -21,6 +24,9 @@ #define ADDRESS_HTTP__TRUSTCHECK 0x005A2680 #define ADDRESS_CRYPT__VERIFYSIGNATUREBASE64 0x0079ECF0 +#define ADDRESS_SERVERREPLICATOR__PROCESSPACKET 0x00507420 +#define ADDRESS_RAKNET__BITSTREAM 0x004DBF00 + // MFC specific definitions #define CLASSLOCATION_CROBLOXAPP 0x00BFF898 #define CLASSLOCATION_CAPP 0x00405D20 @@ -34,6 +40,10 @@ #define ADDRESS_CWORKSPACE__EXECURLSCRIPT 0x0047EC10 #define ADDRESS_CROBLOXCOMMANDLINEINFO__PARSEPARAM 0x00450AC0 #define ADDRESS_CCOMMANDLINEINFO__PARSELAST 0x007A80A0 + +// RakNet packet definitions +#define ID_REQUEST_CHARACTER 96 +#define ID_SUBMIT_TICKET 104 #endif // RobloxApp (2011) @@ -59,6 +69,9 @@ #define ADDRESS_CWORKSPACE__EXECURLSCRIPT 0x0049FC90 #define ADDRESS_CROBLOXCOMMANDLINEINFO__PARSEPARAM 0x0045EE50 #define ADDRESS_CCOMMANDLINEINFO__PARSELAST 0x0081354A + +#define ID_DATA 129 +#define ID_SUBMIT_TICKET 135 #endif // RobloxApp/RobloxPlayer (2012) @@ -105,7 +118,41 @@ // some of these probably dont even exist in 2010 and 2011 // i'll check later -#define ID_TEACH_DESCRIPTOR_DICTIONARIES 130 +// TODO: move all of these to an enum (2012 and newer are offset by +2) + +// Stock RakNet definitions +// #define ID_CONNECTION_REQUEST_ACCEPTED 14 +// #define ID_CONNECTION_ATTEMPT_FAILED 15 +// #define ID_ALREADY_CONNECTED 16 +// #define ID_NEW_INCOMING_CONNECTION 17 +// #define ID_NO_FREE_INCOMING_CONNECTIONS 18 +// #define ID_DISCONNECTION_NOTIFICATION 19 +// #define ID_CONNECTION_LOST 20 +// #define ID_CONNECTION_BANNED 21 +// #define ID_INVALID_PASSWORD 22 +// #define ID_INCOMPATIBLE_PROTOCOL_VERSION 23 +// #define ID_TIMESTAMP 27 + +// ROBLOX-specific RakNet definitions +// #define ID_SET_GLOBALS 127 +// #define ID_TEACH_DESCRIPTOR_DICTIONARIES 128 +// #define ID_DATA 129 +// #define ID_REQUEST_MARKER 130 +// #define ID_SUBMIT_TICKET 135 + +// according to the 2016 source, here's all the enums that practically do the same thing in Replicator.cpp: +// ID_PHYSICS_TOUCHES +// ID_SCHEMA_SYNC +// ID_TEACH_DESCRIPTOR_DICTIONARIES +// ID_DATA +// ID_CLUSTER +// ID_SET_GLOBALS + +// in the 2016 source there's an extra enum between ID_SUBMIT_TICKET and ID_REQUEST_MARKER +// in 2011, ID_REQUEST_MARKER is 130 and ID_SUBMIT_TICKET is 135 +// but in the 2016 source, ID_REQUEST_MARKER is 132 and ID_SUBMIT_TICKET is 138 + +/* #define ID_TEACH_DESCRIPTOR_DICTIONARIES 130 #define ID_DATA 131 #define ID_REQUEST_MARKER 132 #define ID_PHYSICS 133 @@ -125,7 +172,7 @@ #define ID_DICTIONARY_FORMAT 147 #define ID_HASH_MISMATCH 148 #define ID_SECURITYKEY_MISMATCH 149 -#define ID_REQUEST_STATS 150 +#define ID_REQUEST_STATS 150 */ #define RR_STOP_PROCESSING_AND_DEALLOCATE 0 #define RR_CONTINUE_PROCESSING 1 diff --git a/PolygonClientUtilities/Logger.cpp b/PolygonClientUtilities/Logger.cpp index f44205b..81ec1c4 100644 --- a/PolygonClientUtilities/Logger.cpp +++ b/PolygonClientUtilities/Logger.cpp @@ -44,6 +44,33 @@ void Logger::Log(LogType type, const std::string message) } } +void Logger::Print(int type, const std::string message) +{ + if (!Logger::handle) return; + + switch (type) + { + case 1: // RBX::MESSAGE_OUTPUT: + Logger::Log(LogType::Output, std::string("[MESSAGE_OUTPUT] ") + message); + SetConsoleTextAttribute(Logger::handle, FOREGROUND_BLUE | FOREGROUND_INTENSITY); + break; + case 0: // RBX::MESSAGE_INFO: + Logger::Log(LogType::Output, std::string("[MESSAGE_INFO] ") + message); + SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + break; + case 2: // RBX::MESSAGE_WARNING: + Logger::Log(LogType::Output, std::string("[MESSAGE_WARNING] ") + message); + SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN); + break; + case 3: // RBX::MESSAGE_ERROR: + Logger::Log(LogType::Output, std::string("[MESSAGE_ERROR] ") + message); + SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_INTENSITY); + break; + } + printf("%s\n", message.c_str()); + SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); +} + std::string Logger::UtcTime() { std::stringstream time; diff --git a/PolygonClientUtilities/Logger.h b/PolygonClientUtilities/Logger.h index 17a3b68..21c7836 100644 --- a/PolygonClientUtilities/Logger.h +++ b/PolygonClientUtilities/Logger.h @@ -13,5 +13,6 @@ public: static HANDLE handle; static void Initialize(const std::string jobId); static void Log(LogType type, const std::string message); + static void Print(int type, const std::string message); static std::string UtcTime(); }; \ No newline at end of file diff --git a/PolygonClientUtilities/RobloxMFCClasses.h b/PolygonClientUtilities/RobloxMFCClasses.h index 207ee13..0373c5c 100644 --- a/PolygonClientUtilities/RobloxMFCClasses.h +++ b/PolygonClientUtilities/RobloxMFCClasses.h @@ -10,6 +10,14 @@ struct DataModel void* padding1[CLASSPADDING_DATAMODEL__JOBID]; std::string jobId; }; + +struct Packet +{ + void* padding1[7]; + unsigned int length; + void* padding2[1]; + unsigned char* data; +}; #endif #if defined(MFC2010) || defined(MFC2011) diff --git a/PolygonClientUtilities/RobloxMFCHooks.cpp b/PolygonClientUtilities/RobloxMFCHooks.cpp index 1d79a43..525d9ce 100644 --- a/PolygonClientUtilities/RobloxMFCHooks.cpp +++ b/PolygonClientUtilities/RobloxMFCHooks.cpp @@ -34,6 +34,9 @@ Application__ParseArguments_t Application__ParseArguments = (Application__ParseA CRobloxApp__InitInstance_t CRobloxApp__InitInstance = (CRobloxApp__InitInstance_t)ADDRESS_CROBLOXAPP__INITINSTANCE; CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobloxCommandLineInfo__ParseParam_t)ADDRESS_CROBLOXCOMMANDLINEINFO__PARSEPARAM; #endif +#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET +ServerReplicator__processPacket_t ServerReplicator__processPacket = (ServerReplicator__processPacket_t)ADDRESS_SERVERREPLICATOR__PROCESSPACKET; +#endif // Hook Definitions // @@ -116,27 +119,7 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* std::string* message = reinterpret_cast(messagePtr); #endif - switch (type) - { - case 1: // RBX::MESSAGE_OUTPUT: - Logger::Log(LogType::Output, std::string("[MESSAGE_OUTPUT] ") + *message); - SetConsoleTextAttribute(Logger::handle, FOREGROUND_BLUE | FOREGROUND_INTENSITY); - break; - case 0: // RBX::MESSAGE_INFO: - Logger::Log(LogType::Output, std::string("[MESSAGE_INFO] ") + *message); - SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - break; - case 2: // RBX::MESSAGE_WARNING: - Logger::Log(LogType::Output, std::string("[MESSAGE_WARNING] ") + *message); - SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN); - break; - case 3: // RBX::MESSAGE_ERROR: - Logger::Log(LogType::Output, std::string("[MESSAGE_ERROR] ") + *message); - SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_INTENSITY); - break; - } - printf("%s\n", message->c_str()); - SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + Logger::Print(type, *message); } } @@ -307,4 +290,31 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* CRobloxCommandLineInfo__ParseParam(_this, pszParam, bFlag, bLast); } +#endif + +#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET +INT __fastcall ServerReplicator__processPacket_hook(int _this, void*, Packet* packet) +{ + if ((unsigned char)packet->data[0] == ID_SUBMIT_TICKET) + { + printf("ServerReplicator::processPacket received ID_SUBMIT_TICKET\n"); + } + + /* switch ((unsigned char)packet->data[0]) + { + case ID_SUBMIT_TICKET: + // printf("ServerReplicator::processPacket called: ID_SUBMIT_TICKET\n"); + return ServerReplicator__processPacket(_this, packet); + + default: + if (true) + { + Logger::Print(2, "Player not authenticated s"); + return RR_STOP_PROCESSING_AND_DEALLOCATE; + } + return ServerReplicator__processPacket(_this, packet); + } */ + + return ServerReplicator__processPacket(_this, packet); +} #endif \ No newline at end of file diff --git a/PolygonClientUtilities/RobloxMFCHooks.h b/PolygonClientUtilities/RobloxMFCHooks.h index da5347c..4efce6c 100644 --- a/PolygonClientUtilities/RobloxMFCHooks.h +++ b/PolygonClientUtilities/RobloxMFCHooks.h @@ -19,23 +19,8 @@ typedef BOOL(__thiscall* Application__ParseArguments_t)(int _this, int a2, const typedef BOOL(__thiscall* CRobloxApp__InitInstance_t)(CRobloxApp* _this); typedef void(__thiscall* CRobloxCommandLineInfo__ParseParam_t)(CRobloxCommandLineInfo* _this, const char* pszParam, BOOL bFlag, BOOL bLast); #endif - -// Externals // - -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; -#ifdef PLAYER2012 -extern Application__ParseArguments_t Application__ParseArguments; -#endif -#endif -#if defined(MFC2010) || defined(MFC2011) -// extern CApp__CreateGame_t CApp__CreateGame; -extern CRobloxApp__InitInstance_t CRobloxApp__InitInstance; -extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam; +#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET +typedef int(__thiscall* ServerReplicator__processPacket_t)(int _this, Packet* packet); #endif // Hook Declarations // @@ -54,4 +39,28 @@ BOOL __fastcall Application__ParseArguments_hook(int _this, void*, int a2, const // INT __fastcall CApp__CreateGame_hook(CApp* _this, void*, int *a2, LPCWSTR a3); BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this); void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* _this, void*, const char* pszParam, BOOL bFlag, BOOL bLast); +#endif +#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET +INT __fastcall ServerReplicator__processPacket_hook(int _this, void*, Packet* packet); +#endif + +// Externals // + +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; +#ifdef PLAYER2012 +extern Application__ParseArguments_t Application__ParseArguments; +#endif +#endif +#if defined(MFC2010) || defined(MFC2011) +// extern CApp__CreateGame_t CApp__CreateGame; +extern CRobloxApp__InitInstance_t CRobloxApp__InitInstance; +extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam; +#endif +#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET +extern ServerReplicator__processPacket_t ServerReplicator__processPacket; #endif \ No newline at end of file diff --git a/PolygonClientUtilities/dllmain.cpp b/PolygonClientUtilities/dllmain.cpp index 108b79a..87df7b8 100644 --- a/PolygonClientUtilities/dllmain.cpp +++ b/PolygonClientUtilities/dllmain.cpp @@ -20,13 +20,16 @@ ADD_PATCH(Application__ParseArguments, Application__ParseArguments_hook) ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook) ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook) #endif +#ifdef DEBUG_SERVERREPLICATOR__PROCESSPACKET +ADD_PATCH(ServerReplicator__processPacket, ServerReplicator__processPacket_hook) +#endif END_PATCH_LIST() // DLLs for release will be loaded with VMProtect, so this isn't necessary // Arbiter will still use Stud_PE for ease in swapping DLLs however -// #ifdef ARBITERBUILD +#ifdef ARBITERBUILD void __declspec(dllexport) import() {} -// #endif +#endif BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {