Clean up some parts of the code that made me mad

This commit is contained in:
lightbulblighter 2022-06-04 03:44:12 -07:00
parent ef76a754f0
commit 1c52e8e499
No known key found for this signature in database
GPG Key ID: 0B2452F9DE0E2D01
3 changed files with 33 additions and 27 deletions

View File

@ -3,19 +3,20 @@
#define MFC2010 #define MFC2010
#define PLAYERBUILD #define PLAYERBUILD
#define ARBITERBUILD #define ARBITERBUILD
// #define DEBUG_SERVERREPLICATOR__PROCESSPACKET // #define DEBUG_SERVERREPLICATOR__PROCESSPACKET
// when PLAYERBUILD is defined, the following changes occur for 2010 and 2012 only: /*
// the -jobId arg is parsed * PLAYERBUILD (2010 and 2012):
* - The "-jobId" argument is parsed
// when ARBITERBUILD is defined, the following changes occur: *
// DataModel::getJobId is hooked * ARBITERBUILD:
// DataModel::~DataModel is hooked * - DataModel::getJobId is hooked
// StandardOut::print is hooked * - DataModel::~DataModel is hooked
// Network::RakNetAddressToString is hooked * - StandardOut::print is hooked
// -jobId arg becomes available * - Network::RakNetAddressToString is hooked
// HTTP requests and output messages are logged to a file * - The "-jobId" argument becomes available
* - HTTP requests and console output is logged to a file
*/
// RobloxApp (2010) // RobloxApp (2010)
#ifdef MFC2010 #ifdef MFC2010

View File

@ -30,9 +30,8 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string*
StandardOut__print(_this, type, message); StandardOut__print(_this, type, message);
#ifdef NDEBUG #ifdef NDEBUG
// i have absolutely no clue why but the location of the message pointer is offset 4 bytes when the dll compiled as release // Message pointer is offset 4 bytes when the DLL is compiled as release
int messagePtr = (int)message + 4; message = reinterpret_cast<std::string*>((int)message + 4);
message = reinterpret_cast<std::string*>(messagePtr);
#endif #endif
if (message->compare("NewGame") == 0 || message->compare("NewGame2") == 0) if (message->compare("NewGame") == 0 || message->compare("NewGame2") == 0)
@ -64,19 +63,20 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string*
switch (type) switch (type)
{ {
case 1: // RBX::MESSAGE_OUTPUT: case RBX__MESSAGE_OUTPUT:
SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY); SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
break; break;
case 0: // RBX::MESSAGE_INFO: case RBX__MESSAGE_INFO:
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
break; break;
case 2: // RBX::MESSAGE_WARNING: case RBX__MESSAGE_WARNING:
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN); SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN);
break; break;
case 3: // RBX::MESSAGE_ERROR: case RBX__MESSAGE_ERROR:
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY); SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY);
break; break;
} }
printf("%s\n", message->c_str()); printf("%s\n", message->c_str());
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} }

View File

@ -6,4 +6,9 @@ void InitializeOutput();
typedef void(__thiscall* StandardOut__print_t)(int _this, int type, std::string* message); typedef void(__thiscall* StandardOut__print_t)(int _this, int type, std::string* message);
void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message); void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message);
extern StandardOut__print_t StandardOut__print; extern StandardOut__print_t StandardOut__print;
#define RBX__MESSAGE_INFO 0
#define RBX__MESSAGE_OUTPUT 1
#define RBX__MESSAGE_WARNING 2
#define RBX__MESSAGE_ERROR 3