diff --git a/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.cpp b/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.cpp index 3229773c..ca978398 100644 --- a/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.cpp +++ b/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.cpp @@ -36,6 +36,35 @@ void QHexEdit::replace( int pos, int len, const QByteArray & after, const QByteA qHexEdit_p->replace(pos, len, after, mask); } +void QHexEdit::fill(int index, const QString & pattern) +{ + QString convert; + for(int i=0; i= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (wildcardEnabled() && ch == '?')) + convert += ch; + } + if(convert.length()%2) //odd length + convert += "0"; + QByteArray data(convert.length(), 0); + QByteArray mask(data.length(), 0); + for(int i=0; ifill(index, QByteArray().fromHex(data), QByteArray().fromHex(mask)); +} + void QHexEdit::redo() { qHexEdit_p->redo(); diff --git a/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.h b/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.h index 8fa26091..89fe780c 100644 --- a/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.h +++ b/x64_dbg_gui/Project/Src/QHexEdit/QHexEdit.h @@ -21,7 +21,8 @@ public: void insert(int i, const QByteArray & ba, const QByteArray & mask); void insert(int i, char ch, char mask); void remove(int pos, int len=1); - void replace( int pos, int len, const QByteArray & after, const QByteArray & mask); + void replace(int pos, int len, const QByteArray & after, const QByteArray & mask); + void fill(int index, const QString & pattern); //properties void setCursorPosition(int cusorPos); diff --git a/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.cpp b/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.cpp index f832fcd1..ce0737d8 100644 --- a/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.cpp +++ b/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.cpp @@ -149,6 +149,25 @@ void QHexEditPrivate::replace(int pos, int len, const QByteArray &after, const Q emit dataChanged(); } +void QHexEditPrivate::fill(int index, const QByteArray & ba, const QByteArray & mask) +{ + int dataSize = _xData.size(); + if(index >= dataSize) + return; + int repeat = dataSize / ba.size() + 1; + QByteArray fillData = ba.repeated(repeat); + fillData.resize(dataSize); + fillData = fillData.toHex(); + QByteArray fillMask = mask.repeated(repeat); + fillMask.resize(dataSize); + fillMask = fillMask.toHex(); + QByteArray origData = _xData.data().mid(index).toHex(); + for(int i=0; ireplace(index, QByteArray().fromHex(fillData), QByteArray().fromHex(fillMask)); +} + void QHexEditPrivate::setOverwriteMode(bool overwriteMode) { _overwriteMode = overwriteMode; @@ -183,6 +202,7 @@ void QHexEditPrivate::setHorizontalSpacing(int x) { _horizonalSpacing = x; adjust(); + setCursorPos(cursorPos()); this->repaint(); } diff --git a/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.h b/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.h index f59e726d..a0211282 100644 --- a/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.h +++ b/x64_dbg_gui/Project/Src/QHexEdit/QHexEditPrivate.h @@ -40,6 +40,7 @@ public: void replace(int index, char ch, char mask); void replace(int index, const QByteArray & ba, const QByteArray & mask); void replace(int pos, int len, const QByteArray & after, const QByteArray & mask); + void fill(int index, const QByteArray & ba, const QByteArray & mask); void undo(); void redo(); diff --git a/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.cpp b/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.cpp index 47a05f55..beb1fc73 100644 --- a/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.cpp +++ b/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.cpp @@ -2,7 +2,6 @@ XByteArray::XByteArray() { - _oldSize = -99; } QByteArray & XByteArray::data() diff --git a/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.h b/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.h index 0e5058bc..f70998e3 100644 --- a/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.h +++ b/x64_dbg_gui/Project/Src/QHexEdit/XByteArray.h @@ -27,9 +27,6 @@ public slots: private: QByteArray _data; //raw byte array - QByteArray _mask; //masked byte array - - int _oldSize; // size of data }; #endif // XBYTEARRAY_H