Cleanup Discord implementation, proper gameserver stuff

This commit is contained in:
lightbulblighter 2022-08-11 21:11:35 -07:00
parent 9321545e65
commit d371022291
No known key found for this signature in database
GPG Key ID: 58D6EDC2C38C9B3B
17 changed files with 335 additions and 163 deletions

View File

@ -8,7 +8,7 @@ bool isRunning = false;
std::string username; std::string username;
int placeId; int placeId;
void InitializeDiscord() void Discord::Initialize(std::string joinScriptUrl)
{ {
// Check if Discord should be enabled by checking if the binary is the client as well as if the binary's containing folder contains a ".nodiscord" file // Check if Discord should be enabled by checking if the binary is the client as well as if the binary's containing folder contains a ".nodiscord" file
std::string path = Helpers::getModulePath(); std::string path = Helpers::getModulePath();
@ -23,8 +23,32 @@ void InitializeDiscord()
return; return;
} }
std::pair<bool, std::map<std::string, std::string>> parsed = Helpers::parseURL(joinScriptUrl);
if (!parsed.first)
{
return;
}
if (parsed.second["query"].empty())
{
return;
}
std::map<std::string, std::string> query = Helpers::parseQueryString(parsed.second["query"]);
if (query.find("ticket") == query.end())
{
return;
}
if (query["ticket"].empty())
{
return;
}
// Get the username and placeId // Get the username and placeId
std::pair<bool, std::string> response = Helpers::httpGet(BASE_URL + std::string("/api/places/information?ticket=") + ticket); std::pair<bool, std::string> response = Helpers::httpGet(BASE_URL + std::string("/api/places/information?ticket=" + query["ticket"]));
if (!response.first) if (!response.first)
{ {
return; return;
@ -41,14 +65,14 @@ void InitializeDiscord()
username = document["username"].GetString(); username = document["username"].GetString();
placeId = document["placeId"].GetInt(); placeId = document["placeId"].GetInt();
UpdatePresence(); Discord::Update();
// Run the updater // Run the updater
std::thread updater(UpdatePresence); std::thread updater(Discord::Update);
updater.join(); updater.join();
} }
void UpdatePresence() void Discord::Update()
{ {
isRunning = true; isRunning = true;
@ -61,7 +85,7 @@ void UpdatePresence()
int max = 0; int max = 0;
// Get title, size, and max // Get title, size, and max
std::pair<bool, std::string> response = Helpers::httpGet(BASE_URL + std::string("/api/places/information?id=") + std::to_string(placeId)); std::pair<bool, std::string> response = Helpers::httpGet(BASE_URL + std::string("/api/places/information?id=" + placeId));
if (!response.first) if (!response.first)
{ {
return; return;
@ -94,7 +118,7 @@ void UpdatePresence()
} }
} }
void CleanupDiscord() void Discord::Cleanup()
{ {
isRunning = false; isRunning = false;
Discord_Shutdown(); Discord_Shutdown();

View File

@ -2,15 +2,19 @@
#include "Hooks/CRoblox.h" #include "Hooks/CRoblox.h"
std::string ticket = ""; #ifdef SERVER
#include "Server.h"
#endif
static bool hasAuthUrlArg = false; bool hasAuthUrlArg = false;
static bool hasAuthTicketArg = false; bool hasAuthTicketArg = false;
static bool hasJoinArg = false; bool hasJoinArg = false;
bool hasJobIdArg = false;
static std::wstring authenticationUrl; std::wstring authenticationUrl;
static std::wstring authenticationTicket; std::wstring authenticationTicket;
static std::wstring joinScriptUrl; std::wstring joinScriptUrl;
std::wstring jobId;
CRobloxApp__InitInstance_t CRobloxApp__InitInstance = (CRobloxApp__InitInstance_t)ADDRESS_CROBLOXAPP__INITINSTANCE; CRobloxApp__InitInstance_t CRobloxApp__InitInstance = (CRobloxApp__InitInstance_t)ADDRESS_CROBLOXAPP__INITINSTANCE;
CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobloxCommandLineInfo__ParseParam_t)ADDRESS_CROBLOXCOMMANDLINEINFO__PARSEPARAM; CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobloxCommandLineInfo__ParseParam_t)ADDRESS_CROBLOXCOMMANDLINEINFO__PARSEPARAM;
@ -18,16 +22,19 @@ CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam = (CRobl
BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this) BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this)
{ {
if (!CRobloxApp__InitInstance(_this)) if (!CRobloxApp__InitInstance(_this))
{
return FALSE; return FALSE;
}
CApp* app = reinterpret_cast<CApp*>(CLASSLOCATION_CAPP); CApp* app = reinterpret_cast<CApp*>(CLASSLOCATION_CAPP);
#ifndef SERVER
if (hasAuthUrlArg && hasAuthTicketArg && !authenticationUrl.empty() && !authenticationTicket.empty()) if (hasAuthUrlArg && hasAuthTicketArg && !authenticationUrl.empty() && !authenticationTicket.empty())
{ {
CApp__RobloxAuthenticate(app, nullptr, authenticationUrl.c_str(), authenticationTicket.c_str()); CApp__RobloxAuthenticate(app, nullptr, authenticationUrl.c_str(), authenticationTicket.c_str());
} }
#endif
#ifndef SERVER
if (hasJoinArg && !joinScriptUrl.empty()) if (hasJoinArg && !joinScriptUrl.empty())
{ {
try try
@ -40,14 +47,12 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this)
return FALSE; return FALSE;
} }
} }
#endif
return TRUE; return TRUE;
} }
void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* _this, void*, const char* pszParam, BOOL bFlag, BOOL bLast) void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* _this, void*, const char* pszParam, BOOL bFlag, BOOL bLast)
{ {
#ifndef SERVER
if (hasJoinArg && joinScriptUrl.empty()) if (hasJoinArg && joinScriptUrl.empty())
{ {
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0); int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
@ -58,28 +63,12 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
CCommandLineInfo__ParseLast(_this, bLast); CCommandLineInfo__ParseLast(_this, bLast);
// Parse the joinScriptUrl for it's placeId here #ifndef SERVER
std::pair<bool, std::map<std::string, std::string>> result = Helpers::parseURL(Helpers::ws2s(joinScriptUrl)); Discord::Initialize(Helpers::ws2s(joinScriptUrl));
if (!result.first)
{
ExitProcess(EXIT_FAILURE);
}
std::map<std::string, std::string> parameters = result.second;
if (parameters.find("ticket") != parameters.end())
{
ticket = parameters["ticket"];
}
if (ticket.empty())
{
ExitProcess(EXIT_FAILURE);
}
return;
}
#endif #endif
}
#ifndef SERVER
if (hasAuthUrlArg && authenticationUrl.empty()) if (hasAuthUrlArg && authenticationUrl.empty())
{ {
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0); int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
@ -99,7 +88,21 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
CCommandLineInfo__ParseLast(_this, bLast); CCommandLineInfo__ParseLast(_this, bLast);
return; return;
} }
#endif
#ifdef SERVER
if (hasJobIdArg && jobId.empty())
{
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
jobId.resize(size);
MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), &jobId[0], size);
CCommandLineInfo__ParseLast(_this, bLast);
return;
}
#endif
#ifndef SERVER
if (bFlag && _stricmp(pszParam, "a") == 0) if (bFlag && _stricmp(pszParam, "a") == 0)
{ {
hasAuthUrlArg = true; hasAuthUrlArg = true;
@ -113,14 +116,25 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
CCommandLineInfo__ParseLast(_this, bLast); CCommandLineInfo__ParseLast(_this, bLast);
return; return;
} }
#endif
#ifndef SERVER
if (bFlag && _stricmp(pszParam, "j") == 0) if (bFlag && _stricmp(pszParam, "j") == 0)
{ {
hasJoinArg = true; hasJoinArg = true;
CCommandLineInfo__ParseLast(_this, bLast); CCommandLineInfo__ParseLast(_this, bLast);
return; return;
} }
#ifdef SERVER
if (bFlag && _stricmp(pszParam, "jobId") == 0)
{
hasJobIdArg = true;
CCommandLineInfo__ParseLast(_this, bLast);
Server::Initialize(jobId);
return;
}
#endif #endif
CRobloxCommandLineInfo__ParseParam(_this, pszParam, bFlag, bLast); CRobloxCommandLineInfo__ParseParam(_this, pszParam, bFlag, bLast);

View File

@ -0,0 +1,22 @@
#include "pch.h"
#include "Hooks/DataModel.h"
#ifdef SERVER
bool setJobId = false;
DataModel__getJobId_t DataModel__getJobId = (DataModel__getJobId_t)ADDRESS_DATAMODEL__GETJOBID;
int __fastcall DataModel__getJobId_hook(DataModel* _this, void*, int a2)
{
if (!setJobId && hasJobIdArg && !jobId.empty())
{
_this->jobId = Helpers::ws2s(jobId);
setJobId = true;
}
return DataModel__getJobId(_this, a2);
}
#endif

View File

@ -90,9 +90,10 @@ void __fastcall Http__httpGetPostWinInet_hook(Http* _this, void*, bool isPost, i
} }
#ifdef SERVER #ifdef SERVER
httpLog.open(httpLogPath, std::ios::out); if (Server::Handle)
httpLog << "[" << Helpers::getISOTimestamp << "] [" << (isPost ? "POST" : "GET") << "] '" << _this->url << "'" << std::endl; {
httpLog.close(); Server::Log::Http((RequestType)isPost, _this->url);
}
#endif #endif
Http__httpGetPostWinInet(_this, isPost, a3, compressData, additionalHeaders, a6); Http__httpGetPostWinInet(_this, isPost, a3, compressData, additionalHeaders, a6);

View File

@ -2,7 +2,7 @@
#include "Hooks/ServerReplicator.h" #include "Hooks/ServerReplicator.h"
#if defined(SERVER) #ifdef SERVER
static std::map<ServerReplicator*, RakPeerInterface*> rakPeers; static std::map<ServerReplicator*, RakPeerInterface*> rakPeers;

View File

@ -4,86 +4,23 @@
#ifdef SERVER #ifdef SERVER
HANDLE outputHandle;
std::string httpLogPath;
std::string stdoutLogPath;
std::ofstream httpLog;
std::ofstream stdoutLog;
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);
printf("Tadah.DLL v1.0.0\n");
#ifdef _DEBUG
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN);
printf("Compiled as Debug\n\n");
#endif
// Initialize file logging
fs::create_directory(fs::path(Helpers::getModulePath()).parent_path() / "logs");
std::string time = Helpers::getISOTimestamp();
stdoutLogPath = (fs::path(Helpers::getModulePath()).parent_path() / "logs" / (time + "-StandardOut.log")).string();
httpLogPath = (fs::path(Helpers::getModulePath()).parent_path() / "logs" / (time + "-Http.log")).string();
stdoutLog.open(stdoutLogPath, std::ios::out);
httpLog.open(stdoutLogPath, std::ios::out);
stdoutLog << "Tadah.DLL v1.0.0 - StandardOut" << std::endl << std::endl;
httpLog << "Tadah.DLL v1.0.0 - Http" << std::endl << std::endl;
stdoutLog.close();
httpLog.close();
}
StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT; StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT;
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)
{ {
StandardOut__print(_this, type, message); StandardOut__print(_this, type, message);
#ifdef SERVER
if (Server::Handle)
{
#ifndef _DEBUG #ifndef _DEBUG
// Message pointer is offset 4 bytes when the DLL is compiled as release // Message pointer is offset 4 bytes when the DLL is compiled as release
message = reinterpret_cast<std::string*>((int)message + 4); message = reinterpret_cast<std::string*>((int)message + 4);
#endif #endif
std::string stringifiedType; Server::Log::Output((LogSeverity)type, message->c_str());
std::string time = Helpers::getISOTimestamp();
switch (type)
{
case RBX__MESSAGE_OUTPUT:
SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
stringifiedType = "out";
break;
case RBX__MESSAGE_INFO:
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
stringifiedType = "info";
break;
case RBX__MESSAGE_WARNING:
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN);
stringifiedType = "warn";
break;
case RBX__MESSAGE_ERROR:
stringifiedType = "err";
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY);
break;
} }
#endif
printf("%s\n", message->c_str());
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
stdoutLog.open(stdoutLogPath, std::ios::out);
stdoutLog << "[" << time << "] [" << stringifiedType << "] " << message << std::endl;
stdoutLog.close();
} }
#endif #endif

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
//#define SERVER
#define BASE_URL "https://tadah.rocks" #define BASE_URL "https://tadah.rocks"
#define DISCORD_APP_ID 923705431543668736 #define DISCORD_APP_ID 923705431543668736
@ -16,16 +17,16 @@
#define CLASSPADDING_DATAMODEL__JOBID 739 #define CLASSPADDING_DATAMODEL__JOBID 739
#define ADDRESS_STANDARDOUT__PRINT 0x005B25E0
#define ADDRESS_CRYPT__VERIFYSIGNATUREBASE64 0x00809EC0
#define ADDRESS_SERVERREPLICATOR__SENDTOP 0x00513E80
#define ADDRESS_SERVERREPLICATOR__PROCESSTICKET 0x00514B60
#define ADDRESS_SERVERREPLICATOR__PROCESSPACKET 0x0
#define ADDRESS_GAME__CONSTRUCT 0x0
#define ADDRESS_HTTP__HTTPGETPOSTWININET 0x0 #define ADDRESS_HTTP__HTTPGETPOSTWININET 0x0
#define ADDRESS_HTTP__TRUSTCHECK 0x005B7050 #define ADDRESS_HTTP__TRUSTCHECK 0x005B7050
#define ADDRESS_CRYPT__VERIFYSIGNATUREBASE64 0x00809EC0
#define ADDRESS_CONTEXT__REQUIREPERMISSION 0x0 #define ADDRESS_CONTEXT__REQUIREPERMISSION 0x0
#define ADDRESS_CONTEXT__ISINROLE 0x0 #define ADDRESS_CONTEXT__ISINROLE 0x0
#define ADDRESS_DATAMODEL__GETJOBID 0x005E70C0
#define ADDRESS_STANDARDOUT__PRINT 0x005B25E0
#define ADDRESS_SERVERREPLICATOR__SENDTOP 0x00513E80
#define ADDRESS_SERVERREPLICATOR__PROCESSTICKET 0x00514B60
#define ADDRESS_SERVERREPLICATOR__PROCESSPACKET 0x00514B60
#define CLASSLOCATION_CROBLOXAPP 0x00CBA8A0 #define CLASSLOCATION_CROBLOXAPP 0x00CBA8A0
#define CLASSLOCATION_CAPP 0x00406D80 #define CLASSLOCATION_CAPP 0x00406D80
@ -45,3 +46,8 @@
#else #else
#define PADDING_STRUCT 0 #define PADDING_STRUCT 0
#endif #endif
#define RBX__MESSAGE_INFO 0
#define RBX__MESSAGE_OUTPUT 1
#define RBX__MESSAGE_WARNING 2
#define RBX__MESSAGE_ERROR 3

View File

@ -10,8 +10,12 @@
#ifndef SERVER #ifndef SERVER
void InitializeDiscord(); class Discord {
void UpdatePresence(); public:
void CleanupDiscord(); static void Initialize(std::string joinScriptUrl);
static void Cleanup();
private:
static void Update();
};
#endif #endif

View File

@ -4,6 +4,7 @@
#include "Configuration.h" #include "Configuration.h"
#include "Helpers.h" #include "Helpers.h"
#include "Discord.h"
class CWorkspace; class CWorkspace;
@ -42,4 +43,5 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
extern CRobloxApp__InitInstance_t CRobloxApp__InitInstance; extern CRobloxApp__InitInstance_t CRobloxApp__InitInstance;
extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam; extern CRobloxCommandLineInfo__ParseParam_t CRobloxCommandLineInfo__ParseParam;
extern std::string ticket; extern std::wstring jobId;
extern bool hasJobIdArg;

View File

@ -0,0 +1,20 @@
#pragma once
#include "Helpers.h"
#include "Configuration.h"
#include "Hooks/CRoblox.h"
#ifdef SERVER
struct DataModel
{
void* padding1[CLASSPADDING_DATAMODEL__JOBID];
std::string jobId;
};
typedef INT(__thiscall* DataModel__getJobId_t)(DataModel* _this, int a2);
int __fastcall DataModel__getJobId_hook(DataModel* _this, void*, int a2);
extern DataModel__getJobId_t DataModel__getJobId;
#endif

View File

@ -12,7 +12,6 @@ struct Packet
unsigned char* data; unsigned char* data;
}; };
struct ConcurrentRakPeer {};
struct RakPeerInterface {}; struct RakPeerInterface {};
struct ServerReplicator struct ServerReplicator

View File

@ -3,24 +3,12 @@
#include "Configuration.h" #include "Configuration.h"
#include "Patches.h" #include "Patches.h"
#include "Helpers.h" #include "Helpers.h"
#include "Server.h"
#ifdef SERVER #ifdef SERVER
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;
extern std::string httpLogPath;
extern std::string stdoutLogPath;
extern std::ofstream httpLog;
extern std::ofstream stdoutLog;
#define RBX__MESSAGE_INFO 0
#define RBX__MESSAGE_OUTPUT 1
#define RBX__MESSAGE_WARNING 2
#define RBX__MESSAGE_ERROR 3
#endif #endif

View File

@ -0,0 +1,42 @@
#pragma once
#include "Configuration.h"
#include "Helpers.h"
#include "Hooks/StandardOut.h"
#ifdef SERVER
enum class RequestType {
POST,
GET
};
enum class LogSeverity {
Information = RBX__MESSAGE_INFO,
Output = RBX__MESSAGE_OUTPUT,
Warning = RBX__MESSAGE_WARNING,
Error = RBX__MESSAGE_ERROR
};
class Server {
public:
static HANDLE Handle;
static void Initialize(const std::wstring jobId);
static void Cleanup();
struct Log
{
static void Http(const RequestType type, const std::string message);
static void Output(const LogSeverity severity, const std::string message);
};
private:
static std::string HttpLogPath;
static std::string OutputLogPath;
static std::ofstream HttpLog;
static std::ofstream OutputLog;
};
#endif

99
Tadah.DLL/Server.cpp Normal file
View File

@ -0,0 +1,99 @@
#include "pch.h"
#include "Server.h"
#ifdef SERVER
HANDLE Server::Handle;
std::ofstream Server::OutputLog;
std::ofstream Server::HttpLog;
std::string Server::OutputLogPath;
std::string Server::HttpLogPath;
void Server::Initialize(const std::wstring jobId)
{
std::string _jobId = Helpers::ws2s(jobId);
std::string signature = "Tadah.DLL v1.0.0";
#ifdef _DEBUG
signature += " (compiled as Debug)";
#endif
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
Server::Handle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
SetStdHandle(STD_OUTPUT_HANDLE, Server::Handle);
printf((signature + "\n\n").c_str());
// Initialize file logging
fs::create_directory(fs::path(Helpers::getModulePath()).parent_path() / "logs");
OutputLogPath = (fs::path(Helpers::getModulePath()).parent_path() / "logs" / (_jobId + "-Output.log")).string();
HttpLogPath = (fs::path(Helpers::getModulePath()).parent_path() / "logs" / (_jobId + "-Http.log")).string();
OutputLog.open(OutputLogPath, std::ios::out);
HttpLog.open(HttpLogPath, std::ios::out);
OutputLog << signature << " - StandardOut" << std::endl << std::endl;
HttpLog << signature << " - Http" << std::endl << std::endl;
OutputLog.close();
HttpLog.close();
}
void Server::Log::Output(const LogSeverity severity, const std::string message)
{
std::string type;
std::string time = Helpers::getISOTimestamp();
switch (severity)
{
case LogSeverity::Output:
SetConsoleTextAttribute(Server::Handle, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
type = "out";
break;
case LogSeverity::Information:
SetConsoleTextAttribute(Server::Handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
type = "info";
break;
case LogSeverity::Warning:
SetConsoleTextAttribute(Server::Handle, FOREGROUND_RED | FOREGROUND_GREEN);
type = "warn";
break;
case LogSeverity::Error:
type = "err";
SetConsoleTextAttribute(Server::Handle, FOREGROUND_RED | FOREGROUND_INTENSITY);
break;
}
printf("%s\n", message.c_str());
SetConsoleTextAttribute(Server::Handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
OutputLog.open(OutputLogPath, std::ios::out);
OutputLog << "[" << time << "] [" << type << "] " << message << std::endl;
OutputLog.close();
}
void Server::Log::Http(const RequestType request, const std::string url)
{
std::string type;
std::string time = Helpers::getISOTimestamp();
type = (request == RequestType::GET ? "GET" : "POST");
HttpLog.open(HttpLogPath, std::ios::out);
HttpLog << "[" << time << "] [" << type << "] " << "'" << url << "'" << std::endl;
HttpLog.close();
}
void Server::Cleanup()
{
CloseHandle(Server::Handle);
OutputLog.close();
HttpLog.close();
}
#endif

View File

@ -127,9 +127,11 @@
<ClInclude Include="Include\Discord.h" /> <ClInclude Include="Include\Discord.h" />
<ClInclude Include="Include\Hooks\Context.h" /> <ClInclude Include="Include\Hooks\Context.h" />
<ClInclude Include="Include\Hooks\CRoblox.h" /> <ClInclude Include="Include\Hooks\CRoblox.h" />
<ClInclude Include="Include\Hooks\DataModel.h" />
<ClInclude Include="Include\Hooks\StandardOut.h" /> <ClInclude Include="Include\Hooks\StandardOut.h" />
<ClInclude Include="Include\Hooks\ServerReplicator.h" /> <ClInclude Include="Include\Hooks\ServerReplicator.h" />
<ClInclude Include="Include\Hooks\Http.h" /> <ClInclude Include="Include\Hooks\Http.h" />
<ClInclude Include="Include\Server.h" />
<ClInclude Include="Include\Patches.h" /> <ClInclude Include="Include\Patches.h" />
<ClInclude Include="Include\pch.h" /> <ClInclude Include="Include\pch.h" />
<ClInclude Include="Include\Helpers.h" /> <ClInclude Include="Include\Helpers.h" />
@ -141,6 +143,8 @@
<ClCompile Include="Hooks\Context.cpp" /> <ClCompile Include="Hooks\Context.cpp" />
<ClCompile Include="dllmain.cpp" /> <ClCompile Include="dllmain.cpp" />
<ClCompile Include="Hooks\CRoblox.cpp" /> <ClCompile Include="Hooks\CRoblox.cpp" />
<ClCompile Include="Hooks\DataModel.cpp" />
<ClCompile Include="Server.cpp" />
<ClCompile Include="Patches.cpp" /> <ClCompile Include="Patches.cpp" />
<ClCompile Include="pch.cpp"> <ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

View File

@ -27,9 +27,6 @@
<ClInclude Include="Include\Patches.h"> <ClInclude Include="Include\Patches.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Include\Configuration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Include\Helpers.h"> <ClInclude Include="Include\Helpers.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -57,6 +54,15 @@
<ClInclude Include="Include\Discord.h"> <ClInclude Include="Include\Discord.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Include\Server.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Include\Hooks\DataModel.h">
<Filter>Header Files\Hooks</Filter>
</ClInclude>
<ClInclude Include="Include\Configuration.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
@ -92,6 +98,12 @@
<ClCompile Include="Discord.cpp"> <ClCompile Include="Discord.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Server.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Hooks\DataModel.cpp">
<Filter>Source Files\Hooks</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Tadah.DLL.rc"> <ResourceCompile Include="Tadah.DLL.rc">

View File

@ -1,4 +1,5 @@
#include "pch.h" #include "pch.h"
#include "Configuration.h" #include "Configuration.h"
#include "Patches.h" #include "Patches.h"
@ -6,20 +7,24 @@
#include "Discord.h" #include "Discord.h"
#endif #endif
#ifdef SERVER
#include "Server.h"
#endif
#include "Hooks/Http.h" #include "Hooks/Http.h"
#include "Hooks/Crypt.h" #include "Hooks/Crypt.h"
#include "Hooks/CRoblox.h"
#ifdef _DEBUG #ifdef _DEBUG
#include "Hooks/Context.h" #include "Hooks/Context.h"
#endif #endif
#ifdef SERVER #ifdef SERVER
#include "Hooks/DataModel.h"
#include "Hooks/StandardOut.h" #include "Hooks/StandardOut.h"
#include "Hooks/ServerReplicator.h" #include "Hooks/ServerReplicator.h"
#endif #endif
#include "Hooks/CRoblox.h"
START_PATCH_LIST() START_PATCH_LIST()
ADD_PATCH(Http__httpGetPostWinInet, Http__httpGetPostWinInet_hook) ADD_PATCH(Http__httpGetPostWinInet, Http__httpGetPostWinInet_hook)
@ -27,28 +32,22 @@ ADD_PATCH(Http__trustCheck, Http__trustCheck_hook)
ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook) ADD_PATCH(Crypt__verifySignatureBase64, Crypt__verifySignatureBase64_hook)
ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook)
ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook)
#ifdef _DEBUG #ifdef _DEBUG
ADD_PATCH(Context__requirePermission, Context__requirePermission_hook) ADD_PATCH(Context__requirePermission, Context__requirePermission_hook)
#endif #endif
#ifdef SERVER #ifdef SERVER
ADD_PATCH(StandardOut__print, StandardOut__print_hook) ADD_PATCH(DataModel__getJobId, DataModel__getJobId_hook)
#endif
ADD_PATCH(StandardOut__print, StandardOut__print_hook)
#if defined(SERVER) && defined(MFC2011)
ADD_PATCH(ServerReplicator__sendTop, ServerReplicator__sendTop_hook) ADD_PATCH(ServerReplicator__sendTop, ServerReplicator__sendTop_hook)
ADD_PATCH(ServerReplicator__processTicket, ServerReplicator__processTicket_hook) ADD_PATCH(ServerReplicator__processTicket, ServerReplicator__processTicket_hook)
#endif #endif
#if defined(SERVER) && defined(PLAYER2012)
ADD_PATCH(Application__ParseArguments, Application__ParseArguments_hook)
#endif
#if defined(MFC2010) || defined(MFC2011)
ADD_PATCH(CRobloxApp__InitInstance, CRobloxApp__InitInstance_hook)
ADD_PATCH(CRobloxCommandLineInfo__ParseParam, CRobloxCommandLineInfo__ParseParam_hook)
#endif
END_PATCH_LIST() END_PATCH_LIST()
void __declspec(dllexport) import() {} void __declspec(dllexport) import() {}
@ -57,10 +56,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
{ {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{ {
#ifdef SERVER
InitializeOutput();
#endif
LONG patchesError = Patches::Apply(); LONG patchesError = Patches::Apply();
if (patchesError != NO_ERROR) if (patchesError != NO_ERROR)
{ {
@ -82,10 +77,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
ExitProcess(EXIT_FAILURE); ExitProcess(EXIT_FAILURE);
} }
#ifndef SERVER
InitializeDiscord();
#endif
} }
if (ul_reason_for_call == DLL_PROCESS_DETACH) if (ul_reason_for_call == DLL_PROCESS_DETACH)
@ -93,7 +84,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
curl_global_cleanup(); curl_global_cleanup();
#ifndef SERVER #ifndef SERVER
CleanupDiscord(); Discord::Cleanup();
#endif
#ifdef SERVER
if (Server::Handle)
{
Server::Cleanup();
}
#endif #endif
} }