Custom Script Hooks
Good Day! You have some plans about will add support OnScriptHook_ via Detours ? For custom features: OnScriptHook_RoundRespawn (detour void CCSPlayer::RoundRespawn) OnScriptHook_ClientCommand (detour bool CCSPlayer::ClientCommand), and via return value - access for continue/prohibit execute function etc ...
So maybe in future inline detours is too will be great (for example for large subroutines)
OnGameEvent_ OnScriptEvent_ and OnScriptHook_ are all done under the same code, event listener/callback, which I can try add support for SM plugin to call those callbacks, if that's what you're asking for.
Also while at it, can look into having SM plugin hooking/detouring those callbacks itself, e.g. detouring OnScriptHook_OnTakeDamage to make use of all of the parameters.
Well, there is actually already support for this through VScriptExecute, made a helper function to call OnScriptEvent_ callbacks, where passing CustomEvent to the first param would call OnScriptEvent_CustomEvent. I can add this stock function to vscript.inc to help start it off.
stock void VScript_FireScriptEvent(const char[] event, HSCRIPT params)
{
static HSCRIPT func;
if (!func)
func = HSCRIPT_RootTable.GetValue("FireScriptEvent");
VScriptExecute execute = new VScriptExecute(func);
execute.SetParamString(1, FIELD_CSTRING, event);
execute.SetParam(2, FIELD_HSCRIPT, params);
execute.Execute();
delete execute;
}
So. What about inline detours, maybe give access for registers, because classic detours is un useful for that?
Could you give an example for inline detours? Im not sure what you mean by this, and if any vscript functions have one.
For example i want detour AttackState::OnUpdate (when bot attacking somebody CCSPlayer) According to my pseudocode i have next:
...
}
}
<--- I Want setup detour here for continue or blocking code
LABEL_24:
if ( CCSBot::IsUsingKnife(a2) )
{
*(this + 48) = 0;
v10 = *(*a2 + 1944);
if ( v10 == CBot<CCSPlayer>::StandUp )
*(a2 + 6869) = 0;
else
...
In code above (for example) UNIX: EAX - this (AttackState*) ESI - CCSBot* WIN: ECX - this (AttackState*) ESI - CCSBot
So for example in VScript maybe this have implementation:
function OnScriptHook_AttackState_OnUpdate::Detour_1(attack_state, bot) -
code body
return <value> - according to return value -> jump from trampoline to code or retn (0xC3) - give some access for align stack (ESP/EBP) ?
Able to inline detour anywhere in bin is out of the scope for this vscript plugin, but if you were to use dhooks and successfully detour it for sm plugin, then you can just simply call VScript_FireScriptEvent("AttackState_OnUpdate", params) to let vscript make use of it.