mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
convert ?E
to API (#3025)
This commit is contained in:
parent
cab85d204e
commit
7a83001a06
@ -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}")
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <common/TempConfig.h>
|
||||
#include <common/Configuration.h>
|
||||
#include <MainWindow.h>
|
||||
#include <librz/rz_core.h>
|
||||
|
||||
void CutterSamplePlugin::setupPlugin() {}
|
||||
|
||||
@ -46,25 +47,21 @@ CutterSamplePluginWidget::CutterSamplePluginWidget(MainWindow *main) : CutterDoc
|
||||
void CutterSamplePluginWidget::on_seekChanged(RVA addr)
|
||||
{
|
||||
Q_UNUSED(addr);
|
||||
QString res;
|
||||
{
|
||||
RzCoreLocked core(Core());
|
||||
TempConfig tempConfig;
|
||||
tempConfig.set("scr.color", 0);
|
||||
res = Core()->cmd("?E `pi 1`");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user