Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ExecuteCmdString Hook */
- typedef void (__cdecl *_ExecuteCmdString)(byte*, bool, int);
- _ExecuteCmdString rlExecuteCmdString = 0;
- void __cdecl hkExecuteCmdString(byte *inCmd, bool bUnknown, int iUnknown)
- {
- char *cmdstr = (char*)(inCmd + 8);
- ILuaInterface *li = STATES[MENUSTATE];
- ILuaObject *fn = li->GetGlobal("GABV9K_CallHook");
- if (fn->isFunction())
- {
- li->Push(fn);
- li->Push("ExecuteCmdString");
- li->Push(cmdstr);
- li->Call(2, 1);
- ILuaObject *ret = li->GetReturn(0);
- bool block_cmd = (!ret->isNil() && (ret->GetBool() == false));
- ret->UnReference();
- if (block_cmd) return;
- }
- fn->UnReference();
- rlExecuteCmdString(inCmd, bUnknown, iUnknown);
- }
- LUA_FUNCTION(lua_HookExecuteCmdString)
- {
- Lua()->CheckType(1, GLua::TYPE_LIGHTUSERDATA);
- BYTE *ECS = (BYTE*)Lua()->GetLightUserData(1);
- if (ECS == 0) { Lua()->Msg("[GABV9K] Invalid Pointer!"); return 0; }
- rlExecuteCmdString = (_ExecuteCmdString)ECS;
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(void*&)rlExecuteCmdString, (void*)hkExecuteCmdString);
- DetourTransactionCommit();
- return 0;
- }
- LUA_FUNCTION(lua_UnHookExecuteCmdString)
- {
- if (rlExecuteCmdString == 0) { Lua()->Msg("[GABV9K] Invalid Pointer!"); return 0; }
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
- DetourDetach(&(void*&)rlExecuteCmdString, (void*)hkExecuteCmdString);
- DetourTransactionCommit();
- return 0;
- }
- /* ExecuteCmdString Hook */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement