Removed non-working onfunction.
							parent
							
								
									93662034fe
								
							
						
					
					
						commit
						1c013486d5
					
				@ -1 +0,0 @@
 | 
				
			|||||||
as  -anl --32 -o functions.o functions.asm
 | 
					 | 
				
			||||||
@ -1,23 +0,0 @@
 | 
				
			|||||||
.intel_syntax
 | 
					 | 
				
			||||||
push eax
 | 
					 | 
				
			||||||
push ebp
 | 
					 | 
				
			||||||
push esp
 | 
					 | 
				
			||||||
push esi
 | 
					 | 
				
			||||||
push edi
 | 
					 | 
				
			||||||
push edx
 | 
					 | 
				
			||||||
push ecx
 | 
					 | 
				
			||||||
push ebx
 | 
					 | 
				
			||||||
push eax
 | 
					 | 
				
			||||||
mov eax,[esp+36]
 | 
					 | 
				
			||||||
push eax
 | 
					 | 
				
			||||||
function:
 | 
					 | 
				
			||||||
call 0xdeadbee0
 | 
					 | 
				
			||||||
function2:
 | 
					 | 
				
			||||||
mov [0xdeadbeef],eax
 | 
					 | 
				
			||||||
pop eax
 | 
					 | 
				
			||||||
function3:
 | 
					 | 
				
			||||||
jmp [0xdeadbeef]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
											
												Binary file not shown.
											
										
									
								@ -1,68 +0,0 @@
 | 
				
			|||||||
onfunction=onfunction or {}
 | 
					 | 
				
			||||||
function onfunction.install()
 | 
					 | 
				
			||||||
	ModData=engine.installMod("dfusion/onfunction/functions.o","functions",4)
 | 
					 | 
				
			||||||
	modpos=ModData.pos
 | 
					 | 
				
			||||||
	modsize=ModData.size
 | 
					 | 
				
			||||||
	onfunction.pos=modpos
 | 
					 | 
				
			||||||
	trgpos=engine.getpushvalue()
 | 
					 | 
				
			||||||
	print(string.format("Function installed in:%x function to call is: %x",modpos,trgpos))
 | 
					 | 
				
			||||||
	local firstpos=modpos+engine.FindMarker(ModData,"function")
 | 
					 | 
				
			||||||
	engine.poked(firstpos,trgpos-firstpos-4) --call Lua-Onfunction
 | 
					 | 
				
			||||||
	onfunction.fpos=modpos+engine.FindMarker(ModData,"function3")
 | 
					 | 
				
			||||||
	engine.poked(modpos+engine.FindMarker(ModData,"function2"),modpos+modsize)
 | 
					 | 
				
			||||||
	engine.poked(onfunction.fpos,modpos+modsize)
 | 
					 | 
				
			||||||
	SetExecute(modpos)
 | 
					 | 
				
			||||||
	onfunction.calls={}
 | 
					 | 
				
			||||||
	onfunction.functions={}
 | 
					 | 
				
			||||||
	onfunction.names={}
 | 
					 | 
				
			||||||
	onfunction.hints={}
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
function OnFunction(values)
 | 
					 | 
				
			||||||
	--[=[print("Onfunction called!")
 | 
					 | 
				
			||||||
	print("Data:")
 | 
					 | 
				
			||||||
	for k,v in pairs(values) do
 | 
					 | 
				
			||||||
		print(string.format("%s=%x",k,v))
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	print("stack:")
 | 
					 | 
				
			||||||
	for i=0,3 do 
 | 
					 | 
				
			||||||
		print(string.format("%d %x",i,engine.peekd(values.esp+i*4)))
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	--]=]
 | 
					 | 
				
			||||||
	if onfunction.functions[values.ret] ~=nil then
 | 
					 | 
				
			||||||
		onfunction.functions[values.ret](values)
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return  onfunction.calls[values.ret] --returns real function to call
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
function onfunction.patch(addr)
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if(engine.peekb(addr)~=0xe8) then
 | 
					 | 
				
			||||||
		error("Incorrect address, not a function call")
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		onfunction.calls[addr+5]=addr+engine.peekd(addr+1)+5 --adds real function to call
 | 
					 | 
				
			||||||
		engine.poked(addr+1,engine.getmod("functions")-addr-5)
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
function onfunction.AddFunction(addr,name,hints)
 | 
					 | 
				
			||||||
	onfunction.patch(addr)
 | 
					 | 
				
			||||||
	onfunction.names[name]=addr+5
 | 
					 | 
				
			||||||
	if hints~=nil then
 | 
					 | 
				
			||||||
		onfunction.hints[name]=hints
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
function onfunction.ReadHint(values,name,hintname)
 | 
					 | 
				
			||||||
	local hints=onfunction.hints[name]
 | 
					 | 
				
			||||||
	if hints ==nil then return nil end
 | 
					 | 
				
			||||||
	local hint=hints[hintname]
 | 
					 | 
				
			||||||
	if type(hint)=="string" then return values[hint] end
 | 
					 | 
				
			||||||
	local off=hint.off or 0
 | 
					 | 
				
			||||||
	return engine.peek(off+values[hint.reg],hints[hintname].rtype)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
function onfunction.SetCallback(name,func)
 | 
					 | 
				
			||||||
	if onfunction.names[name]==nil then
 | 
					 | 
				
			||||||
		error("No such function:"..name)
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		onfunction.functions[onfunction.names[name]]=func
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,16 +0,0 @@
 | 
				
			|||||||
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"}) 
 | 
					 | 
				
			||||||
	onfunction.AddFunction(0x5af826+offsets.base(),"Hurt",{target="esi",attacker={off=0x74,rtype=DWORD,reg="esp"}}) 
 | 
					 | 
				
			||||||
	onfunction.AddFunction(0x3D5886+offsets.base(),"Flip",{building="esi"}) 
 | 
					 | 
				
			||||||
	onfunction.AddFunction(0x35E340+offsets.base(),"ItemCreate")--]=]
 | 
					 | 
				
			||||||
	--onfunction.AddFunction(0x4B34B6+offsets.base(),"ReactionFinish") --esp item. Ecx creature, edx? 0.34.07
 | 
					 | 
				
			||||||
	onfunction.AddFunction(0x72aB6+offsets.base(),"Die",{creature="edi"}) --0.34.07
 | 
					 | 
				
			||||||
else --linux
 | 
					 | 
				
			||||||
	--[=[onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
 | 
					 | 
				
			||||||
	onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"})  -- same--]=]
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
@ -1,15 +0,0 @@
 | 
				
			|||||||
mypos=engine.getmod("functions")
 | 
					 | 
				
			||||||
function DeathMsg(values)
 | 
					 | 
				
			||||||
	local name
 | 
					 | 
				
			||||||
	local u=engine.cast(df.unit,values[onfunction.hints["Die"].creature])
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	print(u.name.first_name.." died")
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
if mypos then
 | 
					 | 
				
			||||||
	print("Onfunction already installed")
 | 
					 | 
				
			||||||
	--onfunction.patch(0x189dd6+offsets.base())
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
	onfunction.install()
 | 
					 | 
				
			||||||
	dofile("dfusion/onfunction/locations.lua")
 | 
					 | 
				
			||||||
	onfunction.SetCallback("Die",DeathMsg)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue