Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed Apr 4, 2024
1 parent a68a547 commit 337a4f1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
16 changes: 16 additions & 0 deletions source/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Tlua_pcall func_lua_pcall;
Tlua_atpanic func_lua_atpanic;
luaL_loadstring func_luaL_loadstring;
lua_tostring func_lua_tostring;
llua_getstack func_lua_getstack;
llua_getinfo func_lua_getinfo;
llua_pushstring func_lua_pushstring;
llua_setfield func_lua_setfield;
GMOD_LoadBinaryModule func_GMOD_LoadBinaryModule;

TInitLuaLibraries func_InitLuaLibraries;
Expand Down Expand Up @@ -126,6 +130,18 @@ void Symbols_Init()
func_lua_tostring = (lua_tostring)FindFunction(lua_shared_loader.GetModule(), lua_tostringSym);
CheckFunction(func_lua_tostring, "lua_tostring");

func_lua_getstack = (llua_getstack)FindFunction(lua_shared_loader.GetModule(), lua_getstackSym);
CheckFunction(func_lua_getstack, "lua_getstack");

func_lua_getinfo = (llua_getinfo)FindFunction(lua_shared_loader.GetModule(), lua_getinfoSym);
CheckFunction(func_lua_getinfo, "lua_getinfo");

func_lua_pushstring = (llua_pushstring)FindFunction(lua_shared_loader.GetModule(), lua_pushstringSym);
CheckFunction(func_lua_pushstring, "lua_pushstring");

func_lua_setfield = (llua_setfield)FindFunction(lua_shared_loader.GetModule(), lua_setfieldSym);
CheckFunction(func_lua_setfield, "lua_setfield");

func_GMOD_LoadBinaryModule = (GMOD_LoadBinaryModule)FindFunction(lua_shared_loader.GetModule(), GMOD_LoadBinaryModuleSym);
CheckFunction(func_GMOD_LoadBinaryModule, "GMOD_LoadBinaryModule");

Expand Down
16 changes: 16 additions & 0 deletions source/detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ typedef const char* (*lua_tostring)(lua_State*, int, int);
extern lua_tostring func_lua_tostring;
const Symbol lua_tostringSym = Symbol::FromName("lua_tolstring");

typedef const char* (*llua_getstack)(lua_State*, int, lua_Debug*);
extern llua_getstack func_lua_getstack;
const Symbol lua_getstackSym = Symbol::FromName("lua_getstack");

typedef const char* (*llua_getinfo)(lua_State*, const char*, lua_Debug*);
extern llua_getinfo func_lua_getinfo;
const Symbol lua_getinfoSym = Symbol::FromName("lua_getinfo");

typedef const char* (*llua_pushstring)(lua_State*, const char*);
extern llua_pushstring func_lua_pushstring;
const Symbol lua_pushstringSym = Symbol::FromName("lua_pushstring");

typedef const char* (*llua_setfield)(lua_State*, int, const char*);
extern llua_setfield func_lua_setfield;
const Symbol lua_setfieldSym = Symbol::FromName("lua_setfield");

typedef const char* (*GMOD_LoadBinaryModule)(lua_State*, const char*);
extern GMOD_LoadBinaryModule func_GMOD_LoadBinaryModule;
const Symbol GMOD_LoadBinaryModuleSym = Symbol::FromName("GMOD_LoadBinaryModule");
Expand Down
8 changes: 4 additions & 4 deletions source/lua_ILuaInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ void RunString(ILuaThread* thread, const char* str, const char* pFile)

lua_Debug ar;
lua_State* L = thread->IFace->GetState();
lua_getstack(L, 0, &ar);
lua_getinfo(L, "Sl", &ar);
lua_pushstring(L, pFile);
lua_setfield(L, -2, "source");
func_lua_getstack(L, 0, &ar);
func_lua_getinfo(L, "Sl", &ar);
func_lua_pushstring(L, pFile);
func_lua_setfield(L, -2, "source");
}
else
{
Expand Down

0 comments on commit 337a4f1

Please sign in to comment.