more functions&commands to enable/disable log,add favourite tools and fold disassembly for plugins&scripts. (#895)
This commit is contained in:
parent
6e61cf5452
commit
97e99ce7f7
|
@ -1452,6 +1452,36 @@ BRIDGE_IMPEXP void GuiUpdateGraphView()
|
|||
_gui_sendmessage(GUI_UPDATE_GRAPH_VIEW, nullptr, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiDisableLog()
|
||||
{
|
||||
_gui_sendmessage(GUI_SET_LOG_ENABLED, (void*)0, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiEnableLog()
|
||||
{
|
||||
_gui_sendmessage(GUI_SET_LOG_ENABLED, (void*)1, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiAddFavouriteTool(const char* name, const char* description)
|
||||
{
|
||||
_gui_sendmessage(GUI_ADD_FAVOURITE_TOOL, (void*)name, (void*)description);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiAddFavouriteCommand(const char* name, const char* shortcut)
|
||||
{
|
||||
_gui_sendmessage(GUI_ADD_FAVOURITE_COMMAND, (void*)name, (void*)shortcut);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiSetFavouriteToolShortcut(const char* name, const char* shortcut)
|
||||
{
|
||||
_gui_sendmessage(GUI_SET_FAVOURITE_TOOL_SHORTCUT, (void*)name, (void*)shortcut);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiFoldDisassembly(duint startAddress, duint length)
|
||||
{
|
||||
_gui_sendmessage(GUI_FOLD_DISASSEMBLY, (void*)startAddress, (void*)length);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
hInst = hinstDLL;
|
||||
|
|
|
@ -954,7 +954,12 @@ typedef enum
|
|||
GUI_UPDATE_WATCH_VIEW, // param1=unused, param2=unused
|
||||
GUI_LOAD_GRAPH, // param1=BridgeCFGraphList* param2=unused
|
||||
GUI_GRAPH_AT, // param1=duint addr param2=unused
|
||||
GUI_UPDATE_GRAPH_VIEW // param1=unused, param2=unused
|
||||
GUI_UPDATE_GRAPH_VIEW, // param1=unused, param2=unused
|
||||
GUI_SET_LOG_ENABLED, // param1=bool isEnabled param2=unused
|
||||
GUI_ADD_FAVOURITE_TOOL, // param1=const char* name param2=const char* description
|
||||
GUI_ADD_FAVOURITE_COMMAND, // param1=const char* command param2=const char* shortcut
|
||||
GUI_SET_FAVOURITE_TOOL_SHORTCUT,// param1=const char* name param2=const char* shortcut
|
||||
GUI_FOLD_DISASSEMBLY // param1=duint startAddress param2=duint length
|
||||
} GUIMSG;
|
||||
|
||||
//GUI Typedefs
|
||||
|
@ -1078,6 +1083,12 @@ BRIDGE_IMPEXP void GuiUpdateDisable();
|
|||
BRIDGE_IMPEXP void GuiLoadGraph(BridgeCFGraphList* graph, duint addr);
|
||||
BRIDGE_IMPEXP bool GuiGraphAt(duint addr);
|
||||
BRIDGE_IMPEXP void GuiUpdateGraphView();
|
||||
BRIDGE_IMPEXP void GuiDisableLog();
|
||||
BRIDGE_IMPEXP void GuiEnableLog();
|
||||
BRIDGE_IMPEXP void GuiAddFavouriteTool(const char* name, const char* description);
|
||||
BRIDGE_IMPEXP void GuiAddFavouriteCommand(const char* name, const char* shortcut);
|
||||
BRIDGE_IMPEXP void GuiSetFavouriteToolShortcut(const char* name, const char* shortcut);
|
||||
BRIDGE_IMPEXP void GuiFoldDisassembly(duint startAddress, duint length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -2855,3 +2855,83 @@ CMDRESULT cbInstrGraph(int argc, char* argv[])
|
|||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrDisableLog(int argc, char* argv[])
|
||||
{
|
||||
GuiDisableLog();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
CMDRESULT cbInstrEnableLog(int argc, char* argv[])
|
||||
{
|
||||
GuiEnableLog();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
CMDRESULT cbInstrAddFavTool(int argc, char* argv[])
|
||||
{
|
||||
// filename, description
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("Not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
else if(argc == 2)
|
||||
GuiAddFavouriteTool(argv[1], nullptr);
|
||||
else
|
||||
GuiAddFavouriteTool(argv[1], argv[2]);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrAddFavCmd(int argc, char* argv[])
|
||||
{
|
||||
// command, shortcut
|
||||
if(argc < 2)
|
||||
{
|
||||
dputs("Not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
else if(argc == 2)
|
||||
GuiAddFavouriteCommand(argv[1], nullptr);
|
||||
else
|
||||
GuiAddFavouriteCommand(argv[1], argv[2]);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrSetFavToolShortcut(int argc, char* argv[])
|
||||
{
|
||||
// filename, shortcut
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("Not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiSetFavouriteToolShortcut(argv[1], argv[2]);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrFoldDisassembly(int argc, char* argv[])
|
||||
{
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("Not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
duint start, length;
|
||||
if(!valfromstring(argv[1], &start))
|
||||
{
|
||||
dprintf("Invalid argument 1 : %s\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(!valfromstring(argv[2], &length))
|
||||
{
|
||||
dprintf("Invalid argument 2 : %s\n", argv[2]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
GuiFoldDisassembly(start, length);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
}
|
|
@ -102,5 +102,11 @@ CMDRESULT cbInstrExhandlers(int argc, char* argv[]);
|
|||
CMDRESULT cbInstrInstrUndo(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrExinfo(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrGraph(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrDisableLog(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrEnableLog(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrAddFavTool(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrAddFavCmd(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrSetFavToolShortcut(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrFoldDisassembly(int argc, char* argv[]);
|
||||
|
||||
#endif // _INSTRUCTION_H
|
||||
|
|
|
@ -113,6 +113,8 @@ void pluginload(const char* pluginDir)
|
|||
pluginregistercallback(curPluginHandle, CB_MENUENTRY, cbPlugin);
|
||||
pluginregistercallback(curPluginHandle, CB_WINEVENT, cbPlugin);
|
||||
pluginregistercallback(curPluginHandle, CB_WINEVENTGLOBAL, cbPlugin);
|
||||
pluginregistercallback(curPluginHandle, CB_LOADDB, cbPlugin);
|
||||
pluginregistercallback(curPluginHandle, CB_SAVEDB, cbPlugin);
|
||||
}
|
||||
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBINITDEBUG");
|
||||
if(cbPlugin)
|
||||
|
@ -177,6 +179,12 @@ void pluginload(const char* pluginDir)
|
|||
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBWINEVENTGLOBAL");
|
||||
if(cbPlugin)
|
||||
pluginregistercallback(curPluginHandle, CB_WINEVENTGLOBAL, cbPlugin);
|
||||
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBLOADDB");
|
||||
if(cbPlugin)
|
||||
pluginregistercallback(curPluginHandle, CB_LOADDB, cbPlugin);
|
||||
cbPlugin = (CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSAVEDB");
|
||||
if(cbPlugin)
|
||||
pluginregistercallback(curPluginHandle, CB_SAVEDB, cbPlugin);
|
||||
|
||||
//init plugin
|
||||
if(!pluginData.pluginit(&pluginData.initStruct))
|
||||
|
@ -719,7 +727,7 @@ bool pluginexprfuncunregister(int pluginHandle, const char* name)
|
|||
EXCLUSIVE_RELEASE();
|
||||
if(!ExpressionFunctions::Unregister(name))
|
||||
return false;
|
||||
dprintf("[PLUGIN] command \"%s\" unregistered!\n", name);
|
||||
dprintf("[PLUGIN] expression function \"%s\" unregistered!\n", name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,6 +309,12 @@ static void registercommands()
|
|||
dbgcmdnew("analxrefs\1analx", cbInstrAnalxrefs, true); //analyze xrefs
|
||||
dbgcmdnew("analadv", cbInstrAnalyseadv, true); //analyze xref,function and data
|
||||
dbgcmdnew("graph", cbInstrGraph, true); //graph function
|
||||
dbgcmdnew("DisableLog\1LogDisable", cbInstrDisableLog, false); //disable log
|
||||
dbgcmdnew("EnableLog\1LogEnable", cbInstrEnableLog, false); //enable log
|
||||
dbgcmdnew("AddFavouriteTool", cbInstrAddFavTool, false); //add favourite tool
|
||||
dbgcmdnew("AddFavouriteCommand", cbInstrAddFavCmd, false); //add favourite command
|
||||
dbgcmdnew("AddFavouriteToolShortcut\1SetFavouriteToolShortcut", cbInstrSetFavToolShortcut, false); //set favourite tool shortcut
|
||||
dbgcmdnew("FoldDisassembly", cbInstrFoldDisassembly, true); //fold disassembly segment
|
||||
}
|
||||
|
||||
static bool cbCommandProvider(char* cmd, int maxlen)
|
||||
|
|
|
@ -598,7 +598,56 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
case GUI_UPDATE_GRAPH_VIEW:
|
||||
emit updateGraph();
|
||||
break;
|
||||
|
||||
case GUI_SET_LOG_ENABLED:
|
||||
emit setLogEnabled(param1 != 0);
|
||||
break;
|
||||
|
||||
case GUI_ADD_FAVOURITE_TOOL:
|
||||
{
|
||||
QString name;
|
||||
QString description;
|
||||
if(param1 == nullptr)
|
||||
return nullptr;
|
||||
name = QString::fromUtf8((const char*)param1);
|
||||
if(param2 != nullptr)
|
||||
description = QString::fromUtf8((const char*)param2);
|
||||
emit addFavouriteItem(0, name, description);
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_ADD_FAVOURITE_COMMAND:
|
||||
{
|
||||
QString name;
|
||||
QString shortcut;
|
||||
if(param1 == nullptr)
|
||||
return nullptr;
|
||||
name = QString::fromUtf8((const char*)param1);
|
||||
if(param2 != nullptr)
|
||||
shortcut = QString::fromUtf8((const char*)param2);
|
||||
emit addFavouriteItem(2, name, shortcut);
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_SET_FAVOURITE_TOOL_SHORTCUT:
|
||||
{
|
||||
QString name;
|
||||
QString shortcut;
|
||||
if(param1 == nullptr)
|
||||
return nullptr;
|
||||
name = QString::fromUtf8((const char*)param1);
|
||||
if(param2 != nullptr)
|
||||
shortcut = QString::fromUtf8((const char*)param2);
|
||||
emit setFavouriteItemShortcut(0, name, shortcut);
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_FOLD_DISASSEMBLY:
|
||||
emit foldDisassembly(duint(param1), duint(param2));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,10 @@ signals:
|
|||
void loadGraph(BridgeCFGraphList* graph, duint addr);
|
||||
void graphAt(duint addr);
|
||||
void updateGraph();
|
||||
void setLogEnabled(bool enabled);
|
||||
void addFavouriteItem(int type, const QString & name, const QString & description);
|
||||
void setFavouriteItemShortcut(int type, const QString & name, const QString & shortcut);
|
||||
void foldDisassembly(duint startAddr, duint length);
|
||||
|
||||
private:
|
||||
QMutex* mBridgeMutex;
|
||||
|
|
|
@ -29,6 +29,7 @@ void CPUSideBar::updateSlots()
|
|||
{
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateColors()));
|
||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateFonts()));
|
||||
connect(Bridge::getBridge(), SIGNAL(foldDisassembly(duint, duint)), this, SLOT(foldDisassembly(duint, duint)));
|
||||
|
||||
// Init all other updates once
|
||||
updateColors();
|
||||
|
@ -784,6 +785,11 @@ CodeFoldingHelper* CPUSideBar::getCodeFoldingManager()
|
|||
return &mCodeFoldingManager;
|
||||
}
|
||||
|
||||
void CPUSideBar::foldDisassembly(duint startAddress, duint length)
|
||||
{
|
||||
mCodeFoldingManager.addFoldSegment(startAddress, length);
|
||||
}
|
||||
|
||||
void* CPUSideBar::operator new(size_t size)
|
||||
{
|
||||
return _aligned_malloc(size, 16);
|
||||
|
|
|
@ -37,6 +37,7 @@ public slots:
|
|||
void changeTopmostAddress(dsint i);
|
||||
void setViewableRows(int rows);
|
||||
void setSelection(dsint selVA);
|
||||
void foldDisassembly(duint startAddress, duint length);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
|
|
@ -14,6 +14,7 @@ LogView::LogView(QWidget* parent) : QTextEdit(parent), logRedirection(NULL)
|
|||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateStyle()));
|
||||
connect(Bridge::getBridge(), SIGNAL(addMsgToLog(QString)), this, SLOT(addMsgToLogSlot(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(clearLog()), this, SLOT(clearLogSlot()));
|
||||
connect(Bridge::getBridge(), SIGNAL(setLogEnabled(bool)), this, SLOT(setLoggingEnabled(bool)));
|
||||
|
||||
setupContextMenu();
|
||||
}
|
||||
|
@ -125,7 +126,7 @@ void LogView::redirectLogSlot()
|
|||
{
|
||||
logRedirection = _wfopen(browse.path.toStdWString().c_str(), L"ab");
|
||||
if(logRedirection == NULL)
|
||||
addMsgToLogSlot(tr("_wfopen() failed. Log will not be redirected to %1.\n").arg(browse.path));
|
||||
GuiAddLogMessage(tr("_wfopen() failed. Log will not be redirected to %1.\n").arg(browse.path).toUtf8().constData());
|
||||
else
|
||||
{
|
||||
if(ftell(logRedirection) == 0)
|
||||
|
@ -133,14 +134,23 @@ void LogView::redirectLogSlot()
|
|||
unsigned short BOM = 0xfeff;
|
||||
fwrite(&BOM, 2, 1, logRedirection);
|
||||
}
|
||||
addMsgToLogSlot(tr("Log will be redirected to %1.\n").arg(browse.path));
|
||||
GuiAddLogMessage(tr("Log will be redirected to %1.\n").arg(browse.path).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LogView::setLoggingEnabled(bool enabled)
|
||||
{
|
||||
loggingEnabled = enabled;
|
||||
if(enabled)
|
||||
{
|
||||
loggingEnabled = true;
|
||||
GuiAddLogMessage(tr("Logging will be enabled.\n").toUtf8().constData());
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiAddLogMessage(tr("Logging will be disabled.\n").toUtf8().constData());
|
||||
loggingEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool LogView::getLoggingEnabled()
|
||||
|
@ -156,13 +166,13 @@ void LogView::saveSlot()
|
|||
savedLog.open(QIODevice::Append | QIODevice::Text);
|
||||
if(savedLog.error() != QFile::NoError)
|
||||
{
|
||||
addMsgToLogSlot(tr("Error, log have not been saved.\n"));
|
||||
GuiAddLogMessage(tr("Error, log have not been saved.\n").toUtf8().constData());
|
||||
}
|
||||
else
|
||||
{
|
||||
savedLog.write(this->document()->toPlainText().toUtf8().constData());
|
||||
savedLog.close();
|
||||
addMsgToLogSlot(tr("Log have been saved as %1\n").arg(fileName));
|
||||
GuiAddLogMessage(tr("Log have been saved as %1\n").arg(fileName).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
connect(Bridge::getBridge(), SIGNAL(closeQWidgetTab(QWidget*)), this, SLOT(closeQWidgetTab(QWidget*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(executeOnGuiThread(void*)), this, SLOT(executeOnGuiThread(void*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(dbgStateChangedSlot(DBGSTATE)));
|
||||
connect(Bridge::getBridge(), SIGNAL(addFavouriteItem(int, QString, QString)), this, SLOT(addFavouriteItem(int, QString, QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(setFavouriteItemShortcut(int, QString, QString)), this, SLOT(setFavouriteItemShortcut(int, QString, QString)));
|
||||
|
||||
// Setup menu API
|
||||
initMenuApi();
|
||||
|
@ -1669,6 +1671,59 @@ void MainWindow::chooseLanguage()
|
|||
msg.exec();
|
||||
}
|
||||
|
||||
void MainWindow::addFavouriteItem(int type, const QString & name, const QString & description)
|
||||
{
|
||||
if(type == 0) // Tools
|
||||
{
|
||||
char buffer[MAX_SETTING_SIZE];
|
||||
unsigned int i;
|
||||
for(i = 1; BridgeSettingGet("Favourite", (QString("Tool") + QString::number(i)).toUtf8().constData(), buffer); i++)
|
||||
{
|
||||
}
|
||||
BridgeSettingSet("Favourite", (QString("Tool") + QString::number(i)).toUtf8().constData(), name.toUtf8().constData());
|
||||
BridgeSettingSet("Favourite", (QString("ToolDescription") + QString::number(i)).toUtf8().constData(), description.toUtf8().constData());
|
||||
if(BridgeSettingGet("Favourite", (QString("Tool") + QString::number(i + 1)).toUtf8().constData(), buffer))
|
||||
{
|
||||
buffer[0] = 0;
|
||||
BridgeSettingSet("Favourite", (QString("Tool") + QString::number(i + 1)).toUtf8().constData(), buffer);
|
||||
}
|
||||
updateFavouriteTools();
|
||||
}
|
||||
else if(type == 2) // Commands
|
||||
{
|
||||
char buffer[MAX_SETTING_SIZE];
|
||||
unsigned int i;
|
||||
for(i = 1; BridgeSettingGet("Favourite", (QString("Command") + QString::number(i)).toUtf8().constData(), buffer); i++)
|
||||
{
|
||||
}
|
||||
BridgeSettingSet("Favourite", (QString("Command") + QString::number(i)).toUtf8().constData(), name.toUtf8().constData());
|
||||
BridgeSettingSet("Favourite", (QString("CommandShortcut") + QString::number(i)).toUtf8().constData(), description.toUtf8().constData());
|
||||
if(BridgeSettingGet("Favourite", (QString("Command") + QString::number(i + 1)).toUtf8().constData(), buffer))
|
||||
{
|
||||
buffer[0] = 0;
|
||||
BridgeSettingSet("Favourite", (QString("Command") + QString::number(i + 1)).toUtf8().constData(), buffer);
|
||||
}
|
||||
updateFavouriteTools();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setFavouriteItemShortcut(int type, const QString & name, const QString & shortcut)
|
||||
{
|
||||
if(type == 0)
|
||||
{
|
||||
char buffer[MAX_SETTING_SIZE];
|
||||
for(unsigned int i = 1; BridgeSettingGet("Favourite", QString("Tool%1").arg(i).toUtf8().constData(), buffer); i++)
|
||||
{
|
||||
if(QString(buffer) == name)
|
||||
{
|
||||
BridgeSettingSet("Favourite", (QString("ToolShortcut") + QString::number(i)).toUtf8().constData(), shortcut.toUtf8().constData());
|
||||
updateFavouriteTools();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStepIntoSource_triggered()
|
||||
{
|
||||
DbgCmdExec("TraceIntoConditional src.line(cip) && !src.disp(cip)");
|
||||
|
|
|
@ -148,6 +148,8 @@ public slots:
|
|||
void updateFavouriteTools();
|
||||
void clickFavouriteTool();
|
||||
void chooseLanguage();
|
||||
void addFavouriteItem(int type, const QString & name, const QString & description);
|
||||
void setFavouriteItemShortcut(int type, const QString & name, const QString & shortcut);
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
|
|
Loading…
Reference in New Issue