Beispiel #1
0
void lua::RegisterEngine(lua::state &st)
{
	st.getglobal("engine");
	if(st.is<lua::nil>())
	{
		st.pop();
		st.newtable();
	}
	lua::RegFunctionsLocal(st,lua_engine_func);
	st.setglobal("engine");
}
Beispiel #2
0
void lua::RegisterProcess(lua::state &st,DFHack::Process *p)
{
	st.getglobal("Process");
	if(st.is<lua::nil>())
	{
		st.pop();
		st.newtable();
	}

	st.pushlightuserdata(p);
	st.setfield("__pointer");
	
	lua::RegFunctionsLocal(st, lua_process_func);

	st.setglobal("Process");
}
Beispiel #3
0
void handle_registerX(lua::state& L, uint64_t addr, int lfn)
{
    //Put the context in userdata so it can be gc'd when Lua context is terminated.
    lua_debug_callback2* D = (lua_debug_callback2*)L.newuserdata(sizeof(lua_debug_callback2));
    new(D) lua_debug_callback2;
    L.newtable();
    L.pushstring("__gc");
    L.push_trampoline(&lua_debug_callback2::on_lua_gc, 0);
    L.rawset(-3);
    L.setmetatable(-2);
    L.pushlightuserdata(D);
    L.pushvalue(-2);
    L.rawset(LUA_REGISTRYINDEX);
    L.pop(1); //Pop the copy of object.

    D->L = &L.get_master();
    D->addr = addr;
    D->type = type;
    D->dead = false;
    D->set_lua_fn(lfn);
    D->link_to_list();

    CORE().dbg->add_callback(addr, type, *D);
}
Beispiel #4
0
void lua::RegCommon(lua::state &L)
{
    L.newtable();
    //L.push(&GetOffset);
    lua_pushcfunction(L,&GetOffset);
    L.setfield("get");
    lua_pushcfunction(L,&GetOffset2);
    L.setfield("getEx");
    lua_pushcfunction(L,&Find);
    L.setfield("find");
    lua_pushcfunction(L,&NewOffset);
    L.setfield("new");
    lua_pushcfunction(L,&NewLazyOffset);
    L.setfield("newlazy");
    lua_pushcfunction(L,&GetBase);
    L.setfield("base");
    lua_pushcfunction(L,&Save);
    L.setfield("save");
    lua_pushcfunction(L,&GetVecs);
    L.setfield("getvectors");
    lua_pushcfunction(L,&GetCalls);
    L.setfield("getcalls");
    L.setglobal("offsets");

    //find functionality...
    /*
        #define EOL			0x100
        #define ANYBYTE		0x101
        //#define FF_OR_00	0x102				// deprecated
        #define HERE		0x103
        #define EITHER		0x104
        #define SKIP_UP_TO	0x105
        #define RANGE_LO	0x106				// deprecated
        #define RANGE_HI	0x107				// deprecated
        #define DWORD_		0x108
        #define	ANYDWORD	0x109
        #define ADDRESS		0x10A
        #define	BYTERANGE	0x10B
        #define DWORDRANGE	0x10C
        #define JZ			0x174
        #define JNZ			0x175
        #define JCC			0x170
        #define CALL		0x1E8
        #define JUMP		0x1E9
    */
    L.push(EOL);
    L.setglobal("EOL");
    L.push(ANYBYTE);
    L.setglobal("ANYBYTE");
    L.push(HERE);
    L.setglobal("HERE");
    L.push(EITHER);
    L.setglobal("EITHER");
    L.push(SKIP_UP_TO);
    L.setglobal("SKIP_UP_TO");
    L.push(DWORD_);
    L.setglobal("DWORD_");
    L.push(ANYDWORD);
    L.setglobal("ANYDWORD");
    L.push(ADDRESS);
    L.setglobal("ADDRESS");
    L.push(BYTERANGE);
    L.setglobal("BYTERANGE");
    L.push(DWORDRANGE);
    L.setglobal("DWORDRANGE");
    L.push(JZ);
    L.setglobal("JZ");
    L.push(JNZ);
    L.setglobal("JNZ");
    L.push(JCC);
    L.setglobal("JCC");
    L.push(CALL);
    L.setglobal("CALL");
    L.push(JUMP);
    L.setglobal("JUMP");
    luaopen_bit(L);

}