Added calldf function to call df functions (did not find any working function yet). Added 3 new function for onfunction.

develop
Warmist 2011-09-21 21:35:58 +03:00
parent ab448d4109
commit 6a56eabd71
3 changed files with 23 additions and 2 deletions

@ -8,6 +8,7 @@
#include "luamain.h"
#include "OutFile.h"
#include "bit.h"
#include "functioncall.h"
namespace lua
{

@ -2,6 +2,9 @@ if WINDOWS then --windows function defintions
onfunction.AddFunction(0x55499D+offsets.base(),"Move") --on creature move found with "watch mem=xcoord"
onfunction.AddFunction(0x275933+offsets.base(),"Die",{creature="edi"}) --on creature death? found by watching dead flag then stepping until new function
onfunction.AddFunction(0x2c1834+offsets.base(),"CreateCreature",{protocreature="eax"}) --arena
onfunction.AddFunction(0x349640+offsets.base(),"AddItem",{item="esp"}) --or esp
onfunction.AddFunction(0x26e840+offsets.base(),"Dig_Create",{item_type="esp"}) --esp+8 -> material esp->block type
onfunction.AddFunction(0x3d4301+offsets.base(),"Make_Item",{item_type="esp"})
else --linux
onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"}) -- same

@ -136,6 +136,8 @@ static size_t __stdcall PushValue(size_t ret,uint32_t eax,uint32_t ebx,uint32_t
#endif
{
lua::state st=lua::glua::Get();
st.getglobal("err");
int perr=st.gettop();
st.getglobal("OnFunction");
if(st.is<lua::nil>())
return 0;
@ -152,13 +154,13 @@ static size_t __stdcall PushValue(size_t ret,uint32_t eax,uint32_t ebx,uint32_t
st.setfield("edi");
st.push(esi);
st.setfield("esi");
st.push(esp);
st.push(esp+12);
st.setfield("esp");
st.push(ebp);
st.setfield("ebp");
st.push(ret);
st.setfield("ret");
st.pcall(1,1);
st.pcall(1,1,perr);
return st.as<uint32_t>();
}
static int Get_PushValue(lua_State *L)
@ -167,6 +169,20 @@ static int Get_PushValue(lua_State *L)
st.push((uint32_t)&PushValue);
return 1;
}
static int Call_Df(lua_State *L)
{
lua::state st(L);
FunctionCaller f(0);
std::vector<int> args;
size_t ptr;
FunctionCaller::callconv conv;
ptr=st.as<size_t>(1);
conv=(FunctionCaller::callconv)st.as<size_t>(2);
for(size_t j=3;j<=st.gettop();j++)
args.push_back(st.as<int>(j));
st.push(f.CallFunction(ptr,conv,args));
return 1;
}
const luaL_Reg lua_misc_func[]=
{
{"loadmod",LoadMod},
@ -176,6 +192,7 @@ const luaL_Reg lua_misc_func[]=
{"findmarker",FindMarker},
{"newmod",NewMod},
{"getpushvalue",Get_PushValue},
{"calldf",Call_Df},
{NULL,NULL}
};
void lua::RegisterMisc(lua::state &st)