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*
|
*CMakeCache.txt*
|
||||||
*cmake_install.cmake*
|
*cmake_install.cmake*
|
||||||
src/CMakeFiles/*
|
src/CMakeFiles/*
|
||||||
|
CMakeSettings.json
|
||||||
|
|
||||||
# Prepare_r2
|
# Prepare_r2
|
||||||
ninja.exe
|
ninja.exe
|
||||||
|
8
dist/WindowsBundleQt.cmake
vendored
8
dist/WindowsBundleQt.cmake
vendored
@ -1,10 +1,14 @@
|
|||||||
message("Running windeployqt")
|
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"
|
--plugindir "qtplugins"
|
||||||
--no-translations # Cutter currently isn't loading Qt translation file
|
--no-translations # Cutter currently isn't loading Qt translation file
|
||||||
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
|
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
|
||||||
RESULT_VARIABLE SCRIPT_RESULT)
|
RESULT_VARIABLE SCRIPT_RESULT)
|
||||||
if (SCRIPT_RESULT)
|
if (SCRIPT_RESULT)
|
||||||
message(FATAL_ERROR "Failed to bundle python")
|
message(FATAL_ERROR "Failed to bundle qt")
|
||||||
endif()
|
endif()
|
||||||
file(WRITE "${CMAKE_INSTALL_PREFIX}/qt.conf" "[PATHS]\nPlugins = qtplugins")
|
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)
|
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);
|
name.remove(regExp);
|
||||||
QString ret = cmdRawAt(QString("af %1").arg(name), addr);
|
QString ret = cmdRawAt(QString("af %1").arg(name), addr);
|
||||||
emit functionsChanged();
|
emit functionsChanged();
|
||||||
@ -3742,8 +3742,8 @@ QString CutterCore::nearestFlag(RVA offset, RVA *flagOffsetOut)
|
|||||||
auto r = cmdj(QString("fdj @") + QString::number(offset)).object();
|
auto r = cmdj(QString("fdj @") + QString::number(offset)).object();
|
||||||
QString name = r.value("name").toString();
|
QString name = r.value("name").toString();
|
||||||
if (flagOffsetOut) {
|
if (flagOffsetOut) {
|
||||||
int queryOffset = r.value("offset").toInt(0);
|
auto offsetValue = r.value("offset");
|
||||||
*flagOffsetOut = offset + static_cast<RVA>(-queryOffset);
|
*flagOffsetOut = offsetValue.isUndefined() ? offset : offsetValue.toVariant().toULongLong();
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -811,10 +811,21 @@ void DisassemblyContextMenu::on_actionAddComment_triggered()
|
|||||||
void DisassemblyContextMenu::on_actionAnalyzeFunction_triggered()
|
void DisassemblyContextMenu::on_actionAnalyzeFunction_triggered()
|
||||||
{
|
{
|
||||||
bool ok;
|
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
|
// Create dialog
|
||||||
QString functionName =
|
QString functionName =
|
||||||
QInputDialog::getText(this, tr("New function %1").arg(RAddressString(offset)),
|
QInputDialog::getText(this, tr("New function at %1").arg(RAddressString(offset)),
|
||||||
tr("Function name:"), QLineEdit::Normal, QString(), &ok);
|
tr("Function name:"), QLineEdit::Normal, name, &ok);
|
||||||
|
|
||||||
// If user accepted
|
// If user accepted
|
||||||
if (ok && !functionName.isEmpty()) {
|
if (ok && !functionName.isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user