Skip to content

Commit

Permalink
hotload/detour stringtables
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Sep 30, 2023
1 parent 1b953fe commit e8d0e5f
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 52 deletions.
2 changes: 2 additions & 0 deletions data/badwords.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string
bonjour
24 changes: 24 additions & 0 deletions data/events_schedule.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
string,int,int,string
season_2_stream,1573581601,2147968800,all
season_2_bonus_stream,1548784800,2147968800,all
digital_refresh_v3,1569862800,2147968800,all
reserves_drop_12,1573581600,2147968800,all
sunset_features,1573581600,2147364000,all
bribe_offer_launch,1573581600,1576000800,all
bribe_offer_holidays_2019,1576000800,2147364000,all
reserve_completion_meter,1573581600,2147364000,all
global_2xtier_mp_server,1594915200,2147364000,all
global_2xtier_mp_client,1594918800,2147364000,all
global_2xtier_wz_server,1594915200,2147364000,all
global_2xtier_wz_client,1594918800,2147364000,all
global_2wxp_mp_server,1545156000,2147364000,all
global_2wxp_mp_client,1545156000,2147364000,all
global_2wxp_zm_server,1545156000,2147364000,all
global_2wxp_zm_client,1545156000,2147364000,all
global_2xnp_zm_server,1545156000,2147364000,all
global_2xnp_zm_client,1545156000,2147364000,all
global_2xp_mp_server,1545156000,2147364000,all
global_2xp_mp_client,1545156000,2147364000,all
zm_lab_titanium_treble_slot_1,1545156000,2147364000,all
zm_lab_tungsten_tripler_slot_2,1545156000,2147364000,all

6 changes: 6 additions & 0 deletions data/stringtables.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file_name,stringtable_name
events_schedule.csv,gamedata/events/schedule_pc.csv
events_schedule.csv,gamedata/events/schedule_xbox.csv
events_schedule.csv,gamedata/events/schedule_ps4.csv
badwords.csv,gamedata/tables/badwords.csv
test_injection.csv,acts/test_injection.csv
3 changes: 3 additions & 0 deletions data/test_injection.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
string,int,bool,hash,float,undefined
atian,42,true,atianmenu,45.2,,
yolo,69,false,ar_accurate_t8,2.0,,
87 changes: 52 additions & 35 deletions src/bo4-dll/bo4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,40 +127,52 @@ namespace bo4 {
INT32 Pad0;
};

enum offsetbo4 : uintptr_t {
OFFSET_ScrVm_Error = 0x2770330,
OFFSET_ScrVm_RuntimeError = 0x27775B0,
OFFSET_DB_FindXAssetHeader = 0x2EB75B0,
OFFSET_StringTable_GetAsset = 0x28A2660,
OFFSET_LogCompilerError = 0x2890470,
OFFSET_Error = 0x3D36CC0,

// Scr link functions
OFFSET_Scr_GetFunctionReverseLookup = 0x33AF8A0,
OFFSET_CScr_GetFunctionReverseLookup = 0x1F132A0,
OFFSET_Scr_GetFunction = 0x1F13140,
OFFSET_CScr_GetFunction = 0x33AF840,
OFFSET_Scr_GetMethod = 0x33AFC20,
OFFSET_CScr_GetMethod = 0x1F13650,

// Scr vm functions
OFFSET_ScrVm_AddBool = 0x276E760,
OFFSET_ScrVm_AddFloat = 0x276E9B0,
OFFSET_ScrVm_AddHash = 0x276EAB0,
OFFSET_ScrVm_AddInt = 0x276EB80,
OFFSET_ScrVm_AddString = 0x276EE30,
OFFSET_ScrVm_AddUndefined = 0x276F3C0,
OFFSET_ScrVm_AddConstString = 0x276E5F0,
OFFSET_ScrVm_GetBool = 0x2772AB0,
OFFSET_ScrVm_GetFloat = 0x27733F0,
OFFSET_ScrVm_GetHash = 0x27738E0,
OFFSET_ScrVm_GetInt = 0x2773B50,
OFFSET_ScrVm_GetNumParam = 0x2774440,
OFFSET_ScrVm_GetPointerType = 0x27746E0,
OFFSET_ScrVm_GetString = 0x2774840,
OFFSET_ScrVm_GetType = 0x2774A20,
OFFSET_ScrVm_GetVector = 0x2774E40,
OFFSET_ScrVm_GetConstString = 0x02772E10
struct CmdFunction
{
CmdFunction* next;
uint64_t name;
uint64_t pad0;
uint64_t pad1;
uint64_t pad2;
void (*function)();
};

enum offsetbo4 : uintptr_t {
OFFSET_ScrVm_Error = 0x2770330,
OFFSET_ScrVm_RuntimeError = 0x27775B0,
OFFSET_DB_FindXAssetHeader = 0x2EB75B0,
OFFSET_StringTable_GetAsset = 0x28A2660,
OFFSET_LogCompilerError = 0x2890470,
OFFSET_Error = 0x3D36CC0,

// Scr link functions
OFFSET_Scr_GetFunctionReverseLookup = 0x33AF8A0,
OFFSET_CScr_GetFunctionReverseLookup = 0x1F132A0,
OFFSET_Scr_GetFunction = 0x1F13140,
OFFSET_CScr_GetFunction = 0x33AF840,
OFFSET_Scr_GetMethod = 0x33AFC20,
OFFSET_CScr_GetMethod = 0x1F13650,

// Scr vm functions
OFFSET_ScrVm_AddBool = 0x276E760,
OFFSET_ScrVm_AddFloat = 0x276E9B0,
OFFSET_ScrVm_AddHash = 0x276EAB0,
OFFSET_ScrVm_AddInt = 0x276EB80,
OFFSET_ScrVm_AddString = 0x276EE30,
OFFSET_ScrVm_AddUndefined = 0x276F3C0,
OFFSET_ScrVm_AddConstString = 0x276E5F0,
OFFSET_ScrVm_GetBool = 0x2772AB0,
OFFSET_ScrVm_GetFloat = 0x27733F0,
OFFSET_ScrVm_GetHash = 0x27738E0,
OFFSET_ScrVm_GetInt = 0x2773B50,
OFFSET_ScrVm_GetNumParam = 0x2774440,
OFFSET_ScrVm_GetPointerType = 0x27746E0,
OFFSET_ScrVm_GetString = 0x2774840,
OFFSET_ScrVm_GetType = 0x2774A20,
OFFSET_ScrVm_GetVector = 0x2774E40,
OFFSET_ScrVm_GetConstString = 0x02772E10,

OFFSET_Cmd_AddCommandInternal = 0x3CDEE80,
};
typedef ObjFileInfo ObjFileInfoTable[650];

Expand All @@ -185,6 +197,8 @@ namespace bo4 {
const auto ScrVm_GetType = reinterpret_cast<t8internal::ScrVarType(__fastcall*)(scriptinstance::ScriptInstance inst, unsigned int index)>(Relativise(OFFSET_ScrVm_GetType));
const auto Internal_ScrVm_Error = reinterpret_cast<void(__fastcall*)(uint64_t code, scriptinstance::ScriptInstance inst, char* unk, bool terminal)>(Relativise(OFFSET_ScrVm_Error));

const auto Cmd_AddCommandInternal = reinterpret_cast<void(__fastcall*)(Hash* cmdName, void (*command)(), CmdFunction* alloc)>(Relativise(OFFSET_Cmd_AddCommandInternal));

extern t8internal::scrVmPub* scrVmPub;
extern t8internal::scrVarPub* scrVarPub;
extern ObjFileInfoTable* objFileInfo;
Expand All @@ -194,4 +208,7 @@ namespace bo4 {
void ScrVm_Error(scriptinstance::ScriptInstance inst, const char* format, bool terminal, ...);
bool FindGSCFuncLocation(BYTE* location, scriptinstance::ScriptInstance& inst, GSCOBJ*& obj, GSCExport*& exp, UINT32& rloc);

}
}
#define REGISTER_COMMAND(id, name, cmd) static bo4::CmdFunction alloc_func_##id;\
static bo4::Hash alloc_func_hash##id = { hash::Hash64Pattern(name) };\
bo4::Cmd_AddCommandInternal(&alloc_func_hash##id, cmd, &alloc_func_##id)
5 changes: 5 additions & 0 deletions src/bo4-dll/cli_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ void SyncCLIOnce(clisync::CliSyncData* data) {

hash_lookup::LoadFile(strLookup.data());

stringtables::SyncTables();

// add the commands

REGISTER_COMMAND(ACTS_CSV_READER, "acts_csv", []() { stringtables::SyncTables(); });

LOG_INFO("Done.");
}
Expand Down
Loading

0 comments on commit e8d0e5f

Please sign in to comment.