diff --git a/PolygonClientUtilities/Hooks.cpp b/PolygonClientUtilities/Hooks.cpp index c98db72..4f5613f 100644 --- a/PolygonClientUtilities/Hooks.cpp +++ b/PolygonClientUtilities/Hooks.cpp @@ -5,7 +5,7 @@ #include "Util.h" #include "LUrlParser.h" #ifdef ARBITERBUILD -#include "Logger.h" +// #include "Logger.h" #endif static bool hasJobId = false; diff --git a/PolygonClientUtilities/Logger.cpp b/PolygonClientUtilities/Logger.cpp deleted file mode 100644 index bad31e2..0000000 --- a/PolygonClientUtilities/Logger.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "pch.h" -#include "Logger.h" - -//#pragma warning(disable : 4996) - -HANDLE Logger::handle; -std::ofstream Logger::outputLog; -std::ofstream Logger::httpLog; - -void Logger::Initialize(const std::string jobId) -{ - AllocConsole(); - freopen_s((FILE**)stdout, "CONOUT$", "w", stdout); - 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"); - - Logger::outputLog = std::ofstream(jobId + std::string("-Output.txt")); - Logger::httpLog = std::ofstream(jobId + std::string("-Http.txt")); -} - -void Logger::Log(LogType type, const std::string message) -{ - if (!handle) return; - - switch (type) - { - case LogType::Output: - outputLog << "[" << Logger::UtcTime() << "] " << message.c_str() << std::endl; - break; - case LogType::Http: - httpLog << "[" << Logger::UtcTime() << "] " << message.c_str() << std::endl; - break; - } -} - -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; - std::time_t now = std::time(NULL); - // time << std::put_time(std::localtime(&now), "%F %T"); - return time.str(); -} \ No newline at end of file diff --git a/PolygonClientUtilities/Logger.h b/PolygonClientUtilities/Logger.h deleted file mode 100644 index 21c7836..0000000 --- a/PolygonClientUtilities/Logger.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "pch.h" - -enum class LogType { Output, Http }; - -class Logger -{ -private: - static std::ofstream outputLog; - static std::ofstream httpLog; -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/PolygonClientUtilities.vcxproj b/PolygonClientUtilities/PolygonClientUtilities.vcxproj index 10e8042..c1ad3a4 100644 --- a/PolygonClientUtilities/PolygonClientUtilities.vcxproj +++ b/PolygonClientUtilities/PolygonClientUtilities.vcxproj @@ -166,7 +166,6 @@ - @@ -178,7 +177,6 @@ - NotUsing NotUsing diff --git a/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters b/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters index 695bb0d..7a9a6a1 100644 --- a/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters +++ b/PolygonClientUtilities/PolygonClientUtilities.vcxproj.filters @@ -39,9 +39,6 @@ Header Files - - Header Files - Header Files @@ -80,9 +77,6 @@ Source Files - - Source Files - Source Files diff --git a/PolygonClientUtilities/RCCOutput.cpp b/PolygonClientUtilities/RCCOutput.cpp index b533aad..3f22a8a 100644 --- a/PolygonClientUtilities/RCCOutput.cpp +++ b/PolygonClientUtilities/RCCOutput.cpp @@ -1,6 +1,26 @@ #include "pch.h" #include "RCCOutput.h" -#include "Logger.h" + +HANDLE outputHandle; + +void InitializeOutput() +{ + AllocConsole(); + freopen_s((FILE**)stdout, "CONOUT$", "w", stdout); + outputHandle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + SetStdHandle(STD_OUTPUT_HANDLE, outputHandle); + +#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"); +} StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT; @@ -8,14 +28,27 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* { StandardOut__print(_this, type, message); - if (Logger::handle) - { #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 - int messagePtr = (int)message + 4; - std::string* message = reinterpret_cast(messagePtr); + // 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; + message = reinterpret_cast(messagePtr); #endif - Logger::Print(type, *message); + switch (type) + { + case 1: // RBX::MESSAGE_OUTPUT: + SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY); + break; + case 0: // RBX::MESSAGE_INFO: + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + break; + case 2: // RBX::MESSAGE_WARNING: + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN); + break; + case 3: // RBX::MESSAGE_ERROR: + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY); + break; } + printf("%s\n", message->c_str()); + SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); } \ No newline at end of file diff --git a/PolygonClientUtilities/RCCOutput.h b/PolygonClientUtilities/RCCOutput.h index a6a2d29..fe25b92 100644 --- a/PolygonClientUtilities/RCCOutput.h +++ b/PolygonClientUtilities/RCCOutput.h @@ -2,6 +2,8 @@ #include "Classes.h" +void InitializeOutput(); + 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); extern StandardOut__print_t StandardOut__print; \ No newline at end of file diff --git a/PolygonClientUtilities/dllmain.cpp b/PolygonClientUtilities/dllmain.cpp index a971692..46f863a 100644 --- a/PolygonClientUtilities/dllmain.cpp +++ b/PolygonClientUtilities/dllmain.cpp @@ -62,6 +62,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { +#ifdef ARBITERBUILD + InitializeOutput(); +#endif + LONG error = Patches::Apply(); if (error != NO_ERROR) {