Skip to content

Commit

Permalink
fix for utf16 + color highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarmix committed Jul 27, 2023
1 parent 0764cec commit 528ffc8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
18 changes: 9 additions & 9 deletions hexwalk/advancedsearchdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ void AdvancedSearchDialog::findAll()
}
}

result.datastr = binToStr(preData) + QString("<b>")+ binToStr(inData) + QString("</b>")+ binToStr(postData);
result.hexdatastr = preData.toHex()+ QString("<b>") + inData.toHex() + QString("</b>")+ postData.toHex();
result.datastr = binToStr(preData) + QString("<b style='color:red'>")+ binToStr(inData) + QString("</b>")+ binToStr(postData);
result.hexdatastr = preData.toHex()+ QString("<b style='color:red'>") + inData.toHex() + QString("</b>")+ postData.toHex();
resultslist.append(result);
count++;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ void AdvancedSearchDialog::setData()

void AdvancedSearchDialog::on_resultsTableView_clicked(const QModelIndex &index)
{
_hexEdit->indexOf("",resultslist.at(index.row()).cursor,ui->cbRegex->isChecked(),ui->cbCase->isChecked());
//_hexEdit->indexOf("",resultslist.at(index.row()).cursor,ui->cbRegex->isChecked(),ui->cbCase->isChecked(),ui->cbFindFormat->currentIndex()==1);
_hexEdit->setCursorPosition(resultslist.at(index.row()).cursor);
_hexEdit->indexOf(_findBa, resultslist.at(index.row()).cursor - 1,ui->cbRegex->isChecked(),ui->cbCase->isChecked());
_hexEdit->update();
Expand Down Expand Up @@ -313,18 +313,18 @@ void AdvancedSearchDialog::on_cbCase_clicked()

void AdvancedSearchDialog::on_cbFindFormat_currentIndexChanged(int index)
{
if(!ui->cbFindFormat->currentText().compare("Hex"))
if(!ui->cbFindFormat->currentText().compare("UTF-8"))
{
ui->cbRegex->setEnabled(true);
ui->cbCase->setEnabled(true);
}
else
{
ui->cbRegex->setChecked(false);
ui->cbCase->setChecked(false);
ui->cbRegex->setEnabled(false);
ui->cbCase->setEnabled(false);
}
else
{
ui->cbRegex->setEnabled(true);
ui->cbCase->setEnabled(true);
}
}


Expand Down
2 changes: 1 addition & 1 deletion hexwalk/hexwalkmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void HexWalkMain::loadFile(const QString &fileName)
void HexWalkMain::about()
{
QMessageBox::about(this, tr("About HexWalk"),
tr("HexWalk v1.4.0 is an HEX editor/viewer/analyzer.\r\n"
tr("HexWalk v1.4.1 is an HEX editor/viewer/analyzer.\r\n"
"It is open source and it is based on QT, qhexedit2, binwalk\r\n"
"Sources at https://github.com/gcarmix/HexWalk\r\n"));
}
Expand Down
10 changes: 5 additions & 5 deletions src/chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ qint64 Chunks::indexOf(const QByteArray &ba, qint64 from,bool isRegex,bool isCas
icase = std::regex_constants::icase;
}

std::regex re(regex,(std::regex_constants::syntax_option_type)icase);
std::regex re(regex,(std::regex_constants::syntax_option_type)icase);

std::smatch match;
if (std::regex_search(buf, match, re)) {
findPos = match.position(0);
matchSize = match.str(0).size();
std::smatch match;
if (std::regex_search(buf, match, re)) {
findPos = match.position(0);
matchSize = match.str(0).size();
}
} catch (std::regex_error& e) {
// std::cerr << "Regex syntax error:" << std::endl << e.what() << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion src/qhexedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ class QHEXEDIT_API QHexEdit : public QAbstractScrollArea
* \param ba Data to find
* \param from Point where the search starts
* \param isRegex regex on off switch
* \return pos if fond, else -1
* \param isCaseSensitive case sensitive on off switch
* \return pos if found, else -1
*/
qint64 indexOf(const QByteArray &ba, qint64 from, bool isRegex, bool isCaseSensitive);

Expand Down

0 comments on commit 528ffc8

Please sign in to comment.