diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 584a5773..d95156c2 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -29,7 +29,8 @@ jobs: steps: - uses: actions/checkout@v2 with: - submodules: true # 'recursive' 'true' or 'false' + token: ${{ secrets.RIZIN_TOKEN }} # TODO: remove when the repo is public + submodules: recursive persist-credentials: false - name: apt dependencies if: contains(matrix.os, 'ubuntu') @@ -101,20 +102,20 @@ jobs: then cmake \ -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ -DCUTTER_ENABLE_PYTHON=ON \ + -DCMAKE_BUILD_TYPE=Release \ -DPYTHON_LIBRARY="$CUTTER_DEPS_PYTHON_PREFIX/lib/libpython3.6m.so.1.0" \ -DPYTHON_INCLUDE_DIR="$CUTTER_DEPS_PYTHON_PREFIX/include/python3.6m" \ -DPYTHON_EXECUTABLE="$CUTTER_DEPS_PYTHON_PREFIX/bin/python3" \ -DCUTTER_ENABLE_PYTHON_BINDINGS=OFF \ -DCUTTER_ENABLE_CRASH_REPORTS=ON \ - -DCUTTER_USE_BUNDLED_RADARE2=ON \ - ../src + -DCUTTER_USE_BUNDLED_RIZIN=ON \ + ../src && \ else cmake \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ - -DCUTTER_USE_BUNDLED_RADARE2=ON \ + -DCUTTER_USE_BUNDLED_RIZIN=ON \ ../src fi ninja @@ -137,7 +138,7 @@ jobs: -DCUTTER_ENABLE_PYTHON=ON \ -DCUTTER_ENABLE_PYTHON_BINDINGS=ON \ -DCUTTER_ENABLE_CRASH_REPORTS=ON \ - -DCUTTER_USE_BUNDLED_RADARE2=ON \ + -DCUTTER_USE_BUNDLED_RIZIN=ON \ -DBREAKPAD_FRAMEWORK_DIR="$BREAKPAD_FRAMEWORK_DIR" \ ../src && \ make -j4; @@ -163,7 +164,7 @@ jobs: set PACKAGE_NAME=cutter-git-x64.Windows cmake ^ -DCMAKE_BUILD_TYPE=Release ^ - -DCUTTER_USE_BUNDLED_RADARE2=ON ^ + -DCUTTER_USE_BUNDLED_RIZIN=ON ^ -DCUTTER_ENABLE_PYTHON=ON ^ -DCUTTER_ENABLE_PYTHON_BINDINGS=ON ^ -DCUTTER_PACKAGE_DEPENDENCIES=ON ^ diff --git a/.gitignore b/.gitignore index fc74b474..67243c34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,96 +1,99 @@ -# Binaries -AStyle* - -# OSX files -*.DS_Store -.AppleDouble -.LSOverride - -# C++ objects and libs -*.slo -*.lo -*.o -*.a -*.la -*.lai -*.so -*.dll -*.dylib - -# Qt files -*.qmake.cache -*.qmake.stash -*.pro.user -*.pro.user.* -*.qbs.user -*.qbs.user.* -*.moc -moc_*.cpp -qrc_*.cpp -moc_*.h -ui_*.h -build*/ -cmake-build-*/ +# Binaries +AStyle* + +# OSX files +*.DS_Store +.AppleDouble +.LSOverride + +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# Qt files +*.qmake.cache +*.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +qrc_*.cpp +moc_*.h +ui_*.h +build*/ +cmake-build-*/ /src-build/ - -# Build folders -Debug -Release - -# QtCreator -*.autosave -*.qmlproject.user -*.qmlproject.user.* -CMakeLists.txt.user - -# CLion -.idea - -# Vim -*.swp -*~ - -# Git mergetool -~.orig - -# CMake Files: -src/*_automoc.cpp -*CMakeCache.txt* -*cmake_install.cmake* -src/CMakeFiles/* - -# Prepare_r2 -ninja.exe -r2_dist_x86/ -r2_dist_x64/ -r2_dist/ -*.pdb - -# Mesonbuild -src/subprojects/ - -# Python -__pycache__ -/python/ - -# Other -compile_commands.json -.ccls-cache -docs/source/_build - -# vscode -/.vscode/* -!/.vscode/settings.json -!/.vscode/extensions.json - -# Visual Studio CMake -src/out -.vs - -# cutter-deps -/cutter-deps - -/breakpad - -# astyle backup .orig files -*.orig + +# Build folders +Debug +Release + +# QtCreator +*.autosave +*.qmlproject.user +*.qmlproject.user.* +CMakeLists.txt.user + +# CLion +.idea + +# Vim +*.swp +*~ + +# Git mergetool +~.orig + +# CMake Files: +src/*_automoc.cpp +*CMakeCache.txt* +*cmake_install.cmake* +src/CMakeFiles/* + +# Prepare_r2 +ninja.exe +r2_dist_x86/ +r2_dist_x64/ +r2_dist/ +*.pdb + +# Mesonbuild +src/subprojects/ + +# Python +__pycache__ +/python/ + +# Other +compile_commands.json +.ccls-cache +docs/source/_build + +# vscode +/.vscode/* +!/.vscode/settings.json +!/.vscode/extensions.json + +# Visual Studio CMake +src/out +.vs + +# cutter-deps +/cutter-deps + +/breakpad + +# astyle backup .orig files +*.orig + +# Gdb's history +.gdb_history diff --git a/.gitmodules b/.gitmodules index d88371ff..d3aa0d85 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "radare2"] - path = radare2 - url = https://github.com/radareorg/radare2 +[submodule "rizin"] + path = rizin + url = git@github.com:rizinorg/rizin [submodule "src/translations"] path = src/translations - url = https://github.com/radareorg/cutter-translations + url = git@github.com:rizinorg/cutter-translations diff --git a/radare2 b/radare2 deleted file mode 160000 index 293cf5ae..00000000 --- a/radare2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 293cf5ae65ba4e28828095dcae212955593ba255 diff --git a/rizin b/rizin new file mode 160000 index 00000000..8b30c4f0 --- /dev/null +++ b/rizin @@ -0,0 +1 @@ +Subproject commit 8b30c4f0d7282009e52099764e15b686c4d08654 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c006ce7..7bb9784e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,9 +10,9 @@ include(Utils) set(CUTTER_PYTHON_MIN 3.5) -option(CUTTER_USE_BUNDLED_RADARE2 "Use radare2 from src/radare2 submodule instead of searching for it on the system" OFF) -option(CUTTER_USE_ADDITIONAL_RADARE2_PATHS "Search radare2 in additional paths which are not part of default system library paths.\ - Disable this option if you are linking against radare2 pacakged as proper system library or in a custom path and additional are paths causing problems." ON) +option(CUTTER_USE_BUNDLED_RIZIN "Use rizin from src/rizin submodule instead of searching for it on the system" OFF) +option(CUTTER_USE_ADDITIONAL_RIZIN_PATHS "Search rizin in additional paths which are not part of default system library paths.\ + Disable this option if you are linking against rizin pacakged as proper system library or in a custom path and additional are paths causing problems." ON) option(CUTTER_ENABLE_PYTHON "Enable Python integration. Requires Python >= ${CUTTER_PYTHON_MIN}." OFF) option(CUTTER_ENABLE_PYTHON_BINDINGS "Enable generating Python bindings with Shiboken2. Unused if CUTTER_ENABLE_PYTHON=OFF." OFF) option(CUTTER_ENABLE_CRASH_REPORTS "Enable crash report system. Unused if CUTTER_ENABLE_CRASH_REPORTS=OFF" OFF) @@ -65,12 +65,12 @@ find_package(${QT_PREFIX} REQUIRED COMPONENTS Core Widgets Gui Svg Network) include(CutterInstallDirs) -if(CUTTER_USE_BUNDLED_RADARE2) - include(BundledRadare2) - set(RADARE2_TARGET Radare2) +if(CUTTER_USE_BUNDLED_RIZIN) + include(BundledRizin) + set(RIZIN_TARGET Rizin) else() - find_package(Radare2 REQUIRED) - set(RADARE2_TARGET Radare2::libr) + find_package(Rizin REQUIRED) + set(RIZIN_TARGET Rizin::librz) endif() if(CUTTER_ENABLE_PYTHON) @@ -129,7 +129,7 @@ endif() message(STATUS "") message(STATUS "Building Cutter version ${CUTTER_VERSION_FULL}") message(STATUS "Options:") -message(STATUS "- Bundled radare2: ${CUTTER_USE_BUNDLED_RADARE2}") +message(STATUS "- Bundled rizin: ${CUTTER_USE_BUNDLED_RIZIN}") message(STATUS "- Python: ${CUTTER_ENABLE_PYTHON}") message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}") message(STATUS "- Crash Handling: ${CUTTER_ENABLE_CRASH_REPORTS}") @@ -226,7 +226,7 @@ if(CUTTER_ENABLE_CRASH_REPORTS) endif() target_link_libraries(Cutter PUBLIC ${QT_PREFIX}::Core ${QT_PREFIX}::Widgets ${QT_PREFIX}::Gui PRIVATE ${QT_PREFIX}::Svg ${QT_PREFIX}::Network) -target_link_libraries(Cutter PUBLIC ${RADARE2_TARGET}) +target_link_libraries(Cutter PUBLIC ${RIZIN_TARGET}) if(CUTTER_ENABLE_PYTHON) if (WIN32) # On windows some of the Python STABLE API functions are in seperate library @@ -255,7 +255,7 @@ if(CUTTER_ENABLE_PYTHON) list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtWidgets") endif() list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS}) - list(APPEND BINDINGS_INCLUDE_DIRS ${Radare2_INCLUDE_DIRS}) + list(APPEND BINDINGS_INCLUDE_DIRS ${Rizin_INCLUDE_DIRS}) list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") if (NOT WIN32) string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}") diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index 299e7191..5fbf2de8 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -75,8 +75,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc } // Check r2 version - QString r2version = r_core_version(); - QString localVersion = "" R2_GITTAP; + QString r2version = rz_core_version(); + QString localVersion = "" RZ_GITTAP; if (r2version != localVersion) { QMessageBox msg; msg.setIcon(QMessageBox::Critical); @@ -99,7 +99,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc #endif #ifdef Q_OS_WIN - // Redefine r_sys_prefix() behaviour + // Redefine rz_sys_prefix() behaviour qputenv("R_ALT_SRC_DIR", "1"); #endif @@ -151,8 +151,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc appdir.cdUp(); // appdir auto sleighHome = appdir; - sleighHome.cd("share/radare2/plugins/r2ghidra_sleigh"); // appdir/share/radare2/plugins/r2ghidra_sleigh - Core()->setConfig("r2ghidra.sleighhome", sleighHome.absolutePath()); + sleighHome.cd("share/radare2/plugins/rz_ghidra_sleigh"); // appdir/share/radare2/plugins/rz_ghidra_sleigh + Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath()); auto r2decHome = appdir; r2decHome.cd("share/radare2/plugins/r2dec-js"); // appdir/share/radare2/plugins/r2dec-js @@ -162,15 +162,15 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc #ifdef Q_OS_MACOS { - auto r2prefix = QDir(QCoreApplication::applicationDirPath()); // Contents/MacOS - r2prefix.cdUp(); // Contents - r2prefix.cd("Resources/r2"); // Contents/Resources/r2 + auto rzprefix = QDir(QCoreApplication::applicationDirPath()); // Contents/MacOS + rzprefix.cdUp(); // Contents + rzprefix.cd("Resources/r2"); // Contents/Resources/r2 - auto sleighHome = r2prefix; - sleighHome.cd("share/radare2/plugins/r2ghidra_sleigh"); // Contents/Resources/r2/share/radare2/plugins/r2ghidra_sleigh - Core()->setConfig("r2ghidra.sleighhome", sleighHome.absolutePath()); + auto sleighHome = rzprefix; + sleighHome.cd("share/radare2/plugins/rz_ghidra_sleigh"); // Contents/Resources/r2/share/radare2/plugins/rz_ghidra_sleigh + Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath()); - auto r2decHome = r2prefix; + auto r2decHome = rzprefix; r2decHome.cd("share/radare2/plugins/r2dec-js"); // Contents/Resources/r2/share/radare2/plugins/r2dec-js qputenv("R2DEC_HOME", r2decHome.absolutePath().toLocal8Bit()); } @@ -182,8 +182,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc #ifdef Q_OS_WIN { auto sleighHome = QDir(QCoreApplication::applicationDirPath()); - sleighHome.cd("lib/plugins/r2ghidra_sleigh"); - Core()->setConfig("r2ghidra.sleighhome", sleighHome.absolutePath()); + sleighHome.cd("lib/plugins/rz_ghidra_sleigh"); + Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath()); } #endif } diff --git a/src/Main.cpp b/src/Main.cpp index 2cae89f4..a0af5d5c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) qRegisterMetaType>(); qRegisterMetaType>(); - QCoreApplication::setOrganizationName("RadareOrg"); + QCoreApplication::setOrganizationName("RizinOrg"); QCoreApplication::setApplicationName("Cutter"); Cutter::initializeSettings(); diff --git a/src/cmake/BundledRadare2.cmake b/src/cmake/BundledRadare2.cmake deleted file mode 100644 index 877b6f67..00000000 --- a/src/cmake/BundledRadare2.cmake +++ /dev/null @@ -1,74 +0,0 @@ - -include(ExternalProject) - -set(RADARE2_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../radare2") -if(WIN32) - set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}") - if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/$") - endif() - set(RADARE2_INSTALL_BINPATH ".") - set(MESON_OPTIONS "--prefix=${RADARE2_INSTALL_DIR}" "--bindir=${RADARE2_INSTALL_BINPATH}" "-Dr2_incdir=include/libr") -else() - set(RADARE2_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/Radare2-prefix") - set(MESON_OPTIONS "--prefix=${RADARE2_INSTALL_DIR}" --libdir=lib) -endif() - -find_program(MESON meson) -if(NOT MESON) - message(FATAL_ERROR "Failed to find meson, which is required to build bundled radare2") -endif() - -find_program(NINJA ninja) -if(NOT NINJA) - message(FATAL_ERROR "Failed to find ninja, which is required to build bundled radare2") -endif() - -ExternalProject_Add(Radare2-Bundled - SOURCE_DIR "${RADARE2_SOURCE_DIR}" - CONFIGURE_COMMAND "${MESON}" "" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS} --buildtype "$<$:debug>$<$>:release>" - BUILD_COMMAND "${NINJA}" - INSTALL_COMMAND "${NINJA}" install) - -set(Radare2_INCLUDE_DIRS "${RADARE2_INSTALL_DIR}/include/libr" "${RADARE2_INSTALL_DIR}/include/libr/sdb") - -add_library(Radare2 INTERFACE) -add_dependencies(Radare2 Radare2-Bundled) -if(NOT (${CMAKE_VERSION} VERSION_LESS "3.13.0")) - target_link_directories(Radare2 INTERFACE - $ - $) -else() - link_directories("${RADARE2_INSTALL_DIR}/lib") -endif() - -set (R2_LIBS r_core r_config r_cons r_io r_util r_flag r_asm r_debug - r_hash r_bin r_lang r_io r_anal r_parse r_bp r_egg r_reg - r_search r_syscall r_socket r_fs r_magic r_crypto) -set (R2_EXTRA_LIBS r_main) -set (R2_BIN r2agent rabin2 radare2 radiff2 rafind2 ragg2 rahash2 rarun2 rasm2 rax2) - -target_link_libraries(Radare2 INTERFACE - ${R2_LIBS}) -target_include_directories(Radare2 INTERFACE - "$" - "$") - -install(TARGETS Radare2 EXPORT CutterTargets) -if (APPLE) -elseif (WIN32) - foreach(_lib ${R2_LIBS} ${R2_EXTRA_LIBS}) - install(FILES "${RADARE2_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_lib}.dll" DESTINATION "${CMAKE_INSTALL_BINDIR}") - endforeach() - foreach(_exe ${R2_BIN}) - install(FILES "${RADARE2_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_exe}.exe" DESTINATION "${CMAKE_INSTALL_BINDIR}") - endforeach() - install(DIRECTORY "${RADARE2_INSTALL_DIR}/share" DESTINATION ".") - install(DIRECTORY "${RADARE2_INSTALL_DIR}/include" DESTINATION "." - COMPONENT Devel) - install(DIRECTORY "${RADARE2_INSTALL_DIR}/lib" DESTINATION "." - COMPONENT Devel - PATTERN "*.pdb" EXCLUDE) -else () - install(DIRECTORY "${RADARE2_INSTALL_DIR}/" DESTINATION ".") -endif() diff --git a/src/cmake/BundledRizin.cmake b/src/cmake/BundledRizin.cmake new file mode 100644 index 00000000..18e3a6bc --- /dev/null +++ b/src/cmake/BundledRizin.cmake @@ -0,0 +1,74 @@ + +include(ExternalProject) + +set(RIZIN_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rizin") +if(WIN32) + set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}") + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/$") + endif() + set(RIZIN_INSTALL_BINPATH ".") + set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" "--bindir=${RIZIN_INSTALL_BINPATH}" "-Dr2_incdir=include/librz") +else() + set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/Rizin-prefix") + set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" --libdir=lib) +endif() + +find_program(MESON meson) +if(NOT MESON) + message(FATAL_ERROR "Failed to find meson, which is required to build bundled rizin") +endif() + +find_program(NINJA ninja) +if(NOT NINJA) + message(FATAL_ERROR "Failed to find ninja, which is required to build bundled rizin") +endif() + +ExternalProject_Add(Rizin-Bundled + SOURCE_DIR "${RIZIN_SOURCE_DIR}" + CONFIGURE_COMMAND "${MESON}" "" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS} --buildtype "$<$:debug>$<$>:release>" + BUILD_COMMAND "${NINJA}" + INSTALL_COMMAND "${NINJA}" install) + +set(Rizin_INCLUDE_DIRS "${RIZIN_INSTALL_DIR}/include/librz" "${RIZIN_INSTALL_DIR}/include/librz/sdb") + +add_library(Rizin INTERFACE) +add_dependencies(Rizin Rizin-Bundled) +if(NOT (${CMAKE_VERSION} VERSION_LESS "3.13.0")) + target_link_directories(Rizin INTERFACE + $ + $) +else() + link_directories("${RIZIN_INSTALL_DIR}/lib") +endif() + +set (R2_LIBS rz_core rz_config rz_cons rz_io rz_util rz_flag rz_asm rz_debug + rz_hash rz_bin rz_lang rz_io rz_anal rz_parse rz_bp rz_egg rz_reg + rz_search rz_syscall rz_socket rz_magic rz_crypto) +set (R2_EXTRA_LIBS rz_main) +set (R2_BIN r2agent rabin2 rizin radiff2 rafind2 ragg2 rahash2 rarun2 rasm2 rax2) + +target_link_libraries(Rizin INTERFACE + ${R2_LIBS}) +target_include_directories(Rizin INTERFACE + "$" + "$") + +install(TARGETS Rizin EXPORT CutterTargets) +if (APPLE) +elseif (WIN32) + foreach(_lib ${R2_LIBS} ${R2_EXTRA_LIBS}) + install(FILES "${RIZIN_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_lib}.dll" DESTINATION "${CMAKE_INSTALL_BINDIR}") + endforeach() + foreach(_exe ${R2_BIN}) + install(FILES "${RIZIN_INSTALL_DIR}/${R2_INSTALL_BINPATH}/${_exe}.exe" DESTINATION "${CMAKE_INSTALL_BINDIR}") + endforeach() + install(DIRECTORY "${RIZIN_INSTALL_DIR}/share" DESTINATION ".") + install(DIRECTORY "${RIZIN_INSTALL_DIR}/include" DESTINATION "." + COMPONENT Devel) + install(DIRECTORY "${RIZIN_INSTALL_DIR}/lib" DESTINATION "." + COMPONENT Devel + PATTERN "*.pdb" EXCLUDE) +else () + install(DIRECTORY "${RIZIN_INSTALL_DIR}/" DESTINATION ".") +endif() diff --git a/src/cmake/CutterInstallDirs.cmake b/src/cmake/CutterInstallDirs.cmake index 276fe36c..52328b8c 100644 --- a/src/cmake/CutterInstallDirs.cmake +++ b/src/cmake/CutterInstallDirs.cmake @@ -1,4 +1,4 @@ -set(CUTTER_DIR_NAME "RadareOrg/Cutter") +set(CUTTER_DIR_NAME "RizinOrg/Cutter") if(WIN32) set(CMAKE_INSTALL_BINDIR "." CACHE PATH "Executable install directory") set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "Include install directory") diff --git a/src/cmake/FindRadare2.cmake b/src/cmake/FindRadare2.cmake deleted file mode 100644 index 19b92e4d..00000000 --- a/src/cmake/FindRadare2.cmake +++ /dev/null @@ -1,117 +0,0 @@ -# - Find Radare2 (libr) -# -# This module provides the following imported targets, if found: -# -# Radare2::libr -# -# This will define the following variables: -# (but don't use them if you don't know what you are doing, use Radare2::libr) -# -# Radare2_FOUND - True if libr has been found. -# Radare2_INCLUDE_DIRS - libr include directory -# Radare2_LIBRARIES - List of libraries when using libr. -# Radare2_LIBRARY_DIRS - libr library directories -# -# If libr was found using find_library and not pkg-config, the following variables will also be set: -# Radare2_LIBRARY_ - Path to library r_ - -if(WIN32) - find_path(Radare2_INCLUDE_DIRS - NAMES r_core.h r_bin.h r_util.h - HINTS - "$ENV{HOME}/bin/prefix/radare2/include/libr" - /usr/local/include/libr - /usr/include/libr) - find_path(SDB_INCLUDE_DIR - NAMES sdb.h sdbht.h sdb_version.h - HINTS - "$ENV{HOME}/bin/prefix/radare2/include/libr/sdb" - /usr/local/include/libr/sdb - /usr/include/libr/sdb) - - list(APPEND Radare2_INCLUDE_DIRS ${SDB_INCLUDE_DIR}) - - set(Radare2_LIBRARY_NAMES - core - config - cons - io - util - flag - asm - debug - hash - bin - lang - io - anal - parse - bp - egg - reg - search - syscall - socket - fs - magic - crypto) - - set(Radare2_LIBRARIES "") - set(Radare2_LIBRARIES_VARS "") - foreach(libname ${Radare2_LIBRARY_NAMES}) - find_library(Radare2_LIBRARY_${libname} - r_${libname} - HINTS - "$ENV{HOME}/bin/prefix/radare2/lib" - /usr/local/lib - /usr/lib) - - list(APPEND Radare2_LIBRARIES ${Radare2_LIBRARY_${libname}}) - list(APPEND Radare2_LIBRARIES_VARS "Radare2_LIBRARY_${libname}") - endforeach() - - set(Radare2_LIBRARY_DIRS "") - - add_library(Radare2::libr UNKNOWN IMPORTED) - set_target_properties(Radare2::libr PROPERTIES - IMPORTED_LOCATION "${Radare2_LIBRARY_core}" - IMPORTED_LINK_INTERFACE_LIBRARIES "${Radare2_LIBRARIES}" - INTERFACE_LINK_DIRECTORIES "${Radare2_LIBRARY_DIRS}" - INTERFACE_INCLUDE_DIRECTORIES "${Radare2_INCLUDE_DIRS}") - set(Radare2_TARGET Radare2::libr) -else() - # support installation locations used by r2 scripts like sys/user.sh and sys/install.sh - if(CUTTER_USE_ADDITIONAL_RADARE2_PATHS) - set(Radare2_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH}) - list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/radare2") # sys/user.sh - list(APPEND CMAKE_PREFIX_PATH "/usr/local") # sys/install.sh - endif() - - find_package(PkgConfig REQUIRED) - if(CMAKE_VERSION VERSION_LESS "3.6") - pkg_search_module(Radare2 REQUIRED r_core) - else() - pkg_search_module(Radare2 IMPORTED_TARGET REQUIRED r_core) - endif() - - # reset CMAKE_PREFIX_PATH - if(CUTTER_USE_ADDITIONAL_RADARE2_PATHS) - set(CMAKE_PREFIX_PATH ${Radare2_CMAKE_PREFIX_PATH_TEMP}) - endif() - - if((TARGET PkgConfig::Radare2) AND (NOT CMAKE_VERSION VERSION_LESS "3.11.0")) - set_target_properties(PkgConfig::Radare2 PROPERTIES IMPORTED_GLOBAL ON) - add_library(Radare2::libr ALIAS PkgConfig::Radare2) - set(Radare2_TARGET Radare2::libr) - elseif(Radare2_FOUND) - add_library(Radare2::libr INTERFACE IMPORTED) - set_target_properties(Radare2::libr PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Radare2_INCLUDE_DIRS}") - set_target_properties(Radare2::libr PROPERTIES - INTERFACE_LINK_LIBRARIES "${Radare2_LIBRARIES}") - set(Radare2_TARGET Radare2::libr) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Radare2 REQUIRED_VARS Radare2_TARGET Radare2_LIBRARIES Radare2_INCLUDE_DIRS) diff --git a/src/cmake/FindRizin.cmake b/src/cmake/FindRizin.cmake new file mode 100644 index 00000000..b3eb0f12 --- /dev/null +++ b/src/cmake/FindRizin.cmake @@ -0,0 +1,116 @@ +# - Find Rizin (librz) +# +# This module provides the following imported targets, if found: +# +# Rizin::librz +# +# This will define the following variables: +# (but don't use them if you don't know what you are doing, use Rizin::librz) +# +# Rizin_FOUND - True if librz has been found. +# Rizin_INCLUDE_DIRS - librz include directory +# Rizin_LIBRARIES - List of libraries when using librz. +# Rizin_LIBRARY_DIRS - librz library directories +# +# If librz was found using find_library and not pkg-config, the following variables will also be set: +# Rizin_LIBRARY_ - Path to library rz_ + +if(WIN32) + find_path(Rizin_INCLUDE_DIRS + NAMES rz_core.h rz_bin.h rz_util.h + HINTS + "$ENV{HOME}/bin/prefix/rizin/include/librz" + /usr/local/include/libr + /usr/include/librz) + find_path(SDB_INCLUDE_DIR + NAMES sdb.h sdbht.h sdb_version.h + HINTS + "$ENV{HOME}/bin/prefix/rizin/include/librz/sdb" + /usr/local/include/librz/sdb + /usr/include/librz/sdb) + + list(APPEND Rizin_INCLUDE_DIRS ${SDB_INCLUDE_DIR}) + + set(Rizin_LIBRARY_NAMES + core + config + cons + io + util + flag + asm + debug + hash + bin + lang + io + anal + parse + bp + egg + reg + search + syscall + socket + magic + crypto) + + set(Rizin_LIBRARIES "") + set(Rizin_LIBRARIES_VARS "") + foreach(libname ${Rizin_LIBRARY_NAMES}) + find_library(Rizin_LIBRARY_${libname} + r_${libname} + HINTS + "$ENV{HOME}/bin/prefix/rizin/lib" + /usr/local/lib + /usr/lib) + + list(APPEND Rizin_LIBRARIES ${Rizin_LIBRARY_${libname}}) + list(APPEND Rizin_LIBRARIES_VARS "Rizin_LIBRARY_${libname}") + endforeach() + + set(Rizin_LIBRARY_DIRS "") + + add_library(Rizin::librz UNKNOWN IMPORTED) + set_target_properties(Rizin::librz PROPERTIES + IMPORTED_LOCATION "${Rizin_LIBRARY_core}" + IMPORTED_LINK_INTERFACE_LIBRARIES "${Rizin_LIBRARIES}" + INTERFACE_LINK_DIRECTORIES "${Rizin_LIBRARY_DIRS}" + INTERFACE_INCLUDE_DIRECTORIES "${Rizin_INCLUDE_DIRS}") + set(Rizin_TARGET Rizin::librz) +else() + # support installation locations used by r2 scripts like sys/user.sh and sys/install.sh + if(CUTTER_USE_ADDITIONAL_RIZIN_PATHS) + set(Rizin_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH}) + list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/bin/prefix/rizin") # sys/user.sh + list(APPEND CMAKE_PREFIX_PATH "/usr/local") # sys/install.sh + endif() + + find_package(PkgConfig REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.6") + pkg_search_module(Rizin REQUIRED rz_core) + else() + pkg_search_module(Rizin IMPORTED_TARGET REQUIRED rz_core) + endif() + + # reset CMAKE_PREFIX_PATH + if(CUTTER_USE_ADDITIONAL_RIZIN_PATHS) + set(CMAKE_PREFIX_PATH ${Rizin_CMAKE_PREFIX_PATH_TEMP}) + endif() + + if((TARGET PkgConfig::Rizin) AND (NOT CMAKE_VERSION VERSION_LESS "3.11.0")) + set_target_properties(PkgConfig::Rizin PROPERTIES IMPORTED_GLOBAL ON) + add_library(Rizin::librz ALIAS PkgConfig::Rizin) + set(Rizin_TARGET Rizin::librz) + elseif(Rizin_FOUND) + add_library(Rizin::librz INTERFACE IMPORTED) + set_target_properties(Rizin::librz PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Rizin_INCLUDE_DIRS}") + set_target_properties(Rizin::librz PROPERTIES + INTERFACE_LINK_LIBRARIES "${Rizin_LIBRARIES}") + set(Rizin_TARGET Rizin::librz) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Rizin REQUIRED_VARS Rizin_TARGET Rizin_LIBRARIES Rizin_INCLUDE_DIRS) diff --git a/src/common/AnalTask.cpp b/src/common/AnalTask.cpp index 5cbf7e53..b4263b22 100644 --- a/src/common/AnalTask.cpp +++ b/src/common/AnalTask.cpp @@ -18,7 +18,7 @@ AnalTask::~AnalTask() void AnalTask::interrupt() { AsyncTask::interrupt(); - r_cons_singleton()->context->breaked = true; + rz_cons_singleton()->context->breaked = true; } QString AnalTask::getTitle() { @@ -32,9 +32,9 @@ QString AnalTask::getTitle() { void AnalTask::runTask() { - int perms = R_PERM_RX; + int perms = RZ_PERM_RX; if (options.writeEnabled) { - perms |= R_PERM_W; + perms |= RZ_PERM_W; emit Core()->ioModeChanged(); } @@ -63,7 +63,7 @@ void AnalTask::runTask() } } - // r_core_bin_load might change asm.bits, so let's set that after the bin is loaded + // rz_core_bin_load might change asm.bits, so let's set that after the bin is loaded Core()->setCPU(options.arch, options.cpu, options.bits); if (isInterrupted()) { @@ -103,9 +103,6 @@ void AnalTask::runTask() return; } - // Use prj.simple as default as long as regular projects are broken - Core()->setConfig("prj.simple", true); - if (!options.analCmd.empty()) { log(tr("Executing analysis...")); for (const CommandDescription &cmd : options.analCmd) { diff --git a/src/common/ColorThemeWorker.cpp b/src/common/ColorThemeWorker.cpp index c0484343..af300381 100644 --- a/src/common/ColorThemeWorker.cpp +++ b/src/common/ColorThemeWorker.cpp @@ -59,17 +59,17 @@ const QStringList ColorThemeWorker::radare2UnusedOptions = { ColorThemeWorker::ColorThemeWorker(QObject *parent) : QObject (parent) { - char* szThemes = r_str_home(R2_HOME_THEMES); + char* szThemes = rz_str_home(RZ_HOME_THEMES); customR2ThemesLocationPath = szThemes; - r_mem_free(szThemes); + rz_mem_free(szThemes); if (!QDir(customR2ThemesLocationPath).exists()) { QDir().mkpath(customR2ThemesLocationPath); } QDir currDir { QStringLiteral("%1%2%3") - .arg(r_sys_prefix(nullptr)) - .arg(R_SYS_DIR) - .arg(R2_THEMES) + .arg(rz_sys_prefix(nullptr)) + .arg(RZ_SYS_DIR) + .arg(RZ_THEMES) }; if (currDir.exists()) { standardR2ThemesLocationPath = currDir.absolutePath(); diff --git a/src/common/Colors.cpp b/src/common/Colors.cpp index 62a922ad..3c479a09 100644 --- a/src/common/Colors.cpp +++ b/src/common/Colors.cpp @@ -22,81 +22,81 @@ void Colors::colorizeAssembly(RichTextPainter::List &list, QString opcode, ut64 } // Temporary solution -// Copied from R_API const char* r_print_color_op_type(RPrint *p, ut64 anal_type) { +// Copied from RZ_API const char* r_print_color_op_type(RPrint *p, ut64 anal_type) { QString Colors::getColor(ut64 type) { - switch (type & R_ANAL_OP_TYPE_MASK) { - case R_ANAL_OP_TYPE_NOP: + switch (type & RZ_ANAL_OP_TYPE_MASK) { + case RZ_ANAL_OP_TYPE_NOP: return "nop"; - case R_ANAL_OP_TYPE_ADD: - case R_ANAL_OP_TYPE_SUB: - case R_ANAL_OP_TYPE_MUL: - case R_ANAL_OP_TYPE_DIV: - case R_ANAL_OP_TYPE_MOD: - case R_ANAL_OP_TYPE_LENGTH: + case RZ_ANAL_OP_TYPE_ADD: + case RZ_ANAL_OP_TYPE_SUB: + case RZ_ANAL_OP_TYPE_MUL: + case RZ_ANAL_OP_TYPE_DIV: + case RZ_ANAL_OP_TYPE_MOD: + case RZ_ANAL_OP_TYPE_LENGTH: return "math"; - case R_ANAL_OP_TYPE_AND: - case R_ANAL_OP_TYPE_OR: - case R_ANAL_OP_TYPE_XOR: - case R_ANAL_OP_TYPE_NOT: - case R_ANAL_OP_TYPE_SHL: - case R_ANAL_OP_TYPE_SAL: - case R_ANAL_OP_TYPE_SAR: - case R_ANAL_OP_TYPE_SHR: - case R_ANAL_OP_TYPE_ROL: - case R_ANAL_OP_TYPE_ROR: - case R_ANAL_OP_TYPE_CPL: + case RZ_ANAL_OP_TYPE_AND: + case RZ_ANAL_OP_TYPE_OR: + case RZ_ANAL_OP_TYPE_XOR: + case RZ_ANAL_OP_TYPE_NOT: + case RZ_ANAL_OP_TYPE_SHL: + case RZ_ANAL_OP_TYPE_SAL: + case RZ_ANAL_OP_TYPE_SAR: + case RZ_ANAL_OP_TYPE_SHR: + case RZ_ANAL_OP_TYPE_ROL: + case RZ_ANAL_OP_TYPE_ROR: + case RZ_ANAL_OP_TYPE_CPL: return "bin"; - case R_ANAL_OP_TYPE_IO: + case RZ_ANAL_OP_TYPE_IO: return "swi"; - case R_ANAL_OP_TYPE_JMP: - case R_ANAL_OP_TYPE_UJMP: - case R_ANAL_OP_TYPE_IJMP: - case R_ANAL_OP_TYPE_RJMP: - case R_ANAL_OP_TYPE_IRJMP: - case R_ANAL_OP_TYPE_MJMP: + case RZ_ANAL_OP_TYPE_JMP: + case RZ_ANAL_OP_TYPE_UJMP: + case RZ_ANAL_OP_TYPE_IJMP: + case RZ_ANAL_OP_TYPE_RJMP: + case RZ_ANAL_OP_TYPE_IRJMP: + case RZ_ANAL_OP_TYPE_MJMP: return "jmp"; - case R_ANAL_OP_TYPE_CJMP: - case R_ANAL_OP_TYPE_UCJMP: - case R_ANAL_OP_TYPE_SWITCH: + case RZ_ANAL_OP_TYPE_CJMP: + case RZ_ANAL_OP_TYPE_UCJMP: + case RZ_ANAL_OP_TYPE_SWITCH: return "cjmp"; - case R_ANAL_OP_TYPE_CMP: - case R_ANAL_OP_TYPE_ACMP: + case RZ_ANAL_OP_TYPE_CMP: + case RZ_ANAL_OP_TYPE_ACMP: return "cmp"; - case R_ANAL_OP_TYPE_UCALL: - case R_ANAL_OP_TYPE_ICALL: - case R_ANAL_OP_TYPE_RCALL: - case R_ANAL_OP_TYPE_IRCALL: - case R_ANAL_OP_TYPE_UCCALL: - case R_ANAL_OP_TYPE_CALL: - case R_ANAL_OP_TYPE_CCALL: + case RZ_ANAL_OP_TYPE_UCALL: + case RZ_ANAL_OP_TYPE_ICALL: + case RZ_ANAL_OP_TYPE_RCALL: + case RZ_ANAL_OP_TYPE_IRCALL: + case RZ_ANAL_OP_TYPE_UCCALL: + case RZ_ANAL_OP_TYPE_CALL: + case RZ_ANAL_OP_TYPE_CCALL: return "call"; - case R_ANAL_OP_TYPE_NEW: - case R_ANAL_OP_TYPE_SWI: + case RZ_ANAL_OP_TYPE_NEW: + case RZ_ANAL_OP_TYPE_SWI: return "swi"; - case R_ANAL_OP_TYPE_ILL: - case R_ANAL_OP_TYPE_TRAP: + case RZ_ANAL_OP_TYPE_ILL: + case RZ_ANAL_OP_TYPE_TRAP: return "trap"; - case R_ANAL_OP_TYPE_CRET: - case R_ANAL_OP_TYPE_RET: + case RZ_ANAL_OP_TYPE_CRET: + case RZ_ANAL_OP_TYPE_RET: return "ret"; - case R_ANAL_OP_TYPE_CAST: - case R_ANAL_OP_TYPE_MOV: - case R_ANAL_OP_TYPE_LEA: - case R_ANAL_OP_TYPE_CMOV: // TODO: add cmov cathegory? + case RZ_ANAL_OP_TYPE_CAST: + case RZ_ANAL_OP_TYPE_MOV: + case RZ_ANAL_OP_TYPE_LEA: + case RZ_ANAL_OP_TYPE_CMOV: // TODO: add cmov cathegory? return "mov"; - case R_ANAL_OP_TYPE_PUSH: - case R_ANAL_OP_TYPE_UPUSH: - case R_ANAL_OP_TYPE_LOAD: + case RZ_ANAL_OP_TYPE_PUSH: + case RZ_ANAL_OP_TYPE_UPUSH: + case RZ_ANAL_OP_TYPE_LOAD: return "push"; - case R_ANAL_OP_TYPE_POP: - case R_ANAL_OP_TYPE_STORE: + case RZ_ANAL_OP_TYPE_POP: + case RZ_ANAL_OP_TYPE_STORE: return "pop"; - case R_ANAL_OP_TYPE_CRYPTO: + case RZ_ANAL_OP_TYPE_CRYPTO: return "crypto"; - case R_ANAL_OP_TYPE_NULL: + case RZ_ANAL_OP_TYPE_NULL: return "other"; - case R_ANAL_OP_TYPE_UNK: + case RZ_ANAL_OP_TYPE_UNK: default: return "invalid"; } diff --git a/src/common/Colors.h b/src/common/Colors.h index a1572644..3d301aad 100644 --- a/src/common/Colors.h +++ b/src/common/Colors.h @@ -3,7 +3,7 @@ #include "core/Cutter.h" #include "common/RichTextPainter.h" -#include +#include class Colors { diff --git a/src/common/Configuration.cpp b/src/common/Configuration.cpp index 8ef5a63e..14ba83b1 100644 --- a/src/common/Configuration.cpp +++ b/src/common/Configuration.cpp @@ -122,7 +122,7 @@ static const QHash asmOptions = { { "asm.ucase", false }, { "asm.bb.line", false }, { "asm.capitalize", false }, - { "asm.var.sub", true }, + { "asm.sub.var", true }, { "asm.sub.varonly", true }, { "asm.tabs", 8 }, { "asm.tabs.off", 5 }, diff --git a/src/common/Decompiler.cpp b/src/common/Decompiler.cpp index 40b8a67b..208a4cf6 100644 --- a/src/common/Decompiler.cpp +++ b/src/common/Decompiler.cpp @@ -12,9 +12,9 @@ Decompiler::Decompiler(const QString &id, const QString &name, QObject *parent) { } -RAnnotatedCode *Decompiler::makeWarning(QString warningMessage){ +RzAnnotatedCode *Decompiler::makeWarning(QString warningMessage){ std::string temporary = warningMessage.toStdString(); - return r_annotated_code_new(strdup(temporary.c_str())); + return rz_annotated_code_new(strdup(temporary.c_str())); } R2DecDecompiler::R2DecDecompiler(QObject *parent) @@ -42,7 +42,7 @@ void R2DecDecompiler::decompileAt(RVA addr) emit finished(Decompiler::makeWarning(tr("Failed to parse JSON from r2dec"))); return; } - RAnnotatedCode *code = r_annotated_code_new(nullptr); + RzAnnotatedCode *code = rz_annotated_code_new(nullptr); QString codeString = ""; for (const auto &line : json["log"].toArray()) { if (!line.isString()) { @@ -57,14 +57,14 @@ void R2DecDecompiler::decompileAt(RVA addr) if (lineObject.isEmpty()) { continue; } - RCodeAnnotation annotationi = { 0 }; + RzCodeAnnotation annotationi = { 0 }; annotationi.start = codeString.length(); codeString.append(lineObject["str"].toString() + "\n"); annotationi.end = codeString.length(); bool ok; - annotationi.type = R_CODE_ANNOTATION_TYPE_OFFSET; + annotationi.type = RZ_CODE_ANNOTATION_TYPE_OFFSET; annotationi.offset.offset = lineObject["offset"].toVariant().toULongLong(&ok); - r_annotated_code_add_annotation(code, &annotationi); + rz_annotated_code_add_annotation(code, &annotationi); } for (const auto &line : json["errors"].toArray()) { diff --git a/src/common/Decompiler.h b/src/common/Decompiler.h index 5c886f9d..1d464a6f 100644 --- a/src/common/Decompiler.h +++ b/src/common/Decompiler.h @@ -3,7 +3,7 @@ #include "CutterCommon.h" #include "R2Task.h" -#include +#include #include #include @@ -23,7 +23,7 @@ public: Decompiler(const QString &id, const QString &name, QObject *parent = nullptr); virtual ~Decompiler() = default; - static RAnnotatedCode *makeWarning(QString warningMessage); + static RzAnnotatedCode *makeWarning(QString warningMessage); QString getId() const { return id; } QString getName() const { return name; } @@ -34,7 +34,7 @@ public: virtual void cancel() {} signals: - void finished(RAnnotatedCode *codeDecompiled); + void finished(RzAnnotatedCode *codeDecompiled); }; class R2DecDecompiler: public Decompiler diff --git a/src/common/DecompilerHighlighter.cpp b/src/common/DecompilerHighlighter.cpp index 1ae2f51d..9c9028a2 100644 --- a/src/common/DecompilerHighlighter.cpp +++ b/src/common/DecompilerHighlighter.cpp @@ -12,7 +12,7 @@ DecompilerHighlighter::DecompilerHighlighter(QTextDocument *parent) }); } -void DecompilerHighlighter::setAnnotations(RAnnotatedCode *code) +void DecompilerHighlighter::setAnnotations(RzAnnotatedCode *code) { this->code = code; } @@ -23,14 +23,14 @@ void DecompilerHighlighter::setupTheme() RSyntaxHighlightType type; QString name; } mapping[] = { - {R_SYNTAX_HIGHLIGHT_TYPE_KEYWORD, "pop"}, - {R_SYNTAX_HIGHLIGHT_TYPE_COMMENT, "comment"}, - {R_SYNTAX_HIGHLIGHT_TYPE_DATATYPE, "func_var_type"}, - {R_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_NAME, "fname"}, - {R_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_PARAMETER, "args"}, - {R_SYNTAX_HIGHLIGHT_TYPE_LOCAL_VARIABLE, "func_var"}, - {R_SYNTAX_HIGHLIGHT_TYPE_CONSTANT_VARIABLE, "num"}, - {R_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE, "flag"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_KEYWORD, "pop"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_COMMENT, "comment"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_DATATYPE, "func_var_type"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_NAME, "fname"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_PARAMETER, "args"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_LOCAL_VARIABLE, "func_var"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_CONSTANT_VARIABLE, "num"}, + {RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE, "flag"}, }; for (const auto &pair : mapping) { assert(pair.type < format.size()); @@ -47,11 +47,11 @@ void DecompilerHighlighter::highlightBlock(const QString &) size_t start = block.position(); size_t end = block.position() + block.length(); - std::unique_ptr annotations(r_annotated_code_annotations_range(code, start, end), &r_pvector_free); + std::unique_ptr annotations(rz_annotated_code_annotations_range(code, start, end), &rz_pvector_free); void **iter; - r_pvector_foreach(annotations.get(), iter) { - RCodeAnnotation *annotation = static_cast(*iter); - if (annotation->type != R_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT) { + rz_pvector_foreach(annotations.get(), iter) { + RzCodeAnnotation *annotation = static_cast(*iter); + if (annotation->type != RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT) { continue; } auto type = annotation->syntax_highlight.type; diff --git a/src/common/DecompilerHighlighter.h b/src/common/DecompilerHighlighter.h index eaa93a70..7ca96840 100644 --- a/src/common/DecompilerHighlighter.h +++ b/src/common/DecompilerHighlighter.h @@ -2,7 +2,7 @@ #define DECOMPILER_HIGHLIGHTER_H #include "CutterCommon.h" -#include +#include #include #include #include @@ -28,7 +28,7 @@ public: * * @param code */ - void setAnnotations(RAnnotatedCode *code); + void setAnnotations(RzAnnotatedCode *code); protected: void highlightBlock(const QString &text) override; @@ -36,9 +36,9 @@ protected: private: void setupTheme(); - static const int HIGHLIGHT_COUNT = R_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE + 1; + static const int HIGHLIGHT_COUNT = RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE + 1; std::array format; - RAnnotatedCode *code = nullptr; + RzAnnotatedCode *code = nullptr; }; #endif diff --git a/src/common/R2Task.cpp b/src/common/R2Task.cpp index 1ff89449..0f4571eb 100644 --- a/src/common/R2Task.cpp +++ b/src/common/R2Task.cpp @@ -3,18 +3,18 @@ R2Task::R2Task(const QString &cmd, bool transient) { - task = r_core_task_new(Core()->core(), + task = rz_core_task_new(Core()->core(), true, cmd.toLocal8Bit().constData(), - static_cast(&R2Task::taskFinishedCallback), + static_cast(&R2Task::taskFinishedCallback), this); task->transient = transient; - r_core_task_incref(task); + rz_core_task_incref(task); } R2Task::~R2Task() { - r_core_task_decref(task); + rz_core_task_decref(task); } void R2Task::taskFinishedCallback(void *user, char *) @@ -29,17 +29,17 @@ void R2Task::taskFinished() void R2Task::startTask() { - r_core_task_enqueue(&Core()->core_->tasks, task); + rz_core_task_enqueue(&Core()->core_->tasks, task); } void R2Task::breakTask() { - r_core_task_break(&Core()->core_->tasks, task->id); + rz_core_task_break(&Core()->core_->tasks, task->id); } void R2Task::joinTask() { - r_core_task_join(&Core()->core_->tasks, nullptr, task->id); + rz_core_task_join(&Core()->core_->tasks, nullptr, task->id); } QString R2Task::getResult() diff --git a/src/common/R2Task.h b/src/common/R2Task.h index f9aff2a7..1ad67584 100644 --- a/src/common/R2Task.h +++ b/src/common/R2Task.h @@ -9,7 +9,7 @@ class R2Task: public QObject Q_OBJECT private: - RCoreTask *task; + RzCoreTask *task; static void taskFinishedCallback(void *user, char *); void taskFinished(); diff --git a/src/common/RunScriptTask.cpp b/src/common/RunScriptTask.cpp index 8a2fe579..cdeb6521 100644 --- a/src/common/RunScriptTask.cpp +++ b/src/common/RunScriptTask.cpp @@ -14,7 +14,7 @@ RunScriptTask::~RunScriptTask() void RunScriptTask::interrupt() { AsyncTask::interrupt(); - r_cons_singleton()->context->breaked = true; + rz_cons_singleton()->context->breaked = true; } void RunScriptTask::runTask() diff --git a/src/common/SettingsUpgrade.cpp b/src/common/SettingsUpgrade.cpp index aa444747..ce8d0c42 100644 --- a/src/common/SettingsUpgrade.cpp +++ b/src/common/SettingsUpgrade.cpp @@ -28,7 +28,7 @@ static bool migrateSettingsPre18(QSettings &newSettings) return true; } -#define CUTTER_SETTINGS_VERSION_CURRENT 4 +#define CUTTER_SETTINGS_VERSION_CURRENT 5 #define CUTTER_SETTINGS_VERSION_KEY "version" /* @@ -103,16 +103,24 @@ static void migrateSettingsTo3(QSettings &settings) { settings.remove("unsync"); } -static void migrateSettingsTo4(QSettings &settings) { - auto renameAsmOption = [&](QString oldName, QString newName) { - if (settings.contains(oldName)) { - auto value = settings.value(oldName); - settings.remove(oldName); - settings.setValue(newName, value); - } - }; - renameAsmOption("asm.var.subonly", "asm.sub.varonly"); - renameAsmOption("asm.bytespace", "asm.bytes.space"); +static void renameAsmOption(QSettings &settings, const QString &oldName, const QString &newName) +{ + if (settings.contains(oldName)) { + auto value = settings.value(oldName); + settings.remove(oldName); + settings.setValue(newName, value); + } +} + +static void migrateSettingsTo4(QSettings &settings) +{ + renameAsmOption(settings, "asm.var.subonly", "asm.sub.varonly"); + renameAsmOption(settings, "asm.bytespace", "asm.bytes.space"); +} + +static void migrateSettingsTo5(QSettings &settings) +{ + renameAsmOption(settings, "asm.var.sub", "asm.sub.var"); } void Cutter::initializeSettings() @@ -140,6 +148,8 @@ void Cutter::initializeSettings() migrateSettingsTo3(settings); break; case 4: migrateSettingsTo4(settings); break; + case 5: + migrateSettingsTo5(settings); break; default: break; } diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 4ebadfec..dcd36477 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -18,113 +18,113 @@ #include "common/Json.h" #include "core/Cutter.h" #include "Decompiler.h" -#include "r_asm.h" -#include "r_cmd.h" +#include "rz_asm.h" +#include "rz_cmd.h" #include "sdb.h" Q_GLOBAL_STATIC(CutterCore, uniqueInstance) -#define R_JSON_KEY(name) static const QString name = QStringLiteral(#name) +#define RZ_JSON_KEY(name) static const QString name = QStringLiteral(#name) namespace RJsonKey { - R_JSON_KEY(addr); - R_JSON_KEY(addrs); - R_JSON_KEY(addr_end); - R_JSON_KEY(arrow); - R_JSON_KEY(baddr); - R_JSON_KEY(bind); - R_JSON_KEY(blocks); - R_JSON_KEY(blocksize); - R_JSON_KEY(bytes); - R_JSON_KEY(calltype); - R_JSON_KEY(cc); - R_JSON_KEY(classname); - R_JSON_KEY(code); - R_JSON_KEY(comment); - R_JSON_KEY(comments); - R_JSON_KEY(cost); - R_JSON_KEY(data); - R_JSON_KEY(description); - R_JSON_KEY(ebbs); - R_JSON_KEY(edges); - R_JSON_KEY(enabled); - R_JSON_KEY(entropy); - R_JSON_KEY(fcn_addr); - R_JSON_KEY(fcn_name); - R_JSON_KEY(fields); - R_JSON_KEY(file); - R_JSON_KEY(flags); - R_JSON_KEY(flagname); - R_JSON_KEY(format); - R_JSON_KEY(from); - R_JSON_KEY(functions); - R_JSON_KEY(graph); - R_JSON_KEY(haddr); - R_JSON_KEY(hw); - R_JSON_KEY(in_functions); - R_JSON_KEY(index); - R_JSON_KEY(jump); - R_JSON_KEY(laddr); - R_JSON_KEY(lang); - R_JSON_KEY(len); - R_JSON_KEY(length); - R_JSON_KEY(license); - R_JSON_KEY(methods); - R_JSON_KEY(name); - R_JSON_KEY(realname); - R_JSON_KEY(nargs); - R_JSON_KEY(nbbs); - R_JSON_KEY(nlocals); - R_JSON_KEY(offset); - R_JSON_KEY(opcode); - R_JSON_KEY(opcodes); - R_JSON_KEY(ordinal); - R_JSON_KEY(libname); - R_JSON_KEY(outdegree); - R_JSON_KEY(paddr); - R_JSON_KEY(path); - R_JSON_KEY(perm); - R_JSON_KEY(pid); - R_JSON_KEY(plt); - R_JSON_KEY(prot); - R_JSON_KEY(ref); - R_JSON_KEY(refs); - R_JSON_KEY(reg); - R_JSON_KEY(rwx); - R_JSON_KEY(section); - R_JSON_KEY(sections); - R_JSON_KEY(size); - R_JSON_KEY(stackframe); - R_JSON_KEY(status); - R_JSON_KEY(string); - R_JSON_KEY(strings); - R_JSON_KEY(symbols); - R_JSON_KEY(text); - R_JSON_KEY(to); - R_JSON_KEY(trace); - R_JSON_KEY(type); - R_JSON_KEY(uid); - R_JSON_KEY(vaddr); - R_JSON_KEY(value); - R_JSON_KEY(vsize); + RZ_JSON_KEY(addr); + RZ_JSON_KEY(addrs); + RZ_JSON_KEY(addr_end); + RZ_JSON_KEY(arrow); + RZ_JSON_KEY(baddr); + RZ_JSON_KEY(bind); + RZ_JSON_KEY(blocks); + RZ_JSON_KEY(blocksize); + RZ_JSON_KEY(bytes); + RZ_JSON_KEY(calltype); + RZ_JSON_KEY(cc); + RZ_JSON_KEY(classname); + RZ_JSON_KEY(code); + RZ_JSON_KEY(comment); + RZ_JSON_KEY(comments); + RZ_JSON_KEY(cost); + RZ_JSON_KEY(data); + RZ_JSON_KEY(description); + RZ_JSON_KEY(ebbs); + RZ_JSON_KEY(edges); + RZ_JSON_KEY(enabled); + RZ_JSON_KEY(entropy); + RZ_JSON_KEY(fcn_addr); + RZ_JSON_KEY(fcn_name); + RZ_JSON_KEY(fields); + RZ_JSON_KEY(file); + RZ_JSON_KEY(flags); + RZ_JSON_KEY(flagname); + RZ_JSON_KEY(format); + RZ_JSON_KEY(from); + RZ_JSON_KEY(functions); + RZ_JSON_KEY(graph); + RZ_JSON_KEY(haddr); + RZ_JSON_KEY(hw); + RZ_JSON_KEY(in_functions); + RZ_JSON_KEY(index); + RZ_JSON_KEY(jump); + RZ_JSON_KEY(laddr); + RZ_JSON_KEY(lang); + RZ_JSON_KEY(len); + RZ_JSON_KEY(length); + RZ_JSON_KEY(license); + RZ_JSON_KEY(methods); + RZ_JSON_KEY(name); + RZ_JSON_KEY(realname); + RZ_JSON_KEY(nargs); + RZ_JSON_KEY(nbbs); + RZ_JSON_KEY(nlocals); + RZ_JSON_KEY(offset); + RZ_JSON_KEY(opcode); + RZ_JSON_KEY(opcodes); + RZ_JSON_KEY(ordinal); + RZ_JSON_KEY(libname); + RZ_JSON_KEY(outdegree); + RZ_JSON_KEY(paddr); + RZ_JSON_KEY(path); + RZ_JSON_KEY(perm); + RZ_JSON_KEY(pid); + RZ_JSON_KEY(plt); + RZ_JSON_KEY(prot); + RZ_JSON_KEY(ref); + RZ_JSON_KEY(refs); + RZ_JSON_KEY(reg); + RZ_JSON_KEY(rwx); + RZ_JSON_KEY(section); + RZ_JSON_KEY(sections); + RZ_JSON_KEY(size); + RZ_JSON_KEY(stackframe); + RZ_JSON_KEY(status); + RZ_JSON_KEY(string); + RZ_JSON_KEY(strings); + RZ_JSON_KEY(symbols); + RZ_JSON_KEY(text); + RZ_JSON_KEY(to); + RZ_JSON_KEY(trace); + RZ_JSON_KEY(type); + RZ_JSON_KEY(uid); + RZ_JSON_KEY(vaddr); + RZ_JSON_KEY(value); + RZ_JSON_KEY(vsize); } -#undef R_JSON_KEY +#undef RZ_JSON_KEY static void updateOwnedCharPtr(char *&variable, const QString &newValue) { auto data = newValue.toUtf8(); - R_FREE(variable) + RZ_FREE(variable) variable = strdup(data.data()); } static QString fromOwnedCharPtr(char *str) { QString result(str ? str : ""); - r_mem_free(str); + rz_mem_free(str); return result; } -RCoreLocked::RCoreLocked(CutterCore *core) +RzCoreLocked::RzCoreLocked(CutterCore *core) : core(core) { core->coreMutex.lock(); @@ -132,34 +132,34 @@ RCoreLocked::RCoreLocked(CutterCore *core) core->coreLockDepth++; if (core->coreLockDepth == 1) { assert(core->coreBed); - r_cons_sleep_end(core->coreBed); + rz_cons_sleep_end(core->coreBed); core->coreBed = nullptr; } } -RCoreLocked::~RCoreLocked() +RzCoreLocked::~RzCoreLocked() { assert(core->coreLockDepth > 0); core->coreLockDepth--; if (core->coreLockDepth == 0) { - core->coreBed = r_cons_sleep_begin(); + core->coreBed = rz_cons_sleep_begin(); } core->coreMutex.unlock(); } -RCoreLocked::operator RCore *() const +RzCoreLocked::operator RzCore *() const { return core->core_; } -RCore *RCoreLocked::operator->() const +RzCore *RzCoreLocked::operator->() const { return core->core_; } -#define CORE_LOCK() RCoreLocked core(this) +#define CORE_LOCK() RzCoreLocked core(this) -static void cutterREventCallback(REvent *, int type, void *user, void *data) +static void cutterREventCallback(RzEvent *, int type, void *user, void *data) { auto core = reinterpret_cast(user); core->handleREvent(type, data); @@ -180,13 +180,13 @@ CutterCore *CutterCore::instance() void CutterCore::initialize(bool loadPlugins) { - r_cons_new(); // initialize console - core_ = r_core_new(); - r_core_task_sync_begin(&core_->tasks); - coreBed = r_cons_sleep_begin(); + rz_cons_new(); // initialize console + core_ = rz_core_new(); + rz_core_task_sync_begin(&core_->tasks); + coreBed = rz_cons_sleep_begin(); CORE_LOCK(); - r_event_hook(core_->anal->ev, R_EVENT_ALL, cutterREventCallback, this); + rz_event_hook(core_->anal->ev, RZ_EVENT_ALL, cutterREventCallback, this); #if defined(APPIMAGE) || defined(MACOS_R2_BUNDLED) auto prefix = QDir(QCoreApplication::applicationDirPath()); @@ -216,9 +216,9 @@ void CutterCore::initialize(bool loadPlugins) setConfig("cfg.plugins", 0); } if (getConfigi("cfg.plugins")) { - r_core_loadlibs(this->core_, R_CORE_LOADLIBS_ALL, nullptr); + rz_core_loadlibs(this->core_, RZ_CORE_LOADLIBS_ALL, nullptr); } - // IMPLICIT r_bin_iobind (core_->bin, core_->io); + // IMPLICIT rz_bin_iobind (core_->bin, core_->io); // Otherwise r2 may ask the user for input and Cutter would freeze setConfig("scr.interactive", false); @@ -233,15 +233,15 @@ void CutterCore::initialize(bool loadPlugins) CutterCore::~CutterCore() { delete bbHighlighter; - r_cons_sleep_end(coreBed); - r_core_task_sync_end(&core_->tasks); - r_core_free(this->core_); - r_cons_free(); + rz_cons_sleep_end(coreBed); + rz_core_task_sync_end(&core_->tasks); + rz_core_free(this->core_); + rz_cons_free(); } -RCoreLocked CutterCore::core() +RzCoreLocked CutterCore::core() { - return RCoreLocked(this); + return RzCoreLocked(this); } QDir CutterCore::getCutterRCDefaultDirectory() const @@ -271,7 +271,7 @@ void CutterCore::loadCutterRC() continue; } qInfo() << "Loading initialization file from " << cutterRCFilePath; - r_core_cmd_file(core, cutterRCFilePath.toUtf8().constData()); + rz_core_cmd_file(core, cutterRCFilePath.toUtf8().constData()); } } @@ -284,7 +284,7 @@ void CutterCore::loadDefaultCutterRC() return; } qInfo() << "Loading initialization file from " << cutterRCFilePath; - r_core_cmd_file(core, cutterRCFilePath.toUtf8().constData()); + rz_core_cmd_file(core, cutterRCFilePath.toUtf8().constData()); } @@ -358,7 +358,7 @@ QString CutterCore::cmd(const char *str) CORE_LOCK(); RVA offset = core->offset; - char *res = r_core_cmd_str(core, str); + char *res = rz_core_cmd_str(core, str); QString o = fromOwnedCharPtr(res); if (offset != core->offset) { @@ -451,17 +451,17 @@ QString CutterCore::cmdRaw(const char *cmd) { QString res; CORE_LOCK(); - r_cons_push (); + rz_cons_push (); - // r_cmd_call does not return the output of the command - r_cmd_call(core->rcmd, cmd); + // rz_cmd_call does not return the output of the command + rz_cmd_call(core->rcmd, cmd); - // we grab the output straight from r_cons - res = r_cons_get_buffer(); + // we grab the output straight from rz_cons + res = rz_cons_get_buffer(); // cleaning up - r_cons_pop (); - r_cons_echo (NULL); + rz_cons_pop (); + rz_cons_echo (NULL); return res; } @@ -471,11 +471,11 @@ QJsonDocument CutterCore::cmdj(const char *str) char *res; { CORE_LOCK(); - res = r_core_cmd_str(core, str); + res = rz_core_cmd_str(core, str); } QJsonDocument doc = parseJson(res, str); - r_mem_free(res); + rz_mem_free(res); return doc; } @@ -539,26 +539,26 @@ QJsonDocument CutterCore::parseJson(const char *res, const char *cmd) return doc; } -QStringList CutterCore::autocomplete(const QString &cmd, RLinePromptType promptType, size_t limit) +QStringList CutterCore::autocomplete(const QString &cmd, RzLinePromptType promptType, size_t limit) { - RLineBuffer buf; + RzLineBuffer buf; int c = snprintf(buf.data, sizeof(buf.data), "%s", cmd.toUtf8().constData()); if (c < 0) { return {}; } buf.index = buf.length = std::min((int)(sizeof(buf.data) - 1), c); - RLineCompletion completion; - r_line_completion_init(&completion, limit); - r_core_autocomplete(core(), &completion, &buf, promptType); + RzLineCompletion completion; + rz_line_completion_init(&completion, limit); + rz_core_autocomplete(core(), &completion, &buf, promptType); QStringList r; - r.reserve(r_pvector_len(&completion.args)); - for (size_t i = 0; i < r_pvector_len(&completion.args); i++) { - r.push_back(QString::fromUtf8(reinterpret_cast(r_pvector_at(&completion.args, i)))); + r.reserve(rz_pvector_len(&completion.args)); + for (size_t i = 0; i < rz_pvector_len(&completion.args); i++) { + r.push_back(QString::fromUtf8(reinterpret_cast(rz_pvector_at(&completion.args, i)))); } - r_line_completion_fini(&completion); + rz_line_completion_fini(&completion); return r; } @@ -566,11 +566,11 @@ QStringList CutterCore::autocomplete(const QString &cmd, RLinePromptType promptT * @brief CutterCore::loadFile * Load initial file. TODO Maybe use the "o" commands? * @param path File path - * @param baddr Base (RBin) address + * @param baddr Base (RzBin) address * @param mapaddr Map address * @param perms * @param va - * @param loadbin Load RBin information + * @param loadbin Load RzBin information * @param forceBinPlugin * @return */ @@ -578,48 +578,48 @@ bool CutterCore::loadFile(QString path, ut64 baddr, ut64 mapaddr, int perms, int bool loadbin, const QString &forceBinPlugin) { CORE_LOCK(); - RCoreFile *f; - r_config_set_i(core->config, "io.va", va); + RzCoreFile *f; + rz_config_set_i(core->config, "io.va", va); - f = r_core_file_open(core, path.toUtf8().constData(), perms, mapaddr); + f = rz_core_file_open(core, path.toUtf8().constData(), perms, mapaddr); if (!f) { - eprintf("r_core_file_open failed\n"); + eprintf("rz_core_file_open failed\n"); return false; } if (!forceBinPlugin.isNull()) { - r_bin_force_plugin(r_core_get_bin(core), forceBinPlugin.toUtf8().constData()); + rz_bin_force_plugin(rz_core_get_bin(core), forceBinPlugin.toUtf8().constData()); } if (loadbin && va) { - if (!r_core_bin_load(core, path.toUtf8().constData(), baddr)) { + if (!rz_core_bin_load(core, path.toUtf8().constData(), baddr)) { eprintf("CANNOT GET RBIN INFO\n"); } #if HAVE_MULTIPLE_RBIN_FILES_INSIDE_SELECT_WHICH_ONE - if (!r_core_file_open(core, path.toUtf8(), R_IO_READ | (rw ? R_IO_WRITE : 0, mapaddr))) { + if (!rz_core_file_open(core, path.toUtf8(), RZ_IO_READ | (rw ? RZ_IO_WRITE : 0, mapaddr))) { eprintf("Cannot open file\n"); } else { - // load RBin information + // load RzBin information // XXX only for sub-bins - r_core_bin_load(core, path.toUtf8(), baddr); - r_bin_select_idx(core->bin, NULL, idx); + rz_core_bin_load(core, path.toUtf8(), baddr); + rz_bin_select_idx(core->bin, NULL, idx); } #endif } else { - // Not loading RBin info coz va = false + // Not loading RzBin info coz va = false } auto iod = core->io ? core->io->desc : NULL; auto debug = core->file && iod && (core->file->fd == iod->fd) && iod->plugin && \ iod->plugin->isdbg; - if (!debug && r_flag_get (core->flags, "entry0")) { - r_core_cmd0 (core, "s entry0"); + if (!debug && rz_flag_get (core->flags, "entry0")) { + rz_core_cmd0 (core, "s entry0"); } - if (perms & R_PERM_W) { - r_core_cmd0 (core, "omfg+w"); + if (perms & RZ_PERM_W) { + rz_core_cmd0 (core, "omfg+w"); } fflush(stdout); @@ -629,15 +629,15 @@ bool CutterCore::loadFile(QString path, ut64 baddr, ut64 mapaddr, int perms, int bool CutterCore::tryFile(QString path, bool rw) { CORE_LOCK(); - RCoreFile *cf; - int flags = R_PERM_R; - if (rw) flags = R_PERM_RW; - cf = r_core_file_open(core, path.toUtf8().constData(), flags, 0LL); + RzCoreFile *cf; + int flags = RZ_PERM_R; + if (rw) flags = RZ_PERM_RW; + cf = rz_core_file_open(core, path.toUtf8().constData(), flags, 0LL); if (!cf) { return false; } - r_core_file_close (core, cf); + rz_core_file_close (core, cf); return true; } @@ -653,8 +653,8 @@ bool CutterCore::mapFile(QString path, RVA mapaddr) CORE_LOCK(); RVA addr = mapaddr != RVA_INVALID ? mapaddr : 0; ut64 baddr = Core()->getFileInfo().object()["bin"].toObject()["baddr"].toVariant().toULongLong(); - if (r_core_file_open(core, path.toUtf8().constData(), R_PERM_RX, addr)) { - r_core_bin_load(core, path.toUtf8().constData(), baddr); + if (rz_core_file_open(core, path.toUtf8().constData(), RZ_PERM_RX, addr)) { + rz_core_bin_load(core, path.toUtf8().constData(), baddr); } else { return false; } @@ -682,10 +682,10 @@ void CutterCore::renameFlag(QString old_name, QString new_name) void CutterCore::renameFunctionVariable(QString newName, QString oldName, RVA functionAddress) { CORE_LOCK(); - RAnalFunction *function = r_anal_get_function_at(core->anal, functionAddress); - RAnalVar *variable = r_anal_function_get_var_byname(function, oldName.toUtf8().constData()); + RzAnalFunction *function = rz_anal_get_function_at(core->anal, functionAddress); + RzAnalVar *variable = rz_anal_function_get_var_byname(function, oldName.toUtf8().constData()); if (variable) { - r_anal_var_rename(variable, newName.toUtf8().constData(), true); + rz_anal_var_rename(variable, newName.toUtf8().constData(), true); } emit refreshCodeViews(); } @@ -832,7 +832,7 @@ void CutterCore::delComment(RVA addr) QString CutterCore::getCommentAt(RVA addr) { CORE_LOCK(); - return r_meta_get_string(core->anal, R_META_TYPE_COMMENT, addr); + return rz_meta_get_string(core->anal, RZ_META_TYPE_COMMENT, addr); } void CutterCore::setImmediateBase(const QString &r2BaseName, RVA offset) @@ -871,7 +871,7 @@ void CutterCore::seekSilent(ut64 offset) if (offset == RVA_INVALID) { return; } - r_core_seek(core, offset, true); + rz_core_seek(core, offset, true); } void CutterCore::seek(ut64 offset) @@ -969,13 +969,13 @@ RVA CutterCore::getOffset() ut64 CutterCore::math(const QString &expr) { CORE_LOCK(); - return r_num_math(core ? core->num : NULL, expr.toUtf8().constData()); + return rz_num_math(core ? core->num : NULL, expr.toUtf8().constData()); } ut64 CutterCore::num(const QString &expr) { CORE_LOCK(); - return r_num_get(core ? core->num : NULL, expr.toUtf8().constData()); + return rz_num_get(core ? core->num : NULL, expr.toUtf8().constData()); } QString CutterCore::itoa(ut64 num, int rdx) @@ -986,55 +986,55 @@ QString CutterCore::itoa(ut64 num, int rdx) void CutterCore::setConfig(const char *k, const char *v) { CORE_LOCK(); - r_config_set(core->config, k, v); + rz_config_set(core->config, k, v); } void CutterCore::setConfig(const QString &k, const char *v) { CORE_LOCK(); - r_config_set(core->config, k.toUtf8().constData(), v); + rz_config_set(core->config, k.toUtf8().constData(), v); } void CutterCore::setConfig(const char *k, const QString &v) { CORE_LOCK(); - r_config_set(core->config, k, v.toUtf8().constData()); + rz_config_set(core->config, k, v.toUtf8().constData()); } void CutterCore::setConfig(const char *k, int v) { CORE_LOCK(); - r_config_set_i(core->config, k, static_cast(v)); + rz_config_set_i(core->config, k, static_cast(v)); } void CutterCore::setConfig(const char *k, bool v) { CORE_LOCK(); - r_config_set_i(core->config, k, v ? 1 : 0); + rz_config_set_i(core->config, k, v ? 1 : 0); } int CutterCore::getConfigi(const char *k) { CORE_LOCK(); - return static_cast(r_config_get_i(core->config, k)); + return static_cast(rz_config_get_i(core->config, k)); } ut64 CutterCore::getConfigut64(const char *k) { CORE_LOCK(); - return r_config_get_i(core->config, k); + return rz_config_get_i(core->config, k); } bool CutterCore::getConfigb(const char *k) { CORE_LOCK(); - return r_config_get_i(core->config, k) != 0; + return rz_config_get_i(core->config, k) != 0; } QString CutterCore::getConfigDescription(const char *k) { CORE_LOCK(); - RConfigNode *node = r_config_node_get (core->config, k); + RzConfigNode *node = rz_config_node_get (core->config, k); return node ? QString(node->desc) : QString("Unrecognized configuration key"); } @@ -1068,7 +1068,7 @@ void CutterCore::message(const QString &msg, bool debug) QString CutterCore::getConfig(const char *k) { CORE_LOCK(); - return QString(r_config_get(core->config, k)); + return QString(rz_config_get(core->config, k)); } void CutterCore::setConfig(const char *k, const QVariant &v) @@ -1105,24 +1105,24 @@ void CutterCore::setEndianness(bool big) QByteArray CutterCore::assemble(const QString &code) { CORE_LOCK(); - RAsmCode *ac = r_asm_massemble(core->rasm, code.toUtf8().constData()); + RzAsmCode *ac = rz_asm_massemble(core->rasm, code.toUtf8().constData()); QByteArray res; if (ac && ac->bytes) { res = QByteArray(reinterpret_cast(ac->bytes), ac->len); } - r_asm_code_free(ac); + rz_asm_code_free(ac); return res; } QString CutterCore::disassemble(const QByteArray &data) { CORE_LOCK(); - RAsmCode *ac = r_asm_mdisassemble(core->rasm, reinterpret_cast(data.constData()), data.length()); + RzAsmCode *ac = rz_asm_mdisassemble(core->rasm, reinterpret_cast(data.constData()), data.length()); QString code; if (ac && ac->assembly) { code = QString::fromUtf8(ac->assembly); } - r_asm_code_free(ac); + rz_asm_code_free(ac); return code; } @@ -1131,19 +1131,19 @@ QString CutterCore::disassembleSingleInstruction(RVA addr) return cmdRawAt("pi 1", addr).simplified(); } -RAnalFunction *CutterCore::functionIn(ut64 addr) +RzAnalFunction *CutterCore::functionIn(ut64 addr) { CORE_LOCK(); - RList *fcns = r_anal_get_functions_in (core->anal, addr); - RAnalFunction *fcn = !r_list_empty(fcns) ? reinterpret_cast(r_list_first(fcns)) : nullptr; - r_list_free(fcns); + RzList *fcns = rz_anal_get_functions_in (core->anal, addr); + RzAnalFunction *fcn = !rz_list_empty(fcns) ? reinterpret_cast(rz_list_first(fcns)) : nullptr; + rz_list_free(fcns); return fcn; } -RAnalFunction *CutterCore::functionAt(ut64 addr) +RzAnalFunction *CutterCore::functionAt(ut64 addr) { CORE_LOCK(); - return r_anal_get_function_at(core->anal, addr); + return rz_anal_get_function_at(core->anal, addr); } /** @@ -1154,7 +1154,7 @@ RAnalFunction *CutterCore::functionAt(ut64 addr) RVA CutterCore::getFunctionStart(RVA addr) { CORE_LOCK(); - RAnalFunction *fcn = Core()->functionIn(addr); + RzAnalFunction *fcn = Core()->functionIn(addr); return fcn ? fcn->addr : RVA_INVALID; } @@ -1166,7 +1166,7 @@ RVA CutterCore::getFunctionStart(RVA addr) RVA CutterCore::getFunctionEnd(RVA addr) { CORE_LOCK(); - RAnalFunction *fcn = Core()->functionIn(addr); + RzAnalFunction *fcn = Core()->functionIn(addr); return fcn ? fcn->addr : RVA_INVALID; } @@ -1178,12 +1178,12 @@ RVA CutterCore::getFunctionEnd(RVA addr) RVA CutterCore::getLastFunctionInstruction(RVA addr) { CORE_LOCK(); - RAnalFunction *fcn = Core()->functionIn(addr); + RzAnalFunction *fcn = Core()->functionIn(addr); if (!fcn) { return RVA_INVALID; } - RAnalBlock *lastBB = (RAnalBlock *)r_list_last(fcn->bbs); - return lastBB ? lastBB->addr + r_anal_bb_offset_inst(lastBB, lastBB->ninstr-1) : RVA_INVALID; + RzAnalBlock *lastBB = (RzAnalBlock *)rz_list_last(fcn->bbs); + return lastBB ? lastBB->addr + rz_anal_bb_offset_inst(lastBB, lastBB->ninstr-1) : RVA_INVALID; } QString CutterCore::cmdFunctionAt(QString addr) @@ -1398,71 +1398,71 @@ QJsonObject CutterCore::getAddrRefs(RVA addr, int depth) { CORE_LOCK(); int bits = core->rasm->bits; QByteArray buf = QByteArray(); - ut64 type = r_core_anal_address(core, addr); + ut64 type = rz_core_anal_address(core, addr); json["addr"] = QString::number(addr); // Search for the section the addr is in, avoid duplication for heap/stack with type - if(!(type & R_ANAL_ADDR_TYPE_HEAP || type & R_ANAL_ADDR_TYPE_STACK)) { + if(!(type & RZ_ANAL_ADDR_TYPE_HEAP || type & RZ_ANAL_ADDR_TYPE_STACK)) { // Attempt to find the address within a map - RDebugMap *map = r_debug_map_get(core->dbg, addr); + RzDebugMap *map = rz_debug_map_get(core->dbg, addr); if (map && map->name && map->name[0]) { json["mapname"] = map->name; } - RBinSection *sect = r_bin_get_section_at(r_bin_cur_object (core->bin), addr, true); + RzBinSection *sect = rz_bin_get_section_at(rz_bin_cur_object (core->bin), addr, true); if (sect && sect->name[0]) { json["section"] = sect->name; } } // Check if the address points to a register - RFlagItem *fi = r_flag_get_i(core->flags, addr); + RzFlagItem *fi = rz_flag_get_i(core->flags, addr); if (fi) { - RRegItem *r = r_reg_get(core->dbg->reg, fi->name, -1); + RzRegItem *r = rz_reg_get(core->dbg->reg, fi->name, -1); if (r) { json["reg"] = r->name; } } // Attempt to find the address within a function - RAnalFunction *fcn = r_anal_get_fcn_in(core->anal, addr, 0); + RzAnalFunction *fcn = rz_anal_get_fcn_in(core->anal, addr, 0); if (fcn) { json["fcn"] = fcn->name; } // Update type and permission information if (type != 0) { - if (type & R_ANAL_ADDR_TYPE_HEAP) { + if (type & RZ_ANAL_ADDR_TYPE_HEAP) { json["type"] = "heap"; - } else if (type & R_ANAL_ADDR_TYPE_STACK) { + } else if (type & RZ_ANAL_ADDR_TYPE_STACK) { json["type"] = "stack"; - } else if (type & R_ANAL_ADDR_TYPE_PROGRAM) { + } else if (type & RZ_ANAL_ADDR_TYPE_PROGRAM) { json["type"] = "program"; - } else if (type & R_ANAL_ADDR_TYPE_LIBRARY) { + } else if (type & RZ_ANAL_ADDR_TYPE_LIBRARY) { json["type"] = "library"; - } else if (type & R_ANAL_ADDR_TYPE_ASCII) { + } else if (type & RZ_ANAL_ADDR_TYPE_ASCII) { json["type"] = "ascii"; - } else if (type & R_ANAL_ADDR_TYPE_SEQUENCE) { + } else if (type & RZ_ANAL_ADDR_TYPE_SEQUENCE) { json["type"] = "sequence"; } QString perms = ""; - if (type & R_ANAL_ADDR_TYPE_READ) { + if (type & RZ_ANAL_ADDR_TYPE_READ) { perms += "r"; } - if (type & R_ANAL_ADDR_TYPE_WRITE) { + if (type & RZ_ANAL_ADDR_TYPE_WRITE) { perms += "w"; } - if (type & R_ANAL_ADDR_TYPE_EXEC) { - RAsmOp op; + if (type & RZ_ANAL_ADDR_TYPE_EXEC) { + RzAsmOp op; buf.resize(32); perms += "x"; // Instruction disassembly - r_io_read_at(core->io, addr, (unsigned char*)buf.data(), buf.size()); - r_asm_set_pc(core->rasm, addr); - r_asm_disassemble(core->rasm, &op, (unsigned char*)buf.data(), buf.size()); - json["asm"] = r_asm_op_get_asm(&op); + rz_io_read_at(core->io, addr, (unsigned char*)buf.data(), buf.size()); + rz_asm_set_pc(core->rasm, addr); + rz_asm_disassemble(core->rasm, &op, (unsigned char*)buf.data(), buf.size()); + json["asm"] = rz_asm_op_get_asm(&op); } if (!perms.isEmpty()) { @@ -1471,11 +1471,11 @@ QJsonObject CutterCore::getAddrRefs(RVA addr, int depth) { } // Try to telescope further if depth permits it - if ((type & R_ANAL_ADDR_TYPE_READ) && !(type & R_ANAL_ADDR_TYPE_EXEC)) { + if ((type & RZ_ANAL_ADDR_TYPE_READ) && !(type & RZ_ANAL_ADDR_TYPE_EXEC)) { buf.resize(64); ut32 *n32 = (ut32 *)buf.data(); ut64 *n64 = (ut64 *)buf.data(); - r_io_read_at(core->io, addr, (unsigned char*)buf.data(), buf.size()); + rz_io_read_at(core->io, addr, (unsigned char*)buf.data(), buf.size()); ut64 n = (bits == 64)? *n64: *n32; // The value of the next address will serve as an indication that there's more to // telescope if we have reached the depth limit @@ -1488,7 +1488,7 @@ QJsonObject CutterCore::getAddrRefs(RVA addr, int depth) { // might have a string in this address if (ref["type"].toString().contains("ascii")) { buf.resize(128); - r_io_read_at(core->io, addr, (unsigned char*)buf.data(), buf.size()); + rz_io_read_at(core->io, addr, (unsigned char*)buf.data(), buf.size()); QString strVal = QString(buf); // Indicate that the string is longer than the printed value if (strVal.size() == buf.size()) { @@ -2088,10 +2088,10 @@ void CutterCore::toggleBreakpoint(RVA addr) void CutterCore::addBreakpoint(const BreakpointDescription &config) { CORE_LOCK(); - RBreakpointItem *breakpoint = nullptr; + RzBreakpointItem *breakpoint = nullptr; int watchpoint_prot = 0; if (config.hw) { - watchpoint_prot = config.permission & ~(R_BP_PROT_EXEC); + watchpoint_prot = config.permission & ~(RZ_BP_PROT_EXEC); } auto address = config.addr; @@ -2104,7 +2104,7 @@ void CutterCore::addBreakpoint(const BreakpointDescription &config) moduleNameData = config.positionExpression.toUtf8(); module = moduleNameData.data(); } - breakpoint = r_debug_bp_add(core->dbg, address, (config.hw && watchpoint_prot == 0), + breakpoint = rz_debug_bp_add(core->dbg, address, (config.hw && watchpoint_prot == 0), watchpoint_prot, watchpoint_prot, module, config.moduleDelta); if (!breakpoint) { @@ -2142,12 +2142,12 @@ void CutterCore::addBreakpoint(const BreakpointDescription &config) void CutterCore::updateBreakpoint(int index, const BreakpointDescription &config) { CORE_LOCK(); - if (auto bp = r_bp_get_index(core->dbg->bp, index)) { - r_bp_del(core->dbg->bp, bp->addr); + if (auto bp = rz_bp_get_index(core->dbg->bp, index)) { + rz_bp_del(core->dbg->bp, bp->addr); } // Delete by index currently buggy, // required for breakpoints with non address based position - //r_bp_del_index(core->dbg->bp, index); + //rz_bp_del_index(core->dbg->bp, index); addBreakpoint(config); } @@ -2184,7 +2184,7 @@ void CutterCore::setBreakpointTrace(int index, bool enabled) } } -static BreakpointDescription breakpointDescriptionFromR2(int index, r_bp_item_t *bpi) +static BreakpointDescription breakpointDescriptionFromR2(int index, rz_bp_item_t *bpi) { BreakpointDescription bp; bp.addr = bpi->addr; @@ -2207,14 +2207,14 @@ static BreakpointDescription breakpointDescriptionFromR2(int index, r_bp_item_t int CutterCore::breakpointIndexAt(RVA addr) { CORE_LOCK(); - return r_bp_get_index_at(core->dbg->bp, addr); + return rz_bp_get_index_at(core->dbg->bp, addr); } BreakpointDescription CutterCore::getBreakpointAt(RVA addr) { CORE_LOCK(); int index = breakpointIndexAt(addr); - auto bp = r_bp_get_index(core->dbg->bp, index); + auto bp = rz_bp_get_index(core->dbg->bp, index); if (bp) { return breakpointDescriptionFromR2(index, bp); } @@ -2368,8 +2368,6 @@ void CutterCore::setSettings() setConfig("anal.hasnext", false); setConfig("asm.lines.call", false); - setConfig("cfg.fortunes.tts", false); - // Colors setConfig("scr.color", COLOR_MODE_DISABLED); @@ -2392,11 +2390,11 @@ QList CutterCore::getSeekHistory() QStringList CutterCore::getAsmPluginNames() { CORE_LOCK(); - RListIter *it; + RzListIter *it; QStringList ret; - RAsmPlugin *ap; - CutterRListForeach(core->rasm->plugins, it, RAsmPlugin, ap) { + RzAsmPlugin *ap; + CutterRListForeach(core->rasm->plugins, it, RzAsmPlugin, ap) { ret << ap->name; } @@ -2406,11 +2404,11 @@ QStringList CutterCore::getAsmPluginNames() QStringList CutterCore::getAnalPluginNames() { CORE_LOCK(); - RListIter *it; + RzListIter *it; QStringList ret; - RAnalPlugin *ap; - CutterRListForeach(core->anal->plugins, it, RAnalPlugin, ap) { + RzAnalPlugin *ap; + CutterRListForeach(core->anal->plugins, it, RzAnalPlugin, ap) { ret << ap->name; } @@ -2419,19 +2417,12 @@ QStringList CutterCore::getAnalPluginNames() QStringList CutterCore::getProjectNames() { - CORE_LOCK(); - QStringList ret; - - QJsonArray jsonArray = cmdj("Pj").array(); - for (const QJsonValue &value : jsonArray) - ret.append(value.toString()); - - return ret; + return {}; } -QList CutterCore::getRBinPluginDescriptions(const QString &type) +QList CutterCore::getRBinPluginDescriptions(const QString &type) { - QList ret; + QList ret; QJsonObject jsonRoot = cmdj("iLj").object(); for (const QString &key : jsonRoot.keys()) { @@ -2443,7 +2434,7 @@ QList CutterCore::getRBinPluginDescriptions(const QString for (const QJsonValue &pluginValue : pluginArray) { QJsonObject pluginObject = pluginValue.toObject(); - RBinPluginDescription desc; + RzBinPluginDescription desc; desc.name = pluginObject[RJsonKey::name].toString(); desc.description = pluginObject[RJsonKey::description].toString(); @@ -2457,15 +2448,15 @@ QList CutterCore::getRBinPluginDescriptions(const QString return ret; } -QList CutterCore::getRIOPluginDescriptions() +QList CutterCore::getRIOPluginDescriptions() { - QList ret; + QList ret; QJsonArray plugins = cmdj("oLj").object()["io_plugins"].toArray(); for (const QJsonValue &pluginValue : plugins) { QJsonObject pluginObject = pluginValue.toObject(); - RIOPluginDescription plugin; + RzIOPluginDescription plugin; plugin.name = pluginObject["name"].toString(); plugin.description = pluginObject["description"].toString(); @@ -2481,15 +2472,15 @@ QList CutterCore::getRIOPluginDescriptions() return ret; } -QList CutterCore::getRCorePluginDescriptions() +QList CutterCore::getRCorePluginDescriptions() { - QList ret; + QList ret; QJsonArray plugins = cmdj("Lsj").array(); for (const QJsonValue &pluginValue : plugins) { QJsonObject pluginObject = pluginValue.toObject(); - RCorePluginDescription plugin; + RzCorePluginDescription plugin; plugin.name = pluginObject["Name"].toString(); plugin.description = pluginObject["Description"].toString(); @@ -2500,15 +2491,15 @@ QList CutterCore::getRCorePluginDescriptions() return ret; } -QList CutterCore::getRAsmPluginDescriptions() +QList CutterCore::getRAsmPluginDescriptions() { CORE_LOCK(); - RListIter *it; - QList ret; + RzListIter *it; + QList ret; - RAsmPlugin *ap; - CutterRListForeach(core->rasm->plugins, it, RAsmPlugin, ap) { - RAsmPluginDescription plugin; + RzAsmPlugin *ap; + CutterRListForeach(core->rasm->plugins, it, RzAsmPlugin, ap) { + RzAsmPluginDescription plugin; plugin.name = ap->name; plugin.architecture = ap->arch; @@ -2529,24 +2520,24 @@ QList CutterCore::getAllFunctions() CORE_LOCK(); QList funcList; - funcList.reserve(r_list_length(core->anal->fcns)); + funcList.reserve(rz_list_length(core->anal->fcns)); - RListIter *iter; - RAnalFunction *fcn; - CutterRListForeach (core->anal->fcns, iter, RAnalFunction, fcn) { + RzListIter *iter; + RzAnalFunction *fcn; + CutterRListForeach (core->anal->fcns, iter, RzAnalFunction, fcn) { FunctionDescription function; function.offset = fcn->addr; - function.linearSize = r_anal_function_linear_size(fcn); - function.nargs = r_anal_var_count(core->anal, fcn, 'b', 1) + - r_anal_var_count(core->anal, fcn, 'r', 1) + - r_anal_var_count(core->anal, fcn, 's', 1); - function.nlocals = r_anal_var_count(core->anal, fcn, 'b', 0) + - r_anal_var_count(core->anal, fcn, 'r', 0) + - r_anal_var_count(core->anal, fcn, 's', 0); - function.nbbs = r_list_length (fcn->bbs); + function.linearSize = rz_anal_function_linear_size(fcn); + function.nargs = rz_anal_var_count(core->anal, fcn, 'b', 1) + + rz_anal_var_count(core->anal, fcn, 'r', 1) + + rz_anal_var_count(core->anal, fcn, 's', 1); + function.nlocals = rz_anal_var_count(core->anal, fcn, 'b', 0) + + rz_anal_var_count(core->anal, fcn, 'r', 0) + + rz_anal_var_count(core->anal, fcn, 's', 0); + function.nbbs = rz_list_length (fcn->bbs); function.calltype = fcn->cc ? QString::fromUtf8(fcn->cc) : QString(); function.name = fcn->name ? QString::fromUtf8(fcn->name) : QString(); - function.edges = r_anal_function_count_edges(fcn, nullptr); + function.edges = rz_anal_function_count_edges(fcn, nullptr); function.stackframe = fcn->maxstack; funcList.append(function); } @@ -2607,13 +2598,13 @@ QList CutterCore::getAllExports() QList CutterCore::getAllSymbols() { CORE_LOCK(); - RListIter *it; + RzListIter *it; QList ret; - RBinSymbol *bs; + RzBinSymbol *bs; if (core && core->bin && core->bin->cur && core->bin->cur->o) { - CutterRListForeach(core->bin->cur->o->symbols, it, RBinSymbol, bs) { + CutterRListForeach(core->bin->cur->o->symbols, it, RzBinSymbol, bs) { QString type = QString(bs->bind) + " " + QString(bs->type); SymbolDescription symbol; symbol.vaddr = bs->vaddr; @@ -2625,8 +2616,8 @@ QList CutterCore::getAllSymbols() /* list entrypoints as symbols too */ int n = 0; - RBinAddr *entry; - CutterRListForeach(core->bin->cur->o->entries, it, RBinAddr, entry) { + RzBinAddr *entry; + CutterRListForeach(core->bin->cur->o->entries, it, RzBinAddr, entry) { SymbolDescription symbol; symbol.vaddr = entry->vaddr; symbol.name = QString("entry") + QString::number(n++); @@ -2723,8 +2714,8 @@ QList CutterCore::getAllRelocs() if (core && core->bin && core->bin->cur && core->bin->cur->o) { auto relocs = core->bin->cur->o->relocs; RBIter iter; - RBinReloc *br; - r_rbtree_foreach (relocs, iter, br, RBinReloc, vrb) { + RzBinReloc *br; + rz_rbtree_foreach (relocs, iter, br, RzBinReloc, vrb) { RelocDescription reloc; reloc.vaddr = br->vaddr; @@ -3016,7 +3007,7 @@ QList CutterCore::getAllAnalClasses(bool sorted) CORE_LOCK(); QList ret; - SdbListPtr l = makeSdbListPtr(r_anal_class_get_all(core->anal, sorted)); + SdbListPtr l = makeSdbListPtr(rz_anal_class_get_all(core->anal, sorted)); if (!l) { return ret; } @@ -3037,21 +3028,21 @@ QList CutterCore::getAnalClassMethods(const QString &cls) CORE_LOCK(); QList ret; - RVector *meths = r_anal_class_method_get_all(core->anal, cls.toUtf8().constData()); + RzVector *meths = rz_anal_class_method_get_all(core->anal, cls.toUtf8().constData()); if (!meths) { return ret; } ret.reserve(static_cast(meths->len)); - RAnalMethod *meth; - CutterRVectorForeach(meths, meth, RAnalMethod) { + RzAnalMethod *meth; + CutterRVectorForeach(meths, meth, RzAnalMethod) { AnalMethodDescription desc; desc.name = QString::fromUtf8(meth->name); desc.addr = meth->addr; desc.vtableOffset = meth->vtable_offset; ret.append(desc); } - r_vector_free(meths); + rz_vector_free(meths); return ret; } @@ -3061,21 +3052,21 @@ QList CutterCore::getAnalClassBaseClasses(const QStrin CORE_LOCK(); QList ret; - RVector *bases = r_anal_class_base_get_all(core->anal, cls.toUtf8().constData()); + RzVector *bases = rz_anal_class_base_get_all(core->anal, cls.toUtf8().constData()); if (!bases) { return ret; } ret.reserve(static_cast(bases->len)); - RAnalBaseClass *base; - CutterRVectorForeach(bases, base, RAnalBaseClass) { + RzAnalBaseClass *base; + CutterRVectorForeach(bases, base, RzAnalBaseClass) { AnalBaseClassDescription desc; desc.id = QString::fromUtf8(base->id); desc.offset = base->offset; desc.className = QString::fromUtf8(base->class_name); ret.append(desc); } - r_vector_free(bases); + rz_vector_free(bases); return ret; } @@ -3085,21 +3076,21 @@ QList CutterCore::getAnalClassVTables(const QString &cls) CORE_LOCK(); QList acVtables; - RVector *vtables = r_anal_class_vtable_get_all(core->anal, cls.toUtf8().constData()); + RzVector *vtables = rz_anal_class_vtable_get_all(core->anal, cls.toUtf8().constData()); if (!vtables) { return acVtables; } acVtables.reserve(static_cast(vtables->len)); - RAnalVTable *vtable; - CutterRVectorForeach(vtables, vtable, RAnalVTable) { + RzAnalVTable *vtable; + CutterRVectorForeach(vtables, vtable, RzAnalVTable) { AnalVTableDescription desc; desc.id = QString::fromUtf8(vtable->id); desc.offset = vtable->offset; desc.addr = vtable->addr; acVtables.append(desc); } - r_vector_free(vtables); + rz_vector_free(vtables); return acVtables; } @@ -3107,50 +3098,50 @@ QList CutterCore::getAnalClassVTables(const QString &cls) void CutterCore::createNewClass(const QString &cls) { CORE_LOCK(); - r_anal_class_create(core->anal, cls.toUtf8().constData()); + rz_anal_class_create(core->anal, cls.toUtf8().constData()); } void CutterCore::renameClass(const QString &oldName, const QString &newName) { CORE_LOCK(); - r_anal_class_rename(core->anal, oldName.toUtf8().constData(), newName.toUtf8().constData()); + rz_anal_class_rename(core->anal, oldName.toUtf8().constData(), newName.toUtf8().constData()); } void CutterCore::deleteClass(const QString &cls) { CORE_LOCK(); - r_anal_class_delete(core->anal, cls.toUtf8().constData()); + rz_anal_class_delete(core->anal, cls.toUtf8().constData()); } bool CutterCore::getAnalMethod(const QString &cls, const QString &meth, AnalMethodDescription *desc) { CORE_LOCK(); - RAnalMethod analMeth; - if (r_anal_class_method_get(core->anal, cls.toUtf8().constData(), meth.toUtf8().constData(), &analMeth) != R_ANAL_CLASS_ERR_SUCCESS) { + RzAnalMethod analMeth; + if (rz_anal_class_method_get(core->anal, cls.toUtf8().constData(), meth.toUtf8().constData(), &analMeth) != RZ_ANAL_CLASS_ERR_SUCCESS) { return false; } desc->name = QString::fromUtf8(analMeth.name); desc->addr = analMeth.addr; desc->vtableOffset = analMeth.vtable_offset; - r_anal_class_method_fini(&analMeth); + rz_anal_class_method_fini(&analMeth); return true; } void CutterCore::setAnalMethod(const QString &className, const AnalMethodDescription &meth) { CORE_LOCK(); - RAnalMethod analMeth; + RzAnalMethod analMeth; analMeth.name = strdup (meth.name.toUtf8().constData()); analMeth.addr = meth.addr; analMeth.vtable_offset = meth.vtableOffset; - r_anal_class_method_set(core->anal, className.toUtf8().constData(), &analMeth); - r_anal_class_method_fini(&analMeth); + rz_anal_class_method_set(core->anal, className.toUtf8().constData(), &analMeth); + rz_anal_class_method_fini(&analMeth); } void CutterCore::renameAnalMethod(const QString &className, const QString &oldMethodName, const QString &newMethodName) { CORE_LOCK(); - r_anal_class_method_rename(core->anal, className.toUtf8().constData(), oldMethodName.toUtf8().constData(), newMethodName.toUtf8().constData()); + rz_anal_class_method_rename(core->anal, className.toUtf8().constData(), oldMethodName.toUtf8().constData(), newMethodName.toUtf8().constData()); } QList CutterCore::getAllResources() @@ -3318,23 +3309,23 @@ QString CutterCore::addTypes(const char *str) { CORE_LOCK(); char *error_msg = nullptr; - char *parsed = r_parse_c_string(core->anal, str, &error_msg); + char *parsed = rz_parse_c_string(core->anal, str, &error_msg); QString error; if (!parsed) { if (error_msg) { error = error_msg; - r_mem_free(error_msg); + rz_mem_free(error_msg); } return error; } - r_anal_save_parsed_type(core->anal, parsed); - r_mem_free(parsed); + rz_anal_save_parsed_type(core->anal, parsed); + rz_mem_free(parsed); if (error_msg) { error = error_msg; - r_mem_free(error_msg); + rz_mem_free(error_msg); } return error; @@ -3565,7 +3556,7 @@ void CutterCore::addFlag(RVA offset, QString name, RVA size) QString CutterCore::listFlagsAsStringAt(RVA addr) { CORE_LOCK(); - char *flagList = r_flag_get_liststr (core->flags, addr); + char *flagList = rz_flag_get_liststr (core->flags, addr); QString result = fromOwnedCharPtr(flagList); return result; } @@ -3584,38 +3575,38 @@ QString CutterCore::nearestFlag(RVA offset, RVA *flagOffsetOut) void CutterCore::handleREvent(int type, void *data) { switch (type) { - case R_EVENT_CLASS_NEW: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_CLASS_NEW: { + auto ev = reinterpret_cast(data); emit classNew(QString::fromUtf8(ev->name)); break; } - case R_EVENT_CLASS_DEL: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_CLASS_DEL: { + auto ev = reinterpret_cast(data); emit classDeleted(QString::fromUtf8(ev->name)); break; } - case R_EVENT_CLASS_RENAME: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_CLASS_RENAME: { + auto ev = reinterpret_cast(data); emit classRenamed(QString::fromUtf8(ev->name_old), QString::fromUtf8(ev->name_new)); break; } - case R_EVENT_CLASS_ATTR_SET: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_CLASS_ATTR_SET: { + auto ev = reinterpret_cast(data); emit classAttrsChanged(QString::fromUtf8(ev->attr.class_name)); break; } - case R_EVENT_CLASS_ATTR_DEL: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_CLASS_ATTR_DEL: { + auto ev = reinterpret_cast(data); emit classAttrsChanged(QString::fromUtf8(ev->class_name)); break; } - case R_EVENT_CLASS_ATTR_RENAME: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_CLASS_ATTR_RENAME: { + auto ev = reinterpret_cast(data); emit classAttrsChanged(QString::fromUtf8(ev->attr.class_name)); break; } - case R_EVENT_DEBUG_PROCESS_FINISHED: { - auto ev = reinterpret_cast(data); + case RZ_EVENT_DEBUG_PROCESS_FINISHED: { + auto ev = reinterpret_cast(data); emit debugProcessFinished(ev->pid); break; } @@ -3736,7 +3727,7 @@ QByteArray CutterCore::hexStringToBytes(const QString &hex) QByteArray hexChars = hex.toUtf8(); QByteArray bytes; bytes.reserve(hexChars.length() / 2); - int size = r_hex_str2bin(hexChars.constData(), reinterpret_cast(bytes.data())); + int size = rz_hex_str2bin(hexChars.constData(), reinterpret_cast(bytes.data())); bytes.resize(size); return bytes; } @@ -3745,7 +3736,7 @@ QString CutterCore::bytesToHexString(const QByteArray &bytes) { QByteArray hex; hex.resize(bytes.length() * 2); - r_hex_bin2str(reinterpret_cast(bytes.constData()), bytes.size(), hex.data()); + rz_hex_bin2str(reinterpret_cast(bytes.constData()), bytes.size(), hex.data()); return QString::fromUtf8(hex); } @@ -3753,7 +3744,7 @@ void CutterCore::loadScript(const QString &scriptname) { { CORE_LOCK(); - r_core_cmd_file(core, scriptname.toUtf8().constData()); + rz_core_cmd_file(core, scriptname.toUtf8().constData()); } triggerRefreshAll(); } @@ -3766,33 +3757,32 @@ QString CutterCore::getVersionInformation() const char *name; const char *(*callback)(); } vcs[] = { - { "r_anal", &r_anal_version }, - { "r_lib", &r_lib_version }, - { "r_egg", &r_egg_version }, - { "r_asm", &r_asm_version }, - { "r_bin", &r_bin_version }, - { "r_cons", &r_cons_version }, - { "r_flag", &r_flag_version }, - { "r_core", &r_core_version }, - { "r_crypto", &r_crypto_version }, - { "r_bp", &r_bp_version }, - { "r_debug", &r_debug_version }, - { "r_hash", &r_hash_version }, - { "r_fs", &r_fs_version }, - { "r_io", &r_io_version }, + { "rz_anal", &rz_anal_version }, + { "rz_lib", &rz_lib_version }, + { "rz_egg", &rz_egg_version }, + { "rz_asm", &rz_asm_version }, + { "rz_bin", &rz_bin_version }, + { "rz_cons", &rz_cons_version }, + { "rz_flag", &rz_flag_version }, + { "rz_core", &rz_core_version }, + { "rz_crypto", &rz_crypto_version }, + { "rz_bp", &rz_bp_version }, + { "rz_debug", &rz_debug_version }, + { "rz_hash", &rz_hash_version }, + { "rz_io", &rz_io_version }, #if !USE_LIB_MAGIC - { "r_magic", &r_magic_version }, + { "rz_magic", &rz_magic_version }, #endif - { "r_parse", &r_parse_version }, - { "r_reg", &r_reg_version }, - { "r_sign", &r_sign_version }, - { "r_search", &r_search_version }, - { "r_syscall", &r_syscall_version }, - { "r_util", &r_util_version }, + { "rz_parse", &rz_parse_version }, + { "rz_reg", &rz_reg_version }, + { "rz_sign", &rz_sign_version }, + { "rz_search", &rz_search_version }, + { "rz_syscall", &rz_syscall_version }, + { "rz_util", &rz_util_version }, /* ... */ {NULL, NULL} }; - versionInfo.append(QString("%1 r2\n").arg(R2_GITTAP)); + versionInfo.append(QString("%1 r2\n").arg(RZ_GITTAP)); for (i = 0; vcs[i].name; i++) { struct vcs_t *v = &vcs[i]; const char *name = v->callback (); @@ -3820,12 +3810,12 @@ QList CutterCore::getColorThemes() QString CutterCore::ansiEscapeToHtml(const QString &text) { int len; - char *html = r_cons_html_filter(text.toUtf8().constData(), &len); + char *html = rz_cons_html_filter(text.toUtf8().constData(), &len); if (!html) { return QString(); } QString r = QString::fromUtf8(html, len); - r_mem_free(html); + rz_mem_free(html); return r; } @@ -3971,7 +3961,7 @@ QByteArray CutterCore::ioRead(RVA addr, int len) /* Zero-copy */ array.resize(len); - if (!r_io_read_at(core->io, addr, (uint8_t *)array.data(), len)) { + if (!rz_io_read_at(core->io, addr, (uint8_t *)array.data(), len)) { qWarning() << "Can't read data" << addr << len; array.fill(0xff); } diff --git a/src/core/Cutter.h b/src/core/Cutter.h index b6a3065e..cb5963c2 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -30,13 +30,13 @@ class R2TaskDialog; #define Core() (CutterCore::instance()) -class RCoreLocked; +class RzCoreLocked; class CUTTER_EXPORT CutterCore: public QObject { Q_OBJECT - friend class RCoreLocked; + friend class RzCoreLocked; friend class R2Task; public: @@ -140,7 +140,7 @@ public: return parseJson(res, cmd.isNull() ? nullptr : cmd.toLocal8Bit().constData()); } - QStringList autocomplete(const QString &cmd, RLinePromptType promptType, size_t limit = 4096); + QStringList autocomplete(const QString &cmd, RzLinePromptType promptType, size_t limit = 4096); /* Functions methods */ void renameFunction(const RVA offset, const QString &newName); @@ -160,13 +160,13 @@ public: * @param addr * @return a function that contains addr or nullptr */ - RAnalFunction *functionIn(ut64 addr); + RzAnalFunction *functionIn(ut64 addr); /** * @param addr * @return the function that has its entrypoint at addr or nullptr */ - RAnalFunction *functionAt(ut64 addr); + RzAnalFunction *functionAt(ut64 addr); RVA getFunctionStart(RVA addr); RVA getFunctionEnd(RVA addr); @@ -256,7 +256,7 @@ public: void setAnalMethod(const QString &cls, const AnalMethodDescription &meth); /* File related methods */ - bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = R_PERM_R, + bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = RZ_PERM_R, int va = 0, bool loadbin = false, const QString &forceBinPlugin = QString()); bool tryFile(QString path, bool rw); bool mapFile(QString path, RVA mapaddr); @@ -481,10 +481,10 @@ public: static bool isProjectNameValid(const QString &name); /* Widgets */ - QList getRBinPluginDescriptions(const QString &type = QString()); - QList getRIOPluginDescriptions(); - QList getRCorePluginDescriptions(); - QList getRAsmPluginDescriptions(); + QList getRBinPluginDescriptions(const QString &type = QString()); + QList getRIOPluginDescriptions(); + QList getRCorePluginDescriptions(); + QList getRAsmPluginDescriptions(); QList getAllFunctions(); QList getAllImports(); QList getAllExports(); @@ -545,10 +545,10 @@ public: /** * @brief Adds new types - * It first uses the r_parse_c_string() function from radare2 API to parse the + * It first uses the rz_parse_c_string() function from radare2 API to parse the * supplied C file (in the form of a string). If there were errors, they are displayed. * If there were no errors, it uses sdb_query_lines() function from radare2 API - * to save the parsed types returned by r_parse_c_string() + * to save the parsed types returned by rz_parse_c_string() * \param str Contains the definition of the data types * \return returns an empty QString if there was no error, else returns the error */ @@ -603,7 +603,7 @@ public: QStringList getSectionList(); - RCoreLocked core(); + RzCoreLocked core(); static QString ansiEscapeToHtml(const QString &text); BasicBlockHighlighter *getBBHighlighter(); @@ -711,10 +711,10 @@ private: QString notes; /** - * Internal reference to the RCore. + * Internal reference to the RzCore. * NEVER use this directly! Always use the CORE_LOCK(); macro and access it like core->... */ - RCore *core_ = nullptr; + RzCore *core_ = nullptr; #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QMutex coreMutex; #else @@ -740,18 +740,18 @@ private: QVector getCutterRCFilePaths() const; }; -class CUTTER_EXPORT RCoreLocked +class CUTTER_EXPORT RzCoreLocked { CutterCore * const core; public: - explicit RCoreLocked(CutterCore *core); - RCoreLocked(const RCoreLocked &) = delete; - RCoreLocked &operator=(const RCoreLocked &) = delete; - RCoreLocked(RCoreLocked &&); - ~RCoreLocked(); - operator RCore *() const; - RCore *operator->() const; + explicit RzCoreLocked(CutterCore *core); + RzCoreLocked(const RzCoreLocked &) = delete; + RzCoreLocked &operator=(const RzCoreLocked &) = delete; + RzCoreLocked(RzCoreLocked &&); + ~RzCoreLocked(); + operator RzCore *() const; + RzCore *operator->() const; }; #endif // CUTTER_H diff --git a/src/core/CutterCommon.h b/src/core/CutterCommon.h index 687301a7..bef58a70 100644 --- a/src/core/CutterCommon.h +++ b/src/core/CutterCommon.h @@ -5,7 +5,7 @@ #ifndef CUTTERCORE_H #define CUTTERCORE_H -#include "r_core.h" +#include "rz_core.h" #include // Workaround for compile errors on Windows diff --git a/src/core/CutterDescriptions.h b/src/core/CutterDescriptions.h index 91a8587c..1a178b99 100644 --- a/src/core/CutterDescriptions.h +++ b/src/core/CutterDescriptions.h @@ -26,7 +26,7 @@ struct FunctionDescription { bool contains(RVA addr) const { // TODO: this is not exactly correct in edge cases. - // r_anal_function_contains() does it right. + // rz_anal_function_contains() does it right. return addr >= offset && addr < offset + linearSize; } }; @@ -158,14 +158,14 @@ struct XrefDescription { QString type; }; -struct RBinPluginDescription { +struct RzBinPluginDescription { QString name; QString description; QString license; QString type; }; -struct RIOPluginDescription { +struct RzIOPluginDescription { QString name; QString description; QString license; @@ -173,12 +173,12 @@ struct RIOPluginDescription { QList uris; }; -struct RCorePluginDescription { +struct RzCorePluginDescription { QString name; QString description; }; -struct RAsmPluginDescription { +struct RzAsmPluginDescription { QString name; QString architecture; QString author; @@ -338,10 +338,10 @@ Q_DECLARE_METATYPE(FlagspaceDescription) Q_DECLARE_METATYPE(FlagDescription) Q_DECLARE_METATYPE(XrefDescription) Q_DECLARE_METATYPE(EntrypointDescription) -Q_DECLARE_METATYPE(RBinPluginDescription) -Q_DECLARE_METATYPE(RIOPluginDescription) -Q_DECLARE_METATYPE(RCorePluginDescription) -Q_DECLARE_METATYPE(RAsmPluginDescription) +Q_DECLARE_METATYPE(RzBinPluginDescription) +Q_DECLARE_METATYPE(RzIOPluginDescription) +Q_DECLARE_METATYPE(RzCorePluginDescription) +Q_DECLARE_METATYPE(RzAsmPluginDescription) Q_DECLARE_METATYPE(BinClassMethodDescription) Q_DECLARE_METATYPE(BinClassFieldDescription) Q_DECLARE_METATYPE(BinClassDescription) diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 5a8d0a8a..1e6234dc 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -535,7 +535,7 @@ void MainWindow::openNewFile(InitialOptions &options, bool skipOptionsDialog) /* Prompt to load filename.r2 script */ if (options.script.isEmpty()) { QString script = QString("%1.r2").arg(this->filename); - if (r_file_exists(script.toStdString().data())) { + if (rz_file_exists(script.toStdString().data())) { QMessageBox mb; mb.setWindowTitle(tr("Script loading")); mb.setText(tr("Do you want to load the '%1' script?").arg(script)); diff --git a/src/dialogs/AboutDialog.cpp b/src/dialogs/AboutDialog.cpp index dd4a8b53..323a7360 100644 --- a/src/dialogs/AboutDialog.cpp +++ b/src/dialogs/AboutDialog.cpp @@ -1,4 +1,4 @@ -#include "r_version.h" +#include "rz_version.h" #include "core/Cutter.h" #include "AboutDialog.h" @@ -27,7 +27,7 @@ AboutDialog::AboutDialog(QWidget *parent) : ui->logoSvgWidget->load(Config()->getLogoFile()); QString aboutString(tr("Version") + " " CUTTER_VERSION_FULL "
" - + tr("Using r2-") + R2_GITTAP + "
" + + tr("Using r2-") + RZ_GITTAP + "
" + buildQtVersionString() + "

" + tr("Optional Features:") + "
" + QString("Python: %1
").arg( diff --git a/src/dialogs/BreakpointsDialog.cpp b/src/dialogs/BreakpointsDialog.cpp index 28a50393..2a0fa98d 100644 --- a/src/dialogs/BreakpointsDialog.cpp +++ b/src/dialogs/BreakpointsDialog.cpp @@ -85,9 +85,9 @@ BreakpointsDialog::BreakpointsDialog(const BreakpointDescription &breakpoint, QW ui->breakpointCondition->setEditText(breakpoint.condition); if (breakpoint.hw) { ui->radioHardware->setChecked(true); - ui->hwRead->setChecked(breakpoint.permission & R_BP_PROT_READ); - ui->hwWrite->setChecked(breakpoint.permission & R_BP_PROT_WRITE); - ui->hwExecute->setChecked(breakpoint.permission & R_BP_PROT_EXEC); + ui->hwRead->setChecked(breakpoint.permission & RZ_BP_PROT_READ); + ui->hwWrite->setChecked(breakpoint.permission & RZ_BP_PROT_WRITE); + ui->hwExecute->setChecked(breakpoint.permission & RZ_BP_PROT_EXEC); ui->breakpointSize->setCurrentText(QString::number(breakpoint.size)); } else { ui->radioSoftware->setChecked(true); @@ -201,13 +201,13 @@ int BreakpointsDialog::getHwPermissions() { int result = 0; if (ui->hwRead->isChecked()) { - result |= R_BP_PROT_READ; + result |= RZ_BP_PROT_READ; } if (ui->hwWrite->isChecked()) { - result |= R_BP_PROT_WRITE; + result |= RZ_BP_PROT_WRITE; } if (ui->hwExecute->isChecked()) { - result |= R_BP_PROT_EXEC; + result |= RZ_BP_PROT_EXEC; } return result; } diff --git a/src/dialogs/FlagDialog.cpp b/src/dialogs/FlagDialog.cpp index e8b8e069..95907a94 100644 --- a/src/dialogs/FlagDialog.cpp +++ b/src/dialogs/FlagDialog.cpp @@ -15,7 +15,7 @@ FlagDialog::FlagDialog(RVA offset, QWidget *parent) : // Setup UI ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); - RFlagItem* flag = r_flag_get_i(Core()->core()->flags, offset); + RzFlagItem *flag = rz_flag_get_i(Core()->core()->flags, offset); if (flag) { flagName = QString(flag->name); flagOffset = flag->offset; diff --git a/src/dialogs/InitialOptionsDialog.cpp b/src/dialogs/InitialOptionsDialog.cpp index d377a444..01a0c7cc 100644 --- a/src/dialogs/InitialOptionsDialog.cpp +++ b/src/dialogs/InitialOptionsDialog.cpp @@ -106,7 +106,7 @@ void InitialOptionsDialog::updateCPUComboBox() QString arch = getSelectedArch(); QStringList cpus; if (!arch.isEmpty()) { - auto pluginDescr = std::find_if(asmPlugins.begin(), asmPlugins.end(), [&](const RAsmPluginDescription &plugin) { + auto pluginDescr = std::find_if(asmPlugins.begin(), asmPlugins.end(), [&](const RzAsmPluginDescription &plugin) { return plugin.name == arch; }); if (pluginDescr != asmPlugins.end()) { @@ -269,7 +269,7 @@ void InitialOptionsDialog::setupAndStartAnalysis(/*int level, QList adv options.loadBinInfo = !ui->binCheckBox->isChecked(); QVariant forceBinPluginData = ui->formatComboBox->currentData(); if (!forceBinPluginData.isNull()) { - RBinPluginDescription pluginDesc = forceBinPluginData.value(); + RzBinPluginDescription pluginDesc = forceBinPluginData.value(); options.forceBinPlugin = pluginDesc.name; } options.demangle = ui->demangleCheckBox->isChecked(); diff --git a/src/dialogs/InitialOptionsDialog.h b/src/dialogs/InitialOptionsDialog.h index 68ce60af..67877fd9 100644 --- a/src/dialogs/InitialOptionsDialog.h +++ b/src/dialogs/InitialOptionsDialog.h @@ -46,7 +46,7 @@ private: QString analysisDescription(int level); QString shellcode; int analLevel; - QList asmPlugins; + QList asmPlugins; void updateCPUComboBox(); diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 876bdddf..fbb3df23 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -339,8 +339,8 @@ void NewFileDialog::fillIOPluginsList() ui->ioPlugin->setItemData(0, tr("Open a file with no extra treatment."), Qt::ToolTipRole); int index = 1; - QList ioPlugins = Core()->getRIOPluginDescriptions(); - for (const RIOPluginDescription &plugin : ioPlugins) { + QList ioPlugins = Core()->getRIOPluginDescriptions(); + for (const RzIOPluginDescription &plugin : ioPlugins) { // Hide debug plugins if (plugin.permissions.contains('d')) { continue; diff --git a/src/dialogs/R2PluginsDialog.cpp b/src/dialogs/R2PluginsDialog.cpp index 0715d620..05959abf 100644 --- a/src/dialogs/R2PluginsDialog.cpp +++ b/src/dialogs/R2PluginsDialog.cpp @@ -17,10 +17,10 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) : item->setText(1, plugin.description); item->setText(2, plugin.license); item->setText(3, plugin.type); - ui->RBinTreeWidget->addTopLevelItem(item); + ui->RzBinTreeWidget->addTopLevelItem(item); } - ui->RBinTreeWidget->sortByColumn(0, Qt::AscendingOrder); - qhelpers::adjustColumns(ui->RBinTreeWidget, 0); + ui->RzBinTreeWidget->sortByColumn(0, Qt::AscendingOrder); + qhelpers::adjustColumns(ui->RzBinTreeWidget, 0); for (const auto &plugin : Core()->getRIOPluginDescriptions()) { QTreeWidgetItem *item = new QTreeWidgetItem(); @@ -28,19 +28,19 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) : item->setText(1, plugin.description); item->setText(2, plugin.license); item->setText(3, plugin.permissions); - ui->RIOTreeWidget->addTopLevelItem(item); + ui->RzIOTreeWidget->addTopLevelItem(item); } - ui->RIOTreeWidget->sortByColumn(0, Qt::AscendingOrder); - qhelpers::adjustColumns(ui->RIOTreeWidget, 0); + ui->RzIOTreeWidget->sortByColumn(0, Qt::AscendingOrder); + qhelpers::adjustColumns(ui->RzIOTreeWidget, 0); for (const auto &plugin : Core()->getRCorePluginDescriptions()) { QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, plugin.name); item->setText(1, plugin.description); - ui->RCoreTreeWidget->addTopLevelItem(item); + ui->RzCoreTreeWidget->addTopLevelItem(item); } - ui->RCoreTreeWidget->sortByColumn(0, Qt::AscendingOrder); - qhelpers::adjustColumns(ui->RCoreTreeWidget, 0); + ui->RzCoreTreeWidget->sortByColumn(0, Qt::AscendingOrder); + qhelpers::adjustColumns(ui->RzCoreTreeWidget, 0); for (const auto &plugin : Core()->getRAsmPluginDescriptions()) { QTreeWidgetItem *item = new QTreeWidgetItem(); @@ -51,10 +51,10 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) : item->setText(4, plugin.description); item->setText(5, plugin.license); item->setText(6, plugin.author); - ui->RAsmTreeWidget->addTopLevelItem(item); + ui->RzAsmTreeWidget->addTopLevelItem(item); } - ui->RAsmTreeWidget->sortByColumn(0, Qt::AscendingOrder); - qhelpers::adjustColumns(ui->RAsmTreeWidget, 0); + ui->RzAsmTreeWidget->sortByColumn(0, Qt::AscendingOrder); + qhelpers::adjustColumns(ui->RzAsmTreeWidget, 0); } R2PluginsDialog::~R2PluginsDialog() diff --git a/src/dialogs/R2PluginsDialog.ui b/src/dialogs/R2PluginsDialog.ui index 871c1ae5..f898bbf7 100644 --- a/src/dialogs/R2PluginsDialog.ui +++ b/src/dialogs/R2PluginsDialog.ui @@ -19,20 +19,20 @@ 4 - + - RBin + RzBin - + - RBin plugins + RzBin plugins - + true @@ -60,20 +60,20 @@ - + - RIO + RzIO - + - RIO plugins + RzIO plugins - + true @@ -101,20 +101,20 @@ - + - RCore + RzCore - + - RCore plugins + RzCore plugins - + true @@ -132,20 +132,20 @@ - + - RAsm + RzAsm - + - RAsm plugins + RzAsm plugins - + true diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 94a7ddc6..7621e7b4 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -26,7 +26,7 @@ AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog *dialog) { ui->refptrCheckBox, "asm.refptr" }, { ui->xrefCheckBox, "asm.xrefs" }, { ui->bblineCheckBox, "asm.bb.line" }, - { ui->varsubCheckBox, "asm.var.sub" }, + { ui->varsubCheckBox, "asm.sub.var" }, { ui->varsubOnlyCheckBox, "asm.sub.varonly" }, { ui->lbytesCheckBox, "asm.lbytes" }, { ui->bytespaceCheckBox, "asm.bytes.space" }, @@ -92,7 +92,7 @@ void AsmOptionsWidget::updateAsmOptionsFromVars() ui->nbytesSpinBox->blockSignals(false); ui->nbytesLabel->setEnabled(bytesEnabled); ui->nbytesSpinBox->setEnabled(bytesEnabled); - bool varsubEnabled = Config()->getConfigBool("asm.var.sub"); + bool varsubEnabled = Config()->getConfigBool("asm.sub.var"); ui->varsubOnlyCheckBox->setEnabled(varsubEnabled); QString currentSyntax = Config()->getConfigString("asm.syntax"); @@ -222,7 +222,7 @@ void AsmOptionsWidget::on_asmTabsOffSpinBox_valueChanged(int value) void AsmOptionsWidget::on_varsubCheckBox_toggled(bool checked) { - Config()->setConfig("asm.var.sub", checked); + Config()->setConfig("asm.sub.var", checked); ui->varsubOnlyCheckBox->setEnabled(checked); triggerAsmOptionsChanged(); } diff --git a/src/dialogs/preferences/AsmOptionsWidget.ui b/src/dialogs/preferences/AsmOptionsWidget.ui index 139d0889..ac629113 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.ui +++ b/src/dialogs/preferences/AsmOptionsWidget.ui @@ -472,7 +472,7 @@ - Substitute variables (asm.var.sub) + Substitute variables (asm.sub.var) diff --git a/src/menus/DecompilerContextMenu.cpp b/src/menus/DecompilerContextMenu.cpp index 206ca4b2..6b59cdd3 100644 --- a/src/menus/DecompilerContextMenu.cpp +++ b/src/menus/DecompilerContextMenu.cpp @@ -71,7 +71,7 @@ DecompilerContextMenu::~DecompilerContextMenu() { } -void DecompilerContextMenu::setAnnotationHere(RCodeAnnotation *annotation) +void DecompilerContextMenu::setAnnotationHere(RzCodeAnnotation *annotation) { annotationHere = annotation; } @@ -199,16 +199,16 @@ void DecompilerContextMenu::aboutToShowSlot() if (!annotationHere || annotationHere->type == - R_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { // If constant, don't show rename and targeted show-in + RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { // If constant, don't show rename and targeted show-in actionRenameThingHere.setVisible(false); copySeparator->setVisible(false); } else { copySeparator->setVisible(true); - if (annotationHere->type == R_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { + if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { actionRenameThingHere.setText(tr("Rename function %1").arg(QString( annotationHere->reference.name))); - } else if (annotationHere->type == R_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE) { - RFlagItem *flagDetails = r_flag_get_i(Core()->core()->flags, annotationHere->reference.offset); + } else if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE) { + RzFlagItem *flagDetails = rz_flag_get_i(Core()->core()->flags, annotationHere->reference.offset); if (flagDetails) { actionRenameThingHere.setText(tr("Rename %1").arg(QString(flagDetails->name))); actionDeleteName.setText(tr("Remove %1").arg(QString(flagDetails->name))); @@ -223,8 +223,8 @@ void DecompilerContextMenu::aboutToShowSlot() if (isReference()) { actionCopyReferenceAddress.setVisible(true); RVA referenceAddr = annotationHere->reference.offset; - RFlagItem *flagDetails = r_flag_get_i(Core()->core()->flags, referenceAddr); - if (annotationHere->type == R_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { + RzFlagItem *flagDetails = rz_flag_get_i(Core()->core()->flags, referenceAddr); + if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { actionCopyReferenceAddress.setText(tr("Copy address of %1 (%2)").arg (QString(annotationHere->reference.name), RAddressString(referenceAddr))); } else if (flagDetails) { @@ -386,16 +386,16 @@ void DecompilerContextMenu::actionDeleteCommentTriggered() void DecompilerContextMenu::actionRenameThingHereTriggered() { - if (!annotationHere || annotationHere->type == R_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { + if (!annotationHere || annotationHere->type == RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { return; } - RCoreLocked core = Core()->core(); + RzCoreLocked core = Core()->core(); bool ok; auto type = annotationHere->type; - if (type == R_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { + if (type == RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { QString currentName(annotationHere->reference.name); RVA func_addr = annotationHere->reference.offset; - RAnalFunction *func = Core()->functionAt(func_addr); + RzAnalFunction *func = Core()->functionAt(func_addr); if (func == NULL) { QString function_name = QInputDialog::getText(this, tr("Define this function at %2").arg(RAddressString(func_addr)), @@ -410,9 +410,9 @@ void DecompilerContextMenu::actionRenameThingHereTriggered() Core()->renameFunction(func_addr, newName); } } - } else if (type == R_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE) { + } else if (type == RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE) { RVA var_addr = annotationHere->reference.offset; - RFlagItem *flagDetails = r_flag_get_i(core->flags, var_addr); + RzFlagItem *flagDetails = rz_flag_get_i(core->flags, var_addr); if (flagDetails) { QString newName = QInputDialog::getText(this, tr("Rename %2").arg(flagDetails->name), tr("Enter name"), QLineEdit::Normal, flagDetails->name, &ok); @@ -470,7 +470,7 @@ void DecompilerContextMenu::actionXRefsTriggered() return; } XrefsDialog dialog(mainWindow, nullptr); - QString displayString = (annotationHere->type == R_CODE_ANNOTATION_TYPE_FUNCTION_NAME) ? QString( + QString displayString = (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME) ? QString( annotationHere->reference.name) : RAddressString(annotationHere->reference.offset); dialog.fillRefsForAddress(annotationHere->reference.offset, displayString, false); dialog.exec(); @@ -549,22 +549,22 @@ void DecompilerContextMenu::updateTargetMenuActions() action->deleteLater(); } showTargetMenuActions.clear(); - RCoreLocked core = Core()->core(); + RzCoreLocked core = Core()->core(); if (isReference()) { QString name; QMenu *menu; - if (annotationHere->type == R_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE - || annotationHere->type == R_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { + if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE + || annotationHere->type == RZ_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE) { menu = mainWindow->createShowInMenu(this, annotationHere->reference.offset, MainWindow::AddressTypeHint::Data); RVA var_addr = annotationHere->reference.offset; - RFlagItem *flagDetails = r_flag_get_i(core->flags, var_addr); + RzFlagItem *flagDetails = rz_flag_get_i(core->flags, var_addr); if (flagDetails) { name = tr("Show %1 in").arg(flagDetails->name); } else { name = tr("Show %1 in").arg(RAddressString(annotationHere->reference.offset)); } - } else if (annotationHere->type == R_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { + } else if (annotationHere->type == RZ_CODE_ANNOTATION_TYPE_FUNCTION_NAME) { menu = mainWindow->createShowInMenu(this, annotationHere->reference.offset, MainWindow::AddressTypeHint::Function); name = tr("%1 (%2)").arg(QString(annotationHere->reference.name), @@ -579,12 +579,12 @@ void DecompilerContextMenu::updateTargetMenuActions() bool DecompilerContextMenu::isReference() { - return (annotationHere && r_annotation_is_reference(annotationHere)); + return (annotationHere && rz_annotation_is_reference(annotationHere)); } bool DecompilerContextMenu::isFunctionVariable() { - return (annotationHere && r_annotation_is_variable(annotationHere)); + return (annotationHere && rz_annotation_is_variable(annotationHere)); } bool DecompilerContextMenu::variablePresentInR2() diff --git a/src/menus/DecompilerContextMenu.h b/src/menus/DecompilerContextMenu.h index e164814e..fc9edca8 100644 --- a/src/menus/DecompilerContextMenu.h +++ b/src/menus/DecompilerContextMenu.h @@ -5,7 +5,7 @@ #include #include -#include +#include class MainWindow; @@ -18,7 +18,7 @@ public: ~DecompilerContextMenu(); bool getIsTogglingBreakpoints(); - void setAnnotationHere(RCodeAnnotation *annotation); + void setAnnotationHere(RzCodeAnnotation *annotation); RVA getFirstOffsetInLine(); signals: @@ -78,7 +78,7 @@ private: * Context-related annotation for the data under cursor in the decompiler widget. * If such an annotation doesn't exist, its value is nullptr. */ - RCodeAnnotation *annotationHere; + RzCodeAnnotation *annotationHere; // Actions and menus in the context menu QAction actionCopy; diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index 6d98627c..719c58a9 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -372,8 +372,8 @@ void DisassemblyContextMenu::setCurHighlightedWord(const QString &text) DisassemblyContextMenu::ThingUsedHere DisassemblyContextMenu::getThingAt(ut64 address) { ThingUsedHere tuh; - RAnalFunction *fcn = Core()->functionAt(address); - RFlagItem *flag = r_flag_get_i(Core()->core()->flags, address); + RzAnalFunction *fcn = Core()->functionAt(address); + RzFlagItem *flag = rz_flag_get_i(Core()->core()->flags, address); // We will lookup through existing r2 types to find something relevant @@ -560,7 +560,7 @@ void DisassemblyContextMenu::aboutToShowSlot() setupRenaming(); // Only show retype for local vars if in a function - RAnalFunction *in_fcn = Core()->functionIn(offset); + RzAnalFunction *in_fcn = Core()->functionIn(offset); if (in_fcn) { auto vars = Core()->getVariables(offset); actionSetFunctionVarTypes.setVisible(!vars.empty()); @@ -835,7 +835,7 @@ void DisassemblyContextMenu::on_actionRename_triggered() FlagDialog dialog(doRenameInfo.addr, this->mainWindow); ok = dialog.exec(); } else if (doRenameAction == RENAME_LOCAL) { - RAnalFunction *fcn = Core()->functionIn(offset); + RzAnalFunction *fcn = Core()->functionIn(offset); if (fcn) { EditVariablesDialog dialog(fcn->addr, curHighlightedWord, this->mainWindow); if (!dialog.empty()) { @@ -858,7 +858,7 @@ void DisassemblyContextMenu::on_actionRename_triggered() void DisassemblyContextMenu::on_actionSetFunctionVarTypes_triggered() { - RAnalFunction *fcn = Core()->functionIn(offset); + RzAnalFunction *fcn = Core()->functionIn(offset); if (!fcn) { QMessageBox::critical(this, tr("Re-type Local Variables"), @@ -1002,9 +1002,9 @@ void DisassemblyContextMenu::on_actionDeleteFunction_triggered() void DisassemblyContextMenu::on_actionEditFunction_triggered() { - RCore *core = Core()->core(); + RzCore *core = Core()->core(); EditFunctionDialog dialog(mainWindow); - RAnalFunction *fcn = r_anal_get_fcn_in(core->anal, offset, 0); + RzAnalFunction *fcn = rz_anal_get_fcn_in(core->anal, offset, 0); if (fcn) { dialog.setWindowTitle(tr("Edit function %1").arg(fcn->name)); diff --git a/src/plugins/PluginManager.cpp b/src/plugins/PluginManager.cpp index ed2e1142..837c25a4 100644 --- a/src/plugins/PluginManager.cpp +++ b/src/plugins/PluginManager.cpp @@ -108,7 +108,7 @@ QVector PluginManager::getPluginDirectories() const { auto plugdir = QDir(QCoreApplication::applicationDirPath()); // appdir/bin plugdir.cdUp(); // appdir - if (plugdir.cd("share/RadareOrg/Cutter/plugins")) { // appdir/share/RadareOrg/Cutter/plugins + if (plugdir.cd("share/RizinOrg/Cutter/plugins")) { // appdir/share/RizinOrg/Cutter/plugins result.push_back(plugdir); } } diff --git a/src/widgets/BreakpointWidget.cpp b/src/widgets/BreakpointWidget.cpp index 1928fd1f..2b449d9d 100644 --- a/src/widgets/BreakpointWidget.cpp +++ b/src/widgets/BreakpointWidget.cpp @@ -32,13 +32,13 @@ int BreakpointModel::columnCount(const QModelIndex &) const static QString formatHwBreakpoint(int permission) { char data[] = "rwx"; - if ((permission & (R_BP_PROT_READ | R_BP_PROT_ACCESS)) == 0) { + if ((permission & (RZ_BP_PROT_READ | RZ_BP_PROT_ACCESS)) == 0) { data[0] = '-'; } - if ((permission & (R_BP_PROT_WRITE | R_BP_PROT_ACCESS)) == 0) { + if ((permission & (RZ_BP_PROT_WRITE | RZ_BP_PROT_ACCESS)) == 0) { data[1] = '-'; } - if ((permission & R_BP_PROT_EXEC) == 0) { + if ((permission & RZ_BP_PROT_EXEC) == 0) { data[2] = '-'; } return data; diff --git a/src/widgets/ConsoleWidget.cpp b/src/widgets/ConsoleWidget.cpp index 8730f953..4a116c41 100644 --- a/src/widgets/ConsoleWidget.cpp +++ b/src/widgets/ConsoleWidget.cpp @@ -373,7 +373,7 @@ void ConsoleWidget::updateCompletion() } auto current = ui->r2InputLineEdit->text(); - auto completions = Core()->autocomplete(current, R_LINE_PROMPT_DEFAULT); + auto completions = Core()->autocomplete(current, RZ_LINE_PROMPT_DEFAULT); int lastSpace = current.lastIndexOf(' '); if (lastSpace >= 0) { current = current.left(lastSpace + 1); diff --git a/src/widgets/DecompilerWidget.cpp b/src/widgets/DecompilerWidget.cpp index b24fcd0c..2292a55a 100644 --- a/src/widgets/DecompilerWidget.cpp +++ b/src/widgets/DecompilerWidget.cpp @@ -31,7 +31,7 @@ DecompilerWidget::DecompilerWidget(MainWindow *main) : previousFunctionAddr(RVA_INVALID), decompiledFunctionAddr(RVA_INVALID), code(Decompiler::makeWarning(tr("Choose an offset and refresh to get decompiled code")), - &r_annotated_code_free) + &rz_annotated_code_free) { ui->setupUi(this); setObjectName(main @@ -58,8 +58,8 @@ DecompilerWidget::DecompilerWidget(MainWindow *main) : auto decompilers = Core()->getDecompilers(); QString selectedDecompilerId = Config()->getSelectedDecompiler(); if (selectedDecompilerId.isEmpty()) { - // If no decompiler was previously chosen. set r2ghidra as default decompiler - selectedDecompilerId = "r2ghidra"; + // If no decompiler was previously chosen. set rz-ghidra as default decompiler + selectedDecompilerId = "ghidra"; } for (Decompiler *dec : decompilers) { ui->decompilerComboBox->addItem(dec->getName(), dec->getId()); @@ -124,9 +124,9 @@ ut64 DecompilerWidget::offsetForPosition(size_t pos) size_t closestPos = SIZE_MAX; ut64 closestOffset = mCtxMenu->getFirstOffsetInLine(); void *iter; - r_vector_foreach(&code->annotations, iter) { - RCodeAnnotation *annotation = (RCodeAnnotation *)iter; - if (annotation->type != R_CODE_ANNOTATION_TYPE_OFFSET || annotation->start > pos + rz_vector_foreach(&code->annotations, iter) { + RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter; + if (annotation->type != RZ_CODE_ANNOTATION_TYPE_OFFSET || annotation->start > pos || annotation->end <= pos) { continue; } @@ -144,9 +144,9 @@ size_t DecompilerWidget::positionForOffset(ut64 offset) size_t closestPos = SIZE_MAX; ut64 closestOffset = UT64_MAX; void *iter; - r_vector_foreach(&code->annotations, iter) { - RCodeAnnotation *annotation = (RCodeAnnotation *)iter; - if (annotation->type != R_CODE_ANNOTATION_TYPE_OFFSET || annotation->offset.offset > offset) { + rz_vector_foreach(&code->annotations, iter) { + RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter; + if (annotation->type != RZ_CODE_ANNOTATION_TYPE_OFFSET || annotation->offset.offset > offset) { continue; } if (closestOffset != UT64_MAX && closestOffset >= annotation->offset.offset) { @@ -188,14 +188,14 @@ void DecompilerWidget::setInfoForBreakpoints() gatherBreakpointInfo(*code, startPos, endPos); } -void DecompilerWidget::gatherBreakpointInfo(RAnnotatedCode &codeDecompiled, size_t startPos, +void DecompilerWidget::gatherBreakpointInfo(RzAnnotatedCode &codeDecompiled, size_t startPos, size_t endPos) { RVA firstOffset = RVA_MAX; void *iter; - r_vector_foreach(&codeDecompiled.annotations, iter) { - RCodeAnnotation *annotation = (RCodeAnnotation *)iter; - if (annotation->type != R_CODE_ANNOTATION_TYPE_OFFSET) { + rz_vector_foreach(&codeDecompiled.annotations, iter) { + RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter; + if (annotation->type != RZ_CODE_ANNOTATION_TYPE_OFFSET) { continue; } if ((startPos <= annotation->start && annotation->start < endPos) || (startPos < annotation->end @@ -284,7 +284,7 @@ QTextCursor DecompilerWidget::getCursorForAddress(RVA addr) return cursor; } -void DecompilerWidget::decompilationFinished(RAnnotatedCode *codeDecompiled) +void DecompilerWidget::decompilationFinished(RzAnnotatedCode *codeDecompiled) { bool isDisplayReset = false; if (previousFunctionAddr == decompiledFunctionAddr) { @@ -315,9 +315,9 @@ void DecompilerWidget::decompilationFinished(RAnnotatedCode *codeDecompiled) lowestOffsetInCode = RVA_MAX; highestOffsetInCode = 0; void *iter; - r_vector_foreach(&code->annotations, iter) { - RCodeAnnotation *annotation = (RCodeAnnotation *)iter; - if (annotation->type == R_CODE_ANNOTATION_TYPE_OFFSET) { + rz_vector_foreach(&code->annotations, iter) { + RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter; + if (annotation->type == RZ_CODE_ANNOTATION_TYPE_OFFSET) { if (lowestOffsetInCode > annotation->offset.offset) { lowestOffsetInCode = annotation->offset.offset; } @@ -336,12 +336,12 @@ void DecompilerWidget::decompilationFinished(RAnnotatedCode *codeDecompiled) void DecompilerWidget::setAnnotationsAtCursor(size_t pos) { - RCodeAnnotation *annotationAtPos = nullptr; + RzCodeAnnotation *annotationAtPos = nullptr; void *iter; - r_vector_foreach(&this->code->annotations, iter) { - RCodeAnnotation *annotation = (RCodeAnnotation *)iter; - if (annotation->type == R_CODE_ANNOTATION_TYPE_OFFSET || - annotation->type == R_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT || + rz_vector_foreach(&this->code->annotations, iter) { + RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter; + if (annotation->type == RZ_CODE_ANNOTATION_TYPE_OFFSET || + annotation->type == RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT || annotation->start > pos || annotation->end <= pos) { continue; } @@ -444,7 +444,7 @@ void DecompilerWidget::updateSelection() QString DecompilerWidget::getWindowTitle() const { - RAnalFunction *fcn = Core()->functionAt(decompiledFunctionAddr); + RzAnalFunction *fcn = Core()->functionAt(decompiledFunctionAddr); QString windowTitle = tr("Decompiler"); if (fcn != NULL) { windowTitle += " (" + QString(fcn->name) + ")"; @@ -566,12 +566,12 @@ bool DecompilerWidget::addressInRange(RVA addr) } /** - * Convert annotation ranges from byte offsets in utf8 used by RAnnotated code to QString QChars used by QString + * Convert annotation ranges from byte offsets in utf8 used by RzAnnotated code to QString QChars used by QString * and Qt text editor. - * @param code - RAnnotated code with annotations that need to be modified + * @param code - RzAnnotated code with annotations that need to be modified * @return Decompiled code */ -static QString remapAnnotationOffsetsToQString(RAnnotatedCode &code) +static QString remapAnnotationOffsetsToQString(RzAnnotatedCode &code) { QByteArray bytes(code.code); QString text; @@ -598,15 +598,15 @@ static QString remapAnnotationOffsetsToQString(RAnnotatedCode &code) }; void *iter; - r_vector_foreach(&code.annotations, iter) { - RCodeAnnotation *annotation = (RCodeAnnotation *)iter; + rz_vector_foreach(&code.annotations, iter) { + RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter; annotation->start = mapPos(annotation->start); annotation->end = mapPos(annotation->end); } return text; } -void DecompilerWidget::setCode(RAnnotatedCode *code) +void DecompilerWidget::setCode(RzAnnotatedCode *code) { connectCursorPositionChanged(false); if (auto highlighter = qobject_cast(syntaxHighlighter.get())) { diff --git a/src/widgets/DecompilerWidget.h b/src/widgets/DecompilerWidget.h index 86d0b5dd..79799ad1 100644 --- a/src/widgets/DecompilerWidget.h +++ b/src/widgets/DecompilerWidget.h @@ -54,7 +54,7 @@ private slots: * - Auto-refresh is disabled. */ void seekChanged(); - void decompilationFinished(RAnnotatedCode *code); + void decompilationFinished(RzAnnotatedCode *code); private: std::unique_ptr ui; @@ -76,7 +76,7 @@ private: int scrollerVertical; RVA previousFunctionAddr; RVA decompiledFunctionAddr; - std::unique_ptr code; + std::unique_ptr code; /** * Specifies the lowest offset of instructions among all the instructions in the decompiled function. @@ -183,17 +183,17 @@ private: void highlightBreakpoints(); /** * @brief Finds the earliest offset and breakpoints within the specified range [startPos, endPos] - * in the specified RAnnotatedCode. + * in the specified RzAnnotatedCode. * * This function is supposed to be used for finding the earliest offset and breakpoints within the specified range * [startPos, endPos]. This will set the value of the variables 'RVA firstOffsetInLine' and 'QVector availableBreakpoints' in * the context menu. * - * @param codeDecompiled - A reference to the RAnnotatedCode for the function that is decompiled. + * @param codeDecompiled - A reference to the RzAnnotatedCode for the function that is decompiled. * @param startPos - Position of the start of the range(inclusive). * @param endPos - Position of the end of the range(inclusive). */ - void gatherBreakpointInfo(RAnnotatedCode &codeDecompiled, size_t startPos, size_t endPos); + void gatherBreakpointInfo(RzAnnotatedCode &codeDecompiled, size_t startPos, size_t endPos); /** * @brief Finds the offset that's closest to the specified position in the decompiled code. * @@ -235,7 +235,7 @@ private: */ bool addressInRange(RVA addr); - void setCode(RAnnotatedCode *code); + void setCode(RzAnnotatedCode *code); void setHighlighter(bool annotationBasedHighlighter); }; diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index dd3eebdc..bfe53db1 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -177,7 +177,7 @@ void DisassemblerGraphView::loadCurrentGraph() .set("asm.lines.fcn", false); QJsonArray functions; - RAnalFunction *fcn = Core()->functionIn(seekable->getOffset()); + RzAnalFunction *fcn = Core()->functionIn(seekable->getOffset()); if (fcn) { currentFcnAddr = fcn->addr; QJsonDocument functionsDoc = Core()->cmdj("agJ " + RAddressString(fcn->addr)); diff --git a/src/widgets/ProcessesWidget.cpp b/src/widgets/ProcessesWidget.cpp index 75e95489..da0ac6c4 100644 --- a/src/widgets/ProcessesWidget.cpp +++ b/src/widgets/ProcessesWidget.cpp @@ -3,7 +3,7 @@ #include "ui_ProcessesWidget.h" #include "common/JsonModel.h" #include "QuickFilterView.h" -#include +#include #include "core/MainWindow.h" @@ -89,17 +89,17 @@ void ProcessesWidget::updateContents() QString ProcessesWidget::translateStatus(QString status) { switch (status.toStdString().c_str()[0]) { - case R_DBG_PROC_STOP: + case RZ_DBG_PROC_STOP: return "Stopped"; - case R_DBG_PROC_RUN: + case RZ_DBG_PROC_RUN: return "Running"; - case R_DBG_PROC_SLEEP: + case RZ_DBG_PROC_SLEEP: return "Sleeping"; - case R_DBG_PROC_ZOMBIE: + case RZ_DBG_PROC_ZOMBIE: return "Zombie"; - case R_DBG_PROC_DEAD: + case RZ_DBG_PROC_DEAD: return "Dead"; - case R_DBG_PROC_RAISED: + case RZ_DBG_PROC_RAISED: return "Raised event"; default: return "Unknown status"; @@ -167,7 +167,7 @@ void ProcessesWidget::onActivated(const QModelIndex &index) for (QJsonValue value : processesValues) { QString status = value.toObject()["status"].toString(); if (pid == value.toObject()["pid"].toInt()) { - if (QString(R_DBG_PROC_ZOMBIE) == status || QString(R_DBG_PROC_DEAD) == status) { + if (QString(RZ_DBG_PROC_ZOMBIE) == status || QString(RZ_DBG_PROC_DEAD) == status) { QMessageBox msgBox; msgBox.setText(tr("Unable to switch to the requested process.")); msgBox.exec(); diff --git a/src/widgets/ThreadsWidget.cpp b/src/widgets/ThreadsWidget.cpp index 75f9c726..3f3abb6a 100644 --- a/src/widgets/ThreadsWidget.cpp +++ b/src/widgets/ThreadsWidget.cpp @@ -3,7 +3,7 @@ #include "ui_ThreadsWidget.h" #include "common/JsonModel.h" #include "QuickFilterView.h" -#include +#include #include "core/MainWindow.h" @@ -88,17 +88,17 @@ void ThreadsWidget::updateContents() QString ThreadsWidget::translateStatus(QString status) { switch (status.toStdString().c_str()[0]) { - case R_DBG_PROC_STOP: + case RZ_DBG_PROC_STOP: return "Stopped"; - case R_DBG_PROC_RUN: + case RZ_DBG_PROC_RUN: return "Running"; - case R_DBG_PROC_SLEEP: + case RZ_DBG_PROC_SLEEP: return "Sleeping"; - case R_DBG_PROC_ZOMBIE: + case RZ_DBG_PROC_ZOMBIE: return "Zombie"; - case R_DBG_PROC_DEAD: + case RZ_DBG_PROC_DEAD: return "Dead"; - case R_DBG_PROC_RAISED: + case RZ_DBG_PROC_RAISED: return "Raised event"; default: return "Unknown status";