New JSDec home (#2563)

Switch from r2dec to jsdec
This commit is contained in:
Anton Kochkov 2021-01-16 18:48:31 +08:00 committed by GitHub
parent ddb3e62353
commit 88478ffb30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 40 additions and 44 deletions

View File

@ -46,7 +46,7 @@ build_script:
-DCUTTER_ENABLE_PACKAGING=ON
-DCUTTER_PACKAGE_DEPENDENCIES=ON
-DCUTTER_PACKAGE_RZ_GHIDRA=ON
-DCUTTER_PACKAGE_R2DEC=OFF
-DCUTTER_PACKAGE_JSDEC=ON
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON
-DCUTTER_ENABLE_CRASH_REPORTS=ON
-DCMAKE_PREFIX_PATH=%CUTTER_DEPS%\\pyside

View File

@ -142,7 +142,7 @@ jobs:
APP_PREFIX=`pwd`/appdir/usr
# export LD_LIBRARY_PATH=${APP_PREFIX}/lib:$Shiboken2_ROOT/lib
export PATH=$PATH:${APP_PREFIX}/bin
# "../scripts/r2dec.sh" --prefix=`pwd`/appdir/usr
"../scripts/jsdec.sh" --prefix=`pwd`/appdir/usr
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage"
chmod a+x linuxdeployqt*.AppImage
rm -fv "../cutter-deps/qt/plugins/imageformats/libqjp2.so"
@ -218,7 +218,7 @@ jobs:
-DCUTTER_ENABLE_PACKAGING=ON ^
-DCUTTER_PACKAGE_DEPENDENCIES=ON ^
-DCUTTER_PACKAGE_RZ_GHIDRA=ON ^
-DCUTTER_PACKAGE_R2DEC=OFF ^
-DCUTTER_PACKAGE_JSDEC=ON ^
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^
-DCUTTER_ENABLE_CRASH_REPORTS=ON ^
-DCMAKE_PREFIX_PATH="%CUTTER_DEPS%\pyside" ^

View File

@ -25,7 +25,7 @@ option(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS "Enable downloading of dependencies. S
option(CUTTER_ENABLE_PACKAGING "Enable building platform-specific packages for distributing" OFF)
option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF)
option(CUTTER_PACKAGE_RZ_GHIDRA "Compile and install rz-ghidra during install step." OFF)
option(CUTTER_PACKAGE_R2DEC "Compile and install r2dec during install step." OFF)
option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF)
OPTION(CUTTER_QT6 "Use QT6" OFF)
if(NOT CUTTER_ENABLE_PYTHON)

View File

@ -8,7 +8,7 @@ if(WIN32)
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}" "-Drz_incdir=include/librz")
set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" "--bindir=${RIZIN_INSTALL_BINPATH}" "-DRZ_INCDIR=include/librz")
else()
set(RIZIN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/Rizin-prefix")
set(MESON_OPTIONS "--prefix=${RIZIN_INSTALL_DIR}" --libdir=lib)

6
dist/CMakeLists.txt vendored
View File

@ -20,15 +20,15 @@ if(WIN32)
endif()
install(SCRIPT WindowsBundleQt.cmake)
endif()
if (CUTTER_PACKAGE_R2DEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
if (CUTTER_PACKAGE_JSDEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
install(CODE "
set(ENV{RZ_ALT_SRC_DIR} 1)
set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\")
execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_r2dec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\"
execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_jsdec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE SCRIPT_RESULT)
if (SCRIPT_RESULT)
message(FATAL_ERROR \"Failed to package r2dec\")
message(FATAL_ERROR \"Failed to package jsdec\")
endif()
")
endif()

View File

@ -1,11 +1,10 @@
$dist = $args[0]
$python = Split-Path((Get-Command python.exe).Path)
if (-not (Test-Path -Path 'r2dec-js' -PathType Container)) {
git clone https://github.com/rizinorg/r2dec-js.git --branch master --depth 1
if (-not (Test-Path -Path 'jsdec' -PathType Container)) {
git clone https://github.com/rizinorg/jsdec.git --branch master --depth 1
}
cd r2dec-js
#git checkout b5a0d15c7bcc488f268ffb0931b7ced2919f6c9d
cd jsdec
& meson.exe --buildtype=release -Dc_args=-DDUK_USE_DATE_NOW_WINDOWS --prefix=$dist --libdir=lib\plugins --datadir=lib\plugins p build
ninja -C build install
Remove-Item -Recurse -Force $dist\lib\plugins\core_pdd.lib

View File

@ -13,7 +13,7 @@ Here's an image that compares one of the decompiler Cutter supports with the Cut
.. image:: ../images/decompiler_vs_disassembly.png
Cutter provides an interface that supports plugins of multiple decompilers including Ghidra, RetDec and R2Dec. The interface receives data from the decompiler and presenting the decompiler code in a context-sensitive decompiler widget. Check the `Decompilers <https://github.com/rizinorg/cutter-plugins#decompilers>`_ section on our Plugins repository to know more about the decompilers we support.
Cutter provides an interface that supports plugins of multiple decompilers including Ghidra, RetDec and JSDec. The interface receives data from the decompiler and presenting the decompiler code in a context-sensitive decompiler widget. Check the `Decompilers <https://github.com/rizinorg/cutter-plugins#decompilers>`_ section on our Plugins repository to know more about the decompilers we support.
Out of the decompiler plugins that we support, the one that's officially maintained by the developers of Cutter is RzGhidra. :doc:`Click here <menus/decompiler-context-menu>` to learn more about the functionalities we provide in the decompiler.

View File

@ -6,14 +6,11 @@ SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "$SCRIPTPATH/.."
if [[ ! -d r2dec-js ]]; then
git clone https://github.com/rizinorg/r2dec-js.git --depth 1 --branch master
#cd r2dec-js
#git checkout b5a0d15c7bcc488f268ffb0931b7ced2919f6c9d
#cd ..
if [[ ! -d jsdec ]]; then
git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch master
fi
cd r2dec-js
cd jsdec
rm -rf build
mkdir build && cd build
meson --buildtype=release --libdir=share/rizin/plugins --datadir=share/rizin/plugins "$@" ../p

View File

@ -513,8 +513,8 @@ if (CUTTER_APPIMAGE_BUILD)
target_compile_definitions(Cutter PRIVATE APPIMAGE)
endif()
if (CUTTER_PACKAGE_R2DEC)
target_compile_definitions(Cutter PRIVATE CUTTER_APPVEYOR_R2DEC)
if (CUTTER_PACKAGE_JSDEC)
target_compile_definitions(Cutter PRIVATE CUTTER_APPVEYOR_JSDEC)
endif()
if(APPLE AND CUTTER_ENABLE_PACKAGING AND CUTTER_USE_BUNDLED_RIZIN)

View File

@ -110,8 +110,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
Config()->setOutputRedirectionEnabled(clOptions.outputRedirectionEnabled);
if (R2DecDecompiler::isAvailable()) {
Core()->registerDecompiler(new R2DecDecompiler(Core()));
if (JSDecDecompiler::isAvailable()) {
Core()->registerDecompiler(new JSDecDecompiler(Core()));
}
#if CUTTER_RZGHIDRA_STATIC
@ -154,9 +154,9 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
sleighHome.cd("share/rizin/plugins/rz_ghidra_sleigh"); // appdir/share/rizin/plugins/rz_ghidra_sleigh
Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath());
auto r2decHome = appdir;
r2decHome.cd("share/rizin/plugins/r2dec-js"); // appdir/share/rizin/plugins/r2dec-js
qputenv("R2DEC_HOME", r2decHome.absolutePath().toLocal8Bit());
auto jsdecHome = appdir;
jsdecHome.cd("share/rizin/plugins/jsdec"); // appdir/share/rizin/plugins/jsdec
qputenv("JSDEC_HOME", jsdecHome.absolutePath().toLocal8Bit());
}
#endif
@ -170,14 +170,14 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
sleighHome.cd("share/rizin/plugins/rz_ghidra_sleigh"); // Contents/Resources/rz/share/rizin/plugins/rz_ghidra_sleigh
Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath());
auto r2decHome = rzprefix;
r2decHome.cd("share/rizin/plugins/r2dec-js"); // Contents/Resources/rz/share/rizin/plugins/r2dec-js
qputenv("R2DEC_HOME", r2decHome.absolutePath().toLocal8Bit());
auto jsdecHome = rzprefix;
jsdecHome.cd("share/rizin/plugins/jsdec"); // Contents/Resources/rz/share/rizin/plugins/jsdec
qputenv("JSDEC_HOME", jsdecHome.absolutePath().toLocal8Bit());
}
#endif
#ifdef CUTTER_APPVEYOR_R2DEC
qputenv("R2DEC_HOME", "lib\\plugins\\r2dec-js");
#ifdef CUTTER_APPVEYOR_JSDEC
qputenv("JSDEC_HOME", "lib\\plugins\\jsdec");
#endif
#ifdef Q_OS_WIN
{

View File

@ -17,18 +17,18 @@ RzAnnotatedCode *Decompiler::makeWarning(QString warningMessage){
return rz_annotated_code_new(strdup(temporary.c_str()));
}
R2DecDecompiler::R2DecDecompiler(QObject *parent)
: Decompiler("r2dec", "r2dec", parent)
JSDecDecompiler::JSDecDecompiler(QObject *parent)
: Decompiler("jsdec", "jsdec", parent)
{
task = nullptr;
}
bool R2DecDecompiler::isAvailable()
bool JSDecDecompiler::isAvailable()
{
return Core()->cmdList("e cmd.pdc=?").contains(QStringLiteral("pdd"));
return Core()->cmdList("es").contains("jsdec");
}
void R2DecDecompiler::decompileAt(RVA addr)
void JSDecDecompiler::decompileAt(RVA addr)
{
if (task) {
return;
@ -39,7 +39,7 @@ void R2DecDecompiler::decompileAt(RVA addr)
delete task;
task = nullptr;
if (json.isEmpty()) {
emit finished(Decompiler::makeWarning(tr("Failed to parse JSON from r2dec")));
emit finished(Decompiler::makeWarning(tr("Failed to parse JSON from jsdec")));
return;
}
RzAnnotatedCode *code = rz_annotated_code_new(nullptr);

View File

@ -37,7 +37,7 @@ signals:
void finished(RzAnnotatedCode *codeDecompiled);
};
class R2DecDecompiler: public Decompiler
class JSDecDecompiler: public Decompiler
{
Q_OBJECT
@ -45,7 +45,7 @@ private:
RizinCmdTask *task;
public:
explicit R2DecDecompiler(QObject *parent = nullptr);
explicit JSDecDecompiler(QObject *parent = nullptr);
void decompileAt(RVA addr) override;
bool isRunning() override { return task != nullptr; }

View File

@ -67,7 +67,7 @@ public:
/**
* @brief send a command to Rizin asynchronously
* @param str the command you want to execute
* @param task a shared pointer that will be returned with the R2 command task
* @param task a shared pointer that will be returned with the Rizin command task
* @note connect to the &RizinTask::finished signal to add your own logic once
* the command is finished. Use task->getResult()/getResultJson() for the
* return value.
@ -124,7 +124,7 @@ public:
/**
* @brief send a command to Rizin and check for ESIL errors
* @param command the command you want to execute
* @param task a shared pointer that will be returned with the R2 command task
* @param task a shared pointer that will be returned with the Rizin command task
* @note connect to the &RizinTask::finished signal to add your own logic once
* the command is finished. Use task->getResult()/getResultJson() for the
* return value.