develop
commit
8ab5697f4a
@ -0,0 +1,89 @@
|
|||||||
|
adv_tools=adv_tools or {}
|
||||||
|
adv_tools.menu=adv_tools.menu or MakeMenu()
|
||||||
|
function adv_tools.ressurect()
|
||||||
|
myoff=offsets.getEx("AdvCreatureVec")
|
||||||
|
vector=engine.peek(myoff,ptr_vector)
|
||||||
|
indx=GetCreatureAtPos(getxyz())
|
||||||
|
if indx<0 then indx=0 end
|
||||||
|
--print(string.format("%x",vector:getval(indx)))
|
||||||
|
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt1)
|
||||||
|
for i=0,v2:size()-1 do
|
||||||
|
v2:setval(i,0)
|
||||||
|
end
|
||||||
|
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt2)
|
||||||
|
v2.type=DWORD
|
||||||
|
for i=0,v2:size()-1 do
|
||||||
|
v2:setval(i,0)
|
||||||
|
end
|
||||||
|
engine.poke(vector:getval(indx),ptr_Creature.bloodlvl,60000) --give blood
|
||||||
|
engine.poke(vector:getval(indx),ptr_Creature.bleedlvl,0) --stop some bleeding...
|
||||||
|
local flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
|
||||||
|
flg:set(1,false) --ALIVE
|
||||||
|
flg:set(39,false) -- leave body yet again
|
||||||
|
flg:set(37,false) -- something todo with wounds- lets you walk again.
|
||||||
|
flg:set(58,true) -- makes them able to breathe
|
||||||
|
flg:set(61,true) -- gives them sight
|
||||||
|
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
||||||
|
end
|
||||||
|
|
||||||
|
function adv_tools.wagonmode() --by rumrusher
|
||||||
|
--first three lines same as before (because we will need an offset of creature at location x,y,z)
|
||||||
|
myoff=offsets.getEx("AdvCreatureVec")
|
||||||
|
vector=engine.peek(myoff,ptr_vector)
|
||||||
|
indx=GetCreatureAtPos(getxyz())
|
||||||
|
--indx=0
|
||||||
|
--print(string.format("%x",vector:getval(indx)))
|
||||||
|
flg=engine.peek(vector:getval(indx),ptr_Creature.flags) --get flags
|
||||||
|
flg:set(1,false)
|
||||||
|
flg:set(74,false)
|
||||||
|
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
||||||
|
print("To stay normal press y, else hit Enter turn Wagon mode on.")
|
||||||
|
r=io.stdin:read() -- repeat for it too work... also creature will be dead.
|
||||||
|
if r== "y" then
|
||||||
|
flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
|
||||||
|
flg:set(1,false)
|
||||||
|
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
||||||
|
else
|
||||||
|
flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
|
||||||
|
flg:set(1,false)
|
||||||
|
flg:flip(74)
|
||||||
|
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function selectall()
|
||||||
|
local retvec={} --return vector (or a list)
|
||||||
|
myoff=offsets.getEx("AdvCreatureVec")
|
||||||
|
vector=engine.peek(myoff,ptr_vector) --standart start
|
||||||
|
for i=0,vector:size()-1 do --check all creatures
|
||||||
|
local off
|
||||||
|
off=vector:getval(i)
|
||||||
|
local flags=engine.peek(off,ptr_Creature.flags)
|
||||||
|
if flags:get(1)==true then --if dead ...
|
||||||
|
table.insert(retvec,off)--... add it to return vector
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return retvec --return the "return vector" :)
|
||||||
|
end
|
||||||
|
function adv_tools.hostilate()
|
||||||
|
vector=engine.peek(offsets.getEx("AdvCreatureVec"),ptr_vector)
|
||||||
|
id=GetCreatureAtPos(getxyz())
|
||||||
|
print(string.format("Vec:%d cr:%d",vector:size(),id))
|
||||||
|
off=vector:getval(id)
|
||||||
|
crciv=engine.peek(vector:getval(id),ptr_Creature.civ)
|
||||||
|
curciv=engine.peek(vector:getval(0),ptr_Creature.civ)
|
||||||
|
|
||||||
|
if curciv==crciv then
|
||||||
|
print("Friendly-making enemy")
|
||||||
|
engine.poke(off,ptr_Creature.civ,-1)
|
||||||
|
flg=engine.peek(off,ptr_Creature.flags)
|
||||||
|
flg:set(17,true)
|
||||||
|
engine.poke(off,ptr_Creature.flags,flg)
|
||||||
|
else
|
||||||
|
print("Enemy- making friendly")
|
||||||
|
engine.poke(off,ptr_Creature.civ,curciv)
|
||||||
|
flg=engine.peek(off,ptr_Creature.flags)
|
||||||
|
flg:set(17,false)
|
||||||
|
flg:set(19,false)
|
||||||
|
engine.poke(off,ptr_Creature.flags,flg)
|
||||||
|
end
|
||||||
|
end
|
@ -1,89 +0,0 @@
|
|||||||
adv_tools=adv_tools or {}
|
|
||||||
adv_tools.menu=adv_tools.menu or MakeMenu()
|
|
||||||
function adv_tools.ressurect()
|
|
||||||
myoff=offsets.getEx("AdvCreatureVec")
|
|
||||||
vector=engine.peek(myoff,ptr_vector)
|
|
||||||
indx=GetCreatureAtPos(getxyz())
|
|
||||||
if indx<0 then indx=0 end
|
|
||||||
--print(string.format("%x",vector:getval(indx)))
|
|
||||||
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt1)
|
|
||||||
for i=0,v2:size()-1 do
|
|
||||||
v2:setval(i,0)
|
|
||||||
end
|
|
||||||
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt2)
|
|
||||||
v2.type=DWORD
|
|
||||||
for i=0,v2:size()-1 do
|
|
||||||
v2:setval(i,0)
|
|
||||||
end
|
|
||||||
engine.poke(vector:getval(indx),ptr_Creature.bloodlvl,60000) --give blood
|
|
||||||
engine.poke(vector:getval(indx),ptr_Creature.bleedlvl,0) --stop some bleeding...
|
|
||||||
local flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
|
|
||||||
flg:set(1,false) --ALIVE
|
|
||||||
flg:set(39,false) -- leave body yet again
|
|
||||||
flg:set(37,false) -- something todo with wounds- lets you walk again.
|
|
||||||
flg:set(58,true) -- makes them able to breathe
|
|
||||||
flg:set(61,true) -- gives them sight
|
|
||||||
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
|
||||||
end
|
|
||||||
|
|
||||||
function adv_tools.wagonmode() --by rumrusher
|
|
||||||
--first three lines same as before (because we will need an offset of creature at location x,y,z)
|
|
||||||
myoff=offsets.getEx("AdvCreatureVec")
|
|
||||||
vector=engine.peek(myoff,ptr_vector)
|
|
||||||
indx=GetCreatureAtPos(getxyz())
|
|
||||||
--indx=0
|
|
||||||
--print(string.format("%x",vector:getval(indx)))
|
|
||||||
flg=engine.peek(vector:getval(indx),ptr_Creature.flags) --get flags
|
|
||||||
flg:set(1,false)
|
|
||||||
flg:set(74,false)
|
|
||||||
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
|
||||||
print("To stay normal press y, else hit Enter turn Wagon mode on.")
|
|
||||||
r=io.stdin:read() -- repeat for it too work... also creature will be dead.
|
|
||||||
if r== "y" then
|
|
||||||
flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
|
|
||||||
flg:set(1,false)
|
|
||||||
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
|
||||||
else
|
|
||||||
flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
|
|
||||||
flg:set(1,false)
|
|
||||||
flg:flip(74)
|
|
||||||
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function selectall()
|
|
||||||
local retvec={} --return vector (or a list)
|
|
||||||
myoff=offsets.getEx("AdvCreatureVec")
|
|
||||||
vector=engine.peek(myoff,ptr_vector) --standart start
|
|
||||||
for i=0,vector:size()-1 do --check all creatures
|
|
||||||
local off
|
|
||||||
off=vector:getval(i)
|
|
||||||
local flags=engine.peek(off,ptr_Creature.flags)
|
|
||||||
if flags:get(1)==true then --if dead ...
|
|
||||||
table.insert(retvec,off)--... add it to return vector
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return retvec --return the "return vector" :)
|
|
||||||
end
|
|
||||||
function adv_tools.hostilate()
|
|
||||||
vector=engine.peek(offsets.getEx("AdvCreatureVec"),ptr_vector)
|
|
||||||
id=GetCreatureAtPos(getxyz())
|
|
||||||
print(string.format("Vec:%d cr:%d",vector:size(),id))
|
|
||||||
off=vector:getval(id)
|
|
||||||
crciv=engine.peek(vector:getval(id),ptr_Creature.civ)
|
|
||||||
curciv=engine.peek(vector:getval(0),ptr_Creature.civ)
|
|
||||||
|
|
||||||
if curciv==crciv then
|
|
||||||
print("Friendly-making enemy")
|
|
||||||
engine.poke(off,ptr_Creature.civ,-1)
|
|
||||||
flg=engine.peek(off,ptr_Creature.flags)
|
|
||||||
flg:set(17,true)
|
|
||||||
engine.poke(off,ptr_Creature.flags,flg)
|
|
||||||
else
|
|
||||||
print("Enemy- making friendly")
|
|
||||||
engine.poke(off,ptr_Creature.civ,curciv)
|
|
||||||
flg=engine.peek(off,ptr_Creature.flags)
|
|
||||||
flg:set(17,false)
|
|
||||||
flg:set(19,false)
|
|
||||||
engine.poke(off,ptr_Creature.flags,flg)
|
|
||||||
end
|
|
||||||
end
|
|
@ -0,0 +1,45 @@
|
|||||||
|
function analyzeF(off)
|
||||||
|
pos=offsets.find(off,0x39,ANYBYTE,0x8c,00,00,00)
|
||||||
|
print(string.format("Compare at:%x",pos))
|
||||||
|
if pos ==0 then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if(pos-off>0x100) then
|
||||||
|
print(string.format("Distance to cmp:%x",pos-off))
|
||||||
|
pos =offsets.find(off,CALL)
|
||||||
|
print(string.format("Distance to call:%x",pos-off))
|
||||||
|
return 0
|
||||||
|
--return analyzeF(pos)
|
||||||
|
else
|
||||||
|
return pos
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function minEx(...)
|
||||||
|
local imin=arg[1]
|
||||||
|
for _,v in ipairs(arg) do
|
||||||
|
if imin> v and v~=0 then
|
||||||
|
imin=v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return imin
|
||||||
|
end
|
||||||
|
function signDword(dw)
|
||||||
|
if(dw>0xFFFFFFFF) then
|
||||||
|
return dw-0xFFFFFFFF
|
||||||
|
end
|
||||||
|
return dw
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
Warning: not all mov's are acounted for. Found one: mov EAX,WORD PTR[EBP+1EF4] WTF??
|
||||||
|
Two more compares are missing. There are calls instead (same function)
|
||||||
|
]]--
|
||||||
|
|
||||||
|
friendship_in={}
|
||||||
|
dofile("dfusion/friendship/install.lua")
|
||||||
|
dofile("dfusion/friendship/patch.lua")
|
||||||
|
|
||||||
|
function friendship(names)
|
||||||
|
friendship_in.install(names)
|
||||||
|
friendship_in.patch()
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
as -anl --32 -o functions.o functions.asm
|
@ -0,0 +1,23 @@
|
|||||||
|
.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.
@ -0,0 +1,61 @@
|
|||||||
|
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.SetCallback(name,func)
|
||||||
|
if onfunction.names[name]==nil then
|
||||||
|
error("No such function:"..name)
|
||||||
|
else
|
||||||
|
onfunction.functions[onfunction.names[name]]=func
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
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
|
||||||
|
else --linux
|
||||||
|
onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
|
||||||
|
onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"}) -- same
|
||||||
|
end
|
@ -0,0 +1,14 @@
|
|||||||
|
mypos=engine.getmod("functions")
|
||||||
|
function DeathMsg(values)
|
||||||
|
local name
|
||||||
|
name=engine.peek(values[onfunction.hints["Die"].creature],ptt_dfstring)
|
||||||
|
print(name:getval().." 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
|
@ -0,0 +1,114 @@
|
|||||||
|
#include <dfhack/Core.h>
|
||||||
|
#include <dfhack/Console.h>
|
||||||
|
#include <dfhack/PluginManager.h>
|
||||||
|
#include <dfhack/Process.h>
|
||||||
|
#include <dfhack/extra/stopwatch.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
using std::string;
|
||||||
|
using namespace DFHack;
|
||||||
|
|
||||||
|
DFhackCExport command_result memview (Core * c, vector <string> & parameters);
|
||||||
|
|
||||||
|
DFhackCExport const char * plugin_name ( void )
|
||||||
|
{
|
||||||
|
return "memview";
|
||||||
|
}
|
||||||
|
|
||||||
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
||||||
|
{
|
||||||
|
commands.clear();
|
||||||
|
commands.push_back(PluginCommand("memview","Shows memory in real time. Params: adrr length refresh_rate.",memview));
|
||||||
|
return CR_OK;
|
||||||
|
}
|
||||||
|
size_t convert(const std::string& p,bool ishex=false)
|
||||||
|
{
|
||||||
|
size_t ret;
|
||||||
|
std::stringstream conv;
|
||||||
|
if(ishex)
|
||||||
|
conv<<std::hex;
|
||||||
|
conv<<p;
|
||||||
|
conv>>ret;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool isAddr(uint32_t *trg,vector<t_memrange> & ranges)
|
||||||
|
{
|
||||||
|
if(trg[0]%4==0)
|
||||||
|
for(size_t i=0;i<ranges.size();i++)
|
||||||
|
if(ranges[i].isInRange(trg[0]))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,Console &con,vector<t_memrange> & ranges)
|
||||||
|
{
|
||||||
|
|
||||||
|
con.clear();
|
||||||
|
const size_t page_size=16;
|
||||||
|
for(size_t i=0;i<len;i+=page_size)
|
||||||
|
{
|
||||||
|
con.print("%8x ",i+start);
|
||||||
|
for(size_t j=0;(j<page_size) && (i+j<len);j++)
|
||||||
|
{
|
||||||
|
if(j%4==0)
|
||||||
|
{
|
||||||
|
con.reset_color();
|
||||||
|
if(isAddr((uint32_t *)(buf+j+i),ranges))
|
||||||
|
con.color(Console::COLOR_LIGHTRED);
|
||||||
|
}
|
||||||
|
if(lbuf[j+i]!=buf[j+i])
|
||||||
|
con.print("*%2x",buf[j+i]);
|
||||||
|
else
|
||||||
|
con.print(" %2x",buf[j+i]);
|
||||||
|
}
|
||||||
|
con.reset_color();
|
||||||
|
con.print(" | ");
|
||||||
|
for(size_t j=0;(j<page_size) && (i+j<len);j++)
|
||||||
|
if(buf[j+i]>20)
|
||||||
|
con.print("%c",buf[j+i]);
|
||||||
|
else
|
||||||
|
con.print(".");
|
||||||
|
con.print("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DFhackCExport command_result memview (Core * c, vector <string> & parameters)
|
||||||
|
{
|
||||||
|
size_t addr=convert(parameters[0],true);
|
||||||
|
size_t len;
|
||||||
|
if(parameters.size()>1)
|
||||||
|
len=convert(parameters[1]);
|
||||||
|
else
|
||||||
|
len=20*16;
|
||||||
|
size_t refresh;
|
||||||
|
if(parameters.size()>2)
|
||||||
|
refresh=convert(parameters[2]);
|
||||||
|
else
|
||||||
|
refresh=0;
|
||||||
|
Console &con=c->con;
|
||||||
|
uint8_t *buf,*lbuf;
|
||||||
|
buf=new uint8_t[len];
|
||||||
|
lbuf=new uint8_t[len];
|
||||||
|
uint64_t timeLast=0;
|
||||||
|
vector<t_memrange> ranges;
|
||||||
|
c->p->getMemRanges(ranges);
|
||||||
|
while(true)//TODO add some sort of way to exit loop??!!
|
||||||
|
{
|
||||||
|
uint64_t time2 = GetTimeMs64();
|
||||||
|
uint64_t delta = time2-timeLast;
|
||||||
|
if(refresh!=0)
|
||||||
|
if(delta<refresh)
|
||||||
|
continue;
|
||||||
|
timeLast = time2;
|
||||||
|
|
||||||
|
c->p->read(addr,len,buf);
|
||||||
|
outputHex(buf,lbuf,len,addr,con,ranges);
|
||||||
|
if(refresh==0)
|
||||||
|
break;
|
||||||
|
memcpy(lbuf, buf, len);
|
||||||
|
}
|
||||||
|
delete[] buf;
|
||||||
|
delete[] lbuf;
|
||||||
|
}
|
Loading…
Reference in New Issue