GUI: added HexEditDialog to CPUStack
This commit is contained in:
		
							parent
							
								
									88b863ed98
								
							
						
					
					
						commit
						0225a2a228
					
				|  | @ -1,5 +1,6 @@ | |||
| #include "CPUStack.h" | ||||
| #include "Configuration.h" | ||||
| #include "HexEditDialog.h" | ||||
| 
 | ||||
| CPUStack::CPUStack(QWidget *parent) : HexDump(parent) | ||||
| { | ||||
|  | @ -49,6 +50,17 @@ void CPUStack::colorsUpdated() | |||
| 
 | ||||
| void CPUStack::setupContextMenu() | ||||
| { | ||||
|     //Binary menu
 | ||||
|     mBinaryMenu = new QMenu("B&inary", this); | ||||
| 
 | ||||
|     //Binary->Edit
 | ||||
|     mBinaryEditAction = new QAction("&Edit", this); | ||||
|     mBinaryEditAction->setShortcutContext(Qt::WidgetShortcut); | ||||
|     mBinaryEditAction->setShortcut(QKeySequence("ctrl+e")); | ||||
|     this->addAction(mBinaryEditAction); | ||||
|     connect(mBinaryEditAction, SIGNAL(triggered()), this, SLOT(binaryEditSlot())); | ||||
|     mBinaryMenu->addAction(mBinaryEditAction); | ||||
| 
 | ||||
| #ifdef _WIN64 | ||||
|     mGotoSp = new QAction("Follow R&SP", this); | ||||
|     mGotoBp = new QAction("Follow R&BP", this); | ||||
|  | @ -182,6 +194,7 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event) | |||
|         return; | ||||
| 
 | ||||
|     QMenu* wMenu = new QMenu(this); //create context menu
 | ||||
|     wMenu->addMenu(mBinaryMenu); | ||||
|     wMenu->addAction(mGotoSp); | ||||
|     wMenu->addAction(mGotoBp); | ||||
|     wMenu->addAction(mGotoExpression); | ||||
|  | @ -298,3 +311,24 @@ void CPUStack::followStackSlot() | |||
|             DbgCmdExec(QString("sdump " + addrText).toUtf8().constData()); | ||||
|         } | ||||
| } | ||||
| 
 | ||||
| void CPUStack::binaryEditSlot() | ||||
| { | ||||
|     HexEditDialog hexEdit(this); | ||||
|     int_t selStart = getSelectionStart(); | ||||
|     int_t selSize = getSelectionEnd() - selStart + 1; | ||||
|     byte_t* data = new byte_t[selSize]; | ||||
|     mMemPage->read(data, selStart, selSize); | ||||
|     hexEdit.mHexEdit->setData(QByteArray((const char*)data, selSize)); | ||||
|     delete [] data; | ||||
|     hexEdit.setWindowTitle("Edit data at " + QString("%1").arg(rvaToVa(selStart), sizeof(int_t) * 2, 16, QChar('0')).toUpper()); | ||||
|     if(hexEdit.exec() != QDialog::Accepted) | ||||
|         return; | ||||
|     int_t dataSize = hexEdit.mHexEdit->data().size(); | ||||
|     int_t newSize = selSize > dataSize ? selSize : dataSize; | ||||
|     data = new byte_t[newSize]; | ||||
|     mMemPage->read(data, selStart, newSize); | ||||
|     QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, newSize)); | ||||
|     mMemPage->write(patched.constData(), selStart, patched.size()); | ||||
|     reloadData(); | ||||
| } | ||||
|  |  | |||
|  | @ -31,10 +31,13 @@ public slots: | |||
|     void followDisasmSlot(); | ||||
|     void followDumpSlot(); | ||||
|     void followStackSlot(); | ||||
|     void binaryEditSlot(); | ||||
| 
 | ||||
| private: | ||||
|     uint_t mCsp; | ||||
| 
 | ||||
|     QMenu* mBinaryMenu; | ||||
|     QAction* mBinaryEditAction; | ||||
|     QAction* mGotoSp; | ||||
|     QAction* mGotoBp; | ||||
|     QAction* mGotoExpression; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue