diff --git a/src/injected/script.cpp b/src/injected/script.cpp index 45354c088..b67839f2c 100644 --- a/src/injected/script.cpp +++ b/src/injected/script.cpp @@ -31,6 +31,10 @@ Say get_say() } } +void infinite_loop(lua_State* argst, lua_Debug * argdb) { + luaL_error(argst, "Reached the script execution amount."); +}; + Script::Script(std::string script, std::string file, bool enable) { strcpy(code, script.data()); @@ -711,6 +715,8 @@ bool Script::run(ImDrawList *dl) } try { + lua_sethook(lua.lua_state(), NULL, 0, 0); + lua_sethook(lua.lua_state(), &infinite_loop, LUA_MASKCOUNT, 100000); drawlist = dl; sol::optional meta_name = lua["meta"]["name"]; sol::optional meta_version = lua["meta"]["version"]; diff --git a/src/injected/script.hpp b/src/injected/script.hpp index afc30dae5..698b4a968 100644 --- a/src/injected/script.hpp +++ b/src/injected/script.hpp @@ -76,6 +76,7 @@ struct ScriptMeta Movable *get_entity(uint32_t id); std::tuple get_position(uint32_t id); std::string sanitize(std::string data); +void infinite_loop(lua_State *argst, lua_Debug *argdb); using Callback = std::variant; @@ -83,6 +84,7 @@ class Script { public: sol::state lua; + char code[204800]; std::string result = ""; ScriptState state = {nullptr, 0, 0, 0, 0, 0, 0, 0};