1
0
Fork 0

GUI: patch -> save to file is now working!

This commit is contained in:
Mr. eXoDia 2014-07-06 21:10:39 +02:00
parent d9907a9fc8
commit cc1a3125e9
3 changed files with 17 additions and 20 deletions

View File

@ -724,7 +724,7 @@ void CPUDisassembly::assembleAt()
return;
Config()->setBool("Disassembler", "FillNOPs", mLineEdit.bChecked);
char error[256]="";
char error[MAX_ERROR_SIZE]="";
if(!DbgFunctions()->AssembleAtEx(wVA, mLineEdit.editText.toUtf8().constData(), error, mLineEdit.bChecked))
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to assemble instruction \"" + mLineEdit.editText + "\" (" + error + ")");

View File

@ -212,7 +212,7 @@ void MainWindow::loadMRUList(int maxItems)
char currentFile[MAX_PATH]="";
if(!BridgeSettingGet("Recent Files", QString().sprintf("%.2d", i+1).toUtf8().constData(), currentFile))
break;
if(QString(currentFile).size())
if(QString(currentFile).size() && QFile(currentFile).exists())
mMRUList.push_back(currentFile);
}
updateMRUMenu();
@ -223,7 +223,10 @@ void MainWindow::saveMRUList()
{
int mruSize=mMRUList.size();
for(int i=0; i<mruSize; i++)
BridgeSettingSet("Recent Files", QString().sprintf("%.2d", i+1).toUtf8().constData(), mMRUList.at(i).toUtf8().constData());
{
if(QFile(mMRUList.at(i)).exists())
BridgeSettingSet("Recent Files", QString().sprintf("%.2d", i+1).toUtf8().constData(), mMRUList.at(i).toUtf8().constData());
}
}
void MainWindow::addMRUEntry(QString entry)
@ -453,15 +456,15 @@ void MainWindow::startScylla() //this is executed
void MainWindow::restartDebugging()
{
char filename[MAX_SETTING_SIZE]="";
if(!BridgeSettingGet("Recent Files", "01", filename)) //most recent file
if(!mMRUList.size())
return;
strcpy(filename, mMRUList.at(0).toUtf8().constData());
if(DbgIsDebugging())
{
DbgCmdExec("stop"); //close current file (when present)
Sleep(400);
}
QString cmd;
DbgCmdExec(cmd.sprintf("init \"%s\"", filename).toUtf8().constData());
DbgCmdExec(QString().sprintf("init \"%s\"", filename).toUtf8().constData());
}
void MainWindow::displayBreakpointWidget()

View File

@ -411,17 +411,8 @@ void PatchDialog::on_btnPatchFile_clicked()
msg.exec();
return;
}
int_t modBase=DbgFunctions()->ModBaseFromName(mod.toUtf8().constData());
if(!modBase)
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to get module base...");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.exec();
return;
}
char szModName[MAX_PATH]="";
if(!GetModuleFileNameA((HMODULE)modBase, szModName, MAX_PATH))
if(!DbgFunctions()->ModPathFromAddr(DbgFunctions()->ModBaseFromName(mod.toUtf8().constData()), szModName, MAX_PATH))
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to get module filename...");
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
@ -442,17 +433,20 @@ void PatchDialog::on_btnPatchFile_clicked()
//call patchSave function
DBGPATCHINFO* dbgPatchList = new DBGPATCHINFO[patchList.size()];
bool patched=DbgFunctions()->PatchFile(dbgPatchList, patchList.size(), filename.toUtf8().constData());
for(int i=0; i<patchList.size(); i++)
dbgPatchList[i]=patchList.at(i);
char error[MAX_ERROR_SIZE]="";
int patched=DbgFunctions()->PatchFile(dbgPatchList, patchList.size(), filename.toUtf8().constData(), error);
delete [] dbgPatchList;
if(!patched)
if(patched==-1)
{
QMessageBox msg(QMessageBox::Critical, "Error!", "Failed to save patched file...");
QMessageBox msg(QMessageBox::Critical, "Error!", QString("Failed to save patched file (" + QString(error) + ")"));
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.exec();
return;
}
QMessageBox msg(QMessageBox::Information, "Information", "Patched file saved!");
QMessageBox msg(QMessageBox::Information, "Information", QString().sprintf("%d/%d patch(es) applied!", patched, patchList.size()));
msg.setWindowIcon(QIcon(":/icons/images/information.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));