x64dbg热键设置的bug(寻源码修改的高人)
本帖最后由 冥界3大法王 于 2021-11-21 11:49 编辑比如你打开x64dbg,找到:选项=》快捷键=》搜索“设置硬件断点(执行)”
并设置一个热键为:Ctrl+Shift+3
但它显示的却是: Ctrl+Shift+#
然后到CPU窗口(上边的)你去按键吧,按到死,它也没有作用
为啥呢? 因为这是一个bug
不信,你修改 x64dbg.ini 来手动修改为 :Ctrl+Shift+3就正常了。
如果是Ctrl+Alt+3就正常
Ctrl+3也正常
这是为啥呢? 原因通过对比试验,很容易猜到 Shift键的处理上没有搞好。
下面是源码:
#include "ShortcutsDialog.h"
#include "ui_ShortcutsDialog.h"
#include <QMessageBox>
ShortcutsDialog::ShortcutsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ShortcutsDialog)
{
ui->setupUi(this);
//set window flags
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint);
setModal(true);
// x64 has no model-view-controler pattern
QStringList tblHeader;
tblHeader << tr("Action") << tr("Shortcut");
currentRow = 0;
ui->tblShortcuts->setColumnCount(2);
ui->tblShortcuts->verticalHeader()->setVisible(false);
ui->tblShortcuts->setHorizontalHeaderLabels(tblHeader);
ui->tblShortcuts->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tblShortcuts->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tblShortcuts->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tblShortcuts->setShowGrid(false);
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
ui->tblShortcuts->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
#else
ui->tblShortcuts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
#endif
ui->tblShortcuts->verticalHeader()->setDefaultSectionSize(15);
showShortcutsFiltered(QString());
connect(ui->tblShortcuts, SIGNAL(itemSelectionChanged()), this, SLOT(syncTextfield()));
connect(ui->shortcutEdit, SIGNAL(askForSave()), this, SLOT(updateShortcut()));
connect(this, SIGNAL(rejected()), this, SLOT(rejectedSlot()));
connect(ui->filterEdit, SIGNAL(textChanged(const QString &)), this, SLOT(on_FilterTextChanged(const QString &)));
}
void ShortcutsDialog::showShortcutsFiltered(const QString & actionName)
{
QMap<QString, Configuration::Shortcut> shorcutsToShow;
filterShortcutsByName(actionName, shorcutsToShow);
ui->tblShortcuts->clearContents();
ui->tblShortcuts->setRowCount(shorcutsToShow.count());
currentRow = 0;
int row = 0;
for(auto shortcut : shorcutsToShow)
{
QTableWidgetItem* shortcutName = new QTableWidgetItem(shortcut.Name);
QTableWidgetItem* shortcutKey = new QTableWidgetItem(shortcut.Hotkey.toString(QKeySequence::NativeText));
ui->tblShortcuts->setItem(row, 0, shortcutName);
ui->tblShortcuts->setItem(row, 1, shortcutKey);
row++;
}
ui->tblShortcuts->setSortingEnabled(true);
}
void ShortcutsDialog::filterShortcutsByName(const QString & nameFilter, QMap<QString, Configuration::Shortcut> & mapToFill)
{
for(auto shortcut : Config()->Shortcuts)
{
if(shortcut.Name.contains(nameFilter, Qt::CaseInsensitive) || nameFilter == QString())
{
mapToFill.insert(shortcut.Name, shortcut);
}
}
}
void ShortcutsDialog::updateShortcut()
{
const QKeySequence newKey = ui->shortcutEdit->getKeysequence();
if(newKey != currentShortcut.Hotkey)
{
bool good = true;
if(!newKey.isEmpty())
{
int idx = 0;
for(QMap<QString, Configuration::Shortcut>::iterator i = Config()->Shortcuts.begin(); i != Config()->Shortcuts.end(); ++i, idx++)
{
if(i.value().Name == currentShortcut.Name) //skip current shortcut in list
continue;
if(i.value().GlobalShortcut && i.value().Hotkey == newKey) //newkey is trying to override a global shortcut
{
good = false;
break;
}
else if(currentShortcut.GlobalShortcut && i.value().Hotkey == newKey) //current shortcut is global and overrides another local hotkey
{
ui->tblShortcuts->setItem(idx, 1, new QTableWidgetItem(""));
Config()->setShortcut(i.key(), QKeySequence());
}
else if(i.value().Hotkey == newKey)// This shortcut already exists (both are local)
{
// Ask user if they want to override the shortcut.
QMessageBox mbox;
mbox.setIcon(QMessageBox::Question);
mbox.setText("This shortcut is already used by action \"" + i.value().Name + "\".\n"
"Do you want to override it?");
mbox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
mbox.setDefaultButton(QMessageBox::Yes);
good = mbox.exec() == QMessageBox::Yes;
if(good)
{
ui->tblShortcuts->setItem(idx, 1, new QTableWidgetItem(""));
Config()->setShortcut(i.key(), QKeySequence());
}
}
}
}
if(good)
{
for(QMap<QString, Configuration::Shortcut>::iterator i = Config()->Shortcuts.begin(); i != Config()->Shortcuts.end(); ++i)
{
if(i.value().Name == currentShortcut.Name)
{
Config()->setShortcut(i.key(), newKey);
break;
}
}
QString keyText = "";
if(!newKey.isEmpty())
keyText = newKey.toString(QKeySequence::NativeText);
ui->tblShortcuts->item(currentRow, 1)->setText(keyText);
ui->shortcutEdit->setErrorState(false);
}
else
{
ui->shortcutEdit->setErrorState(true);
}
}
}
void ShortcutsDialog::on_btnClearShortcut_clicked()
{
for(QMap<QString, Configuration::Shortcut>::iterator i = Config()->Shortcuts.begin(); i != Config()->Shortcuts.end(); ++i)
{
if(i.value().Name == currentShortcut.Name)
{
Config()->setShortcut(i.key(), QKeySequence());
break;
}
}
QString emptyString;
ui->tblShortcuts->item(currentRow, 1)->setText(emptyString);
ui->shortcutEdit->setText(emptyString);
ui->shortcutEdit->setErrorState(false);
}
void ShortcutsDialog::syncTextfield()
{
QModelIndexList indexes = ui->tblShortcuts->selectionModel()->selectedRows();
if(indexes.count() < 1)
return;
currentRow = indexes.at(0).row();
for(auto shortcut : Config()->Shortcuts)
{
if(shortcut.Name == ui->tblShortcuts->item(currentRow, 0)->text())
{
currentShortcut = shortcut;
break;
}
}
ui->shortcutEdit->setErrorState(false);
ui->shortcutEdit->setText(currentShortcut.Hotkey.toString(QKeySequence::NativeText));
ui->shortcutEdit->setFocus();
}
ShortcutsDialog::~ShortcutsDialog()
{
delete ui;
}
void ShortcutsDialog::on_btnSave_clicked()
{
Config()->writeShortcuts();
GuiAddStatusBarMessage(QString("%1\n").arg(tr("Settings saved!")).toUtf8().constData());
}
void ShortcutsDialog::rejectedSlot()
{
Config()->readShortcuts();
}
void ShortcutsDialog::on_FilterTextChanged(const QString & actionName)
{
showShortcutsFiltered(actionName);
}
void ShortcutsDialog::on_shortcutEdit_returnPressed()
{
}
你用的是字母上面的数字键吗,要不试试数字键盘那边的数字键? xiaolong23330 发表于 2021-11-21 11:57
你用的是字母上面的数字键吗,要不试试数字键盘那边的数字键?
那样则显示的是Ctrl+PageDown{:301_976:} 何故 发表于 2021-11-21 12:04
无语,小键盘地球是PageDown啊哈哈哈哈哈
把小键盘Num灯关掉:
则是:Ctrl+Shift+PgDown 这个有趣,shift+3是#,把ctrl+shift+3,按下,电脑说:后面的shift+3怎么翻译?它懵逼了… shift+3就是#,可能当时开发赶时间的时候没有考虑得那么详细,没有进一步考虑和判断
页:
[1]