首页
社区
课程
招聘
[求助]x64dbg热键设置的bug(寻源码修改的高人)
2021-11-21 11:53 8179

[求助]x64dbg热键设置的bug(寻源码修改的高人)

2021-11-21 11:53
8179

比如你打开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()
{
     
}



[培训]二进制漏洞攻防(第3期);满10人开班;模糊测试与工具使用二次开发;网络协议漏洞挖掘;Linux内核漏洞挖掘与利用;AOSP漏洞挖掘与利用;代码审计。

收藏
点赞0
打赏
分享
最新回复 (12)
雪    币: 2576
活跃值: (437)
能力值: ( LV2,RANK:85 )
在线值:
发帖
回帖
粉丝
wyfe 2021-11-26 11:47
2
0
确实如此,反馈给官方了?下个版本就好了
雪    币: 31857
活跃值: (7105)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
ninebell 2021-11-26 21:20
3
0
wyfe 确实如此,反馈给官方了?下个版本就好了
没有,再也不反映了,不知反映了多少个。一个也没有解决。
不打草稿bug就能说出十多个来。
又是字典查英文编文章,又是gif动画演示,完全是对牛弹琴,白提交了。还是番翻,纯粹是浪费精力。

有求人的功夫,网上找了个高人,把编码不点确定不显示对应编码给我修改了一下,自己尝试学习QT和VS
修改着提升编程能力,找乐趣。修改之后爽透了。

另外我还编程开发了几套辅助工具
雪    币: 3568
活跃值: (2125)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
mb_acmeqfbq 2021-11-26 21:34
4
0
x64  bug不少
雪    币: 8044
活跃值: (4335)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
sunsjw 1 2021-11-26 23:36
5
0
ninebell 没有,再也不反映了,不知反映了多少个。一个也没有解决。 不打草稿bug就能说出十多个来。 又是字典查英文编文章,又是gif动画演示,完全是对牛弹琴,白提交了。还是番翻,纯粹是浪费精力。 有求 ...
你可以把你的修改提交上去啊。
雪    币: 31857
活跃值: (7105)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
ninebell 2021-11-27 09:00
6
0
sunsjw 你可以把你的修改提交上去啊。
帐号被封,网络被天狗搞得经常打不开。

假如你收藏夹里创建了多于10个脚本
然后打开x32dbg.ini 你就会发现按字母升序排列的
ScriptCommand10=
ScriptCommand11=
ScriptCommand1
ScriptCommand2
ScriptCommand3

命令行输入:commentclear 你会发现只有在打开注释窗口,原来的才会被清掉
已经打开的则完全不全变化,而源码里是写了刷新代码显示的
而BC命令则会刷新的

还有其他bug明天再说。
雪    币: 8044
活跃值: (4335)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
sunsjw 1 2021-11-27 12:54
7
0
ninebell 帐号被封,网络被天狗搞得经常打不开。[em_11] 假如你收藏夹里创建了多于10个脚本 然后打开x32dbg.ini 你就会发现按字母升序排列的 ScriptCommand10= Scri ...
把GitHub仓库导入到gitee很快的
雪    币: 65
活跃值: (171)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
gzfuqun 2021-12-13 12:59
8
1
这个bug需修改一下源码,但不是在这个文件里,应该在那个ShortcutEdit.cpp里吧
雪    币: 31857
活跃值: (7105)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
ninebell 2021-12-13 20:51
9
0
gzfuqun 这个bug需修改一下源码,但不是在这个文件里,应该在那个ShortcutEdit.cpp里吧
#include "ShortcutEdit.h"
#include <QStyle>

ShortcutEdit::ShortcutEdit(QWidget* parent) : QLineEdit(parent)
{
    keyInt = -1;
    mError = true;
}

const QKeySequence ShortcutEdit::getKeysequence() const
{
    if(keyInt == -1) //return empty on -1
        return QKeySequence();
    // returns current keystroke combination
    return QKeySequence(keyInt);
}

bool ShortcutEdit::error() const
{
    return mError;
}

void ShortcutEdit::setErrorState(bool error)
{
    this->mError = error;

    this->style()->unpolish(this);
    this->style()->polish(this);
}

void ShortcutEdit::keyPressEvent(QKeyEvent* event)
{
    keyInt = event->key();
    // find key-id
    const Qt::Key key = static_cast<Qt::Key>(keyInt);

    // we do not know how to handle this case
    if(key == Qt::Key_unknown)
    {
        keyInt = -1;
        emit askForSave();
        return;
    }

    // any combination of "Ctrl, Alt, Shift" ?
    Qt::KeyboardModifiers modifiers = event->modifiers();
    QString text = event->text();
    // The shift modifier only counts when it is not used to type a symbol
    // that is only reachable using the shift key anyway
    if(modifiers.testFlag(Qt::ShiftModifier) && (text.isEmpty() ||
            !text.at(0).isPrint() ||
            text.at(0).isLetterOrNumber() ||
            text.at(0).isSpace()))
        keyInt += Qt::SHIFT;
    if(modifiers.testFlag(Qt::ControlModifier))
        keyInt += Qt::CTRL;
    if(modifiers.testFlag(Qt::AltModifier))
        keyInt += Qt::ALT;

    // some strange cases (only Ctrl)
    QString KeyText = QKeySequence(keyInt).toString(QKeySequence::NativeText);
    for(int i = 0; i < KeyText.length(); i++)
    {
        if(KeyText[i].toLatin1() == 0)
        {
            setText("");
            keyInt = -1;
            emit askForSave();
            return;
        }
    }

    // display key combination
    setText(QKeySequence(keyInt).toString(QKeySequence::NativeText));
    // do not forward keypress-event
    event->setAccepted(true);

    // everything is fine , so ask for saving
    emit askForSave();
}

源码来了,欢迎表演。

雪    币: 65
活跃值: (171)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
gzfuqun 2021-12-13 22:43
10
0
          if(modifiers.testFlag(Qt::ShiftModifier) && (text.isEmpty() ||
            !text.at(0).isPrint() ||
           text.at(0).isLetterOrNumber() ||
           text.at(0).isSpace()) && (!(
    ((keyInt >= 0x21) && (keyInt <= 0x2F)) ||         
    ((keyInt >= 0x3A) && (keyInt <= 0x40)) ||         
           ((keyInt >= 0x5B) && (keyInt <= 0x60)))))
       keyInt += Qt::SHIFT;
雪    币: 31857
活跃值: (7105)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
ninebell 2021-12-14 13:47
11
0
gzfuqun if(modifiers.testFlag(Qt::ShiftModifier) && (text.isEmpty() || !text.at(0).i ...
修改后, ctrl shift alt 都没作用了。
雪    币: 65
活跃值: (171)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
gzfuqun 2021-12-14 15:39
12
0
不会吧,我只列了我修改的部分,其它的我没列出,是不是你改错了地方。
雪    币: 65
活跃值: (171)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
gzfuqun 2021-12-14 15:44
13
0
53  行这里需要改为:
      text.at(0).isSpace()) && (!(
      ((keyInt >= 0x21) && (keyInt <= 0x2F)) || 
      ((keyInt >= 0x3A) && (keyInt <= 0x40)) ||  
       ((keyInt >= 0x5B) && (keyInt <= 0x60)))))
另外,你怎么QQ将我删除了。
游客
登录 | 注册 方可回帖
返回