Skip to content

Commit

Permalink
Block script bridge term function
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed Jun 29, 2023
1 parent 43767b1 commit 7da2b5b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions gamedata/vscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@
"linux" "@_ZN19CSpeechScriptBridge4InitEv"
"windows" "\x57\x8B\xF9\x80\x3F\x00\x74\x2A\x68\x2A\x2A\x2A\x2A"
}

"CSpeechScriptBridge::Term"
{
"linux" "@_ZN19CSpeechScriptBridge4TermEv_part_78"
"windows" "\x56\x8B\xF1\x83\x3E\xFF\x74\x2A"
}
}
}

Expand Down
15 changes: 14 additions & 1 deletion scripting/vscript/list.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ static ArrayList g_aGlobalFunctions;
static ArrayList g_aClasses;

static DynamicDetour g_hSpeechScriptBridgeInit;
static DynamicDetour g_hSpeechScriptBridgeTerm;

void List_LoadGamedata(GameData hGameData)
{
Expand All @@ -16,9 +17,15 @@ void List_LoadGamedata(GameData hGameData)
hDetour = VTable_CreateDetour(hGameData, "IScriptVM", "RegisterClass", ReturnType_Bool, HookParamType_Int);
hDetour.Enable(Hook_Post, List_RegisterClass);

Address pAddress = hGameData.GetMemSig("CSpeechScriptBridge::Init");
Address pAddress;

pAddress = hGameData.GetMemSig("CSpeechScriptBridge::Init");
if (pAddress)
g_hSpeechScriptBridgeInit = new DynamicDetour(pAddress, CallConv_THISCALL, ReturnType_Void, ThisPointer_Address);

pAddress = hGameData.GetMemSig("CSpeechScriptBridge::Term");
if (pAddress)
g_hSpeechScriptBridgeTerm = new DynamicDetour(pAddress, CallConv_THISCALL, ReturnType_Void, ThisPointer_Address);
}

void List_LoadDefaults()
Expand All @@ -29,6 +36,9 @@ void List_LoadDefaults()
if (g_hSpeechScriptBridgeInit)
g_hSpeechScriptBridgeInit.Enable(Hook_Pre, List_BlockDetour);

if (g_hSpeechScriptBridgeTerm)
g_hSpeechScriptBridgeTerm.Enable(Hook_Pre, List_BlockDetour);

HSCRIPT pScriptVM = GetScriptVM();

// Create new vscriptvm and set back, so we can collect all of the default stuffs
Expand All @@ -39,6 +49,9 @@ void List_LoadDefaults()

if (g_hSpeechScriptBridgeInit)
g_hSpeechScriptBridgeInit.Disable(Hook_Pre, List_BlockDetour);

if (g_hSpeechScriptBridgeTerm)
g_hSpeechScriptBridgeTerm.Disable(Hook_Pre, List_BlockDetour);
}

MRESReturn List_Init(Address pScriptVM, DHookReturn hReturn)
Expand Down

0 comments on commit 7da2b5b

Please sign in to comment.