diff --git a/src/plugins/sample-cpp/CMakeLists.txt b/src/plugins/sample-cpp/CMakeLists.txt index 93e140f5..53e264c2 100644 --- a/src/plugins/sample-cpp/CMakeLists.txt +++ b/src/plugins/sample-cpp/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.12) project(cutter-sample-plugin) find_package(Cutter REQUIRED) +find_package(Rizin REQUIRED) set(CUTTER_INSTALL_PLUGDIR "${Cutter_USER_PLUGINDIR}" CACHE STRING "Directory to install Cutter plugin into") set(CMAKE_AUTOMOC ON) @@ -9,5 +10,5 @@ set(CMAKE_AUTOMOC ON) add_library(sample_plugin MODULE CutterSamplePlugin.h CutterSamplePlugin.cpp) -target_link_libraries(sample_plugin PRIVATE Cutter::Cutter) +target_link_libraries(sample_plugin PRIVATE Cutter::Cutter Rizin::Core) install(TARGETS sample_plugin DESTINATION "${CUTTER_INSTALL_PLUGDIR}") diff --git a/src/plugins/sample-cpp/CutterSamplePlugin.cpp b/src/plugins/sample-cpp/CutterSamplePlugin.cpp index bb2264b3..dae6443a 100644 --- a/src/plugins/sample-cpp/CutterSamplePlugin.cpp +++ b/src/plugins/sample-cpp/CutterSamplePlugin.cpp @@ -8,6 +8,7 @@ #include #include #include +#include void CutterSamplePlugin::setupPlugin() {} @@ -46,25 +47,21 @@ CutterSamplePluginWidget::CutterSamplePluginWidget(MainWindow *main) : CutterDoc void CutterSamplePluginWidget::on_seekChanged(RVA addr) { Q_UNUSED(addr); - QString res; - { - TempConfig tempConfig; - tempConfig.set("scr.color", 0); - res = Core()->cmd("?E `pi 1`"); - } + RzCoreLocked core(Core()); + TempConfig tempConfig; + tempConfig.set("scr.color", 0); + QString disasm = Core()->disassembleSingleInstruction(Core()->getOffset()); + QString res = fromOwnedCharPtr(rz_core_clippy(core, disasm.toUtf8().constData())); text->setText(res); } void CutterSamplePluginWidget::on_buttonClicked() { RzCoreLocked core(Core()); - char *fortune = rz_core_fortune_get_random(core); + auto fortune = fromOwned(rz_core_fortune_get_random(core)); if (!fortune) { return; } - // cmdRaw can be used to execute single raw commands - // this is especially good for user-controlled input - QString res = Core()->cmdRaw("?E " + QString::fromUtf8(fortune)); + QString res = fromOwnedCharPtr(rz_core_clippy(core, fortune.get())); text->setText(res); - rz_mem_free(fortune); }