ScriptContext execution for Datamodel via DLL

This commit is contained in:
pizzaboxer 2022-06-01 14:23:53 +01:00
parent 9885235a4b
commit c232462906
8 changed files with 93 additions and 20 deletions

View File

@ -3,19 +3,38 @@
#include "Config.h"
#include <oaidl.h>
struct Game
struct Tuple
{
void* padding1[26]; // 2010 has a class size of 104
void* padding1[4];
bool padding2;
bool padding3;
};
const auto Game__initializeConstruct = (void * (__thiscall*)(void* _this, int a2))0x455D40;
struct DataModel
{
void* padding1[CLASSPADDING_DATAMODEL__JOBID + PADDING_STRUCT];
std::string jobId;
};
struct Game
{
// void* padding1[26]; // 2010 has a class size of 104
void* padding1[8];
// int dataModel;
// void* padding2[17];
std::shared_ptr<DataModel> dataModel;
void* padding2[9];
};
const auto Game__initializeClass = (Game * (__thiscall*)(void* _this, int a2))0x455D40;
const auto sub_47C280 = (int(__thiscall*)(int _this, int a2))0x47C280;
const auto sub_902680 = (void * (__thiscall*)(void * _this))0x902680;
const auto ServiceProvider__createScriptContext = (void * (__thiscall*)(void* _this))0x4282E0;
const auto ScriptContext__setTimeout = (void (__thiscall*)(void* _this, double seconds))0x616EB0;
// const auto ScriptContext__execute = (void * (__thiscall*)(void* _this, void* a1, int identity, const char* script, const char* name, int arguments))0x617CF0;
const auto ScriptContext__execute = (void (__thiscall*)(void* _this, int identity, const char* script, const char* name))0x617C80;
struct Http
{
#if PADDING_STRUCT != 0

View File

@ -0,0 +1,15 @@
#include "pch.h"
#include "DebugScriptContext.h"
/* ScriptContext__execute_t ScriptContext__execute = (ScriptContext__execute_t)0x617CF0;
void* __fastcall ScriptContext__execute_hook(void* _this, void*, void* a1, int identity, const char* script, const char* name, void* arguments)
{
printf("ScriptContext::execute called\n");
printf("_this: %p\n", _this);
printf("Identity: %d\n", identity);
printf("Script: %s\n", script);
printf("Name: %s\n", name);
printf("Arguments: %p\n", arguments);
return ScriptContext__execute(_this, a1, identity, script, name, arguments);
} */

View File

@ -0,0 +1,7 @@
#pragma once
#include "Classes.h"
/* typedef void* (__thiscall* ScriptContext__execute_t)(void* _this, void* a1, int identity, const char* script, const char* name, void* arguments);
void* __fastcall ScriptContext__execute_hook(void* _this, void*, void* a1, int identity, const char* script, const char* name, void* arguments);
extern ScriptContext__execute_t ScriptContext__execute; */

View File

@ -163,8 +163,8 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Config.h" />
<ClInclude Include="DebugDatamodel.h" />
<ClInclude Include="DebugGame.h" />
<ClInclude Include="DebugScriptContext.h" />
<ClInclude Include="MFCCommandLine.h" />
<ClInclude Include="PlayerCommandLine.h" />
<ClInclude Include="RCCOutput.h" />
@ -180,8 +180,8 @@
<ClInclude Include="VerifySignatureBase64.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DebugDatamodel.cpp" />
<ClCompile Include="DebugGame.cpp" />
<ClCompile Include="DebugScriptContext.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="MFCCommandLine.cpp" />
<ClCompile Include="LUrlParser.cpp">

View File

@ -60,15 +60,15 @@
<ClInclude Include="RCCOutput.h">
<Filter>Header Files\Hooks</Filter>
</ClInclude>
<ClInclude Include="DebugDatamodel.h">
<Filter>Header Files\Hooks</Filter>
</ClInclude>
<ClInclude Include="TestHttpGetPost.h">
<Filter>Header Files\Hooks</Filter>
</ClInclude>
<ClInclude Include="DebugGame.h">
<Filter>Header Files\Hooks</Filter>
</ClInclude>
<ClInclude Include="DebugScriptContext.h">
<Filter>Header Files\Hooks</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@ -107,14 +107,14 @@
<ClCompile Include="RCCOutput.cpp">
<Filter>Source Files\Hooks</Filter>
</ClCompile>
<ClCompile Include="DebugDatamodel.cpp">
<Filter>Source Files\Hooks</Filter>
</ClCompile>
<ClCompile Include="TestHttpGetPost.cpp">
<Filter>Source Files\Hooks</Filter>
</ClCompile>
<ClCompile Include="DebugGame.cpp">
<Filter>Source Files\Hooks</Filter>
</ClCompile>
<ClCompile Include="DebugScriptContext.cpp">
<Filter>Source Files\Hooks</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -44,15 +44,45 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string*
if (message->compare("NewGame") == 0)
{
printf("\n");
printf("Attempting to create new Game...\n");
int v2;
void* v3;
void* v4;
// v3 = operator new(104u);
v3 = new Game();
v4 = Game__initializeConstruct(v3, 0);
v2 = Game__construct_hook((Game*)v4);
Game* game = new Game();
int result = Game__construct(Game__initializeClass(game, 0));
if (result)
{
printf("Failed to create new Game! (returned %d)\n", result);
}
else
{
// int datamodel = game[4];
printf("Successfully created new Game! (%p)\n", game);
// printf("Address of DataModel: %08X\n", game->dataModel);
// printf("Attempting to set DataModel Job ID to 'deez nuts'...\n");
// game->dataModel->jobId = "deez nuts";
printf("Length of DataModel Job ID: %d\n", game->dataModel->jobId.length());
printf("Attempting to create service provider...\n");
void* dataModelPointer = game->dataModel.get();
printf("Address of dataModelPointer: %p\n", dataModelPointer);
printf("Calling ServiceProvider::create<ScriptContext>()...\n");
void* scriptContext = ServiceProvider__createScriptContext(dataModelPointer);
printf("Address of scriptContext: %p\n", scriptContext);
printf("Calling ScriptContext::execute()...\n");
// void* arg;
// ScriptContext__execute(scriptContext, &arg, 1, "print('hi')", "hi", 0);
ScriptContext__execute(scriptContext, 1, "print('hi')", "hi");
// printf("Calling ScriptContext::setTimeout()...\n");
// ScriptContext__setTimeout(scriptContext, 5);
printf("\n");
}
}
switch (type)

View File

@ -4,6 +4,7 @@
//#include "RobloxMFCHooks.h"
#include "DebugGame.h"
#include "DebugScriptContext.h"
// #include "TestHttpGetPost.h"
#include "TrustCheck.h"
#include "VerifySignatureBase64.h"
@ -26,6 +27,7 @@
START_PATCH_LIST()
ADD_PATCH(Game__construct, Game__construct_hook)
// ADD_PATCH(ScriptContext__execute, ScriptContext__execute_hook)
// ADD_PATCH(Http_httpGetPostWinInet, Http_httpGetPostWinInet_hook)
ADD_PATCH(Http__trustCheck, Http__trustCheck_hook)