From ddc83a0a72edb7c23abe8f08daa4750ead3dc5ea Mon Sep 17 00:00:00 2001 From: Warmist Date: Tue, 25 Sep 2012 11:30:38 +0300 Subject: [PATCH] Another dfusion nuking (not much left :) ) --- plugins/Dfusion/dfusion.cpp | 11 +- plugins/Dfusion/include/functioncall.h | 26 --- plugins/Dfusion/include/lua_FunctionCall.h | 14 -- plugins/Dfusion/include/lua_Misc.h | 1 - plugins/Dfusion/include/lua_Offsets.h | 13 -- plugins/Dfusion/include/lua_VersionInfo.h | 12 -- plugins/Dfusion/src/functioncall.cpp | 121 ------------- plugins/Dfusion/src/lua_FunctionCall.cpp | 39 ----- plugins/Dfusion/src/lua_Misc.cpp | 99 +---------- plugins/Dfusion/src/lua_Offsets.cpp | 190 --------------------- plugins/Dfusion/src/lua_VersionInfo.cpp | 115 ------------- 11 files changed, 5 insertions(+), 636 deletions(-) delete mode 100644 plugins/Dfusion/include/functioncall.h delete mode 100644 plugins/Dfusion/include/lua_FunctionCall.h delete mode 100644 plugins/Dfusion/include/lua_Offsets.h delete mode 100644 plugins/Dfusion/include/lua_VersionInfo.h delete mode 100644 plugins/Dfusion/src/functioncall.cpp delete mode 100644 plugins/Dfusion/src/lua_FunctionCall.cpp delete mode 100644 plugins/Dfusion/src/lua_Offsets.cpp delete mode 100644 plugins/Dfusion/src/lua_VersionInfo.cpp diff --git a/plugins/Dfusion/dfusion.cpp b/plugins/Dfusion/dfusion.cpp index 6c698f58a..0f49e860d 100644 --- a/plugins/Dfusion/dfusion.cpp +++ b/plugins/Dfusion/dfusion.cpp @@ -14,10 +14,8 @@ #include "lua_Process.h" #include "lua_Hexsearch.h" #include "lua_Misc.h" -#include "lua_VersionInfo.h" -#include "functioncall.h" -#include "lua_FunctionCall.h" -#include "lua_Offsets.h" + + #include "DataDefs.h" #include "LuaTools.h" @@ -43,15 +41,12 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector -using std::vector; -using std::size_t; -class FunctionCaller -{ -public: - enum callconv - { - STD_CALL, //__stdcall - all in stack - FAST_CALL, //__fastcall - as much in registers as fits - THIS_CALL, //__thiscall - eax ptr to this, rest in stack - CDECL_CALL //__cdecl - same as stdcall but no stack realign - }; - - FunctionCaller(size_t base):base_(base){}; - - int CallFunction(size_t func_ptr,callconv conv,const vector &arguments); - -private: - int CallF(size_t count,callconv conv,void* f,const vector &arguments); - size_t base_; -}; - -#endif //FUNCTIONCALL__H \ No newline at end of file diff --git a/plugins/Dfusion/include/lua_FunctionCall.h b/plugins/Dfusion/include/lua_FunctionCall.h deleted file mode 100644 index bc1af5685..000000000 --- a/plugins/Dfusion/include/lua_FunctionCall.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LUA_FUNCTIONCALL__H -#define LUA_FUNCTIONCALL__H - -#include "luamain.h" -#include "functioncall.h" - -namespace lua -{ - - -void RegisterFunctionCall(lua::state &st); - -} -#endif \ No newline at end of file diff --git a/plugins/Dfusion/include/lua_Misc.h b/plugins/Dfusion/include/lua_Misc.h index b39d60214..ff4611456 100644 --- a/plugins/Dfusion/include/lua_Misc.h +++ b/plugins/Dfusion/include/lua_Misc.h @@ -7,7 +7,6 @@ #include #include "luamain.h" #include "OutFile.h" -#include "functioncall.h" #include "LuaTools.h" namespace lua diff --git a/plugins/Dfusion/include/lua_Offsets.h b/plugins/Dfusion/include/lua_Offsets.h deleted file mode 100644 index 8d6a94b95..000000000 --- a/plugins/Dfusion/include/lua_Offsets.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LUA_OFFSETS_H -#define LUA_OFFSETS_H -#include "luamain.h" - -namespace lua -{ - -void RegisterEngine(lua::state &st); - -} - - -#endif \ No newline at end of file diff --git a/plugins/Dfusion/include/lua_VersionInfo.h b/plugins/Dfusion/include/lua_VersionInfo.h deleted file mode 100644 index a4d7ed658..000000000 --- a/plugins/Dfusion/include/lua_VersionInfo.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef LUA_VERSIONINFO_H -#define LUA_VERSIONINFO_H -#include "Core.h" -#include -#include "luamain.h" -namespace lua -{ - -void RegisterVersionInfo(lua::state &st); - -} -#endif diff --git a/plugins/Dfusion/src/functioncall.cpp b/plugins/Dfusion/src/functioncall.cpp deleted file mode 100644 index b6c38c928..000000000 --- a/plugins/Dfusion/src/functioncall.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "functioncall.h" - -#ifdef LINUX_BUILD -#define __F_TDEF(CONV,CONV_,tag) typedef int(__attribute__ ( (CONV_) ) *F_TYPE##CONV##tag) -#else -#define __F_TDEF(CONV,CONV_,tag) typedef int(__ ## CONV_ *F_TYPE##CONV##tag) -#endif - -#define __F_T(CONV,tag) F_TYPE##CONV##tag -#define __F_TYPEDEFS(CONV,CONV_) __F_TDEF(CONV,CONV_,1)(int);\ - __F_TDEF(CONV,CONV_,2)(int,int);\ - __F_TDEF(CONV,CONV_,3)(int,int,int);\ - __F_TDEF(CONV,CONV_,4)(int,int,int,int);\ - __F_TDEF(CONV,CONV_,5)(int,int,int,int,int);\ - __F_TDEF(CONV,CONV_,6)(int,int,int,int,int,int);\ - __F_TDEF(CONV,CONV_,7)(int,int,int,int,int,int,int) - - -#define __FCALL(CONV,CONV_) if(conv==CONV)\ - { \ - if(count==1)\ - ret= (reinterpret_cast<__F_T(CONV,1)>(f))\ - (arguments[0]);\ - else if(count==2)\ - ret= (reinterpret_cast<__F_T(CONV,2)>(f))\ - (arguments[0],arguments[1]);\ - else if(count==3)\ - ret= (reinterpret_cast<__F_T(CONV,3)>(f))\ - (arguments[0],arguments[1],arguments[2]);\ - else if(count==4)\ - ret= (reinterpret_cast<__F_T(CONV,4)>(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3]);\ - else if(count==5)\ - ret= (reinterpret_cast<__F_T(CONV,5)>(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]);\ - else if(count==6)\ - ret= (reinterpret_cast<__F_T(CONV,6)>(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]);\ - else if(count==7)\ - ret= (reinterpret_cast<__F_T(CONV,7)>(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]);\ - } - -#define __FCALLEX(CONV,CONV_) if(conv==CONV)\ - { if(count==1) {__F_T(CONV,1) tmp_F=reinterpret_cast<__F_T(CONV,1)>(f); return tmp_F(arguments[0]);}\ - else if(count==2){__F_T(CONV,2) tmp_F=reinterpret_cast<__F_T(CONV,2)>(f); return tmp_F(arguments[0],arguments[1]);}\ - else if(count==3){__F_T(CONV,3) tmp_F=reinterpret_cast<__F_T(CONV,3)>(f); return tmp_F(arguments[0],arguments[1],arguments[2]);}\ - else if(count==4){__F_T(CONV,4) tmp_F=reinterpret_cast<__F_T(CONV,4)>(f); return tmp_F(arguments[0],arguments[1],arguments[2],arguments[3]);}\ - else if(count==5){__F_T(CONV,5) tmp_F=reinterpret_cast<__F_T(CONV,5)>(f); return tmp_F(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]);}\ - else if(count==6){__F_T(CONV,6) tmp_F=reinterpret_cast<__F_T(CONV,6)>(f); return tmp_F(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]);}\ - else if(count==7){__F_T(CONV,7) tmp_F=reinterpret_cast<__F_T(CONV,7)>(f); return tmp_F(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]);}\ - } - /*else if(count==8)\ - ret= (reinterpret_cast<__F_T(CONV,8)>(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]);\ - else if(count==9)\ - ret= (reinterpret_cast(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8]);\ - else if(count==10)\ - ret= (reinterpret_cast(f))\ - (arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8],arguments[9]);}*/ - - -/*int FunctionCaller::CallF(size_t count,callconv conv,void* f,const vector &arguments)//more complex but not more error safe -{ - __F_TYPEDEFS(STD_CALL,__stdcall); - __F_TYPEDEFS(FAST_CALL,__fastcall); - __F_TYPEDEFS(THIS_CALL,__thiscall); - __F_TYPEDEFS(CDECL_CALL,__cdecl); - { - __FCALLEX(STD_CALL,__stdcall); - __FCALLEX(FAST_CALL,__fastcall); - __FCALLEX(THIS_CALL,__thiscall); - __FCALLEX(CDECL_CALL,__cdecl); - } -}*/ -int FunctionCaller::CallFunction(size_t func_ptr,callconv conv,const vector &arguments) -{ - //nasty nasty code... -#ifdef LINUX_BUILD //quick fix - if(conv==THIS_CALL) - conv=STD_CALL; -#endif - void* f= reinterpret_cast(func_ptr+base_); - size_t count=arguments.size(); - if(count==0) - return (reinterpret_cast(f))(); //does not matter how we call it... - int ret=0; - //typedefs - __F_TYPEDEFS(STD_CALL,stdcall); - __F_TYPEDEFS(FAST_CALL,fastcall); - __F_TYPEDEFS(THIS_CALL,thiscall); - __F_TYPEDEFS(CDECL_CALL,cdecl); - //calls - __FCALL(STD_CALL,stdcall); - __FCALL(FAST_CALL,fastcall); - __FCALL(THIS_CALL,thiscall); - __FCALL(CDECL_CALL,cdecl); - return -1; //incorect type. Should probably throw... - //return CallF(count,conv,f,arguments); - /*//testing part{ worked some time ago..., put where DFHack::Core is accesible - c->Suspend(); - FunctionCaller caller(c->p->getBase()); - std::vector args; - args.push_back((size_t)"Hello world"); - args.push_back(4); - args.push_back(4); - args.push_back(0); - dfprint mprint=(dfprint)(0x27F030+c->p->getBase()); - mprint("Hello world",4,4,0); - //caller.CallFunction((0x27F030),FunctionCaller::THIS_CALL,args); - c->Resume(); - return CR_OK; - //}end testing*/ -} -#undef __FCALL -#undef __FCALLEX -#undef __F_TYPEDEFS -#undef __F_T diff --git a/plugins/Dfusion/src/lua_FunctionCall.cpp b/plugins/Dfusion/src/lua_FunctionCall.cpp deleted file mode 100644 index a537edbb5..000000000 --- a/plugins/Dfusion/src/lua_FunctionCall.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "lua_FunctionCall.h" -using namespace lua; -int lua_FunctionCall(lua_State *L) -{ - lua::state st(L); - FunctionCaller cl(0); - size_t ptr=st.as(1); - int callconv=st.as(2); - vector arguments; - for(int i=3;i(i)); - int ret=cl.CallFunction(ptr,(FunctionCaller::callconv)callconv,arguments); - st.push(ret); - return 1;// dunno if len is needed... -} - -const luaL_Reg lua_functioncall_func[]= -{ - {"call",lua_FunctionCall}, - {NULL,NULL} -}; - -#define __ADDCONST(name) st.push(::FunctionCaller:: name); st.setglobal(#name) -void lua::RegisterFunctionCall(lua::state &st) -{ - st.getglobal("FunctionCall"); - if(st.is()) - { - st.pop(); - st.newtable(); - } - __ADDCONST(STD_CALL); - __ADDCONST(FAST_CALL); - __ADDCONST(THIS_CALL); - __ADDCONST(CDECL_CALL); - lua::RegFunctionsLocal(st, lua_functioncall_func); - st.setglobal("FunctionCall"); -} -#undef __ADDCONST \ No newline at end of file diff --git a/plugins/Dfusion/src/lua_Misc.cpp b/plugins/Dfusion/src/lua_Misc.cpp index b58efc7ac..6a06781fd 100644 --- a/plugins/Dfusion/src/lua_Misc.cpp +++ b/plugins/Dfusion/src/lua_Misc.cpp @@ -129,111 +129,16 @@ static int GetMod(lua_State *L) st.push(pos); return 1; } -static int lua_malloc(lua_State *L) -{ - lua::state st(L); - size_t size=st.as(1); - size_t pos=reinterpret_cast(malloc(size)); - st.push(pos); - return 1; -} -static int lua_malloc_free(lua_State *L) -{ - lua::state st(L); - size_t ptr=st.as(1); - free(reinterpret_cast(ptr)); - return 0; -} -#ifdef LINUX_BUILD -static size_t __attribute__((stdcall)) PushValue(size_t ret,uint32_t eax,uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t edi,uint32_t esi,uint32_t esp,uint32_t ebp) -#else -static size_t __stdcall PushValue(size_t ret,uint32_t eax,uint32_t ebx,uint32_t ecx,uint32_t edx,uint32_t edi,uint32_t esi,uint32_t esp,uint32_t ebp) -#endif -{ - lua::state st=lua::glua::Get(); - st.getglobal("OnFunction"); - if(st.is()) - return 0; - st.newtable(); - st.push(eax); - st.setfield("eax"); - st.push(ebx); - st.setfield("ebx"); - st.push(ecx); - st.setfield("ecx"); - st.push(edx); - st.setfield("edx"); - st.push(edi); - st.setfield("edi"); - st.push(esi); - st.setfield("esi"); - st.push(esp+12); - st.setfield("esp"); - st.push(ebp); - st.setfield("ebp"); - st.push(ret); - st.setfield("ret"); - DFHack::Lua::SafeCall(DFHack::Core::getInstance().getConsole(),st,1,1); - return st.as(); -} -static int Get_PushValue(lua_State *L) -{ - lua::state st(L); - st.push((uint32_t)&PushValue); - return 1; -} -static int Call_Df(lua_State *L) -{ - lua::state st(L); - FunctionCaller f(0); - std::vector args; - size_t ptr; - FunctionCaller::callconv conv; - ptr=st.as(1); - conv=(FunctionCaller::callconv)st.as(2); - for(size_t j=3;j<=st.gettop();j++) - args.push_back(st.as(j)); - st.push(f.CallFunction(ptr,conv,args)); - return 1; -} -static int Suspend_Df(lua_State *L) -{ - lua::state st(L); - DFHack::Core::getInstance().Suspend(); - return 0; -} -static int Resume_Df(lua_State *L) -{ - lua::state st(L); - DFHack::Core::getInstance().Resume(); - return 0; -} -static int Cast(lua_State *L) -{ - lua::state st(L); - if(DFHack::Lua::IsDFObject(st,1)!=DFHack::Lua::OBJ_TYPE) - st.error("First argument must be df type!"); - if(!st.is(2)) //todo maybe lightuserdata? - st.error("Second argument must be pointer as a number!"); - st.getfield("_identity",1); - DFHack::Lua::PushDFObject(st,(DFHack::type_identity*)lua_touserdata(st,-1),(void*)st.as(2)); - return 1; -} + + const luaL_Reg lua_misc_func[]= { - {"alloc",lua_malloc}, - {"free",lua_malloc_free}, {"loadmod",LoadMod}, {"getmod",GetMod}, {"loadobj",LoadObj}, {"loadobjsymbols",LoadObjSymbols}, {"findmarker",FindMarker}, {"newmod",NewMod}, - {"getpushvalue",Get_PushValue}, - {"calldf",Call_Df}, - {"suspend",Suspend_Df}, - {"resume",Resume_Df}, - {"cast",Cast}, {NULL,NULL} }; void lua::RegisterMisc(lua::state &st) diff --git a/plugins/Dfusion/src/lua_Offsets.cpp b/plugins/Dfusion/src/lua_Offsets.cpp deleted file mode 100644 index 4d66e67e7..000000000 --- a/plugins/Dfusion/src/lua_Offsets.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "lua_Offsets.h" -#include -#include -//TODO make a seperate module with peeks/pokes and page permisions (linux/windows spec) -//TODO maybe remove alltogether- use DFHack::Process instead? -template -T engine_peek(size_t offset) -{ - return *(reinterpret_cast(offset)); -} -template -void engine_poke(size_t offset,T val) -{ - *(reinterpret_cast(offset))=val; -} - -void peekarb(size_t offset, void *mem,size_t size) -{ - memcpy(mem,(void*)offset,size); -} -void peekstr(size_t offset, char* buf, size_t maxsize) -{ - strncpy(buf,(char*)offset,maxsize); -} -void pokearb(size_t offset, void *mem,size_t size) -{ - memcpy((void*)offset,mem,size); -} -void pokestr(size_t offset, char* buf, size_t maxsize) -{ - strncpy((char*)offset,buf,maxsize); -} - -//// lua stuff here -static int lua_peekb(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_peekw(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_peekd(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_peekq(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_peekfloat(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_peekdouble(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_peekarb(lua_State *L) -{ - lua::state st(L); - size_t size=st.as(2); - void *p=st.newuserdata(size); - peekarb(st.as(1),p,size); - return 1; -} -static int lua_peekstr(lua_State *L) -{ - lua::state st(L); - char *buf; - buf=new char[256]; - peekstr(st.as(1),buf,256); - std::string tstr(buf); - st.push(tstr); - delete [] buf; - return 1; -} -static int lua_peekstr2(lua_State *L) -{ - lua::state st(L); - st.push(engine_peek(st.as(1))); - return 1; -} -static int lua_pokeb(lua_State *L) -{ - lua::state st(L); - engine_poke(st.as(1),st.as(2)); - return 0; -} -static int lua_pokew(lua_State *L) -{ - lua::state st(L); - engine_poke(st.as(1),st.as(2)); - return 0; -} -static int lua_poked(lua_State *L) -{ - lua::state st(L); - engine_poke(st.as(1),st.as(2)); - return 0; -} -static int lua_pokeq(lua_State *L) -{ - lua::state st(L); - engine_poke(st.as(1),st.as(2)); - return 0; -} -static int lua_pokefloat(lua_State *L) -{ - lua::state st(L); - engine_poke(st.as(1),st.as(2)); - return 0; -} -static int lua_pokedouble(lua_State *L) -{ - lua::state st(L); - engine_poke(st.as(1),st.as(2)); - return 0; -} -static int lua_pokearb(lua_State *L) -{ - lua::state st(L); - void *p=(void *)lua_touserdata(L, 2);//st.as(2); - size_t size=st.as(3); - pokearb(st.as(1),p,size); - return 0; -} -static int lua_pokestr(lua_State *L) -{ - lua::state st(L); - std::string trg=st.as(2); - pokestr(st.as(1),(char*)trg.c_str(),trg.size()); - return 0; -} -static int lua_pokestr2(lua_State *L) -{ - lua::state st(L); - std::string trg=st.as(2); - engine_poke(st.as(1),trg); - return 0; -} -const luaL_Reg lua_engine_func[]= -{ - {"peekb",lua_peekb}, - {"peekw",lua_peekw}, - {"peekd",lua_peekd}, - {"peekq",lua_peekq}, - {"peekfloat",lua_peekfloat}, - {"peekdouble",lua_peekdouble}, - - {"peekarb",lua_peekarb}, - {"peekstr",lua_peekstr}, - {"peekstr2",lua_peekstr2}, - - {"pokeb",lua_pokeb}, - {"pokew",lua_pokew}, - {"poked",lua_poked}, - {"pokeq",lua_pokeq}, - {"pokefloat",lua_pokefloat}, - {"pokedouble",lua_pokedouble}, - - {"pokearb",lua_pokearb}, - {"pokestr",lua_pokestr}, - {"pokestr2",lua_pokestr2}, - {NULL,NULL} -}; - -void lua::RegisterEngine(lua::state &st) -{ - st.getglobal("engine"); - if(st.is()) - { - st.pop(); - st.newtable(); - } - lua::RegFunctionsLocal(st,lua_engine_func); - st.setglobal("engine"); -} diff --git a/plugins/Dfusion/src/lua_VersionInfo.cpp b/plugins/Dfusion/src/lua_VersionInfo.cpp deleted file mode 100644 index 9f5cd17e7..000000000 --- a/plugins/Dfusion/src/lua_VersionInfo.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "lua_VersionInfo.h" - -#define VI_FUNC(name) int lua_VI_ ## name (lua_State *L){\ - lua::state s(L);\ - DFHack::VersionInfo* vif=DFHack::Core::getInstance().vinfo; -#define END_VI_FUNC } - -VI_FUNC(getBase) -//int lua_VI_getBase(lua_State *L) - s.push(vif->getBase()); - return 1; -END_VI_FUNC - -VI_FUNC(setBase) - uint32_t val=s.as(1); - vif->setBase(val); - return 0; -END_VI_FUNC -VI_FUNC(rebaseTo) - uint32_t val=s.as(1); - vif->rebaseTo(val); - return 0; -END_VI_FUNC -VI_FUNC(addMD5) - std::string val=s.as(1); - vif->addMD5(val); - return 0; -END_VI_FUNC -VI_FUNC(hasMD5) - std::string val=s.as(1); - s.push(vif->hasMD5(val)); - return 1; -END_VI_FUNC - -VI_FUNC(addPE) - uint32_t val=s.as(1); - vif->addPE(val); - return 0; -END_VI_FUNC - -VI_FUNC(hasPE) - uint32_t val=s.as(1); - s.push(vif->hasPE(val)); - return 1; -END_VI_FUNC - -VI_FUNC(setVersion) - std::string val=s.as(1); - vif->setVersion(val); - return 0; -END_VI_FUNC - -VI_FUNC(getVersion) - s.push(vif->getVersion()); - return 1; -END_VI_FUNC - -VI_FUNC(setAddress) - std::string key=s.as(1); - uint32_t val=s.as(2); - vif->setAddress(key,val); - return 0; -END_VI_FUNC - -VI_FUNC(getAddress) - std::string key=s.as(1); - - s.push(vif->getAddress(key)); - return 1; -END_VI_FUNC - -VI_FUNC(setOS) - unsigned os=s.as(1); - vif->setOS((DFHack::OSType)os); - return 0; -END_VI_FUNC - -VI_FUNC(getOS) - s.push(vif->getOS()); - return 1; -END_VI_FUNC -#undef VI_FUNC -#undef END_VI_FUNC -#define VI_FUNC(name) {#name,lua_VI_ ## name} -const luaL_Reg lua_vinfo_func[]= -{ - VI_FUNC(getBase), - VI_FUNC(setBase), - VI_FUNC(rebaseTo), - VI_FUNC(addMD5), - VI_FUNC(hasMD5), - VI_FUNC(addPE), - VI_FUNC(hasPE), - VI_FUNC(setVersion), - VI_FUNC(getVersion), - VI_FUNC(setAddress), - VI_FUNC(getAddress), - VI_FUNC(setOS), - VI_FUNC(getOS), - {NULL,NULL} -}; -#undef VI_FUNC -void lua::RegisterVersionInfo(lua::state &st) -{ - - st.getglobal("VersionInfo"); - if(st.is()) - { - st.pop(); - st.newtable(); - } - - lua::RegFunctionsLocal(st, lua_vinfo_func); - st.setglobal("VersionInfo"); -}