mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Offer a default function name in actionAnalyzeFunction input box (#2572)
This commit is contained in:
parent
42f01fcf5d
commit
b4b9b312e7
1
.gitignore
vendored
1
.gitignore
vendored
@ -55,6 +55,7 @@ src/*_automoc.cpp
|
||||
*CMakeCache.txt*
|
||||
*cmake_install.cmake*
|
||||
src/CMakeFiles/*
|
||||
CMakeSettings.json
|
||||
|
||||
# Prepare_r2
|
||||
ninja.exe
|
||||
|
8
dist/WindowsBundleQt.cmake
vendored
8
dist/WindowsBundleQt.cmake
vendored
@ -1,10 +1,14 @@
|
||||
message("Running windeployqt")
|
||||
execute_process(COMMAND windeployqt cutter.exe
|
||||
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
|
||||
if(NOT WINDEPLOYQT_EXECUTABLE)
|
||||
message(FATAL_ERROR "Failed to find windeployqt")
|
||||
endif()
|
||||
execute_process(COMMAND "${WINDEPLOYQT_EXECUTABLE}" cutter.exe
|
||||
--plugindir "qtplugins"
|
||||
--no-translations # Cutter currently isn't loading Qt translation file
|
||||
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR "Failed to bundle python")
|
||||
message(FATAL_ERROR "Failed to bundle qt")
|
||||
endif()
|
||||
file(WRITE "${CMAKE_INSTALL_PREFIX}/qt.conf" "[PATHS]\nPlugins = qtplugins")
|
||||
|
@ -1248,7 +1248,7 @@ QString CutterCore::createFunctionAt(RVA addr)
|
||||
|
||||
QString CutterCore::createFunctionAt(RVA addr, QString name)
|
||||
{
|
||||
static const QRegularExpression regExp("[^a-zA-Z0-9_]");
|
||||
static const QRegularExpression regExp("[^a-zA-Z0-9_.]");
|
||||
name.remove(regExp);
|
||||
QString ret = cmdRawAt(QString("af %1").arg(name), addr);
|
||||
emit functionsChanged();
|
||||
@ -3742,8 +3742,8 @@ QString CutterCore::nearestFlag(RVA offset, RVA *flagOffsetOut)
|
||||
auto r = cmdj(QString("fdj @") + QString::number(offset)).object();
|
||||
QString name = r.value("name").toString();
|
||||
if (flagOffsetOut) {
|
||||
int queryOffset = r.value("offset").toInt(0);
|
||||
*flagOffsetOut = offset + static_cast<RVA>(-queryOffset);
|
||||
auto offsetValue = r.value("offset");
|
||||
*flagOffsetOut = offsetValue.isUndefined() ? offset : offsetValue.toVariant().toULongLong();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
@ -811,10 +811,21 @@ void DisassemblyContextMenu::on_actionAddComment_triggered()
|
||||
void DisassemblyContextMenu::on_actionAnalyzeFunction_triggered()
|
||||
{
|
||||
bool ok;
|
||||
RVA flagOffset;
|
||||
QString name = Core()->nearestFlag(offset, &flagOffset);
|
||||
if (name.isEmpty() || flagOffset != offset) {
|
||||
// Create a default name for the function
|
||||
QString pfx = Config()->getConfigString("analysis.fcnprefix");
|
||||
if (pfx.isEmpty()) {
|
||||
pfx = QString("fcn");
|
||||
}
|
||||
name = pfx + QString::asprintf(".%llx", offset);
|
||||
}
|
||||
|
||||
// Create dialog
|
||||
QString functionName =
|
||||
QInputDialog::getText(this, tr("New function %1").arg(RAddressString(offset)),
|
||||
tr("Function name:"), QLineEdit::Normal, QString(), &ok);
|
||||
QInputDialog::getText(this, tr("New function at %1").arg(RAddressString(offset)),
|
||||
tr("Function name:"), QLineEdit::Normal, name, &ok);
|
||||
|
||||
// If user accepted
|
||||
if (ok && !functionName.isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user