Port to Rizin

This commit is contained in:
Florian Märkl 2020-10-28 13:28:04 +01:00
parent 0e9b0c92b9
commit 2b8ac6ecf7
No known key found for this signature in database
GPG Key ID: 125BC8A5A6A1E857
52 changed files with 952 additions and 952 deletions

View File

@ -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 ^

3
.gitignore vendored
View File

@ -94,3 +94,6 @@ src/out
# astyle backup .orig files
*.orig
# Gdb's history
.gdb_history

8
.gitmodules vendored
View File

@ -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

@ -1 +0,0 @@
Subproject commit 293cf5ae65ba4e28828095dcae212955593ba255

1
rizin Submodule

@ -0,0 +1 @@
Subproject commit 8b30c4f0d7282009e52099764e15b686c4d08654

View File

@ -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}")

View File

@ -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
}

View File

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
qRegisterMetaType<QList<StringDescription>>();
qRegisterMetaType<QList<FunctionDescription>>();
QCoreApplication::setOrganizationName("RadareOrg");
QCoreApplication::setOrganizationName("RizinOrg");
QCoreApplication::setApplicationName("Cutter");
Cutter::initializeSettings();

View File

@ -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}/$<CONFIG>")
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}" "<SOURCE_DIR>" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS} --buildtype "$<$<CONFIG:Debug>:debug>$<$<NOT:$<CONFIG: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
$<BUILD_INTERFACE:${RADARE2_INSTALL_DIR}/lib>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>)
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
"$<BUILD_INTERFACE:${Radare2_INCLUDE_DIRS}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libr>")
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()

View File

@ -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}/$<CONFIG>")
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}" "<SOURCE_DIR>" ${MESON_OPTIONS} && "${MESON}" configure ${MESON_OPTIONS} --buildtype "$<$<CONFIG:Debug>:debug>$<$<NOT:$<CONFIG: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
$<BUILD_INTERFACE:${RIZIN_INSTALL_DIR}/lib>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>)
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
"$<BUILD_INTERFACE:${Rizin_INCLUDE_DIRS}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/librz>")
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()

View File

@ -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")

View File

@ -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_<name> - Path to library r_<name>
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)

116
src/cmake/FindRizin.cmake Normal file
View File

@ -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_<name> - Path to library rz_<name>
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)

View File

@ -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) {

View File

@ -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();

View File

@ -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";
}

View File

@ -3,7 +3,7 @@
#include "core/Cutter.h"
#include "common/RichTextPainter.h"
#include <r_anal.h>
#include <rz_anal.h>
class Colors
{

View File

@ -122,7 +122,7 @@ static const QHash<QString, QVariant> 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 },

View File

@ -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()) {

View File

@ -3,7 +3,7 @@
#include "CutterCommon.h"
#include "R2Task.h"
#include <r_util/r_annotated_code.h>
#include <rz_util/rz_annotated_code.h>
#include <QString>
#include <QObject>
@ -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

View File

@ -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<RPVector, decltype(&r_pvector_free)> annotations(r_annotated_code_annotations_range(code, start, end), &r_pvector_free);
std::unique_ptr<RzPVector, decltype(&rz_pvector_free)> annotations(rz_annotated_code_annotations_range(code, start, end), &rz_pvector_free);
void **iter;
r_pvector_foreach(annotations.get(), iter) {
RCodeAnnotation *annotation = static_cast<RCodeAnnotation*>(*iter);
if (annotation->type != R_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT) {
rz_pvector_foreach(annotations.get(), iter) {
RzCodeAnnotation *annotation = static_cast<RzCodeAnnotation*>(*iter);
if (annotation->type != RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT) {
continue;
}
auto type = annotation->syntax_highlight.type;

View File

@ -2,7 +2,7 @@
#define DECOMPILER_HIGHLIGHTER_H
#include "CutterCommon.h"
#include <r_util/r_annotated_code.h>
#include <rz_util/rz_annotated_code.h>
#include <QSyntaxHighlighter>
#include <QTextDocument>
#include <QTextCharFormat>
@ -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<QTextCharFormat, HIGHLIGHT_COUNT> format;
RAnnotatedCode *code = nullptr;
RzAnnotatedCode *code = nullptr;
};
#endif

View File

@ -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<RCoreTaskCallback>(&R2Task::taskFinishedCallback),
static_cast<RzCoreTaskCallback>(&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()

View File

@ -9,7 +9,7 @@ class R2Task: public QObject
Q_OBJECT
private:
RCoreTask *task;
RzCoreTask *task;
static void taskFinishedCallback(void *user, char *);
void taskFinished();

View File

@ -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()

View File

@ -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) {
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);
}
};
renameAsmOption("asm.var.subonly", "asm.sub.varonly");
renameAsmOption("asm.bytespace", "asm.bytes.space");
}
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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = QString());
QList<RIOPluginDescription> getRIOPluginDescriptions();
QList<RCorePluginDescription> getRCorePluginDescriptions();
QList<RAsmPluginDescription> getRAsmPluginDescriptions();
QList<RzBinPluginDescription> getRBinPluginDescriptions(const QString &type = QString());
QList<RzIOPluginDescription> getRIOPluginDescriptions();
QList<RzCorePluginDescription> getRCorePluginDescriptions();
QList<RzAsmPluginDescription> getRAsmPluginDescriptions();
QList<FunctionDescription> getAllFunctions();
QList<ImportDescription> getAllImports();
QList<ExportDescription> 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<QString> 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

View File

@ -5,7 +5,7 @@
#ifndef CUTTERCORE_H
#define CUTTERCORE_H
#include "r_core.h"
#include "rz_core.h"
#include <QString>
// Workaround for compile errors on Windows

View File

@ -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<QString> 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)

View File

@ -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));

View File

@ -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 "<br/>"
+ tr("Using r2-") + R2_GITTAP + "<br/>"
+ tr("Using r2-") + RZ_GITTAP + "<br/>"
+ buildQtVersionString()
+ "<p><b>" + tr("Optional Features:") + "</b><br/>"
+ QString("Python: %1<br/>").arg(

View File

@ -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;
}

View File

@ -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;

View File

@ -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<QString> adv
options.loadBinInfo = !ui->binCheckBox->isChecked();
QVariant forceBinPluginData = ui->formatComboBox->currentData();
if (!forceBinPluginData.isNull()) {
RBinPluginDescription pluginDesc = forceBinPluginData.value<RBinPluginDescription>();
RzBinPluginDescription pluginDesc = forceBinPluginData.value<RzBinPluginDescription>();
options.forceBinPlugin = pluginDesc.name;
}
options.demangle = ui->demangleCheckBox->isChecked();

View File

@ -46,7 +46,7 @@ private:
QString analysisDescription(int level);
QString shellcode;
int analLevel;
QList<RAsmPluginDescription> asmPlugins;
QList<RzAsmPluginDescription> asmPlugins;
void updateCPUComboBox();

View File

@ -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<RIOPluginDescription> ioPlugins = Core()->getRIOPluginDescriptions();
for (const RIOPluginDescription &plugin : ioPlugins) {
QList<RzIOPluginDescription> ioPlugins = Core()->getRIOPluginDescriptions();
for (const RzIOPluginDescription &plugin : ioPlugins) {
// Hide debug plugins
if (plugin.permissions.contains('d')) {
continue;

View File

@ -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()

View File

@ -19,20 +19,20 @@
<property name="currentIndex">
<number>4</number>
</property>
<widget class="QWidget" name="RBinTab">
<widget class="QWidget" name="RzBinTab">
<attribute name="title">
<string>RBin</string>
<string>RzBin</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="RBinLabel">
<widget class="QLabel" name="RzBinLabel">
<property name="text">
<string>RBin plugins</string>
<string>RzBin plugins</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="RBinTreeWidget">
<widget class="QTreeWidget" name="RzBinTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
@ -60,20 +60,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="RIOTab">
<widget class="QWidget" name="RzIOTab">
<attribute name="title">
<string>RIO</string>
<string>RzIO</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="RIOLabel">
<widget class="QLabel" name="RzIOLabel">
<property name="text">
<string>RIO plugins</string>
<string>RzIO plugins</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="RIOTreeWidget">
<widget class="QTreeWidget" name="RzIOTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
@ -101,20 +101,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="RCoreTab">
<widget class="QWidget" name="RzCoreTab">
<attribute name="title">
<string>RCore</string>
<string>RzCore</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="RCoreLabel">
<widget class="QLabel" name="RzCoreLabel">
<property name="text">
<string>RCore plugins</string>
<string>RzCore plugins</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="RCoreTreeWidget">
<widget class="QTreeWidget" name="RzCoreTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
@ -132,20 +132,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="RAsmTab">
<widget class="QWidget" name="RzAsmTab">
<attribute name="title">
<string>RAsm</string>
<string>RzAsm</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="RAsmLabel">
<widget class="QLabel" name="RzAsmLabel">
<property name="text">
<string>RAsm plugins</string>
<string>RzAsm plugins</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="RAsmTreeWidget">
<widget class="QTreeWidget" name="RzAsmTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>

View File

@ -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();
}

View File

@ -472,7 +472,7 @@
<item>
<widget class="QCheckBox" name="varsubCheckBox">
<property name="text">
<string>Substitute variables (asm.var.sub)</string>
<string>Substitute variables (asm.sub.var)</string>
</property>
</widget>
</item>

View File

@ -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()

View File

@ -5,7 +5,7 @@
#include <QMenu>
#include <QKeySequence>
#include <r_util/r_annotated_code.h>
#include <rz_util/rz_annotated_code.h>
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;

View File

@ -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));

View File

@ -108,7 +108,7 @@ QVector<QDir> 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);
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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<DecompilerHighlighter*>(syntaxHighlighter.get())) {

View File

@ -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::DecompilerWidget> ui;
@ -76,7 +76,7 @@ private:
int scrollerVertical;
RVA previousFunctionAddr;
RVA decompiledFunctionAddr;
std::unique_ptr<RAnnotatedCode, void (*)(RAnnotatedCode *)> code;
std::unique_ptr<RzAnnotatedCode, void (*)(RzAnnotatedCode *)> 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<RVA> 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);
};

View File

@ -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));

View File

@ -3,7 +3,7 @@
#include "ui_ProcessesWidget.h"
#include "common/JsonModel.h"
#include "QuickFilterView.h"
#include <r_debug.h>
#include <rz_debug.h>
#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();

View File

@ -3,7 +3,7 @@
#include "ui_ThreadsWidget.h"
#include "common/JsonModel.h"
#include "QuickFilterView.h"
#include <r_debug.h>
#include <rz_debug.h>
#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";