1
0
Fork 0

DBG: fixed behavior with function deletion and added functionclear command

This commit is contained in:
mrexodia 2016-03-31 04:28:26 +02:00
parent 9fb0eff70e
commit 74a27e2b5d
12 changed files with 22 additions and 12 deletions

View File

@ -100,10 +100,10 @@ bool FunctionPass::Analyse()
dprintf("%u functions\n", funcs.size());
FunctionClear();
FunctionDelRange(m_VirtualStart, m_VirtualEnd - 1, false);
for(auto & func : funcs)
{
FunctionAdd(func.VirtualStart, func.VirtualEnd, true, func.InstrCount);
FunctionAdd(func.VirtualStart, func.VirtualEnd, false, func.InstrCount);
}
GuiUpdateAllViews();

View File

@ -987,7 +987,7 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
case DBG_DELETE_AUTO_FUNCTION_RANGE:
{
FunctionDelRange((duint)param1, (duint)param2);
FunctionDelRange((duint)param1, (duint)param2, false);
}
break;

View File

@ -48,9 +48,9 @@ SCRIPT_EXPORT bool Script::Function::Delete(duint address)
return FunctionDelete(address);
}
SCRIPT_EXPORT void Script::Function::DeleteRange(duint start, duint end)
SCRIPT_EXPORT void Script::Function::DeleteRange(duint start, duint end, bool deleteManual)
{
FunctionDelRange(start, end);
FunctionDelRange(start, end, deleteManual);
}
SCRIPT_EXPORT void Script::Function::Clear()

View File

@ -22,7 +22,7 @@ namespace Script
SCRIPT_EXPORT bool GetInfo(duint addr, FunctionInfo* info);
SCRIPT_EXPORT bool Overlaps(duint start, duint end);
SCRIPT_EXPORT bool Delete(duint address);
SCRIPT_EXPORT void DeleteRange(duint start, duint end);
SCRIPT_EXPORT void DeleteRange(duint start, duint end, bool deleteManual = false);
SCRIPT_EXPORT void Clear();
SCRIPT_EXPORT bool GetList(ListOf(FunctionInfo) list); //caller has the responsibility to free the list
}; //Function

View File

@ -87,7 +87,7 @@ void ControlFlowAnalysis::Analyse()
void ControlFlowAnalysis::SetMarkers()
{
FunctionDelRange(_base, _base + _size);
FunctionDelRange(_base, _base + _size - 1, false);
auto size = _functionRanges.size();
for(size_t i = size - 1; i != -1; i--)
{

View File

@ -83,7 +83,7 @@ void ExceptionDirectoryAnalysis::Analyse()
void ExceptionDirectoryAnalysis::SetMarkers()
{
FunctionDelRange(_base, _base + _size);
FunctionDelRange(_base, _base + _size - 1, false);
for(const auto & function : _functions)
FunctionAdd(function.first, function.second, false);
}

View File

@ -88,7 +88,7 @@ bool FunctionDelete(duint Address)
return (functions.erase(ModuleRange(ModHashFromAddr(moduleBase), Range(Address - moduleBase, Address - moduleBase))) > 0);
}
void FunctionDelRange(duint Start, duint End)
void FunctionDelRange(duint Start, duint End, bool DeleteManual)
{
ASSERT_DEBUGGING("Export call");
@ -116,7 +116,7 @@ void FunctionDelRange(duint Start, duint End)
const auto & currentFunction = itr->second;
// Ignore manually set entries
if(currentFunction.manual)
if(!DeleteManual && currentFunction.manual)
{
++itr;
continue;

View File

@ -16,7 +16,7 @@ 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 FunctionOverlaps(duint Start, duint End);
bool FunctionDelete(duint Address);
void FunctionDelRange(duint Start, duint End);
void FunctionDelRange(duint Start, duint End, bool DeleteManual = false);
void FunctionCacheSave(JSON Root);
void FunctionCacheLoad(JSON Root);
bool FunctionEnum(FUNCTIONSINFO* List, size_t* Size);

View File

@ -502,6 +502,14 @@ CMDRESULT cbInstrFunctionDel(int argc, char* argv[])
return STATUS_CONTINUE;
}
CMDRESULT cbInstrFunctionClear(int argc, char* argv[])
{
FunctionClear();
GuiUpdateAllViews();
dputs("all functions deleted!");
return STATUS_CONTINUE;
}
CMDRESULT cbInstrCmp(int argc, char* argv[])
{
if(argc < 3)

View File

@ -21,6 +21,7 @@ CMDRESULT cbInstrSavedb(int argc, char* argv[]);
CMDRESULT cbInstrAssemble(int argc, char* argv[]);
CMDRESULT cbInstrFunctionAdd(int argc, char* argv[]);
CMDRESULT cbInstrFunctionDel(int argc, char* argv[]);
CMDRESULT cbInstrFunctionClear(int argc, char* argv[]);
CMDRESULT cbInstrCmp(int argc, char* argv[]);
CMDRESULT cbInstrGpa(int argc, char* argv[]);

View File

@ -21,7 +21,7 @@ void LinearAnalysis::Analyse()
void LinearAnalysis::SetMarkers()
{
FunctionDelRange(_base, _base + _size);
FunctionDelRange(_base, _base + _size - 1, false);
for(auto & function : _functions)
{
if(!function.end)

View File

@ -228,6 +228,7 @@ static void registercommands()
dbgcmdnew("setmaxfindresult\1findsetmaxresult", cbInstrSetMaxFindResult, false); //set the maximum number of occurences found
dbgcmdnew("savedata", cbInstrSavedata, true); //save data to disk
dbgcmdnew("scriptdll\1dllscript", cbScriptDll, false); //execute a script DLL
dbgcmdnew("functionclear", cbInstrFunctionClear, false); //delete all functions
}
static bool cbCommandProvider(char* cmd, int maxlen)