本帖最后由 冥界3大法王 于 2022-6-24 12:37 编辑
@wanxiangyu
还得请教专家们一个问题哟~~
话说在上一回书中,我们提到的那个贴子中。。
还有一个残留问题没有解决:
我简单的修改了一下代码内容如下:void PatchDialog::on_listModules_itemDoubleClicked(QListWidgetItem *item) { QString str = ui->listModules->currentItem()->text(); //这个编译成功啦~~ Bridge::CopyToClipboard("Patch_" + str); //得到的列表项内容 }
然后呢? 请看配图 ! 如图所示哈 ~~ 我想让剪贴板的内容一步到位 到 文件名中去 !
相关的完整代码如下:
[C++] 纯文本查看 复制代码 void PatchDialog::on_btnPatchFile_clicked()
{
//get current module
if(!ui->listModules->selectedItems().size())
return;
QString mod = ui->listModules->selectedItems().at(0)->text();
PatchMap::iterator found = mPatches.find(mod);
if(found == mPatches.end()) //not found
return;
PatchInfoList & curPatchList = found.value();
//get patches to save
QList<DBGPATCHINFO> patchList;
for(int i = 0; i < curPatchList.size(); i++)
if(curPatchList.at(i).status.checked)
patchList.push_back(curPatchList.at(i).patch);
if(!curPatchList.size() || !patchList.size())
{
SimpleInfoBox(this, tr("Information"), tr("Nothing to patch!"));
return;
}
if(containsRelocatedBytes(curPatchList) && !showRelocatedBytesWarning())
return;
char szModName[MAX_PATH] = "";
if(!DbgFunctions()->ModPathFromAddr(DbgFunctions()->ModBaseFromName(mod.toUtf8().constData()), szModName, MAX_PATH))
{
SimpleErrorBox(this, tr("Error!"), tr("Failed to get module filename..."));
return;
}
//open the save file dialog
int len = (int)strlen(szModName);
while(szModName[len] != '\\')
len--;
char szDirName[MAX_PATH] = "";
strcpy_s(szDirName, szModName);
szDirName[len] = '\0';
QString filename = QFileDialog::getSaveFileName(this, tr("Save file"), szDirName, tr("All files (*.*)"));
if(!filename.length())
return;
filename = QDir::toNativeSeparators(filename); //convert to native path format (with backlashes)
//call patchSave function
DBGPATCHINFO* dbgPatchList = new DBGPATCHINFO[patchList.size()];
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 == -1)
{
SimpleErrorBox(this, tr("Error!"), tr("Failed to save patched file (%1)").arg(error));
return;
}
SimpleInfoBox(this, tr("Information"), tr("%1/%2 patch(es) applied!").arg(patched).arg(patchList.size()));
}
能否修改如愿呢? 谢谢~~ |