2011-08-04 15:22:25 -06:00
|
|
|
function friendship_in.patch()
|
2011-09-17 05:59:10 -06:00
|
|
|
UpdateRanges()
|
2011-08-04 15:22:25 -06:00
|
|
|
pos=GetTextRegion().start
|
2012-03-24 06:47:51 -06:00
|
|
|
local _,crace=df.sizeof(df.global.ui:_field("race_id"))
|
2011-08-04 15:22:25 -06:00
|
|
|
hits={}
|
|
|
|
i=1
|
|
|
|
repeat
|
|
|
|
--todo make something better/smarter...
|
|
|
|
pos1=offsets.find(pos+7,0x0f,0xBF,ANYBYTE,DWORD_,crace) -- movsx
|
|
|
|
pos2=offsets.find(pos+7,0x66,0xa1,DWORD_,crace) -- mov ax,[ptr]
|
|
|
|
pos3=offsets.find(pos+7,0xa1,DWORD_,crace) -- mov eax,[ptr]
|
|
|
|
pos4=offsets.find(pos+7,0x66,0x8b,ANYBYTE,DWORD_,crace) -- mov ANYREG,[ptr]
|
|
|
|
--pos5=offsets.find(pos+7,0x66,0x8b,0x15,DWORD_,crace) -- mov dx,[ptr]
|
2012-03-31 03:12:16 -06:00
|
|
|
pos=minEx{pos1,pos2,pos3,pos4}
|
2011-08-04 15:22:25 -06:00
|
|
|
if pos ~=0 then
|
|
|
|
hits[i]=pos
|
|
|
|
i=i+1
|
|
|
|
print(string.format("Found at %x",pos))
|
|
|
|
end
|
|
|
|
until pos==0
|
|
|
|
print("=======================================")
|
|
|
|
for _,p in pairs(hits) do
|
|
|
|
myp=p
|
|
|
|
repeat
|
|
|
|
|
|
|
|
--print(string.format("Analyzing %x...",p))
|
2011-09-17 05:59:10 -06:00
|
|
|
--TODO read offset from memory.xml
|
2011-08-04 15:22:25 -06:00
|
|
|
pos1=offsets.find(myp,0x39,ANYBYTE,0x8c,00,00,00) -- compare [reg+08c] (creature race) with any reg
|
|
|
|
pos2=offsets.find(myp,0x3b,ANYBYTE,0x8c,00,00,00) -- compare any reg with [reg+08c] (creature race)
|
2012-03-31 03:12:16 -06:00
|
|
|
pos=minEx{pos1,pos2}
|
2011-08-04 15:22:25 -06:00
|
|
|
if pos ~=0 then
|
|
|
|
|
|
|
|
if(pos-p>250) then
|
|
|
|
--this here does not work yet...
|
|
|
|
--[[pos =offsets.find(p,CALL)
|
|
|
|
print(string.format("Distance to call:%x",pos-p))
|
|
|
|
print(string.format("Call: %x",signDword(engine.peekd(pos+1)+pos)))
|
|
|
|
pos=analyzeF(signDword(signDword(engine.peekd(pos+1)+pos)))
|
|
|
|
|
|
|
|
print(string.format("Cmp @:%x",pos))]]--
|
|
|
|
print(string.format("skipping %x... Cmp too far away (dist=%i)",p,pos-p))
|
|
|
|
else
|
|
|
|
--print(string.format("Found at %x, simple compare",pos))
|
|
|
|
--print(string.format("Distance =%x",pos-p))
|
|
|
|
--patch compares
|
|
|
|
|
|
|
|
pokeCall(pos)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
break
|
|
|
|
end
|
|
|
|
myp=myp+pos+6
|
|
|
|
if myp-p >250 then break end
|
|
|
|
until false
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|