Results 1 to 3 of 3
  1. #1
    MGPie's Avatar
    Join Date
    Dec 2017
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0

    Trying to make a lua executor, but crashes as soon as executes.

    Hi, I'm trying to make a lua executor but it seems to crash as soon as i try to run anything.

    Code:
    enum LuaInterfaceType
    {
    	LUAINTERFACE_CLIENT = 0,
    	LUAINTERFACE_SERVER = 1,
    	LUAINTERFACE_MENU = 2
    };
    
    class CLuaShared
    {
    public:
    	virtual void            padding00() = 0;
    	virtual void* padding01() = 0;
    	virtual void* padding02() = 0;
    	virtual void* padding03() = 0;
    	virtual void* padding04() = 0;
    	virtual void* padding05() = 0;
    	virtual DWORD			GetLuaInterface(LuaInterfaceType type) = 0;
    };
    
    typedef void* (*CreateInterfaceFn)(const char* Name, int* ReturnCode);
    
    // Lua function prototypes.
    typedef int(__cdecl* _luaL_loadstring)(void* state, const char* s);
    _luaL_loadstring  lua_ls = NULL;
    
    typedef int(__cdecl* _lua_pcall)(void* state, int nargs, int nresults, int errfunc);
    _lua_pcall lua_pcall = NULL;
    
    void ExecuteLua(string code) {
    	HMODULE luaShared = GetModuleHandleA("lua_shared.dll");
    	if (!luaShared) return console.AddLog("[error] Could not get lua_shared.dll");
    	CreateInterfaceFn CreateInterface = (CreateInterfaceFn)GetProcAddress(luaShared, "CreateInterface");
    	if (!CreateInterface) return console.AddLog("[error] Could not get CreateInterface from lua_shared.dll");
    	CLuaShared* ILuaShared = (CLuaShared*)CreateInterface("LUASHARED003", NULL);
    	if (!ILuaShared) return console.AddLog("[error] Could not get LUASHARED003 from CLuaShared");
    	DWORD CLuaInterface = ILuaShared->GetLuaInterface(LUAINTERFACE_CLIENT);
    	if (!CLuaInterface) return console.AddLog("[error] Could not get LUAINTERFACE_CLIENT from CLuaInterface");
    	DWORD pGLuaState = *(DWORD*)(CLuaInterface + 0x4);
    	if (!pGLuaState) return console.AddLog("[error] Could not get pGLuaState from CLuaInterface");
    	lua_pcall = (_lua_pcall)GetProcAddress(luaShared, "lua_pcall");
    	if (!lua_pcall) return console.AddLog("[error] Could not get lua_pcall from lua_shared.dll");
    	lua_ls = (_luaL_loadstring)GetProcAddress(luaShared, "luaL_loadstring");
    	if (!lua_ls) return console.AddLog("[error] Could not get lua_ls from lua_shared.dll");
    	lua_ls((void*)pGLuaState, code.c_str());
    	lua_pcall((void*)pGLuaState, 0, 0, 0);
    }
    now whenever i try to execute anything via ExecuteLua and a console window if I do a simple print('1') it does it, but if I try again it crashes and anything longer crashes aswell. Does anyone know why?

  2. #2
    mangousteFR's Avatar
    Join Date
    Jul 2019
    Gender
    male
    Posts
    0
    Reputation
    10
    Thanks
    0
    it's c++ ?

  3. #3
    Enegry3's Avatar
    Join Date
    Mar 2017
    Gender
    male
    Posts
    11
    Reputation
    10
    Thanks
    1
    You're probably not popping it correctly or someshit. i cbf reading ur code

Similar Threads

  1. Help Im trying to make My private server public but I am struggling can someone help!
    By Gasng in forum Realm of the Mad God Private Servers Help
    Replies: 0
    Last Post: 12-05-2014, 08:07 PM
  2. [Preview] Trying To make 5slot Hack But Cannot Use
    By Anonymouse123 in forum WarRock Philippines Hacks
    Replies: 5
    Last Post: 12-28-2013, 04:37 AM
  3. [Help] I was trying To Make A D3D But I got d3d9.dll Error!!
    By DevilGhost in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 11
    Last Post: 12-05-2011, 09:20 AM
  4. [HELP] Trying to make knive mod but..
    By muumimamma in forum Combat Arms Mod Discussion
    Replies: 9
    Last Post: 03-07-2010, 02:43 PM