rizinorg / cutter

Free and Open Source Reverse Engineering Platform powered by rizin
https://cutter.re
GNU General Public License v3.0
15.93k stars 1.15k forks source link

Switch to use Rizin API directly whenever appropriate #2666

Open XVilka opened 3 years ago

XVilka commented 3 years ago

Using API directly will improve the performance and allow to avoid situations when Rizin command has changed but it went unnoticed in Cutter. Using API will guarantee if the function has changed - it will break the compilation.

Here is the current situation (will be updated periodically):

src/core/Cutter.cpp
3948:        searchArray = cmdj(QString("%1 %2").arg(space, searchFor));

src/widgets/RizinGraphWidget.cpp
99:    CutterJson functionsDoc = Core()->cmdj(QString("%1j").arg(graphCommand));

src/widgets/HexdumpWidget.cpp
242:                selectedCommand != "" ? Core()->cmdRawAt(
XVilka commented 3 years ago

First actionable items are:

XVilka commented 3 years ago

Now ph commands were ported to the newshell and there is nicer hash/crypto API, thanks to @wargio, it is a good starting point to port as well.

ret2libc commented 3 years ago

Please note that in terms of minimum required work, we only really need to convert uses of commands that were converted to rzshell and where the oldshell handler was deleted.

The others should still work. I'm working on this.

imbillow commented 2 years ago

It took too much time and now we have this left

src/core/Cutter.cpp
3948:        searchArray = cmdj(QString("%1 %2").arg(space, searchFor));
3984:    for (CutterJson xrefObject : cmdjAt(findWrites ? "afvWj" : "afvRj", offset)) {

src/widgets/RizinGraphWidget.cpp
99:    CutterJson functionsDoc = Core()->cmdj(QString("%1j").arg(graphCommand));

src/plugins/sample-cpp/CutterSamplePlugin.cpp
53:        res = Core()->cmd("?E `pi 1`");
67:    QString res = Core()->cmdRaw("?E " + QString::fromUtf8(fortune));

src/widgets/CutterGraphView.cpp
376:    qWarning() << Core()->cmdRawAt(QString("%0w \"%1\"").arg(graphCommand).arg(filePath), address);
387:    fileOut << Core()->cmdRawAt(QString("%0").arg(graphCommand), address);

src/common/Decompiler.cpp
103:    task = new RizinCmdTask("pddA @ " + QString::number(addr));
XVilka commented 2 years ago

Thank you, @imbillow, you did an amazing job, I never thought it's actually this big and often quite problematic.

karliss commented 2 years ago

I think you missed the stuff in HexdumpWidget.