HelpGetting Lua state after injection

Posts 16–30 of 51 · Page 2 of 4
Quote Originally Posted by ExiledStyles View Post
what is "the lua base"? about 4 months ago i took some pastebin files of dylib dumps and called the necessary funcs, worked fine for me.
and meep you are trolling and that is not allowed here.
You know the LUA variable? That's the lua base. You get it through injection by doing this.
Code:
ILuaBase* luaBase = state->luabase;
Quote Originally Posted by Azrius View Post
shared->GetLuaInterface( 0 )->Msg( "hello world" )
Yeah, like that works, but none of the functions to use the lua state work, but they do if you use the lua state passed to GMOD_MODULE_OPEN. It's like the state retrieved by GetLuaState is just broken. And yes, I'm testing it with SRCDS and changed the GetLuaInterface argument to State::SERVER (which is 1).

Anybody know what's causing the crashing problem
Quote Originally Posted by tdsx View Post
Anybody know what's causing the crashing problem
Try commenting luaL_dostring then try
Quote Originally Posted by suchisgood View Post
Try commenting luaL_dostring then try
yes, it works if I do that, but I need to be able to manipulate the lua state. it works if I put it in GMOD_MODULE_OPEN.
Quote Originally Posted by tdsx View Post
I tried it just now. Same problem :c
Try switching to pure lua state, Or maybe you can't hook it onto lua shared!
Quote Originally Posted by suchisgood View Post
Try switching to pure lua state, Or maybe you can't hook it onto lua shared!
What is pure lua state?
why are you using shared in the first place
Quote Originally Posted by D3M0L1T10N View Post
why are you using shared in the first place
it's my first project like this and I don't know any other decent way.
Quote Originally Posted by tdsx View Post
it's my first project like this and I don't know any other decent way.
Code:
class CBaseLuaInterface
{
public:
  void *vtable;
public:
  lua_State *L;
};
class CLuaInterface : public CBaseLuaInterface
{
public:
  //more stuff here :)
};
also you have to do all lua things in the main thread until the devs add multithreading

Quote Originally Posted by ExiledStyles View Post
what is "the lua base"? about 4 months ago i took some pastebin files of dylib dumps and called the necessary funcs, worked fine for me.
and meep you are trolling and that is not allowed here.
you're trying to avert the question and accuse me because you have no clue what it would do
Quote Originally Posted by MeepDarknessMeep View Post
Code:
class CBaseLuaInterface
{
public:
  void *vtable;
public:
  lua_State *L;
};
class CLuaInterface : public CBaseLuaInterface
{
public:
  //more stuff here :)
};
I'm not even sure what that would do tbh. This whole thing is getting me confused, but the crashing stopped. I was creating a new thread and trying to use the state from that.

It still doesn't execute the code though.
Code:
#include <Windows.h>
#include "Lua/Interface.h"
#include "icvar.h"
#include "ILuaShared.h"
#include "lua_shared.h"

using namespace GarrysMod::Lua;

void Initialize()
{
	ILuaShared* shared;
	CreateInterfaceFn factory = Sys_GetFactory("lua_shared.dll");
	shared = (ILuaShared*)factory(GMOD_LUASHARED_INTERFACE, NULL);
	ILuaInterface* iface = shared->GetLuaInterface(State::SERVER);
	lua_State* state = iface->GetLuaState();

	luaL_dostring(state, "print(1)");
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD Reason, LPVOID lpReserved)
{
	if (Reason == DLL_PROCESS_ATTACH)
	{
		Initialize();

		return TRUE;
	}
}
The lua headers.
https://bitbucket.org/danielga/gmod-...Lua/?at=master

lua_shared is only filled with externs like this, and the externs work with GMOD_MODULE_OPEN's lua state but not this state.
Code:
extern "C" int luaL_loadstring(lua_State *L, const char *s);
Quote Originally Posted by tdsx View Post
Code:
#include <Windows.h>
#include "Lua/Interface.h"
#include "icvar.h"
#include "ILuaShared.h"
#include "lua_shared.h"

using namespace GarrysMod::Lua;

void Initialize()
{
	ILuaShared* shared;
	CreateInterfaceFn factory = Sys_GetFactory("lua_shared.dll");
	shared = (ILuaShared*)factory(GMOD_LUASHARED_INTERFACE, NULL);
	ILuaInterface* iface = shared->GetLuaInterface(State::SERVER);
	lua_State* state = iface->GetLuaState();

	luaL_dostring(state, "print(1)");
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD Reason, LPVOID lpReserved)
{
	if (Reason == DLL_PROCESS_ATTACH)
	{
		Initialize();

		return TRUE;
	}
}
The lua headers.
https://bitbucket.org/danielga/gmod-...Lua/?at=master

lua_shared is only filled with externs like this, and the externs work with GMOD_MODULE_OPEN's lua state but not this state.
Code:
extern "C" int luaL_loadstring(lua_State *L, const char *s);
luaL_dostring is defined like it is on http://pgl.yoyo.org/luai/i/luaL_dostring , right?
if not then luaL_loadstring only loads the string - it doesn't run it
Posts 16–30 of 51 · Page 2 of 4

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us