1
0
Fork 0

DBG: add parent in function API to support function chunks

This commit is contained in:
Duncan Ogilvie 2020-06-04 17:09:09 +02:00
parent bb49270921
commit 5ab09dae92
2 changed files with 13 additions and 4 deletions

View File

@ -12,6 +12,7 @@ struct FunctionSerializer : JSONWrapper<FUNCTIONSINFO>
setHex("end", value.end);
setHex("icount", value.instructioncount);
setBool("manual", value.manual);
setHex("parent", value.parent);
return true;
}
@ -24,6 +25,8 @@ struct FunctionSerializer : JSONWrapper<FUNCTIONSINFO>
if(!getString("module", mod))
return false;
value.modhash = ModHashFromName(mod.c_str());
value.parent = 0;
getHex("parent", value.parent);
return getHex("start", value.start) &&
getHex("end", value.end) &&
getHex("icount", value.instructioncount) &&
@ -38,6 +41,7 @@ struct Functions : SerializableModuleRangeMap<LockFunctions, FUNCTIONSINFO, Func
auto base = ModBaseFromName(value.mod().c_str());
value.start += base;
value.end += base;
value.parent += base;
}
protected:
@ -54,7 +58,7 @@ protected:
static Functions functions;
bool FunctionAdd(duint Start, duint End, bool Manual, duint InstructionCount)
bool FunctionAdd(duint Start, duint End, bool Manual, duint InstructionCount, duint Parent)
{
// Make sure memory is readable
if(!MemIsValidReadPtr(Start))
@ -76,11 +80,13 @@ bool FunctionAdd(duint Start, duint End, bool Manual, duint InstructionCount)
function.end = End - moduleBase;
function.manual = Manual;
function.instructioncount = InstructionCount;
function.parent = Parent ? Parent : Start;
function.parent -= moduleBase;
return functions.Add(function);
}
bool FunctionGet(duint Address, duint* Start, duint* End, duint* InstrCount)
bool FunctionGet(duint Address, duint* Start, duint* End, duint* InstrCount, duint* Parent)
{
FUNCTIONSINFO function;
if(!functions.Get(Functions::VaKey(Address, Address), function))
@ -92,6 +98,8 @@ bool FunctionGet(duint Address, duint* Start, duint* End, duint* InstrCount)
*End = function.end;
if(InstrCount)
*InstrCount = function.instructioncount;
if(Parent)
*Parent = function.parent;
return true;
}

View File

@ -10,6 +10,7 @@ struct FUNCTIONSINFO
duint end;
bool manual;
duint instructioncount;
duint parent;
std::string mod() const
{
@ -17,8 +18,8 @@ struct FUNCTIONSINFO
}
};
bool FunctionAdd(duint Start, duint End, bool Manual, duint InstructionCount = 0);
bool FunctionGet(duint Address, duint* Start = nullptr, duint* End = nullptr, duint* InstrCount = nullptr);
bool FunctionAdd(duint Start, duint End, bool Manual, duint InstructionCount = 0, duint Parent = 0);
bool FunctionGet(duint Address, duint* Start = nullptr, duint* End = nullptr, duint* InstrCount = nullptr, duint* Parent = nullptr);
bool FunctionOverlaps(duint Start, duint End);
bool FunctionDelete(duint Address);
void FunctionDelRange(duint Start, duint End, bool DeleteManual = false);