1
0
Fork 0

GUI+DBG+BRIDGE: resolved issue #92 (context menu api for plugins)

This commit is contained in:
Mr. eXoDia 2015-01-04 22:18:20 +01:00
parent 23f65f6a91
commit b10e45dfae
11 changed files with 104 additions and 16 deletions

View File

@ -12,18 +12,24 @@ html,body {
}
</style>
</head>
</head>
<body>
<P><STRONG>plugsetup</STRONG><BR>This structure is used by the function that allows the
creation of plugin menu entries:</P>
<P>
struct <STRONG>PLUG_SETUPSTRUCT</STRONG>
<BR>{<BR>&nbsp;&nbsp;&nbsp; <EM>//data provided by the debugger to
the plugin.</EM>
<BR>&nbsp;&nbsp;&nbsp; [IN] <STRONG>HWND</STRONG> hwndDlg; //GUI window
handle<BR>&nbsp;&nbsp;&nbsp; [IN]
<STRONG>int</STRONG> hMenu; //plugin menu
handle<BR>
<body>
<P><STRONG>plugsetup</STRONG><BR>This structure is used by the function that allows the
creation of plugin menu entries:</P>
<P>
struct <STRONG>PLUG_SETUPSTRUCT</STRONG>
<BR>{<BR>&nbsp;&nbsp;&nbsp; <EM>//data provided by the debugger to
the plugin.</EM>
<BR>&nbsp;&nbsp;&nbsp; [IN] <STRONG>HWND</STRONG> hwndDlg; //GUI window
handle<BR>&nbsp;&nbsp;&nbsp; [IN]
<STRONG>int</STRONG> hMenu; //plugin menu
handle<BR>&nbsp;&nbsp;&nbsp; [IN] <STRONG>int</STRONG> hMenuDisasm;
//plugin disasm menu handle<BR>&nbsp;&nbsp;&nbsp; [IN] <STRONG>int</STRONG>
hMenuDump; //plugin dump menu handle<BR>&nbsp;&nbsp;&nbsp; [IN]
<STRONG>int</STRONG> hMenuStack; //plugin stack menu
handle<BR>
};</P></body>
</html>

View File

@ -678,6 +678,9 @@ BRIDGE_IMPEXP bool DbgWinEventGlobal(MSG* message);
//Gui defines
#define GUI_PLUGIN_MENU 0
#define GUI_DISASM_MENU 1
#define GUI_DUMP_MENU 2
#define GUI_STACK_MENU 3
#define GUI_DISASSEMBLY 0
#define GUI_DUMP 1

View File

@ -41,6 +41,9 @@ typedef struct
//provided by the debugger
HWND hwndDlg; //gui window handle
int hMenu; //plugin menu handle
int hMenuDisasm; //plugin disasm menu handle
int hMenuDump; //plugin dump menu handle
int hMenuStack; //plugin stack menu handle
} PLUG_SETUPSTRUCT;
//callback structures

View File

@ -162,7 +162,7 @@ void pluginload(const char* pluginDir)
int hNewMenu = GuiMenuAdd(GUI_PLUGIN_MENU, pluginData.initStruct.pluginName);
if(hNewMenu == -1)
{
dprintf("[PLUGIN] GuiMenuAdd failed for plugin: %s\n", pluginData.initStruct.pluginName);
dprintf("[PLUGIN] GuiMenuAdd(GUI_PLUGIN_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName);
pluginData.hMenu = -1;
}
else
@ -172,7 +172,55 @@ void pluginload(const char* pluginDir)
newMenu.hEntryPlugin = -1;
newMenu.pluginHandle = pluginData.initStruct.pluginHandle;
pluginMenuList.push_back(newMenu);
pluginData.hMenu = hNewMenu;
pluginData.hMenu = newMenu.hEntryMenu;
}
//add disasm plugin menu
hNewMenu = GuiMenuAdd(GUI_DISASM_MENU, pluginData.initStruct.pluginName);
if(hNewMenu == -1)
{
dprintf("[PLUGIN] GuiMenuAdd(GUI_DISASM_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName);
pluginData.hMenu = -1;
}
else
{
PLUG_MENU newMenu;
newMenu.hEntryMenu = hNewMenu;
newMenu.hEntryPlugin = -1;
newMenu.pluginHandle = pluginData.initStruct.pluginHandle;
pluginMenuList.push_back(newMenu);
pluginData.hMenuDisasm = newMenu.hEntryMenu;
}
//add dump plugin menu
hNewMenu = GuiMenuAdd(GUI_DUMP_MENU, pluginData.initStruct.pluginName);
if(hNewMenu == -1)
{
dprintf("[PLUGIN] GuiMenuAdd(GUI_DUMP_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName);
pluginData.hMenu = -1;
}
else
{
PLUG_MENU newMenu;
newMenu.hEntryMenu = hNewMenu;
newMenu.hEntryPlugin = -1;
newMenu.pluginHandle = pluginData.initStruct.pluginHandle;
pluginMenuList.push_back(newMenu);
pluginData.hMenuDump = newMenu.hEntryMenu;
}
//add stack plugin menu
hNewMenu = GuiMenuAdd(GUI_STACK_MENU, pluginData.initStruct.pluginName);
if(hNewMenu == -1)
{
dprintf("[PLUGIN] GuiMenuAdd(GUI_STACK_MENU) failed for plugin: %s\n", pluginData.initStruct.pluginName);
pluginData.hMenu = -1;
}
else
{
PLUG_MENU newMenu;
newMenu.hEntryMenu = hNewMenu;
newMenu.hEntryPlugin = -1;
newMenu.pluginHandle = pluginData.initStruct.pluginHandle;
pluginMenuList.push_back(newMenu);
pluginData.hMenuStack = newMenu.hEntryMenu;
}
pluginList.push_back(pluginData);
//setup plugin
@ -180,7 +228,10 @@ void pluginload(const char* pluginDir)
{
PLUG_SETUPSTRUCT setupStruct;
setupStruct.hwndDlg = GuiGetWindowHandle();
setupStruct.hMenu = hNewMenu;
setupStruct.hMenu = pluginData.hMenu;
setupStruct.hMenuDisasm = pluginData.hMenuDisasm;
setupStruct.hMenuDump = pluginData.hMenuDump;
setupStruct.hMenuStack = pluginData.hMenuStack;
pluginData.plugsetup(&setupStruct);
}
curPluginHandle++;

View File

@ -24,6 +24,9 @@ struct PLUG_DATA
PLUGSTOP plugstop;
PLUGSETUP plugsetup;
int hMenu;
int hMenuDisasm;
int hMenuDump;
int hMenuStack;
PLUG_INITSTRUCT initStruct;
};

View File

@ -228,7 +228,6 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
wMenu->addAction(mEnableHighlightingMode);
wMenu->addSeparator();
wMenu->addAction(mSetLabel);
wMenu->addAction(mSetComment);
wMenu->addAction(mSetBookmark);
@ -273,6 +272,9 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
mReferencesMenu->addAction(mReferenceSelectedAddress);
wMenu->addMenu(mReferencesMenu);
wMenu->addSeparator();
wMenu->addActions(mPluginMenu->actions());
wMenu->exec(event->globalPos());
}
}
@ -519,6 +521,10 @@ void CPUDisassembly::setupRightClickContextMenu()
this->addAction(mEnableHighlightingMode);
connect(mEnableHighlightingMode, SIGNAL(triggered()), this, SLOT(enableHighlightingMode()));
// Plugins
mPluginMenu = new QMenu(this);
Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_DISASM_MENU);
refreshShortcutsSlot();
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
}

View File

@ -80,6 +80,7 @@ private:
QMenu* mReferencesMenu;
QMenu* mSearchMenu;
QMenu* mCopyMenu;
QMenu* mPluginMenu;
QAction* mBinaryEditAction;
QAction* mBinaryFillAction;

View File

@ -341,6 +341,10 @@ void CPUDump::setupContextMenu()
mDisassemblyAction = new QAction("&Disassembly", this);
connect(mDisassemblyAction, SIGNAL(triggered()), this, SLOT(disassemblySlot()));
//Plugins
mPluginMenu = new QMenu(this);
Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_DUMP_MENU);
refreshShortcutsSlot();
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
}
@ -498,6 +502,9 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
mMemoryRemove->setVisible(false);
}
wMenu->addSeparator();
wMenu->addActions(mPluginMenu->actions());
wMenu->exec(event->globalPos()); //execute context menu
}

View File

@ -160,6 +160,7 @@ private:
QMenu* mSpecialMenu;
QMenu* mCustomMenu;
QMenu* mPluginMenu;
GotoDialog* mGoto;

View File

@ -150,6 +150,9 @@ void CPUStack::setupContextMenu()
mFollowStack = new QAction("Follow in &Stack", this);
connect(mFollowStack, SIGNAL(triggered()), this, SLOT(followStackSlot()));
mPluginMenu = new QMenu(this);
Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_STACK_MENU);
refreshShortcutsSlot();
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
}
@ -333,6 +336,9 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event)
wMenu->addAction(mFollowDump);
}
wMenu->addSeparator();
wMenu->addActions(mPluginMenu->actions());
wMenu->exec(event->globalPos());
}

View File

@ -57,6 +57,7 @@ private:
QAction* mFollowDisasm;
QAction* mFollowDump;
QAction* mFollowStack;
QMenu* mPluginMenu;
GotoDialog* mGoto;
};