1
0
Fork 0

PROJECT: updated help

BRIDGE: added function DbgFunctionOverlaps and DbgFunctionGet
DBG: added functiondel + function commands
GUI: added setting/deleting functions in the GUI
This commit is contained in:
mr.exodia 2013-12-27 22:27:29 +01:00
parent bdecbc6458
commit 3da353e8c5
21 changed files with 328 additions and 111 deletions

29
help/functionadd_func.htm Normal file
View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>functionadd/func</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html,body {
/* Default Font */
font-family: Courier New;
font-size: 11pt;
}
</style>
</head>
<body>
<P><STRONG>functionadd[,func]<BR></STRONG>Add a function.</P>
<P><U>arguments </U><BR>&nbsp; arg1:&nbsp;Function range start. </P>
<P>&nbsp; arg2: Function range end.</P>
<P>
<U>
result
</U>
<BR>This command does not set any result
variables.
</P></body>
</html>

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>functiondel/funcc</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html,body {
/* Default Font */
font-family: Courier New;
font-size: 11pt;
}
</style>
</head>
<body>
<P><STRONG>functiondel[,funcc]<BR></STRONG>Delete a function.</P>
<P>
<U>
arguments
</U>
<BR>&nbsp; arg1:&nbsp;Address inside the function range&nbsp;to
delete.</P>
<P >
<U >
result</U>
<BR>
This command does not set any result variables.</P>
<P>&nbsp;</P></body>
</html>

View File

@ -96,7 +96,7 @@ Font=
DefaultTopic=Introduction.htm
[TOPICS]
TitleList=63
TitleList=65
TitleList.Title.0=Introduction
TitleList.Level.0=0
TitleList.Url.0=Introduction.htm
@ -105,7 +105,7 @@ TitleList.Status.0=0
TitleList.Keywords.0=
TitleList.ContextNumber.0=1000
TitleList.ApplyTemp.0=0
TitleList.Expanded.0=1
TitleList.Expanded.0=0
TitleList.Kind.0=0
TitleList.Title.1=Input
TitleList.Level.1=1
@ -145,7 +145,7 @@ TitleList.Status.4=0
TitleList.Keywords.4=
TitleList.ContextNumber.4=1003
TitleList.ApplyTemp.4=0
TitleList.Expanded.4=0
TitleList.Expanded.4=1
TitleList.Kind.4=0
TitleList.Title.5=Debug Control
TitleList.Level.5=1
@ -465,7 +465,7 @@ TitleList.Status.36=0
TitleList.Keywords.36=
TitleList.ContextNumber.36=1042
TitleList.ApplyTemp.36=0
TitleList.Expanded.36=0
TitleList.Expanded.36=1
TitleList.Kind.36=0
TitleList.Title.37=cmt/cmtset/commentset
TitleList.Level.37=2
@ -527,204 +527,224 @@ TitleList.ContextNumber.42=1039
TitleList.ApplyTemp.42=0
TitleList.Expanded.42=0
TitleList.Kind.42=0
TitleList.Title.43=Memory Operations
TitleList.Level.43=1
TitleList.Url.43=Memory_Operations.htm
TitleList.Title.43=functionadd/func
TitleList.Level.43=2
TitleList.Url.43=functionadd_func.htm
TitleList.Icon.43=0
TitleList.Status.43=0
TitleList.Keywords.43=
TitleList.ContextNumber.43=1043
TitleList.ContextNumber.43=1062
TitleList.ApplyTemp.43=0
TitleList.Expanded.43=0
TitleList.Kind.43=0
TitleList.Title.44=alloc
TitleList.Title.44=functiondel/funcc
TitleList.Level.44=2
TitleList.Url.44=alloc.htm
TitleList.Url.44=functiondel_funcc.htm
TitleList.Icon.44=0
TitleList.Status.44=0
TitleList.Keywords.44=
TitleList.ContextNumber.44=1032
TitleList.ContextNumber.44=1063
TitleList.ApplyTemp.44=0
TitleList.Expanded.44=0
TitleList.Kind.44=0
TitleList.Title.45=free
TitleList.Level.45=2
TitleList.Url.45=free.htm
TitleList.Title.45=Memory Operations
TitleList.Level.45=1
TitleList.Url.45=Memory_Operations.htm
TitleList.Icon.45=0
TitleList.Status.45=0
TitleList.Keywords.45=
TitleList.ContextNumber.45=1031
TitleList.ContextNumber.45=1043
TitleList.ApplyTemp.45=0
TitleList.Expanded.45=0
TitleList.Kind.45=0
TitleList.Title.46=Fill/memset
TitleList.Title.46=alloc
TitleList.Level.46=2
TitleList.Url.46=Fill_memset.htm
TitleList.Url.46=alloc.htm
TitleList.Icon.46=0
TitleList.Status.46=0
TitleList.Keywords.46=
TitleList.ContextNumber.46=1033
TitleList.ContextNumber.46=1032
TitleList.ApplyTemp.46=0
TitleList.Expanded.46=0
TitleList.Kind.46=0
TitleList.Title.47=Plugins
TitleList.Level.47=1
TitleList.Url.47=Plugins_section.htm
TitleList.Title.47=free
TitleList.Level.47=2
TitleList.Url.47=free.htm
TitleList.Icon.47=0
TitleList.Status.47=0
TitleList.Keywords.47=
TitleList.ContextNumber.47=1046
TitleList.ContextNumber.47=1031
TitleList.ApplyTemp.47=0
TitleList.Expanded.47=0
TitleList.Kind.47=0
TitleList.Title.48=StartScylla/scylla/imprec
TitleList.Title.48=Fill/memset
TitleList.Level.48=2
TitleList.Url.48=StartScylla_scylla_imprec.htm
TitleList.Url.48=Fill_memset.htm
TitleList.Icon.48=0
TitleList.Status.48=0
TitleList.Keywords.48=
TitleList.ContextNumber.48=1047
TitleList.ContextNumber.48=1033
TitleList.ApplyTemp.48=0
TitleList.Expanded.48=0
TitleList.Kind.48=0
TitleList.Title.49=Plugins
TitleList.Level.49=0
TitleList.Url.49=Plugins.htm
TitleList.Level.49=1
TitleList.Url.49=Plugins_section.htm
TitleList.Icon.49=0
TitleList.Status.49=0
TitleList.Keywords.49=
TitleList.ContextNumber.49=1050
TitleList.ContextNumber.49=1046
TitleList.ApplyTemp.49=0
TitleList.Expanded.49=0
TitleList.Kind.49=0
TitleList.Title.50=Exports
TitleList.Level.50=1
TitleList.Url.50=Exports.htm
TitleList.Title.50=StartScylla/scylla/imprec
TitleList.Level.50=2
TitleList.Url.50=StartScylla_scylla_imprec.htm
TitleList.Icon.50=0
TitleList.Status.50=0
TitleList.Keywords.50=
TitleList.ContextNumber.50=1051
TitleList.ContextNumber.50=1047
TitleList.ApplyTemp.50=0
TitleList.Expanded.50=0
TitleList.Kind.50=0
TitleList.Title.51=_plugin_registercallback
TitleList.Level.51=2
TitleList.Url.51=_plugin_registercallback.htm
TitleList.Title.51=Plugins
TitleList.Level.51=0
TitleList.Url.51=Plugins.htm
TitleList.Icon.51=0
TitleList.Status.51=0
TitleList.Keywords.51=
TitleList.ContextNumber.51=1052
TitleList.ContextNumber.51=1050
TitleList.ApplyTemp.51=0
TitleList.Expanded.51=0
TitleList.Kind.51=0
TitleList.Title.52=_plugin_unregistercallback
TitleList.Level.52=2
TitleList.Url.52=_plugin_unregistercallback.htm
TitleList.Title.52=Exports
TitleList.Level.52=1
TitleList.Url.52=Exports.htm
TitleList.Icon.52=0
TitleList.Status.52=0
TitleList.Keywords.52=
TitleList.ContextNumber.52=1053
TitleList.ContextNumber.52=1051
TitleList.ApplyTemp.52=0
TitleList.Expanded.52=0
TitleList.Kind.52=0
TitleList.Title.53=_plugin_registercommand
TitleList.Title.53=_plugin_registercallback
TitleList.Level.53=2
TitleList.Url.53=_plugin_registercommand.htm
TitleList.Url.53=_plugin_registercallback.htm
TitleList.Icon.53=0
TitleList.Status.53=0
TitleList.Keywords.53=
TitleList.ContextNumber.53=1054
TitleList.ContextNumber.53=1052
TitleList.ApplyTemp.53=0
TitleList.Expanded.53=0
TitleList.Kind.53=0
TitleList.Title.54=_plugin_unregistercommand
TitleList.Title.54=_plugin_unregistercallback
TitleList.Level.54=2
TitleList.Url.54=_plugin_unregistercommand.htm
TitleList.Url.54=_plugin_unregistercallback.htm
TitleList.Icon.54=0
TitleList.Status.54=0
TitleList.Keywords.54=
TitleList.ContextNumber.54=1055
TitleList.ContextNumber.54=1053
TitleList.ApplyTemp.54=0
TitleList.Expanded.54=0
TitleList.Kind.54=0
TitleList.Title.55=_plugin_logprintf
TitleList.Title.55=_plugin_registercommand
TitleList.Level.55=2
TitleList.Url.55=
TitleList.Url.55=_plugin_registercommand.htm
TitleList.Icon.55=0
TitleList.Status.55=1
TitleList.Status.55=0
TitleList.Keywords.55=
TitleList.ContextNumber.55=1056
TitleList.ContextNumber.55=1054
TitleList.ApplyTemp.55=0
TitleList.Expanded.55=0
TitleList.Kind.55=0
TitleList.Title.56=_plugin_logputs
TitleList.Title.56=_plugin_unregistercommand
TitleList.Level.56=2
TitleList.Url.56=
TitleList.Url.56=_plugin_unregistercommand.htm
TitleList.Icon.56=0
TitleList.Status.56=1
TitleList.Status.56=0
TitleList.Keywords.56=
TitleList.ContextNumber.56=1057
TitleList.ContextNumber.56=1055
TitleList.ApplyTemp.56=0
TitleList.Expanded.56=0
TitleList.Kind.56=0
TitleList.Title.57=_plugin_debugpause
TitleList.Title.57=_plugin_logprintf
TitleList.Level.57=2
TitleList.Url.57=
TitleList.Icon.57=0
TitleList.Status.57=1
TitleList.Keywords.57=
TitleList.ContextNumber.57=1058
TitleList.ContextNumber.57=1056
TitleList.ApplyTemp.57=0
TitleList.Expanded.57=0
TitleList.Kind.57=0
TitleList.Title.58=Structures
TitleList.Level.58=1
TitleList.Url.58=Structures.htm
TitleList.Title.58=_plugin_logputs
TitleList.Level.58=2
TitleList.Url.58=
TitleList.Icon.58=0
TitleList.Status.58=0
TitleList.Status.58=1
TitleList.Keywords.58=
TitleList.ContextNumber.58=1059
TitleList.ContextNumber.58=1057
TitleList.ApplyTemp.58=0
TitleList.Expanded.58=0
TitleList.Kind.58=0
TitleList.Title.59=Callbacks
TitleList.Title.59=_plugin_debugpause
TitleList.Level.59=2
TitleList.Url.59=Callbacks.htm
TitleList.Url.59=
TitleList.Icon.59=0
TitleList.Status.59=0
TitleList.Status.59=1
TitleList.Keywords.59=
TitleList.ContextNumber.59=1060
TitleList.ContextNumber.59=1058
TitleList.ApplyTemp.59=0
TitleList.Expanded.59=0
TitleList.Kind.59=0
TitleList.Title.60=PLUG_INITSTRUCT
TitleList.Level.60=2
TitleList.Url.60=PLUGINIT_STRUCT.htm
TitleList.Title.60=Structures
TitleList.Level.60=1
TitleList.Url.60=Structures.htm
TitleList.Icon.60=0
TitleList.Status.60=0
TitleList.Keywords.60=
TitleList.ContextNumber.60=1061
TitleList.ContextNumber.60=1059
TitleList.ApplyTemp.60=0
TitleList.Expanded.60=0
TitleList.Kind.60=0
TitleList.Title.61=Special Thanks
TitleList.Level.61=0
TitleList.Url.61=Special_Thanks.htm
TitleList.Title.61=Callbacks
TitleList.Level.61=2
TitleList.Url.61=Callbacks.htm
TitleList.Icon.61=0
TitleList.Status.61=0
TitleList.Keywords.61=
TitleList.ContextNumber.61=1024
TitleList.ContextNumber.61=1060
TitleList.ApplyTemp.61=0
TitleList.Expanded.61=0
TitleList.Kind.61=0
TitleList.Title.62=Fixed Top Style
TitleList.Level.62=0
TitleList.Url.62=template\fixedtop.htm
TitleList.Title.62=PLUG_INITSTRUCT
TitleList.Level.62=2
TitleList.Url.62=PLUGINIT_STRUCT.htm
TitleList.Icon.62=0
TitleList.Status.62=0
TitleList.Keywords.62=
TitleList.ContextNumber.62=
TitleList.ContextNumber.62=1061
TitleList.ApplyTemp.62=0
TitleList.Expanded.62=0
TitleList.Kind.62=2
TitleList.Kind.62=0
TitleList.Title.63=Special Thanks
TitleList.Level.63=0
TitleList.Url.63=Special_Thanks.htm
TitleList.Icon.63=0
TitleList.Status.63=0
TitleList.Keywords.63=
TitleList.ContextNumber.63=1024
TitleList.ApplyTemp.63=0
TitleList.Expanded.63=0
TitleList.Kind.63=0
TitleList.Title.64=Fixed Top Style
TitleList.Level.64=0
TitleList.Url.64=template\fixedtop.htm
TitleList.Icon.64=0
TitleList.Status.64=0
TitleList.Keywords.64=
TitleList.ContextNumber.64=
TitleList.ApplyTemp.64=0
TitleList.Expanded.64=0
TitleList.Kind.64=2

View File

@ -27,3 +27,4 @@ DBGMEMISVALIDREADPTR _dbg_memisvalidreadptr;
DBGGETBPLIST _dbg_getbplist;
DBGDBGCMDEXECDIRECT _dbg_dbgcmddirectexec;
DBGGETBRANCHDESTINATION _dbg_getbranchdestination;
DBGFUNCTIONOVERLAPS _dbg_functionoverlaps;

View File

@ -4,25 +4,6 @@
#include <windows.h>
#include "bridgemain.h"
#ifndef DLL_EXPORT
#define DLL_EXPORT __declspec(dllexport)
#endif //DLL_IMPORT
#ifndef DLL_EXPORT
#define DLL_IMPORT __declspec(dllimport)
#endif //DLL_IMPORT
#ifdef _WIN64 //defined by default
#define fhex "%.16llX"
#define fext "ll"
#define uint unsigned long long
#define sint long long
#else
#define fhex "%.8X"
#define fext ""
#define uint unsigned long
#define sint long
#endif // _WIN64
//hInst GUI/DBG
extern HINSTANCE hInstGui;
extern HINSTANCE hInstDbg;
@ -53,7 +34,8 @@ typedef bool (*DBGVALTOSTRING)(const char* string, duint* value);
typedef bool (*DBGMEMISVALIDREADPTR)(duint addr);
typedef int (*DBGGETBPLIST)(BPXTYPE type, BPMAP* bplist);
typedef bool (*DBGDBGCMDEXECDIRECT)(const char* cmd);
typedef uint (*DBGGETBRANCHDESTINATION)(uint addr);
typedef duint (*DBGGETBRANCHDESTINATION)(duint addr);
typedef bool (*DBGFUNCTIONOVERLAPS)(duint start, duint end);
//DBG functions
extern DBGDBGINIT _dbg_dbginit;
@ -74,5 +56,6 @@ extern DBGMEMISVALIDREADPTR _dbg_memisvalidreadptr;
extern DBGGETBPLIST _dbg_getbplist;
extern DBGDBGCMDEXECDIRECT _dbg_dbgcmddirectexec;
extern DBGGETBRANCHDESTINATION _dbg_getbranchdestination;
extern DBGFUNCTIONOVERLAPS _dbg_functionoverlaps;
#endif // _GLOBAL_H

View File

@ -116,6 +116,10 @@ BRIDGE_IMPEXP const char* BridgeInit()
_dbg_getbranchdestination=(DBGGETBRANCHDESTINATION)GetProcAddress(hInstDbg, "_dbg_getbranchdestination");
if(!_dbg_getbranchdestination)
return "Export \"_dbg_getbranchdestination\" could not be found!";
//_dbg_functionoverlaps
_dbg_functionoverlaps=(DBGFUNCTIONOVERLAPS)GetProcAddress(hInstDbg, "_dbg_functionoverlaps");
if(!_dbg_functionoverlaps)
return "Export \"_dbg_functionoverlaps\" could not be found!";
return 0;
}
@ -438,6 +442,25 @@ BRIDGE_IMPEXP duint DbgGetBranchDestination(duint addr)
return _dbg_getbranchdestination(addr);
}
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end)
{
return _dbg_functionoverlaps(start, end);
}
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end)
{
ADDRINFO info;
memset(&info, 0, sizeof(info));
info.flags=flagfunction;
if(!_dbg_addrinfoget(addr, SEG_DEFAULT, &info))
return false;
if(start)
*start=info.function.start;
if(end)
*end=info.function.end;
return true;
}
//GUI
BRIDGE_IMPEXP void GuiDisasmAt(duint addr, duint cip)
{

View File

@ -238,6 +238,8 @@ BRIDGE_IMPEXP int DbgGetBpList(BPXTYPE type, BPMAP* list);
BRIDGE_IMPEXP FUNCTYPE DbgGetFunctionTypeAt(duint addr);
BRIDGE_IMPEXP LOOPTYPE DbgGetLoopTypeAt(duint addr, int depth);
BRIDGE_IMPEXP duint DbgGetBranchDestination(duint addr);
BRIDGE_IMPEXP bool DbgFunctionOverlaps(duint start, duint end);
BRIDGE_IMPEXP bool DbgFunctionGet(duint addr, duint* start, duint* end);
//GUI functions
BRIDGE_IMPEXP void GuiDisasmAt(duint addr, duint cip);

View File

@ -215,7 +215,7 @@ extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDR
}
if(addrinfo->flags&flagfunction)
{
if(functionfromaddr(addr, &addrinfo->function.start, &addrinfo->function.end))
if(functionget(addr, &addrinfo->function.start, &addrinfo->function.end))
retval=true;
}
return retval;
@ -473,3 +473,8 @@ extern "C" DLL_EXPORT uint _dbg_getbranchdestination(uint addr)
else
return instr.arg[0].value;
}
extern "C" DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end)
{
return functionoverlaps(start, end);
}

View File

@ -22,6 +22,7 @@ DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump);
DLL_EXPORT bool _dbg_valtostring(const char* string, duint* value);
DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bplist);
DLL_EXPORT uint _dbg_getbranchdestination(uint addr);
DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end);
#ifdef __cplusplus
}

View File

@ -528,8 +528,8 @@ bool symfromname(const char* name, uint* addr)
return true;
}
///function functions :D
bool functionfromaddr(duint addr, duint* start, duint* end)
///function database
bool functionget(duint addr, duint* start, duint* end)
{
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
return false;
@ -544,8 +544,6 @@ bool functionfromaddr(duint addr, duint* start, duint* end)
uint rva=addr-modbase;
sprintf(sql, "SELECT start,end FROM functions WHERE mod='%s' AND start<=%"fext"d AND end>=%"fext"d", modname, rva, rva);
}
if(addr==0x7758100F)
puts(sql);
sqlite3_stmt* stmt;
if(sqlite3_prepare_v2(userdb, sql, -1, &stmt, 0)!=SQLITE_OK)
{
@ -619,3 +617,26 @@ bool functionadd(uint start, uint end, bool manual)
dbsave();
return true;
}
bool functiondel(uint addr)
{
if(!IsFileBeingDebugged() or !functionget(addr, 0, 0))
return false;
char modname[MAX_MODULE_SIZE]="";
char sql[deflen]="";
if(!modnamefromaddr(addr, modname, true))
sprintf(sql, "DELETE FROM functions WHERE mod IS NULL AND start<=%"fext"d AND end>=%"fext"d", addr, addr);
else
{
uint rva=addr-modbasefromaddr(addr);
sprintf(sql, "DELETE FROM functions WHERE mod='%s' AND start<=%"fext"d AND end>=%"fext"d", modname, rva, rva);
}
if(!sqlexec(userdb, sql))
{
dprintf("SQL Error: %s\nSQL Query: %s\n", sqllasterror(), sql);
return false;
}
GuiUpdateAllViews();
dbsave();
return true;
}

View File

@ -40,8 +40,9 @@ bool bookmarkset(uint addr);
bool bookmarkget(uint addr);
bool bookmarkdel(uint addr);
bool symfromname(const char* name, uint* addr);
bool functionfromaddr(duint addr, duint* start, duint* end);
bool functionget(duint addr, duint* start, duint* end);
bool functionoverlaps(uint start, uint end);
bool functionadd(uint start, uint end, bool manual);
bool functiondel(uint addr);
#endif // _ADDRINFO_H

View File

@ -418,7 +418,7 @@ CMDRESULT cbAssemble(int argc, char* argv[])
return STATUS_CONTINUE;
}
CMDRESULT cbFunction(int argc, char* argv[])
CMDRESULT cbFunctionAdd(int argc, char* argv[])
{
if(argc<3)
{
@ -429,9 +429,30 @@ CMDRESULT cbFunction(int argc, char* argv[])
uint end=0;
if(!valfromstring(argv[1], &start, 0, 0, false, 0) or !valfromstring(argv[2], &end, 0, 0, false, 0))
return STATUS_ERROR;
if(functionadd(start, end, true))
dputs("function added!");
else
dputs("function NOT added...");
if(!functionadd(start, end, true))
{
dputs("failed to add function");
return STATUS_ERROR;
}
dputs("function added!");
return STATUS_CONTINUE;
}
CMDRESULT cbFunctionDel(int argc, char* argv[])
{
if(argc<2)
{
dputs("not enough arguments!");
return STATUS_ERROR;
}
uint addr=0;
if(!valfromstring(argv[1], &addr, 0, 0, false, 0))
return STATUS_ERROR;
if(!functiondel(addr))
{
dputs("failed to delete function");
return STATUS_ERROR;
}
dputs("function deleted!");
return STATUS_CONTINUE;
}

View File

@ -20,6 +20,7 @@ CMDRESULT cbInstrBookmarkDel(int argc, char* argv[]);
CMDRESULT cbLoaddb(int argc, char* argv[]);
CMDRESULT cbSavedb(int argc, char* argv[]);
CMDRESULT cbAssemble(int argc, char* argv[]);
CMDRESULT cbFunction(int argc, char* argv[]);
CMDRESULT cbFunctionAdd(int argc, char* argv[]);
CMDRESULT cbFunctionDel(int argc, char* argv[]);
#endif // _INSTRUCTIONS_H

View File

@ -80,7 +80,8 @@ static void registercommands()
cmdnew(cmd, "asm", cbAssemble, true); //assemble instruction
cmdnew(cmd, "AttachDebugger\1attach", cbDebugAttach, false); //attach
//cmdnew(cmd, "DetachDebugger\1detach", cbDebugDetach, true); //detach
cmdnew(cmd, "functionadd\1function\1func", cbFunction, true); //function
cmdnew(cmd, "functionadd\1func", cbFunctionAdd, true); //function
cmdnew(cmd, "functiondel\1funcc", cbFunctionDel, true); //function
}
static bool cbCommandProvider(char* cmd, int maxlen)

View File

@ -898,6 +898,14 @@ int_t Disassembly::getInitialSelection()
return mSelection.firstSelectedIndex;
}
int_t Disassembly::getSelectionRange()
{
int delta = mSelection.toIndex - mSelection.fromIndex;
if(delta < 0)
delta *= -1;
return delta;
}
void Disassembly::selectNext()
{

View File

@ -60,6 +60,7 @@ public:
void expandSelectionUpTo(int_t to);
void setSingleSelection(int_t index);
int_t getInitialSelection();
int_t getSelectionRange();
void selectNext();
void selectPrevious();
bool isSelected(int_t base, int_t offset);

View File

@ -67,6 +67,19 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
wMenu->addAction(mSetComment);
wMenu->addAction(mSetBookmark);
uint_t selection_start = rvaToVa(getInitialSelection());
uint_t selection_end = selection_start + getSelectionRange();
if(!DbgFunctionOverlaps(selection_start, selection_end))
{
mToggleFunction->setText("Add function");
wMenu->addAction(mToggleFunction);
}
else if(DbgGetFunctionTypeAt(selection_start) != FUNC_NONE)
{
mToggleFunction->setText("Delete function");
wMenu->addAction(mToggleFunction);
}
// BP Menu
mBPMenu->clear();
@ -164,6 +177,14 @@ void CPUDisassembly::setupRightClickContextMenu()
this->addAction(mSetBookmark);
connect(mSetBookmark, SIGNAL(triggered()), this, SLOT(setBookmark()));
// Functions
mToggleFunction = new QAction("Function", this);
mToggleFunction->setShortcutContext(Qt::WidgetShortcut);
mToggleFunction->setShortcut(QKeySequence("shift+f"));
this->addAction(mToggleFunction);
connect(mToggleFunction, SIGNAL(triggered()), this, SLOT(toggleFunction()));
//---------------------- Go to -----------------------------------
// Menu
mGotoMenu = new QMenu("Go to", this);
@ -383,3 +404,45 @@ void CPUDisassembly::setBookmark()
msg.exec();
}
}
void CPUDisassembly::toggleFunction()
{
uint_t start = rvaToVa(getInitialSelection());
uint_t range = getSelectionRange();
uint_t end = start + range;
uint_t function_start=0;
uint_t function_end=0;
if(!DbgFunctionOverlaps(start, end))
{
QString start_text=QString("%1").arg(start, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString end_text=QString("%1").arg(end, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char labeltext[MAX_LABEL_SIZE]="";
QString label_text="";
if(DbgGetLabelAt(start, SEG_DEFAULT, labeltext))
label_text = " (" + QString(labeltext) + ")";
QMessageBox msg(QMessageBox::Question, "Do you want to add the function?", start_text + "-" + end_text + label_text, QMessageBox::Yes|QMessageBox::No);
msg.setWindowIcon(QIcon(":/icons/images/compile.png"));
if(msg.exec() != QMessageBox::Yes)
return;
QString cmd = "functionadd " + start_text + "," + end_text;
DbgCmdExec(cmd.toUtf8().constData());
}
else if(DbgFunctionGet(start, &function_start, &function_end))
{
QString start_text=QString("%1").arg(function_start, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
QString end_text=QString("%1").arg(function_end, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
char labeltext[MAX_LABEL_SIZE]="";
QString label_text="";
if(DbgGetLabelAt(function_start, SEG_DEFAULT, labeltext))
label_text = " (" + QString(labeltext) + ")";
QMessageBox msg(QMessageBox::Warning, "You are deleting the function:", start_text + "-" + end_text + label_text, QMessageBox::Ok|QMessageBox::Cancel);
msg.setDefaultButton(QMessageBox::Cancel);
msg.setWindowIcon(QIcon(":/icons/images/compile-warning.png"));
if(msg.exec() != QMessageBox::Ok)
return;
QString cmd = "functiondel " + start_text;
DbgCmdExec(cmd.toUtf8().constData());
}
}

View File

@ -37,6 +37,7 @@ public slots:
void setLabel();
void setComment();
void setBookmark();
void toggleFunction();
private:
void CopyToClipboard(const char* text);
@ -57,6 +58,7 @@ private:
QAction* mSetComment;
QAction* mSetLabel;
QAction* mSetBookmark;
QAction* mToggleFunction;
QAction* msetHwBPOnSlot0Action;
QAction* msetHwBPOnSlot1Action;
QAction* msetHwBPOnSlot2Action;

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

View File

@ -19,5 +19,7 @@
<file>images/scylla.png</file>
<file>images/compile-error.png</file>
<file>images/alphabet/B.png</file>
<file>images/compile-warning.png</file>
<file>images/compile.png</file>
</qresource>
</RCC>