id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,697
|
BaseFindResultsDialog.h
|
rizinorg_cutter/src/tools/basefind/BaseFindResultsDialog.h
|
#ifndef BASEFIND_RESULTS_DIALOG_H
#define BASEFIND_RESULTS_DIALOG_H
#include <QDialog>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <memory>
#include <core/Cutter.h>
class BaseFindResultsDialog;
namespace Ui {
class BaseFindResultsDialog;
}
class BaseFindResultsModel : public QAbstractListModel
{
Q_OBJECT
friend BaseFindResultsDialog;
public:
enum Column { ScoreColumn = 0, CandidateColumn, ColumnCount };
BaseFindResultsModel(QList<BasefindResultDescription> *list, QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
private:
QList<BasefindResultDescription> *list;
};
class BaseFindResultsDialog : public QDialog
{
Q_OBJECT
public:
explicit BaseFindResultsDialog(QList<BasefindResultDescription> results,
QWidget *parent = nullptr);
~BaseFindResultsDialog();
public slots:
void showItemContextMenu(const QPoint &pt);
private slots:
void on_buttonBox_rejected();
private:
void onActionCopyLine();
void onActionSetLoadAddr();
void onActionSetMapAddr();
QList<BasefindResultDescription> list;
std::unique_ptr<Ui::BaseFindResultsDialog> ui;
BaseFindResultsModel *model;
QMenu *blockMenu;
QAction *actionCopyCandidate;
QAction *actionSetLoadAddr;
QAction *actionSetMapAddr;
RVA candidate;
};
#endif // BASEFIND_RESULTS_DIALOG_H
| 1,685
|
C++
|
.h
| 50
| 29.64
| 100
| 0.766852
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,698
|
ThreadsWidget.h
|
rizinorg_cutter/src/widgets/ThreadsWidget.h
|
#pragma once
#include <QJsonObject>
#include <memory>
#include <QStandardItem>
#include <QTableView>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
class MainWindow;
namespace Ui {
class ThreadsWidget;
}
class ThreadsFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
ThreadsFilterModel(QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
};
class ThreadsWidget : public CutterDockWidget
{
Q_OBJECT
public:
enum ColumnIndex {
COLUMN_PID = 0,
COLUMN_STATUS,
COLUMN_PATH,
};
explicit ThreadsWidget(MainWindow *main);
~ThreadsWidget();
private slots:
void updateContents();
void setThreadsGrid();
void fontsUpdatedSlot();
void onActivated(const QModelIndex &index);
private:
QString translateStatus(const char status);
std::unique_ptr<Ui::ThreadsWidget> ui;
QStandardItemModel *modelThreads;
ThreadsFilterModel *modelFilter;
RefreshDeferrer *refreshDeferrer;
};
| 1,076
|
C++
|
.h
| 43
| 21.604651
| 77
| 0.761019
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,699
|
CutterGraphView.h
|
rizinorg_cutter/src/widgets/CutterGraphView.h
|
#ifndef CUTTER_GRAPHVIEW_H
#define CUTTER_GRAPHVIEW_H
#include <QWidget>
#include <QPainter>
#include <QShortcut>
#include <QLabel>
#include <QGestureEvent>
#include "widgets/GraphView.h"
#include "common/CachedFontMetrics.h"
/**
* @brief Common Cutter specific graph functionality.
*/
class CutterGraphView : public GraphView
{
Q_OBJECT
public:
CutterGraphView(QWidget *parent);
virtual bool event(QEvent *event) override;
enum class GraphExportType {
Png,
Jpeg,
Svg,
GVDot,
GVJson,
GVGif,
GVPng,
GVJpeg,
GVPostScript,
GVSvg,
GVPdf,
RzGml,
RzJson
};
/**
* @brief Export graph to a file in the specified format
* @param filePath - output file path
* @param exportType - export type, GV* and Rz* types require \p graphCommand
* @param graphType - graph type, example RZ_CORE_GRAPH_TYPE_FUNCALL or
* RZ_CORE_GRAPH_TYPE_IMPORT
* @param address - object address (if global set it to RVA_INVALID)
*/
void exportGraph(QString filePath, GraphExportType exportType, RzCoreGraphType graphType,
RVA address = RVA_INVALID);
/**
* @brief Export graph in one of the text formats supported by rizin json, gml, SDB key-value
* @param filePath - output file path
* @param type - graph type, example RZ_CORE_GRAPH_TYPE_FUNCALL or RZ_CORE_GRAPH_TYPE_IMPORT
* @param format - graph format, example RZ_CORE_GRAPH_FORMAT_DOT or RZ_CORE_GRAPH_FORMAT_GML
* @param address - object address (if global set it to RVA_INVALID)
*/
void exportRzTextGraph(QString filePath, RzCoreGraphType type, RzCoreGraphFormat format,
RVA address);
static bool graphIsBitamp(GraphExportType type);
/**
* @brief Show graph export dialog.
* @param defaultName - default file name in the export dialog
* @param type - graph type, example RZ_CORE_GRAPH_TYPE_FUNCALL or RZ_CORE_GRAPH_TYPE_IMPORT
* @param address - object address (if global set it to RVA_INVALID)
*/
void showExportGraphDialog(QString defaultName, RzCoreGraphType type,
RVA address = RVA_INVALID);
public slots:
virtual void refreshView();
void updateColors();
void fontsUpdatedSlot();
void zoom(QPointF mouseRelativePos, double velocity);
void setZoom(QPointF mouseRelativePos, double scale);
void zoomIn();
void zoomOut();
void zoomReset();
/**
* @brief Show the export file dialog. Override this to support rizin based export formats.
*/
virtual void showExportDialog();
signals:
void viewRefreshed();
void viewZoomed();
void graphMoved();
void resized();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
bool gestureEvent(QGestureEvent *event) override;
/**
* @brief Save the the currently viewed or displayed block.
* Called before reloading graph. Override to this to implement graph specific logic for what
* block is selected. Default implementation does nothing.
*/
virtual void saveCurrentBlock();
/**
* @brief Restore view focus and block last saved using saveCurrentBlock().
* Called after the graph is reloaded. Default implementation does nothing. Can center the view
* if the new graph displays completely different content and the matching node doesn't exist.
*/
virtual void restoreCurrentBlock();
void initFont();
QPoint getTextOffset(int line) const;
GraphLayout::LayoutConfig getLayoutConfig();
virtual void updateLayout();
// Font data
std::unique_ptr<CachedFontMetrics<qreal>> mFontMetrics;
qreal ACharWidth; // width of character A
int charHeight;
int charOffset;
int baseline;
qreal padding;
// colors
QColor disassemblyBackgroundColor;
QColor disassemblySelectedBackgroundColor;
QColor disassemblySelectionColor;
QColor PCSelectionColor;
QColor jmpColor;
QColor brtrueColor;
QColor brfalseColor;
QColor retShadowColor;
QColor indirectcallShadowColor;
QColor mAutoCommentColor;
QColor mAutoCommentBackgroundColor;
QColor mCommentColor;
QColor mCommentBackgroundColor;
QColor mLabelColor;
QColor mLabelBackgroundColor;
QColor graphNodeColor;
QColor mAddressColor;
QColor mAddressBackgroundColor;
QColor mCipColor;
QColor mBreakpointColor;
QColor mDisabledBreakpointColor;
QAction actionExportGraph;
GraphView::Layout graphLayout;
QMenu *layoutMenu;
QAction *horizontalLayoutAction;
private:
void colorsUpdatedSlot();
};
#endif // CUTTER_GRAPHVIEW_H
| 4,883
|
C++
|
.h
| 138
| 29.782609
| 99
| 0.713349
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,700
|
TypesWidget.h
|
rizinorg_cutter/src/widgets/TypesWidget.h
|
#ifndef TYPESWIDGET_H
#define TYPESWIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class TypesWidget;
namespace Ui {
class TypesWidget;
}
class MainWindow;
class QTreeWidgetItem;
class TypesModel : public QAbstractListModel
{
Q_OBJECT
friend TypesWidget;
private:
QList<TypeDescription> *types;
/**
* @brief Returns a description of the type for the given index
*/
QVariant toolTipValue(const QModelIndex &index) const;
public:
enum Columns { TYPE = 0, SIZE, CATEGORY, FORMAT, COUNT };
static const int TypeDescriptionRole = Qt::UserRole;
TypesModel(QList<TypeDescription> *types, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
};
class TypesSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
TypesSortFilterProxyModel(TypesModel *source_model, QObject *parent = nullptr);
void setCategory(QString category);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
QString selectedCategory;
};
class TypesWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit TypesWidget(MainWindow *main);
~TypesWidget();
private slots:
void refreshTypes();
/**
* @brief Show custom context menu
* @param pt Position of the place where the right mouse button was clicked
*/
void showTypesContextMenu(const QPoint &pt);
/**
* @brief Executed on clicking the Export Types option in the context menu
* It shows the user a file dialog box to select a file where the types
* will be exported.
*/
void on_actionExport_Types_triggered();
/**
* @brief Executed on clicking the Load New types option in the context menu
* It will open the TypesInteractionDialog where the user can either enter the
* types manually, or can select a file from where the types will be loaded
*/
void on_actionLoad_New_Types_triggered();
/**
* @brief Executed on clicking either the Edit Type or View Type options in the context menu
* It will open the TypesInteractionDialog filled with the selected type. Depends on Edit or
* View mode the text view would be read-only or not.
*/
void viewType(bool readOnly = true);
/**
* @brief Executed on clicking the Delete Type option in the context menu
* Upon confirmation from the user, it will delete the selected type.
*/
void on_actionDelete_Type_triggered();
/**
* @brief triggers when the user double-clicks an item. This will open
* a dialog that shows the Type's content
*/
void typeItemDoubleClicked(const QModelIndex &index);
private:
std::unique_ptr<Ui::TypesWidget> ui;
TypesModel *types_model;
TypesSortFilterProxyModel *types_proxy_model;
QList<TypeDescription> types;
CutterTreeWidget *tree;
QAction *actionViewType;
QAction *actionEditType;
void setScrollMode();
/**
* @brief Sets the contents of the ComboBox to the supplied contents
* @param categories The list of categories which has to be added to the ComboBox
*/
void refreshCategoryCombo(const QStringList &categories);
};
#endif // TYPESWIDGET_H
| 3,875
|
C++
|
.h
| 105
| 32.409524
| 96
| 0.735884
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,701
|
MemoryMapWidget.h
|
rizinorg_cutter/src/widgets/MemoryMapWidget.h
|
#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "ListDockWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class MemoryMapWidget;
namespace Ui {
class MemoryMapWidget;
}
class MainWindow;
class QTreeWidgetItem;
class MemoryMapModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend MemoryMapWidget;
private:
QList<MemoryMapDescription> *memoryMaps;
public:
enum Column {
AddrStartColumn = 0,
AddrEndColumn,
NameColumn,
PermColumn,
CommentColumn,
ColumnCount
};
enum Role { MemoryDescriptionRole = Qt::UserRole };
MemoryMapModel(QList<MemoryMapDescription> *memoryMaps, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
};
class MemoryProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
MemoryProxyModel(MemoryMapModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class MemoryMapWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit MemoryMapWidget(MainWindow *main);
~MemoryMapWidget();
private slots:
void refreshMemoryMap();
private:
MemoryMapModel *memoryModel;
MemoryProxyModel *memoryProxyModel;
QList<MemoryMapDescription> memoryMaps;
RefreshDeferrer *refreshDeferrer;
};
| 1,931
|
C++
|
.h
| 62
| 27.064516
| 87
| 0.767064
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,702
|
RegistersWidget.h
|
rizinorg_cutter/src/widgets/RegistersWidget.h
|
#pragma once
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QGridLayout>
#include <QJsonObject>
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "menus/AddressableItemContextMenu.h"
class MainWindow;
namespace Ui {
class RegistersWidget;
}
class RegistersWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit RegistersWidget(MainWindow *main);
~RegistersWidget();
private slots:
void updateContents();
void setRegisterGrid();
void openContextMenu(QPoint point, QString address);
private:
std::unique_ptr<Ui::RegistersWidget> ui;
QGridLayout *registerLayout = new QGridLayout;
AddressableItemContextMenu addressContextMenu;
int numCols = 2;
int registerLen = 0;
RefreshDeferrer *refreshDeferrer;
};
| 804
|
C++
|
.h
| 31
| 23.129032
| 56
| 0.784314
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,703
|
WidgetShortcuts.h
|
rizinorg_cutter/src/widgets/WidgetShortcuts.h
|
#ifndef WIDGETSHORTCUTS_H
#define WIDGETSHORTCUTS_H
#include <QKeySequence>
#include <QHash>
#include <QString>
static const QHash<QString, QKeySequence> widgetShortcuts = {
{ "StringsWidget", Qt::SHIFT | Qt::Key_F12 }, { "GraphWidget", Qt::SHIFT | Qt::Key_G },
{ "ImportsWidget", Qt::SHIFT | Qt::Key_I }, { "ExportsWidget", Qt::SHIFT | Qt::Key_E },
{ "ConsoleWidget", Qt::CTRL | Qt::Key_QuoteLeft }, { "ConsoleWidgetAlternative", Qt::Key_Colon }
};
#endif
| 484
|
C++
|
.h
| 11
| 41.636364
| 100
| 0.670213
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,704
|
ColorPicker.h
|
rizinorg_cutter/src/widgets/ColorPicker.h
|
#ifndef COLORPICKER_H
#define COLORPICKER_H
#include <QWidget>
/**
* @namespace ColorPickerHelpers is a namespace that hides all classes needed for ColorPicker class,
* because classes inherite QObject can not be declared in *.cpp files or inside of another class.
*/
namespace ColorPickerHelpers {
class ColorPickWidgetAbstract : public QWidget
{
Q_OBJECT
public:
ColorPickWidgetAbstract(QWidget *parent = nullptr) : QWidget(parent) {}
virtual ~ColorPickWidgetAbstract() {}
signals:
void colorChanged(const QColor &color);
public slots:
virtual void setColor(const QColor &color) = 0;
protected:
QColor currColor;
};
}
namespace Ui {
class ColorPicker;
}
/**
* @brief The ColorPicker class provides widget that allows user to pick color
* from screen or from palette or type in HSV or RGB or HEX representation of color.
*/
class ColorPicker : public ColorPickerHelpers::ColorPickWidgetAbstract
{
Q_OBJECT
public:
explicit ColorPicker(QWidget *parent = nullptr);
~ColorPicker();
/**
* @brief isPickingFromScreen returns true if color picker is picking from screen.
*/
bool isPickingFromScreen() const;
void setAlphaEnabled(bool enabled);
public slots:
/**
* @brief setColor sets displayed color to @a color and emits colorChanged signal.
*/
virtual void setColor(const QColor &color) override;
void colorChannelChanged();
/**
* @brief updateColor sets displayed color to @a color.
*/
void updateColor(const QColor &color);
/**
* @brief startPickingFromScreen starts process of picking from screen.
* Function is called automatically when "Pick from screen" button is clicked.
*/
void startPickingFromScreen();
/**
* @brief stopPickingFromScreen terminates process of picking from screen.
*/
void stopPickingFromScreen();
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
private:
Ui::ColorPicker *ui;
bool pickingFromScreen;
QColor getColorAtMouse();
/**
* @brief bufferColor is used to buffer current color while picking from screen.
*/
QColor bufferColor;
};
namespace ColorPickerHelpers {
/**
* @brief The ColorPickerWidget class is parent class for ColorPickArea and ColorValueBar classes.
*/
class ColorPickerWidget : public ColorPickWidgetAbstract
{
Q_OBJECT
public:
ColorPickerWidget(QWidget *parent = nullptr);
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
virtual void mouseEvent(QMouseEvent *event);
/**
* @brief pointToColor converts coordinates on widget to color these coordinates represents.
*/
virtual QColor pointToColor(int x, int y) const = 0;
/**
* @brief colorToPoint converts color to coordinates that represent this color.
*/
virtual QPoint colorToPoint(const QColor &color) const = 0;
};
class ColorShowWidget : public ColorPickWidgetAbstract
{
Q_OBJECT
public:
explicit ColorShowWidget(QWidget *parent = nullptr);
void setColor(const QColor &c) override;
protected:
void paintEvent(QPaintEvent *event) override;
};
/**
* @brief The ColorPickArea class provides widget that helps to pick
* Saturation and Hue of color in HSV colorspace.
*/
class ColorPickArea : public ColorPickerWidget
{
Q_OBJECT
public:
explicit ColorPickArea(QWidget *parent = nullptr);
void setColor(const QColor &c) override;
protected:
void paintEvent(QPaintEvent *event) override;
private:
QColor pointToColor(int x, int y) const override;
QPoint colorToPoint(const QColor &color) const override;
};
class AlphaChannelBar : public ColorPickerWidget
{
Q_OBJECT
public:
AlphaChannelBar(QWidget *parent = nullptr) : ColorPickerWidget(parent) {}
void setColor(const QColor &c) override;
protected:
void paintEvent(QPaintEvent *event) override;
private:
QColor pointToColor(int x, int y) const override;
QPoint colorToPoint(const QColor &color) const override;
};
/**
* @brief The ColorValueBar class provides widget that helps to set Valuse of color
* in HSV colorspace.
*/
class ColorValueBar : public ColorPickerWidget
{
Q_OBJECT
public:
ColorValueBar(QWidget *parent = nullptr) : ColorPickerWidget(parent) {}
void setColor(const QColor &c) override;
protected:
void paintEvent(QPaintEvent *event) override;
private:
QColor pointToColor(int x, int y) const override;
QPoint colorToPoint(const QColor &color) const override;
};
}
#endif // COLORPICKER_H
| 4,713
|
C++
|
.h
| 149
| 28.073826
| 100
| 0.753649
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,705
|
DisassemblerGraphView.h
|
rizinorg_cutter/src/widgets/DisassemblerGraphView.h
|
#ifndef DISASSEMBLERGRAPHVIEW_H
#define DISASSEMBLERGRAPHVIEW_H
// Based on the DisassemblerGraphView from x64dbg
#include <QWidget>
#include <QPainter>
#include <QShortcut>
#include <QLabel>
#include "widgets/CutterGraphView.h"
#include "menus/DisassemblyContextMenu.h"
#include "common/RichTextPainter.h"
#include "common/CutterSeekable.h"
class QTextEdit;
class FallbackSyntaxHighlighter;
class DisassemblerGraphView : public CutterGraphView
{
Q_OBJECT
struct Text
{
std::vector<RichTextPainter::List> lines;
Text() {}
Text(const QString &text, QColor color, QColor background)
{
RichTextPainter::List richText;
RichTextPainter::CustomRichText_t rt;
rt.highlight = false;
rt.text = text;
rt.textColor = color;
rt.textBackground = background;
rt.flags = rt.textBackground.alpha() ? RichTextPainter::FlagAll
: RichTextPainter::FlagColor;
richText.push_back(rt);
lines.push_back(richText);
}
Text(const RichTextPainter::List &richText) { lines.push_back(richText); }
QString ToQString() const
{
QString result;
for (const auto &line : lines) {
for (const auto &t : line) {
result += t.text;
}
}
return result;
}
};
struct Instr
{
ut64 addr = 0;
ut64 size = 0;
Text text;
Text fullText;
QString plainText;
std::vector<unsigned char> opcode; // instruction bytes
bool empty() const { return size == 0; }
bool contains(ut64 addr) const;
};
struct Token
{
int start;
int length;
QString type;
Instr *instr;
QString name;
QString content;
};
struct DisassemblyBlock
{
Text header_text;
std::vector<Instr> instrs;
ut64 entry = 0;
ut64 true_path = 0;
ut64 false_path = 0;
bool terminal = false;
bool indirectcall = false;
};
public:
DisassemblerGraphView(QWidget *parent, CutterSeekable *seekable, MainWindow *mainWindow,
QList<QAction *> additionalMenuAction);
~DisassemblerGraphView() override;
std::unordered_map<ut64, DisassemblyBlock> disassembly_blocks;
virtual void drawBlock(QPainter &p, GraphView::GraphBlock &block, bool interactive) override;
virtual void blockClicked(GraphView::GraphBlock &block, QMouseEvent *event,
QPoint pos) override;
virtual void blockDoubleClicked(GraphView::GraphBlock &block, QMouseEvent *event,
QPoint pos) override;
virtual bool helpEvent(QHelpEvent *event) override;
virtual void blockHelpEvent(GraphView::GraphBlock &block, QHelpEvent *event,
QPoint pos) override;
virtual GraphView::EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from,
GraphView::GraphBlock *to,
bool interactive) override;
virtual void blockTransitionedTo(GraphView::GraphBlock *to) override;
void loadCurrentGraph();
QString windowTitle;
int getWidth() { return width; }
int getHeight() { return height; }
std::unordered_map<ut64, GraphBlock> getBlocks() { return blocks; }
using EdgeConfigurationMapping = std::map<std::pair<ut64, ut64>, EdgeConfiguration>;
EdgeConfigurationMapping getEdgeConfigurations();
/**
* @brief keep the current addr of the fcn of Graph
* Everytime overview updates its contents, it compares this value with the one in Graph
* if they aren't same, then Overview needs to update the pixmap cache.
*/
ut64 currentFcnAddr = RVA_INVALID; // TODO: make this less public
public slots:
void refreshView() override;
void onSeekChanged(RVA addr);
void takeTrue();
void takeFalse();
void nextInstr();
void prevInstr();
void copySelection();
protected:
void paintEvent(QPaintEvent *event) override;
void blockContextMenuRequested(GraphView::GraphBlock &block, QContextMenuEvent *event,
QPoint pos) override;
void contextMenuEvent(QContextMenuEvent *event) override;
void restoreCurrentBlock() override;
bool eventFilter(QObject *obj, QEvent *event) override;
private slots:
void showExportDialog() override;
void onActionHighlightBITriggered();
void onActionUnhighlightBITriggered();
void setTooltipStylesheet();
private:
bool transition_dont_seek = false;
Token *highlight_token;
bool emptyGraph;
ut64 currentBlockAddress = RVA_INVALID;
DisassemblyContextMenu *blockMenu;
QMenu *contextMenu;
void connectSeekChanged(bool disconnect);
void prepareGraphNode(GraphBlock &block);
Token *getToken(Instr *instr, int x);
QPoint getInstructionOffset(const DisassemblyBlock &block, int line) const;
RVA getAddrForMouseEvent(GraphBlock &block, QPoint *point);
Instr *getInstrForMouseEvent(GraphBlock &block, QPoint *point, bool force = false);
/**
* @brief Get instructions placement and size relative to block.
* Inefficient don't use this function when iterating over all instructions.
* @param block
* @param addr
* @return
*/
QRectF getInstrRect(GraphView::GraphBlock &block, RVA addr) const;
void showInstruction(GraphView::GraphBlock &block, RVA addr);
const Instr *instrForAddress(RVA addr);
DisassemblyBlock *blockForAddress(RVA addr);
void seekLocal(RVA addr, bool update_viewport = true);
void seekInstruction(bool previous_instr);
CutterSeekable *seekable = nullptr;
QList<QShortcut *> shortcuts;
QList<RVA> breakpoints;
QAction actionUnhighlight;
QAction actionUnhighlightInstruction;
QLabel *emptyText = nullptr;
signals:
void nameChanged(const QString &name);
public:
bool isGraphEmpty() { return emptyGraph; }
};
#endif // DISASSEMBLERGRAPHVIEW_H
| 6,245
|
C++
|
.h
| 163
| 30.202454
| 97
| 0.662973
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,706
|
GraphWidget.h
|
rizinorg_cutter/src/widgets/GraphWidget.h
|
#ifndef GRAPHWIDGET_H
#define GRAPHWIDGET_H
#include "MemoryDockWidget.h"
#include <QLineEdit>
class MainWindow;
class DisassemblerGraphView;
class GraphWidget : public MemoryDockWidget
{
Q_OBJECT
public:
explicit GraphWidget(MainWindow *main);
~GraphWidget() override {}
DisassemblerGraphView *getGraphView() const;
static QString getWidgetType();
signals:
void graphClosed();
protected:
QWidget *widgetToFocusOnRaise() override;
private:
void closeEvent(QCloseEvent *event) override;
QString getWindowTitle() const override;
void prepareHeader();
DisassemblerGraphView *graphView;
QLineEdit *header = nullptr;
};
#endif // GRAPHWIDGET_H
| 699
|
C++
|
.h
| 26
| 23.576923
| 49
| 0.779123
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,707
|
ComboQuickFilterView.h
|
rizinorg_cutter/src/widgets/ComboQuickFilterView.h
|
#ifndef COMBOQUICKFILTERVIEW_H
#define COMBOQUICKFILTERVIEW_H
#include "core/CutterCommon.h"
#include <QWidget>
#include <QComboBox>
#include <QTimer>
namespace Ui {
class ComboQuickFilterView;
}
class CUTTER_EXPORT ComboQuickFilterView : public QWidget
{
Q_OBJECT
public:
explicit ComboQuickFilterView(QWidget *parent = nullptr);
~ComboQuickFilterView();
void setLabelText(const QString &text);
QComboBox *comboBox();
public slots:
void showFilter();
void closeFilter();
void clearFilter();
signals:
void filterTextChanged(const QString &text);
void filterClosed();
private:
Ui::ComboQuickFilterView *ui;
QTimer *debounceTimer;
};
#endif // COMBOQUICKFILTERVIEW_H
| 723
|
C++
|
.h
| 29
| 21.931034
| 61
| 0.77193
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,708
|
CommentsWidget.h
|
rizinorg_cutter/src/widgets/CommentsWidget.h
|
#ifndef COMMENTSWIDGET_H
#define COMMENTSWIDGET_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "common/AddressableItemModel.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include "widgets/ListDockWidget.h"
class MainWindow;
class QTreeWidgetItem;
class CommentsWidget;
struct CommentGroup
{
QString name;
RVA offset;
QList<CommentDescription> comments;
};
class CommentsModel : public AddressableItemModel<>
{
Q_OBJECT
friend CommentsWidget;
private:
QList<CommentDescription> *comments;
QList<CommentGroup> *nestedComments;
bool nested;
public:
enum Column { OffsetColumn = 0, FunctionColumn, CommentColumn, ColumnCount };
enum NestedColumn { OffsetNestedColumn = 0, CommentNestedColumn, NestedColumnCount };
enum Role { CommentDescriptionRole = Qt::UserRole, FunctionRole };
CommentsModel(QList<CommentDescription> *comments, QList<CommentGroup> *nestedComments,
QObject *parent = nullptr);
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
bool isNested() const;
void setNested(bool nested);
RVA address(const QModelIndex &index) const override;
};
class CommentsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
CommentsProxyModel(CommentsModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class CommentsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit CommentsWidget(MainWindow *main);
~CommentsWidget() override;
private slots:
void onActionHorizontalToggled(bool checked);
void onActionVerticalToggled(bool checked);
void showTitleContextMenu(const QPoint &pt);
void refreshTree();
private:
CommentsModel *commentsModel;
CommentsProxyModel *commentsProxyModel;
QAction actionHorizontal;
QAction actionVertical;
QList<CommentDescription> comments;
QList<CommentGroup> nestedComments;
QMenu *titleContextMenu;
};
#endif // COMMENTSWIDGET_H
| 2,699
|
C++
|
.h
| 75
| 31.706667
| 91
| 0.768668
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,709
|
HeapBinsGraphView.h
|
rizinorg_cutter/src/widgets/HeapBinsGraphView.h
|
#ifndef CUTTER_HEAPBINSGRAPHVIEW_H
#define CUTTER_HEAPBINSGRAPHVIEW_H
#include "SimpleTextGraphView.h"
class HeapBinsGraphView : public SimpleTextGraphView
{
Q_OBJECT
struct GraphHeapChunk
{
QString content;
ut64 addr;
ut64 fd;
ut64 bk;
};
public:
explicit HeapBinsGraphView(QWidget *parent, RzHeapBin *bin, MainWindow *main);
protected:
void loadCurrentGraph() override;
void drawBlock(QPainter &p, GraphView::GraphBlock &block, bool interactive) override;
void addBlock(GraphLayout::GraphBlock block, const QString &text,
RVA address = RVA_INVALID) override;
void blockContextMenuRequested(GraphView::GraphBlock &block, QContextMenuEvent *event,
QPoint) override;
private slots:
void viewChunkInfo();
private:
RzHeapBin *heapBin;
void display_single_linked_list(QVector<GraphHeapChunk>);
void display_double_linked_list(QVector<GraphHeapChunk>);
QAction *chunkInfoAction;
RVA selectedBlock;
int bits;
};
#endif // CUTTER_HEAPBINSGRAPHVIEW_H
| 1,098
|
C++
|
.h
| 33
| 27.575758
| 90
| 0.721435
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,710
|
HeadersWidget.h
|
rizinorg_cutter/src/widgets/HeadersWidget.h
|
#ifndef HEADERSWIDGET_H
#define HEADERSWIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "ListDockWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
namespace Ui {
class HeadersWidget;
}
class MainWindow;
class QTreeWidgetItem;
class HeadersWidget;
class HeadersModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend HeadersWidget;
private:
QList<HeaderDescription> *headers;
public:
enum Column { OffsetColumn = 0, NameColumn, ValueColumn, CommentColumn, ColumnCount };
enum Role { HeaderDescriptionRole = Qt::UserRole };
HeadersModel(QList<HeaderDescription> *headers, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
class HeadersProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
HeadersProxyModel(HeadersModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class HeadersWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit HeadersWidget(MainWindow *main);
~HeadersWidget();
private slots:
void refreshHeaders();
private:
HeadersModel *headersModel;
HeadersProxyModel *headersProxyModel;
QList<HeaderDescription> headers;
};
#endif // HEADERSWIDGET_H
| 1,878
|
C++
|
.h
| 56
| 30.071429
| 90
| 0.781111
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,711
|
DecompilerWidget.h
|
rizinorg_cutter/src/widgets/DecompilerWidget.h
|
#ifndef DECOMPILERWIDGET_H
#define DECOMPILERWIDGET_H
#include <QTextEdit>
#include <memory>
#include "core/Cutter.h"
#include "MemoryDockWidget.h"
#include "Decompiler.h"
namespace Ui {
class DecompilerWidget;
}
class QTextEdit;
class QSyntaxHighlighter;
class QTextCursor;
class DecompilerContextMenu;
struct DecompiledCodeTextLine;
class DecompilerWidget : public MemoryDockWidget
{
Q_OBJECT
protected:
DecompilerContextMenu *mCtxMenu;
public:
explicit DecompilerWidget(MainWindow *main);
~DecompilerWidget();
static QString getWidgetType();
public slots:
void showDecompilerContextMenu(const QPoint &pt);
void highlightPC();
private slots:
/**
* @brief Copy to clipboard what's needed depending on the state of text widget.
*
* @note If something is selected in the text widget, copy selection.
* If something is highlighted, copy highlighted word.
* Otherwise, copy the line under cursor.
*/
void copy();
void fontsUpdatedSlot();
void colorsUpdatedSlot();
void refreshDecompiler();
void decompilerSelected();
void cursorPositionChanged();
/**
* @brief When the synced seek is changed, this refreshes the decompiler widget if needed.
*
* Decompiler widget is not refreshed in the following two cases
* - Seek changed to an offset contained in the decompiled function.
* - Auto-refresh is disabled.
*/
void seekChanged(RVA /* addr */, CutterCore::SeekHistoryType type);
void decompilationFinished(RzAnnotatedCode *code);
private:
std::unique_ptr<Ui::DecompilerWidget> ui;
RefreshDeferrer *refreshDeferrer;
bool usingAnnotationBasedHighlighting = false;
std::unique_ptr<QSyntaxHighlighter> syntaxHighlighter;
bool decompilerSelectionEnabled;
/**
* True if the selected decompiler is currently running a decompilation for this widget. Once
* the decompilation is over, this should be set to false.
*/
bool decompilerBusy;
bool seekFromCursor;
int historyPos;
QVector<QPair<int, int>> scrollHistory;
RVA previousFunctionAddr;
RVA decompiledFunctionAddr;
std::unique_ptr<RzAnnotatedCode, void (*)(RzAnnotatedCode *)> code;
/**
* Specifies the lowest offset of instructions among all the instructions in the decompiled
* function.
*/
RVA lowestOffsetInCode;
/**
* Specifies the highest offset of instructions among all the instructions in the decompiled
* function.
*/
RVA highestOffsetInCode;
/**
* @brief Gets the current decompiler selected by the user.
*
* @return A pointer to the currently selected decompiler
*/
Decompiler *getCurrentDecompiler();
/**
* @brief Calls the function doRefresh() if the address specified is a part of the decompiled
* function.
*
* @param addr Address at which a change occurred.
*/
void refreshIfChanged(RVA addr);
/**
* @brief Refreshes the decompiler.
*
* - This does the following if the specified offset is valid
* - Decompile function that contains the specified offset.
* - Clears all selections stored for highlighting purposes.
* - Reset previousFunctionAddr with the current function's address
* and decompiledFunctionAddr with the address of the function that
* was decompiled.
* - If the offset is invalid, error message is shown in the text widget.
*
* @param addr Specified offset/offset in sync.
*/
void doRefresh();
/**
* @brief Update fonts
*/
void setupFonts();
/**
* @brief Update highlights in the text widget.
*
* These include respective highlights for:
* - Line under cursor
* - Word under cursor
* - Program Counter(PC) while debugging
*/
void updateSelection();
/**
* @brief Connect/Disconnect SIGNAL-SLOT connection that deals with changes in cursor position.
*
* If the argument is true, then connect the SIGNAL-SLOT connection
* that changes the view as cursor position gets changed in the text widget.
* Otherwise, disconnect the corresponding signal with slot.
*
* @param connectPositionChange
*/
void connectCursorPositionChanged(bool connectPositionChange);
/**
* @brief Find the current global offset in sync and update cursor
* to the position specified by this offset (found using positionForOffset() )
*/
void updateCursorPosition();
QString getWindowTitle() const override;
/**
* @brief Event filter that intercept the following events:
* 1. Double click
* 2. Right click
*
* @param obj
* @param event
* @return
*/
bool eventFilter(QObject *obj, QEvent *event) override;
/**
* @brief a wrapper around CutterSeekable::seekToReference to seek to an object which is
* referenced from the address under cursor
*/
void seekToReference();
/**
* @brief Retrieve the Cursor for a location as close as possible to the given address
* @param addr - an address in the decompiled function
* @return a Cursor object for the given address
*/
QTextCursor getCursorForAddress(RVA addr);
/**
* @brief Append a highlighted line to the TextEdit
* @param extraSelection - an ExtraSelection object colored with the appropriate color
* @return True on success, otherwise False
*/
bool colorLine(QTextEdit::ExtraSelection extraSelection);
/**
* @brief This function is responsible for highlighting all the breakpoints in the decompiler
* view. It will also run when a breakpoint is added, removed or modified.
*/
void highlightBreakpoints();
/**
* @brief Finds the earliest offset and breakpoints within the specified range [startPos,
* endPos] 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 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(RzAnnotatedCode &codeDecompiled, size_t startPos, size_t endPos);
/**
* @brief Finds the global variable reference that's closes to the specified position in the
* decompiled code. Same as offsetForPosition but for global references only
*
* @note If no global reference annotations are found at the given position, an RVA_INVALID is
* returned
*
* @param pos - Position in the decompiled code
* @return Address of the referenced global for the specified position, or RVA_INVALID if none
* is found
*/
ut64 findReference(size_t pos);
/**
* @brief Finds the offset that's closest to the specified position in the decompiled code.
*
* @note If no annotations that covers the specified position is found, the first offset in the
* line containing specified position will be returned
*
* @param pos - Position of the decompiled code.
* @return Offset for the specified position/first offset in line.
*/
ut64 offsetForPosition(size_t pos);
/**
* @brief Find the start position of the annotation with the offset that's closest to
* the specified offset
*
* @param offset
* @return Position found or SIZE_MAX
*/
size_t positionForOffset(ut64 offset);
/**
* @brief Updates the view when breakpoints are changed
*/
void updateBreakpoints(RVA addr);
/**
* @brief Set information about the breakpoints on the line in the context menu
*/
void setInfoForBreakpoints();
/**
* @brief Find the context-related annotation covering the specified position.
* If found, set the variable annotationHere in the decompiler context menu.
*
* @param pos Position of cursor in the decompiled code.
*/
void setAnnotationsAtCursor(size_t pos);
/**
* @brief Checks if the specified address is a part of the decompiled function.
*
* @param addr An offset in the binary.
* @return True if the specified is a part of the decompiled function, False otherwise.
*/
bool addressInRange(RVA addr);
void setCode(RzAnnotatedCode *code);
void setHighlighter(bool annotationBasedHighlighter);
};
#endif // DECOMPILERWIDGET_H
| 8,804
|
C++
|
.h
| 235
| 32.2
| 99
| 0.701814
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,712
|
ResourcesWidget.h
|
rizinorg_cutter/src/widgets/ResourcesWidget.h
|
#ifndef RESOURCESWIDGET_H
#define RESOURCESWIDGET_H
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeView.h"
#include "common/AddressableItemModel.h"
#include "widgets/ListDockWidget.h"
class MainWindow;
class ResourcesWidget;
class ResourcesModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend ResourcesWidget;
private:
QList<ResourcesDescription> *resources;
public:
enum Columns { INDEX = 0, NAME, VADDR, TYPE, SIZE, LANG, COMMENT, COUNT };
explicit ResourcesModel(QList<ResourcesDescription> *resources, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
};
class ResourcesWidget : public ListDockWidget
{
Q_OBJECT
private:
ResourcesModel *model;
AddressableFilterProxyModel *filterModel;
QList<ResourcesDescription> resources;
public:
explicit ResourcesWidget(MainWindow *main);
private slots:
void refreshResources();
};
#endif // RESOURCESWIDGET_H
| 1,354
|
C++
|
.h
| 38
| 31.947368
| 95
| 0.77573
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,713
|
GraphHorizontalAdapter.h
|
rizinorg_cutter/src/widgets/GraphHorizontalAdapter.h
|
#ifndef GRAPH_HORIZONTAL_ADAPTER_H
#define GRAPH_HORIZONTAL_ADAPTER_H
#include "core/Cutter.h"
#include "GraphLayout.h"
#include <memory>
/**
* @brief Adapter for converting vertical graph layout into horizontal one.
*/
class GraphHorizontalAdapter : public GraphLayout
{
public:
GraphHorizontalAdapter(std::unique_ptr<GraphLayout> layout);
virtual void CalculateLayout(GraphLayout::Graph &blocks, ut64 entry, int &width,
int &height) const override;
void setLayoutConfig(const LayoutConfig &config) override;
private:
std::unique_ptr<GraphLayout> layout;
void swapLayoutConfigDirection();
};
#endif // GRAPH_HORIZONTAL_ADAPTER_H
| 690
|
C++
|
.h
| 20
| 30.5
| 84
| 0.75188
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,714
|
GraphGridLayout.h
|
rizinorg_cutter/src/widgets/GraphGridLayout.h
|
#ifndef GRAPHGRIDLAYOUT_H
#define GRAPHGRIDLAYOUT_H
#include "core/Cutter.h"
#include "GraphLayout.h"
#include "common/LinkedListPool.h"
/**
* @brief Graph layout algorithm on layered graph layout approach. For simplicity all the nodes are
* placed in a grid.
*/
class GraphGridLayout : public GraphLayout
{
public:
enum class LayoutType {
Medium,
Wide,
Narrow,
};
GraphGridLayout(LayoutType layoutType = LayoutType::Medium);
virtual void CalculateLayout(Graph &blocks, ut64 entry, int &width, int &height) const override;
void setTightSubtreePlacement(bool enabled) { tightSubtreePlacement = enabled; }
void setParentBetweenDirectChild(bool enabled) { parentBetweenDirectChild = enabled; }
void setverticalBlockAlignmentMiddle(bool enabled) { verticalBlockAlignmentMiddle = enabled; }
void setLayoutOptimization(bool enabled) { useLayoutOptimization = enabled; }
private:
/// false - use bounding box for smallest subtree when placing them side by side
bool tightSubtreePlacement = false;
/// true if code should try to place parent between direct children as much as possible
bool parentBetweenDirectChild = false;
/// false if blocks in rows should be aligned at top, true for middle alignment
bool verticalBlockAlignmentMiddle = false;
bool useLayoutOptimization = true;
struct GridBlock
{
ut64 id;
std::vector<ut64> tree_edge; //!< subset of outgoing edges that form a tree
std::vector<ut64> dag_edge; //!< subset of outgoing edges that form a dag
std::size_t has_parent = false;
int inputCount = 0;
int outputCount = 0;
/// Number of rows in subtree
int row_count = 0;
/// Column in which the block is
int col = 0;
/// Row in which the block is
int row = 0;
ut64 mergeBlock = 0;
int lastRowLeft; //!< left side of subtree last row
int lastRowRight; //!< right side of subtree last row
int leftPosition; //!< left side of subtree
int rightPosition; //!< right side of subtree
LinkedListPool<int>::List leftSideShape;
LinkedListPool<int>::List rightSideShape;
};
struct Point
{
int row;
int col;
int offset;
int16_t kind;
int16_t spacingOverride;
};
struct GridEdge
{
ut64 dest;
int mainColumn = -1;
std::vector<Point> points;
int secondaryPriority;
void addPoint(int row, int col, int16_t kind = 0)
{
this->points.push_back({ row, col, 0, kind, 0 });
}
};
struct LayoutState
{
std::unordered_map<ut64, GridBlock> grid_blocks;
std::unordered_map<ut64, GraphBlock> *blocks = nullptr;
std::unordered_map<ut64, std::vector<GridEdge>> edge;
size_t rows = -1;
size_t columns = -1;
std::vector<int> columnWidth;
std::vector<int> rowHeight;
std::vector<int> edgeColumnWidth;
std::vector<int> edgeRowHeight;
std::vector<int> columnOffset;
std::vector<int> rowOffset;
std::vector<int> edgeColumnOffset;
std::vector<int> edgeRowOffset;
};
using GridBlockMap = std::unordered_map<ut64, GridBlock>;
/**
* @brief Find nodes where control flow merges after splitting.
* Sets node column offset so that after computing placement merge point is centered bellow
* nodes above.
*/
void findMergePoints(LayoutState &state) const;
/**
* @brief Compute node rows and columns within grid.
* @param blockOrder Nodes in the reverse topological order.
*/
void computeAllBlockPlacement(const std::vector<ut64> &blockOrder,
LayoutState &layoutState) const;
/**
* @brief Perform the topological sorting of graph nodes.
* If the graph contains loops, a subset of edges is selected. Subset of edges forming DAG are
* stored in GridBlock::dag_edge.
* @param state Graph layout state including the input graph.
* @param entry Entrypoint node. When removing loops prefer placing this node at top.
* @return Reverse topological ordering.
*/
static std::vector<ut64> topoSort(LayoutState &state, ut64 entry);
/**
* @brief Assign row positions to nodes.
* @param state
* @param blockOrder reverse topological ordering of nodes
*/
static void assignRows(LayoutState &state, const std::vector<ut64> &blockOrder);
/**
* @brief Select subset of DAG edges that form tree.
* @param state
*/
static void selectTree(LayoutState &state);
/**
* @brief routeEdges Route edges, expects node positions to be calculated previously.
*/
void routeEdges(LayoutState &state) const;
/**
* @brief Choose which column to use for transition from start node row to target node row.
*/
void calculateEdgeMainColumn(LayoutState &state) const;
/**
* @brief Do rough edge routing within grid using up to 5 segments.
*/
void roughRouting(LayoutState &state) const;
/**
* @brief Calculate segment placement relative to their columns.
*/
void elaborateEdgePlacement(LayoutState &state) const;
/**
* @brief Recalculate column widths, trying to compensate for the space taken by edge columns.
*/
void adjustColumnWidths(LayoutState &state) const;
/**
* @brief Calculate position of each column(or row) based on widths.
* It is assumed that columnWidth.size() + 1 = edgeColumnWidth.size() and they are interleaved.
* @param columnWidth
* @param edgeColumnWidth
* @param columnOffset
* @param edgeColumnOffset
* @return total width of all the columns
*/
static int calculateColumnOffsets(const std::vector<int> &columnWidth,
std::vector<int> &edgeColumnWidth,
std::vector<int> &columnOffset,
std::vector<int> &edgeColumnOffset);
/**
* @brief Final graph layout step. Convert grids cell relative positions to absolute pixel
* positions.
* @param state
* @param width image width output argument
* @param height image height output argument
*/
void convertToPixelCoordinates(LayoutState &state, int &width, int &height) const;
/**
* @brief Move the graph content to top left corner and update dimensions.
* @param graph
* @param width width after cropping
* @param height height after cropping
*/
void cropToContent(Graph &graph, int &width, int &height) const;
/**
* @brief Connect edge ends to blocks by changing y.
* @param graph
*/
void connectEdgeEnds(Graph &graph) const;
/**
* @brief Reduce spacing between nodes and edges by pushing everything together ignoring the
* grid.
* @param state
*/
void optimizeLayout(LayoutState &state) const;
};
#endif // GRAPHGRIDLAYOUT_H
| 7,084
|
C++
|
.h
| 182
| 32.021978
| 100
| 0.66473
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,715
|
OverviewWidget.h
|
rizinorg_cutter/src/widgets/OverviewWidget.h
|
#ifndef OVERVIEWWIDGET_H
#define OVERVIEWWIDGET_H
#include "CutterDockWidget.h"
class MainWindow;
class OverviewView;
class GraphWidget;
class OverviewWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit OverviewWidget(MainWindow *main);
~OverviewWidget();
private:
OverviewView *graphView;
bool isAvailable = false;
bool userOpened = false;
GraphWidget *targetGraphWidget;
RefreshDeferrer *graphDataRefreshDeferrer;
/**
* @brief this takes care of scaling the overview when the widget is resized
*/
void resizeEvent(QResizeEvent *event) override;
void setIsAvailable(bool isAvailable);
void setUserOpened(bool userOpened);
void zoomTarget(int d);
private slots:
void showEvent(QShowEvent *event) override;
void closeEvent(QCloseEvent *event) override;
/**
* @brief update the view in the target widget when the range rect in the overview is moved
*/
void updateTargetView();
/**
* @brief update the content of the graph (blocks, edges) in the contained graphView from the
* target widget
*/
void updateGraphData();
/**
* @brief update the rect to show the current view in the target widget
*/
void updateRangeRect();
void targetClosed();
signals:
/**
* @brief emit signal to update the rect
*/
void resized();
/**
* @sa getIsAvailable()
*/
void isAvailableChanged(bool isAvailable);
/**
* @sa getUserOpened()
*/
void userOpenedChanged(bool userOpened);
public:
GraphWidget *getTargetGraphWidget() { return targetGraphWidget; }
void setTargetGraphWidget(GraphWidget *widget);
/**
* @brief whether this widget makes sense to be show, i.e. the menu entry should be enabled
*/
bool getIsAvailable() const { return isAvailable; }
/**
* @brief whether this widget is desired to be shown in general
*
* Will be false when the user closed the overview explicitly.
* Also corresponds to the checked state of the menu entry for this widget.
*/
bool getUserOpened() const { return userOpened; }
OverviewView *getGraphView() const { return graphView; }
void wheelEvent(QWheelEvent *event) override;
};
#endif // OverviewWIDGET_H
| 2,302
|
C++
|
.h
| 73
| 26.753425
| 97
| 0.707748
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,716
|
RizinGraphWidget.h
|
rizinorg_cutter/src/widgets/RizinGraphWidget.h
|
#ifndef RZ_GRAPH_WIDGET_H
#define RZ_GRAPH_WIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/SimpleTextGraphView.h"
#include "common/RefreshDeferrer.h"
class MainWindow;
namespace Ui {
class RizinGraphWidget;
}
class RizinGraphWidget;
/**
* @brief Generic graph view for rizin graphs.
* Not all rizin graph commands output the same kind of json. Only those that have following format
* @code{.json}
* { "nodes": [
* {
* "id": 0,
* "tittle": "node_0_tittle",
* "body": "".
* "out_nodes": [1, 2, 3]
* },
* ...
* ]}
* @endcode
* Id don't have to be sequential. Simple text label is displayed containing concatenation of
* label and body. No rizin builtin graph uses both. Duplicate edges and edges with target id
* not present in the list of nodes are removed.
*/
class GenericRizinGraphView : public SimpleTextGraphView
{
Q_OBJECT
public:
GenericRizinGraphView(RizinGraphWidget *parent, MainWindow *main);
void setGraphCommand(QString cmd);
void refreshView() override;
protected:
void loadCurrentGraph() override;
private:
RefreshDeferrer refreshDeferrer;
QString graphCommand;
QString lastShownCommand;
};
class RizinGraphWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit RizinGraphWidget(MainWindow *main);
~RizinGraphWidget();
private:
std::unique_ptr<Ui::RizinGraphWidget> ui;
GenericRizinGraphView *graphView;
void typeChanged();
};
#endif // RZ_GRAPH_WIDGET_H
| 1,563
|
C++
|
.h
| 56
| 25.375
| 99
| 0.723561
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,717
|
ListDockWidget.h
|
rizinorg_cutter/src/widgets/ListDockWidget.h
|
#ifndef LISTDOCKWIDGET_H
#define LISTDOCKWIDGET_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QMenu>
#include "core/Cutter.h"
#include "common/AddressableItemModel.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include "menus/AddressableItemContextMenu.h"
class MainWindow;
class QTreeWidgetItem;
class CommentsWidget;
namespace Ui {
class ListDockWidget;
}
class CUTTER_EXPORT ListDockWidget : public CutterDockWidget
{
Q_OBJECT
public:
enum class SearchBarPolicy {
ShowByDefault,
HideByDefault,
Hide,
};
explicit ListDockWidget(MainWindow *main,
SearchBarPolicy searchBarPolicy = SearchBarPolicy::ShowByDefault);
~ListDockWidget() override;
void showCount(bool show);
protected:
void setModels(AddressableFilterProxyModel *objectFilterProxyModel);
std::unique_ptr<Ui::ListDockWidget> ui;
private:
AddressableFilterProxyModel *objectFilterProxyModel = nullptr;
CutterTreeWidget *tree;
SearchBarPolicy searchBarPolicy;
};
#endif // LISTDOCKWIDGET_H
| 1,121
|
C++
|
.h
| 39
| 24.974359
| 94
| 0.779439
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,718
|
ColorThemeListView.h
|
rizinorg_cutter/src/widgets/ColorThemeListView.h
|
#ifndef COLORTHEMELISTVIEW_H
#define COLORTHEMELISTVIEW_H
#include <QTimer>
#include <QListView>
#include <QJsonDocument>
#include <QJsonObject>
#include <QAbstractListModel>
#include <QStyledItemDelegate>
struct ColorOption
{
QString optionName;
QColor color;
bool changed;
};
Q_DECLARE_METATYPE(ColorOption);
class ColorSettingsModel;
class ColorThemeListView : public QListView
{
Q_OBJECT
public:
ColorThemeListView(QWidget *parent = nullptr);
virtual ~ColorThemeListView() override {}
ColorSettingsModel *colorSettingsModel() const;
protected slots:
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override;
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
const QVector<int> &roles = QVector<int>()) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
private slots:
void blinkTimeout();
signals:
void itemChanged(const QColor &option);
void dataChanged(const ColorOption &data);
void blink();
private:
QTimer blinkTimer;
QColor backgroundColor;
};
//==============================================
class ColorSettingsModel : public QAbstractListModel
{
Q_OBJECT
public:
ColorSettingsModel(QObject *parent = nullptr);
virtual ~ColorSettingsModel() override {}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override
{
Q_UNUSED(parent)
return theme.size();
}
void updateTheme();
QHash<QString, QColor> getTheme() const;
private:
QList<ColorOption> theme;
};
class ColorOptionDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
ColorOptionDelegate(QObject *parent = nullptr);
~ColorOptionDelegate() override {}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QRect getResetButtonRect() const;
private:
const int margin = 12;
QPixmap resetButtonPixmap;
QRect resetButtonRect;
QPixmap getPixmapFromSvg(const QString &fileName, const QColor &after) const;
};
#endif // COLORTHEMELISTVIEW_H
| 2,486
|
C++
|
.h
| 75
| 29.04
| 100
| 0.743073
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,719
|
DebugActions.h
|
rizinorg_cutter/src/widgets/DebugActions.h
|
#pragma once
#include "core/Cutter.h"
#include "dialogs/RemoteDebugDialog.h"
#include <QAction>
class MainWindow;
class QToolBar;
class QToolButton;
class DebugActions : public QObject
{
Q_OBJECT
public:
explicit DebugActions(QToolBar *toolBar, MainWindow *main);
void addToToolBar(QToolBar *toolBar);
QAction *actionStart;
QAction *actionStartRemote;
QAction *actionStartEmul;
QAction *actionAttach;
QAction *actionContinue;
QAction *actionContinueUntilMain;
QAction *actionContinueUntilCall;
QAction *actionContinueUntilSyscall;
QAction *actionContinueBack;
QAction *actionStep;
QAction *actionStepOver;
QAction *actionStepOut;
QAction *actionStepBack;
QAction *actionStop;
QAction *actionAllContinues;
QAction *actionTrace;
// Continue/suspend and start/restart interchange during runtime
QIcon continueIcon;
QIcon suspendIcon;
QIcon restartIcon;
QIcon startDebugIcon;
QIcon startTraceIcon;
QIcon stopTraceIcon;
QString continueLabel;
QString suspendLabel;
QString restartDebugLabel;
QString startDebugLabel;
QString startTraceLabel;
QString stopTraceLabel;
// Stop and Detach interchange during runtime
QIcon detachIcon;
QIcon stopIcon;
private:
/**
* @brief buttons that will be disabled/enabled on (disable/enable)DebugToolbar
*/
QList<QAction *> toggleActions;
QList<QAction *> toggleConnectionActions;
QList<QAction *> reverseActions;
QList<QAction *> allActions;
QToolButton *continueUntilButton;
RemoteDebugDialog *remoteDialog = nullptr;
MainWindow *main;
bool acceptedDebugWarning = false;
// TODO: Remove once debug is stable
void showDebugWarning();
private slots:
void continueUntilMain();
void startDebug();
void attachProcessDialog();
void attachProcess(int pid);
void attachRemoteDialog();
void attachRemoteDebugger();
void onAttachedRemoteDebugger(bool successfully);
void setAllActionsVisible(bool visible);
void setButtonVisibleIfMainExists();
void chooseThemeIcons();
};
| 2,139
|
C++
|
.h
| 71
| 25.661972
| 83
| 0.758268
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,720
|
ClassesWidget.h
|
rizinorg_cutter/src/widgets/ClassesWidget.h
|
#ifndef CLASSESWIDGET_H
#define CLASSESWIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/ListDockWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
namespace Ui {
class ClassesWidget;
}
class QTreeWidget;
class QTreeWidgetItem;
class MainWindow;
class ClassesWidget;
/**
* @brief Common abstract base class for Bin and Anal classes models
*/
class ClassesModel : public AddressableItemModel<>
{
public:
enum Columns { NAME = 0, REAL_NAME, TYPE, OFFSET, VTABLE, COUNT };
/**
* @brief values for TypeRole data
*/
enum class RowType { Class = 0, Base, VTable, Method, Field };
/**
* @brief Offset role of data for QModelIndex
*
* will contain values of type RVA
*/
static const int OffsetRole = Qt::UserRole;
/**
* @brief Name role of data for QModelIndex
*
* will contain values of QString, used for sorting,
* as well as identifying classes and methods
*/
static const int NameRole = Qt::UserRole + 1;
/**
* @brief Type role of data for QModelIndex
*
* will contain values of RowType
*/
static const int TypeRole = Qt::UserRole + 2;
/**
* @brief VTable role of data for QModelIndex
*
* will contain values of type long long for sorting
* by vtable offset
*/
static const int VTableRole = Qt::UserRole + 3;
/**
* @brief Real Name role of data for QModelIndex
*
* will contain values of QString, used for sorting,
* as well as identifying classes and methods
*/
static const int RealNameRole = Qt::UserRole + 4;
explicit ClassesModel(QObject *parent = nullptr) : AddressableItemModel(parent) {}
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
Q_DECLARE_METATYPE(ClassesModel::RowType)
class BinClassesModel : public ClassesModel
{
Q_OBJECT
private:
QList<BinClassDescription> classes;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
public:
explicit BinClassesModel(QObject *parent = nullptr);
void setClasses(const QList<BinClassDescription> &classes);
};
class AnalysisClassesModel : public ClassesModel
{
Q_OBJECT
private:
/**
* @brief List entry below a class
*
* This roughly corresponds to attributes of Rizin analysis classes, which means it is not an
* attribute in the sense of a class member variable, but any kind of sub-info associated with
* the class. This struct in particular is used to provide a model for the list entries below a
* class.
*/
struct Attribute
{
enum class Type { VTable, Base, Method };
Type type;
QVariant data;
Attribute() = default;
Attribute(Type type, const QVariant &data) : type(type), data(data) {}
};
/**
* This must always stay sorted alphabetically.
*/
QList<QString> classes;
RefreshDeferrer *refreshDeferrer;
/**
* @brief Cache for class attributes
*
* Maps class names to a list of Attributes.
* This is filled only when the attributes of a specific class are requested.
* (i.e. the user expands the class in the QTreeView)
*
* This must be a pointer instead of just a QMap, because it has to be modified
* in methods that are defined as const by QAbstractItemModel.
*/
std::unique_ptr<QMap<QString, QVector<Attribute>>> attrs;
const QVector<Attribute> &getAttrs(const QString &cls) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
public:
explicit AnalysisClassesModel(CutterDockWidget *parent);
public slots:
void refreshAll();
void classNew(const QString &cls);
void classDeleted(const QString &cls);
void classRenamed(const QString &oldName, const QString &newName);
void classAttrsChanged(const QString &cls);
};
class ClassesSortFilterProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
explicit ClassesSortFilterProxyModel(QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
};
class ClassesWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit ClassesWidget(MainWindow *main);
~ClassesWidget();
private slots:
void seekToVTableActionTriggered();
void editMethodActionTriggered();
void addMethodActionTriggered();
void newClassActionTriggered();
void renameClassActionTriggered();
void deleteClassActionTriggered();
void refreshClasses();
void updateActions();
private:
enum class Source { BIN, ANALYSIS };
Source getSource();
BinClassesModel *bin_model = nullptr;
AnalysisClassesModel *analysis_model = nullptr;
ClassesSortFilterProxyModel *proxy_model;
QComboBox *classSourceCombo;
QAction seekToVTableAction;
QAction editMethodAction;
QAction addMethodAction;
QAction newClassAction;
QAction renameClassAction;
QAction deleteClassAction;
QAction *classesMethodsSeparator;
};
#endif // CLASSESWIDGET_H
| 6,250
|
C++
|
.h
| 175
| 30.805714
| 99
| 0.721301
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,721
|
VisualNavbar.h
|
rizinorg_cutter/src/widgets/VisualNavbar.h
|
#ifndef VISUALNAVBAR_H
#define VISUALNAVBAR_H
#include <QToolBar>
#include <QGraphicsScene>
#include "core/Cutter.h"
#include <rz_core.h>
#include <memory>
class MainWindow;
class QGraphicsView;
class VisualNavbar : public QToolBar
{
Q_OBJECT
struct XToAddress
{
double x_start;
double x_end;
RVA address_from;
RVA address_to;
};
public:
explicit VisualNavbar(MainWindow *main, QWidget *parent = nullptr);
public slots:
void paintEvent(QPaintEvent *event) override;
void updateGraphicsScene();
private slots:
void fetchAndPaintData();
void fetchStats();
void drawSeekCursor();
void drawPCCursor();
void drawCursor(RVA addr, QColor color, QGraphicsRectItem *&graphicsItem);
void on_seekChanged(RVA addr);
private:
QGraphicsView *graphicsView;
QGraphicsScene *graphicsScene;
QGraphicsRectItem *seekGraphicsItem;
QGraphicsRectItem *PCGraphicsItem;
MainWindow *main;
UniquePtrC<RzCoreAnalysisStats, &rz_core_analysis_stats_free> stats;
unsigned int statsWidth = 0;
unsigned int previousWidth = 0;
QList<XToAddress> xToAddress;
bool blockTooltip;
RVA localXToAddress(double x);
double addressToLocalX(RVA address);
QList<QString> sectionsForAddress(RVA address);
QString toolTipForAddress(RVA address);
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
};
#endif // VISUALNAVBAR_H
| 1,491
|
C++
|
.h
| 50
| 25.54
| 78
| 0.748772
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,722
|
SdbWidget.h
|
rizinorg_cutter/src/widgets/SdbWidget.h
|
#ifndef SDBWIDGET_H
#define SDBWIDGET_H
#include <memory>
#include "CutterDockWidget.h"
class MainWindow;
class QTreeWidgetItem;
namespace Ui {
class SdbWidget;
}
class SdbWidget : public CutterDockWidget
{
Q_OBJECT
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
# define Q_DISABLE_COPY(SdbWidget) \
SdbWidget(const SdbWidget &s) = delete; \
SdbWidget &operator=(const SdbWidget &s) = delete;
# define Q_DISABLE_MOVE(SdbWidget) \
SdbWidget(SdbWidget &&s) = delete; \
SdbWidget &operator=(SdbWidget &&s) = delete;
# define Q_DISABLE_COPY_MOVE(SdbWidget) \
Q_DISABLE_COPY(SdbWidget) \
Q_DISABLE_MOVE(SdbWidget)
#endif
Q_DISABLE_COPY_MOVE(SdbWidget)
public:
explicit SdbWidget(MainWindow *main);
~SdbWidget() override;
private slots:
void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_lockButton_clicked();
void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column);
void reload(QString _path = QString());
private:
std::unique_ptr<Ui::SdbWidget> ui;
QString path;
};
#endif // SDBWIDGET_H
| 1,482
|
C++
|
.h
| 37
| 36.297297
| 100
| 0.541579
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,723
|
MemoryDockWidget.h
|
rizinorg_cutter/src/widgets/MemoryDockWidget.h
|
#ifndef MEMORYDOCKWIDGET_H
#define MEMORYDOCKWIDGET_H
#include "AddressableDockWidget.h"
#include "core/Cutter.h"
#include <QAction>
/* Disassembly/Graph/Hexdump/Decompiler view priority */
enum class MemoryWidgetType { Disassembly, Graph, Hexdump, Decompiler, CallGraph, GlobalCallGraph };
class CUTTER_EXPORT MemoryDockWidget : public AddressableDockWidget
{
Q_OBJECT
public:
MemoryDockWidget(MemoryWidgetType type, MainWindow *parent);
~MemoryDockWidget() override {}
bool tryRaiseMemoryWidget();
MemoryWidgetType getType() const { return mType; }
bool eventFilter(QObject *object, QEvent *event) override;
private:
MemoryWidgetType mType;
};
#endif // MEMORYDOCKWIDGET_H
| 710
|
C++
|
.h
| 20
| 32.75
| 100
| 0.795022
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,724
|
ColorThemeComboBox.h
|
rizinorg_cutter/src/widgets/ColorThemeComboBox.h
|
#ifndef COLORTHEMECOMBOBOX_H
#define COLORTHEMECOMBOBOX_H
#include <QComboBox>
/**
* @brief The ColorThemeComboBox class provides combobox with Cutter color themes.
*/
class ColorThemeComboBox : public QComboBox
{
Q_OBJECT
public:
explicit ColorThemeComboBox(QWidget *parent = nullptr);
/**
* @brief setShowOnlyCustom sets whether or not combobox should contain only
* custom themes (created by user or imported) or custom and srandard rizin themes.
*/
void setShowOnlyCustom(bool value);
public slots:
/**
* @brief updateFromConfig updates list of themes to be shown.
* @param interfaceThemeChanged should be set to true if the interface theme of Cutter was
* changed since the last call to the function. This will preserve the selected item in the
* combo box.
*
*/
void updateFromConfig(bool interfaceThemeChanged = false);
private slots:
void onCurrentIndexChanged(int index);
private:
bool showOnlyCustom;
};
#endif // COLORTHEMECOMBOBOX_H
| 1,031
|
C++
|
.h
| 31
| 29.483871
| 95
| 0.751259
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,725
|
CutterDockWidget.h
|
rizinorg_cutter/src/widgets/CutterDockWidget.h
|
#ifndef CUTTERWIDGET_H
#define CUTTERWIDGET_H
#include "core/CutterCommon.h"
#include "common/RefreshDeferrer.h"
#include <QDockWidget>
class MainWindow;
class CUTTER_EXPORT CutterDockWidget : public QDockWidget
{
Q_OBJECT
public:
CUTTER_DEPRECATED("Action will be ignored. Use CutterDockWidget(MainWindow*) instead.")
CutterDockWidget(MainWindow *parent, QAction *action);
explicit CutterDockWidget(MainWindow *parent);
~CutterDockWidget() override;
bool eventFilter(QObject *object, QEvent *event) override;
bool isVisibleToUser() { return isVisibleToUserCurrent; }
/**
* @brief Set whether the Widget should be deleted after it is closed.
* This is especially important for extra widgets.
*/
void setTransient(bool v) { isTransient = v; }
/**
* @brief Convenience method for creating and registering a RefreshDeferrer without any
* parameters
* @param refreshNowFunc lambda taking no parameters, called when a refresh should occur
*/
template<typename Func>
RefreshDeferrer *createRefreshDeferrer(Func refreshNowFunc)
{
auto *deferrer = new RefreshDeferrer(nullptr, this);
deferrer->registerFor(this);
connect(deferrer, &RefreshDeferrer::refreshNow, this,
[refreshNowFunc](const RefreshDeferrerParamsResult) { refreshNowFunc(); });
return deferrer;
}
/**
* @brief Convenience method for creating and registering a RefreshDeferrer with a replacing
* Accumulator
* @param replaceIfNull passed to the ReplacingRefreshDeferrerAccumulator
* @param refreshNowFunc lambda taking a single parameter of type ParamResult, called when a
* refresh should occur
*/
template<class ParamResult, typename Func>
RefreshDeferrer *createReplacingRefreshDeferrer(bool replaceIfNull, Func refreshNowFunc)
{
auto *deferrer = new RefreshDeferrer(
new ReplacingRefreshDeferrerAccumulator<ParamResult>(replaceIfNull), this);
deferrer->registerFor(this);
connect(deferrer, &RefreshDeferrer::refreshNow, this,
[refreshNowFunc](const RefreshDeferrerParamsResult paramsResult) {
auto *result = static_cast<const ParamResult *>(paramsResult);
refreshNowFunc(result);
});
return deferrer;
}
/**
* @brief Serialize dock properties for saving as part of layout.
*
* Override this function for saving dock specific view properties. Use
* in situations where it makes sense to have different properties for
* multiple instances of widget. Don't use for options that are more suitable
* as global settings and should be applied equally to all widgets or all
* widgets of this kind.
*
* Keep synchrononized with deserializeViewProperties. When modifying add
* project upgrade step in SettingsUpgrade.cpp if necessary.
*
* @return Dictionary of current dock properties.
* @see CutterDockWidget#deserializeViewProperties
*/
virtual QVariantMap serializeViewProprties();
/**
* @brief Deserialization half of serialize view properties.
*
* When a property is not specified in property map dock should reset it
* to default value instead of leaving it umodified. Empty map should reset
* all properties controlled by serializeViewProprties/deserializeViewProperties
* mechanism.
*
* @param properties to modify for current widget
* @see CutterDockWidget#serializeViewProprties
*/
virtual void deserializeViewProperties(const QVariantMap &properties);
/**
* @brief Ignore visibility status.
* Useful for temporary ignoring visibility changes while this information is unreliable.
* @param ignored - set to true for enabling ignoring mode
*/
void ignoreVisibilityStatus(bool ignored);
void raiseMemoryWidget();
signals:
void becameVisibleToUser();
void closed();
public slots:
void toggleDockWidget(bool show);
protected:
virtual QWidget *widgetToFocusOnRaise();
void closeEvent(QCloseEvent *event) override;
QString getDockNumber();
MainWindow *mainWindow;
private:
bool isTransient = false;
bool isVisibleToUserCurrent = false;
bool ignoreVisibility = false;
void updateIsVisibleToUser();
};
#endif // CUTTERWIDGET_H
| 4,416
|
C++
|
.h
| 107
| 35.242991
| 96
| 0.726701
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,726
|
CutterTreeView.h
|
rizinorg_cutter/src/widgets/CutterTreeView.h
|
#ifndef CUTTERTREEVIEW_H
#define CUTTERTREEVIEW_H
#include "core/CutterCommon.h"
#include <memory>
#include <QAbstractItemView>
#include <QTreeView>
namespace Ui {
class CutterTreeView;
}
class CUTTER_EXPORT CutterTreeView : public QTreeView
{
Q_OBJECT
public:
explicit CutterTreeView(QWidget *parent = nullptr);
~CutterTreeView();
static void applyCutterStyle(QTreeView *view);
private:
std::unique_ptr<Ui::CutterTreeView> ui;
};
#endif // CUTTERTREEVIEW_H
| 486
|
C++
|
.h
| 20
| 21.9
| 55
| 0.786026
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,727
|
BoolToggleDelegate.h
|
rizinorg_cutter/src/widgets/BoolToggleDelegate.h
|
#ifndef BOOLTOGGGLEDELEGATE_H
#define BOOLTOGGGLEDELEGATE_H
#include "core/CutterCommon.h"
#include <QStyledItemDelegate>
class CUTTER_EXPORT BoolTogggleDelegate : public QStyledItemDelegate
{
public:
BoolTogggleDelegate(QObject *parent = nullptr);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
const QModelIndex &index) override;
};
#endif // BOOLTOGGGLEDELEGATE_H
| 597
|
C++
|
.h
| 14
| 37
| 98
| 0.760832
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,728
|
GraphLayout.h
|
rizinorg_cutter/src/widgets/GraphLayout.h
|
#ifndef GRAPHLAYOUT_H
#define GRAPHLAYOUT_H
#include "core/Cutter.h"
#include <unordered_map>
class GraphLayout
{
public:
struct GraphEdge
{
ut64 target;
QPolygonF polyline;
enum ArrowDirection { Down, Left, Up, Right, None };
ArrowDirection arrow = ArrowDirection::Down;
explicit GraphEdge(ut64 target) : target(target) {}
};
struct GraphBlock
{
int x = 0;
int y = 0;
int width = 0;
int height = 0;
// This is a unique identifier, e.g. offset in the case of rizin blocks
ut64 entry;
// Edges
std::vector<GraphEdge> edges;
};
using Graph = std::unordered_map<ut64, GraphBlock>;
struct LayoutConfig
{
int blockVerticalSpacing = 40;
int blockHorizontalSpacing = 20;
int edgeVerticalSpacing = 10;
int edgeHorizontalSpacing = 10;
};
GraphLayout(const LayoutConfig &layout_config) : layoutConfig(layout_config) {}
virtual ~GraphLayout() {}
virtual void CalculateLayout(Graph &blocks, ut64 entry, int &width, int &height) const = 0;
virtual void setLayoutConfig(const LayoutConfig &config) { this->layoutConfig = config; };
protected:
LayoutConfig layoutConfig;
};
#endif // GRAPHLAYOUT_H
| 1,288
|
C++
|
.h
| 42
| 24.785714
| 95
| 0.65966
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,729
|
ImportsWidget.h
|
rizinorg_cutter/src/widgets/ImportsWidget.h
|
#ifndef IMPORTSWIDGET_H
#define IMPORTSWIDGET_H
#include <memory>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include <QRegularExpression>
#include <QStyledItemDelegate>
#include <QTreeWidgetItem>
#include "CutterDockWidget.h"
#include "core/Cutter.h"
#include "widgets/ListDockWidget.h"
#include "common/AddressableItemModel.h"
class MainWindow;
class QTreeWidget;
class ImportsWidget;
class ImportsModel : public AddressableItemModel<QAbstractTableModel>
{
Q_OBJECT
friend ImportsWidget;
private:
const QRegularExpression banned = QRegularExpression(
QStringLiteral("\\A(\\w\\.)*(system|strcpy|strcpyA|strcpyW|wcscpy|_tcscpy|_mbscpy|"
"StrCpy|StrCpyA|StrCpyW|lstrcpy|lstrcpyA|lstrcpyW"
"DCIEnum|DCIOpenProvider|DCISendCommand|DCIBeginAccess"
"|_tccpy|_mbccpy|_ftcscpy|strcat|strcatA|strcatW|wcscat|_tcscat|_mbscat|"
"StrCat|StrCatA|StrCatW|lstrcat|lstrcatA|"
"lstrcatW|StrCatBuff|StrCatBuffA|StrCatBuffW|StrCatChainW|_tccat|_"
"mbccat|_ftcscat|sprintfW|sprintfA|wsprintf|wsprintfW|"
"wsprintfA|sprintf|swprintf|_stprintf|wvsprintf|wvsprintfA|wvsprintfW|"
"vsprintf|_vstprintf|vswprintf|strncpy|wcsncpy|"
"_tcsncpy|_mbsncpy|_mbsnbcpy|StrCpyN|StrCpyNA|StrCpyNW|StrNCpy|strcpynA|"
"StrNCpyA|StrNCpyW|lstrcpyn|lstrcpynA|lstrcpynW|"
"strncat|wcsncat|_tcsncat|_mbsncat|_mbsnbcat|StrCatN|StrCatNA|StrCatNW|"
"StrNCat|StrNCatA|StrNCatW|lstrncat|lstrcatnA|"
"lstrcatnW|lstrcatn|gets|_getts|_gettws|IsBadWritePtr|IsBadHugeWritePtr|"
"IsBadReadPtr|IsBadHugeReadPtr|IsBadCodePtr|"
"IsBadStringPtr|memcpy|RtlCopyMemory|CopyMemory|wmemcpy|wnsprintf|"
"wnsprintfA|wnsprintfW|_snwprintf|_snprintf|_sntprintf|"
"_vsnprintf|vsnprintf|_vsnwprintf|_vsntprintf|wvnsprintf|wvnsprintfA|"
"wvnsprintfW|strtok|_tcstok|wcstok|_mbstok|makepath|"
"_tmakepath| "
"_makepath|_wmakepath|_splitpath|_tsplitpath|_wsplitpath|scanf|wscanf|_"
"tscanf|sscanf|swscanf|_stscanf|snscanf|"
"snwscanf|_sntscanf|_itoa|_itow|_i64toa|_i64tow|_ui64toa|_ui64tot|_"
"ui64tow|_ultoa|_ultot|_ultow|CharToOem|CharToOemA|CharToOemW|"
"OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_"
"alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|"
"ChangeWindowMessageFilter|ChangeWindowMessageFilterEx)\\z"));
QList<ImportDescription> imports;
public:
enum Column {
AddressColumn = 0,
TypeColumn,
LibraryColumn,
NameColumn,
SafetyColumn,
CommentColumn,
ColumnCount
};
enum Role { ImportDescriptionRole = Qt::UserRole, AddressRole };
ImportsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
QString libname(const QModelIndex &index) const;
void reload();
};
class ImportsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
ImportsProxyModel(ImportsModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class ImportsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit ImportsWidget(MainWindow *main);
~ImportsWidget();
private slots:
void refreshImports();
private:
ImportsModel *importsModel;
ImportsProxyModel *importsProxyModel;
void highlightUnsafe();
};
#endif // IMPORTSWIDGET_H
| 4,417
|
C++
|
.h
| 93
| 36.827957
| 100
| 0.664653
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,730
|
HexdumpWidget.h
|
rizinorg_cutter/src/widgets/HexdumpWidget.h
|
#ifndef HEXDUMPWIDGET_H
#define HEXDUMPWIDGET_H
#include <QDebug>
#include <QTextEdit>
#include <QMouseEvent>
#include <QAction>
#include <array>
#include <memory>
#include "core/Cutter.h"
#include "MemoryDockWidget.h"
#include "common/CutterSeekable.h"
#include "common/Highlighter.h"
#include "common/SvgIconEngine.h"
#include "HexWidget.h"
#include "Dashboard.h"
namespace Ui {
class HexdumpWidget;
}
class RefreshDeferrer;
class QSyntaxHighlighter;
class HexdumpWidget : public MemoryDockWidget
{
Q_OBJECT
public:
explicit HexdumpWidget(MainWindow *main);
~HexdumpWidget() override;
Highlighter *highlighter;
static QString getWidgetType();
public slots:
void initParsing();
protected:
virtual void resizeEvent(QResizeEvent *event) override;
QWidget *widgetToFocusOnRaise() override;
private:
std::unique_ptr<Ui::HexdumpWidget> ui;
bool sent_seek = false;
RefreshDeferrer *refreshDeferrer;
QSyntaxHighlighter *syntaxHighLighter;
void refresh();
void refresh(RVA addr);
void selectHexPreview();
void setupFonts();
void refreshSelectionInfo();
void updateParseWindow(RVA start_address, int size);
void clearParseWindow();
void showSidePanel(bool show);
QString getWindowTitle() const override;
private slots:
void onSeekChanged(RVA addr);
void selectionChanged(HexWidget::Selection selection);
void on_parseArchComboBox_currentTextChanged(const QString &arg1);
void on_parseBitsComboBox_currentTextChanged(const QString &arg1);
void on_parseTypeComboBox_currentTextChanged(const QString &arg1);
void on_parseEndianComboBox_currentTextChanged(const QString &arg1);
void fontsUpdated();
void on_hexSideTab_2_currentChanged(int index);
void on_copyMD5_clicked();
void on_copySHA1_clicked();
void on_copySHA256_clicked();
void on_copyCRC32_clicked();
};
#endif // HEXDUMPWIDGET_H
| 1,933
|
C++
|
.h
| 62
| 27.677419
| 72
| 0.772727
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,731
|
ConsoleWidget.h
|
rizinorg_cutter/src/widgets/ConsoleWidget.h
|
#ifndef CONSOLEWIDGET_H
#define CONSOLEWIDGET_H
#include "core/MainWindow.h"
#include "CutterDockWidget.h"
#include "common/CommandTask.h"
#include "common/DirectionalComboBox.h"
#include <QStringListModel>
#include <QSocketNotifier>
#include <QLocalSocket>
#include <memory>
class QCompleter;
class QShortcut;
namespace Ui {
class ConsoleWidget;
}
class ConsoleWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit ConsoleWidget(MainWindow *main);
~ConsoleWidget();
void setDebugOutputEnabled(bool enabled) { debugOutputEnabled = enabled; }
void setMaxHistoryEntries(int max) { maxHistoryEntries = max; }
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
QWidget *widgetToFocusOnRaise() override;
public slots:
void focusInputLineEdit();
void addOutput(const QString &msg);
void addDebugOutput(const QString &msg);
private slots:
void setupFont();
void on_rzInputLineEdit_returnPressed();
void on_debugeeInputLineEdit_returnPressed();
void onIndexChange();
void on_execButton_clicked();
void showCustomContextMenu(const QPoint &pt);
void historyNext();
void historyPrev();
void triggerCompletion();
void disableCompletion();
void updateCompletion();
void clear();
/**
* @brief Passes redirected output from the pipe to the terminal and console
*/
void processQueuedOutput();
private:
void scrollOutputToEnd();
void historyAdd(const QString &input);
void invalidateHistoryPosition();
void removeLastLine();
void executeCommand(const QString &command);
void sendToStdin(const QString &input);
void setWrap(bool wrap);
/**
* @brief Redirects stderr and stdout to the output pipe which is handled by
* processQueuedOutput
*/
void redirectOutput();
QSharedPointer<CommandTask> commandTask;
std::unique_ptr<Ui::ConsoleWidget> ui;
QAction *actionWrapLines;
QList<QAction *> actions;
bool debugOutputEnabled;
int maxHistoryEntries;
int lastHistoryPosition;
QStringList history;
bool completionActive;
QStringListModel completionModel;
QCompleter *completer;
QShortcut *historyUpShortcut;
QShortcut *historyDownShortcut;
FILE *origStderr = nullptr;
FILE *origStdout = nullptr;
FILE *origStdin = nullptr;
QLocalSocket *pipeSocket = nullptr;
#ifdef Q_OS_WIN
HANDLE hRead;
HANDLE hWrite;
#else
int redirectPipeFds[2];
int stdinFile = -1;
QString stdinFifoPath;
QVector<char> *redirectionBuffer;
#endif
};
#endif // CONSOLEWIDGET_H
| 2,626
|
C++
|
.h
| 88
| 25.715909
| 80
| 0.744427
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,732
|
GraphView.h
|
rizinorg_cutter/src/widgets/GraphView.h
|
#ifndef GRAPHVIEW_H
#define GRAPHVIEW_H
#include <QObject>
#include <QPainter>
#include <QWidget>
#include <QAbstractScrollArea>
#include <QScrollBar>
#include <QElapsedTimer>
#include <QHelpEvent>
#include <QGestureEvent>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <memory>
#include "core/Cutter.h"
#include "widgets/GraphLayout.h"
#if defined(QT_NO_OPENGL) || QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
// QOpenGLExtraFunctions were introduced in 5.6
# define CUTTER_NO_OPENGL_GRAPH
#endif
#ifndef CUTTER_NO_OPENGL_GRAPH
class QOpenGLWidget;
#endif
class GraphView : public QAbstractScrollArea
{
Q_OBJECT
signals:
void viewOffsetChanged(QPoint offset);
void viewScaleChanged(qreal scale);
public:
using GraphBlock = GraphLayout::GraphBlock;
using GraphEdge = GraphLayout::GraphEdge;
enum class Layout {
GridNarrow,
GridMedium,
GridWide,
GridAAA,
GridAAB,
GridABA,
GridABB,
GridBAA,
GridBAB,
GridBBA,
GridBBB
#ifdef CUTTER_ENABLE_GRAPHVIZ
,
GraphvizOrtho,
GraphvizPolyline,
GraphvizSfdp,
GraphvizNeato,
GraphvizTwoPi,
GraphvizCirco
#endif
};
static std::unique_ptr<GraphLayout> makeGraphLayout(Layout layout, bool horizontal = false);
struct EdgeConfiguration
{
QColor color = QColor(128, 128, 128);
bool start_arrow = false;
bool end_arrow = true;
qreal width_scale = 1.0;
Qt::PenStyle lineStyle = Qt::PenStyle::SolidLine;
};
explicit GraphView(QWidget *parent);
~GraphView() override;
void showBlock(GraphBlock &block, bool anywhere = false);
/**
* @brief Move view so that area is visible.
* @param rect Rectangle to show
* @param anywhere - set to true for minimizing movement
*/
void showRectangle(const QRect &rect, bool anywhere = false);
/**
* @brief Get block containing specified point logical coordinates.
* @param p positionin graph logical coordinates
* @return Block or nullptr if position is outside all blocks.
*/
GraphView::GraphBlock *getBlockContaining(QPoint p);
QPoint viewToLogicalCoordinates(QPoint p);
QPoint logicalToViewCoordinates(QPoint p);
void setGraphLayout(std::unique_ptr<GraphLayout> layout);
GraphLayout &getGraphLayout() const { return *graphLayoutSystem; }
void setLayoutConfig(const GraphLayout::LayoutConfig &config);
void paint(QPainter &p, QPoint offset, QRect area, qreal scale = 1.0, bool interactive = true);
void saveAsBitmap(QString path, const char *format = nullptr, double scaler = 1.0,
bool transparent = false);
void saveAsSvg(QString path);
void computeGraphPlacement();
/**
* @brief Remove duplicate edges and edges without target in graph.
* @param graph
*/
static void cleanupEdges(GraphLayout::Graph &graph);
protected:
std::unordered_map<ut64, GraphBlock> blocks;
/// image background color
QColor backgroundColor = QColor(Qt::white);
// Padding inside the block
int block_padding = 16;
void setCacheDirty() { cacheDirty = true; }
void addBlock(GraphView::GraphBlock block);
void setEntry(ut64 e);
// Callbacks that should be overridden
/**
* @brief drawBlock
* @param p painter object, not necesarily current widget
* @param block
* @param interactive - can be used for disabling elemnts during export
*/
virtual void drawBlock(QPainter &p, GraphView::GraphBlock &block, bool interactive = true) = 0;
virtual void blockClicked(GraphView::GraphBlock &block, QMouseEvent *event, QPoint pos);
virtual void blockDoubleClicked(GraphView::GraphBlock &block, QMouseEvent *event, QPoint pos);
virtual void blockHelpEvent(GraphView::GraphBlock &block, QHelpEvent *event, QPoint pos);
virtual bool helpEvent(QHelpEvent *event);
virtual void blockTransitionedTo(GraphView::GraphBlock *to);
virtual void wheelEvent(QWheelEvent *event) override;
virtual EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from,
GraphView::GraphBlock *to, bool interactive = true);
virtual bool gestureEvent(QGestureEvent *event);
/**
* @brief Called when user requested context menu for a block. Should open a block specific
* contextmenu. Typically triggered by right click.
* @param block - the block that was clicked on
* @param event - context menu event that triggered the callback, can be used to display context
* menu at correct position
* @param pos - mouse click position in logical coordinates of the drawing, set only if event
* reason is mouse
*/
virtual void blockContextMenuRequested(GraphView::GraphBlock &block, QContextMenuEvent *event,
QPoint pos);
bool event(QEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
// Mouse events
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void paintEvent(QPaintEvent *event) override;
int width = 0;
int height = 0;
bool scale_thickness_multiplier = false;
void clampViewOffset();
void setViewOffsetInternal(QPoint pos, bool emitSignal = true);
void addViewOffset(QPoint move, bool emitSignal = true);
private:
void centerX(bool emitSignal);
void centerY(bool emitSignal);
void paintGraphCache();
bool checkPointClicked(QPointF &point, int x, int y, bool above_y = false);
// Zoom data
qreal current_scale = 1.0;
QPoint offset = QPoint(0, 0);
ut64 entry = 0;
std::unique_ptr<GraphLayout> graphLayoutSystem;
QPoint scrollBase;
bool scroll_mode = false;
bool useGL;
/**
* @brief pixmap that caches the graph nodes
*/
QPixmap pixmap;
#ifndef CUTTER_NO_OPENGL_GRAPH
uint32_t cacheTexture;
uint32_t cacheFBO;
QSize cacheSize;
QOpenGLWidget *glWidget;
#endif
/**
* @brief flag to control if the cache is invalid and should be re-created in the next draw
*/
bool cacheDirty = true;
QSize getCacheSize();
qreal getCacheDevicePixelRatioF();
QSize getRequiredCacheSize();
qreal getRequiredCacheDevicePixelRatioF();
void beginMouseDrag(QMouseEvent *event);
public:
QPoint getViewOffset() const { return offset; }
void setViewOffset(QPoint offset);
qreal getViewScale() const { return current_scale; }
void setViewScale(qreal scale);
void center();
void centerX() { centerX(true); }
void centerY() { centerY(true); }
};
#endif // GRAPHVIEW_H
| 6,965
|
C++
|
.h
| 187
| 31.59893
| 100
| 0.706267
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,733
|
ExportsWidget.h
|
rizinorg_cutter/src/widgets/ExportsWidget.h
|
#ifndef EXPORTSWIDGET_H
#define EXPORTSWIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/ListDockWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class ExportsWidget;
namespace Ui {
class ExportsWidget;
}
class ExportsModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend ExportsWidget;
private:
QList<ExportDescription> *exports;
public:
enum Column {
OffsetColumn = 0,
SizeColumn,
TypeColumn,
NameColumn,
CommentColumn,
ColumnCount
};
enum Role { ExportDescriptionRole = Qt::UserRole };
ExportsModel(QList<ExportDescription> *exports, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
class ExportsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
ExportsProxyModel(ExportsModel *source_model, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class ExportsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit ExportsWidget(MainWindow *main);
~ExportsWidget();
private slots:
void refreshExports();
private:
ExportsModel *exportsModel;
ExportsProxyModel *exportsProxyModel;
QList<ExportDescription> exports;
};
#endif // EXPORTSWIDGET_H
| 1,938
|
C++
|
.h
| 62
| 27.209677
| 84
| 0.760647
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,734
|
VTablesWidget.h
|
rizinorg_cutter/src/widgets/VTablesWidget.h
|
#ifndef VTABLESWIDGET_H
#define VTABLESWIDGET_H
#include <memory>
#include <QTreeView>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
namespace Ui {
class VTablesWidget;
}
class MainWindow;
class VTablesWidget;
class VTableModel : public QAbstractItemModel
{
Q_OBJECT
friend VTablesWidget;
private:
QList<VTableDescription> *vtables;
public:
enum Columns { NAME = 0, ADDRESS, COUNT };
static const int VTableDescriptionRole = Qt::UserRole;
VTableModel(QList<VTableDescription> *vtables, QObject *parent = nullptr);
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
};
class VTableSortFilterProxyModel : public QSortFilterProxyModel
{
public:
VTableSortFilterProxyModel(VTableModel *model, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
};
class VTablesWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit VTablesWidget(MainWindow *main);
~VTablesWidget();
private slots:
void refreshVTables();
void on_vTableTreeView_doubleClicked(const QModelIndex &index);
private:
std::unique_ptr<Ui::VTablesWidget> ui;
VTableModel *model;
QSortFilterProxyModel *proxy;
QList<VTableDescription> vtables;
CutterTreeWidget *tree;
RefreshDeferrer *refreshDeferrer;
};
#endif // VTABLESWIDGET_H
| 1,822
|
C++
|
.h
| 55
| 29.927273
| 100
| 0.780069
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,735
|
RegisterRefsWidget.h
|
rizinorg_cutter/src/widgets/RegisterRefsWidget.h
|
#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include "menus/AddressableItemContextMenu.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class RegisterRefsWidget;
namespace Ui {
class RegisterRefsWidget;
}
class MainWindow;
class QTreeWidgetItem;
struct RegisterRefDescription
{
QString reg;
QString value;
RefDescription refDesc;
};
Q_DECLARE_METATYPE(RegisterRefDescription)
class RegisterRefModel : public QAbstractListModel
{
Q_OBJECT
friend RegisterRefsWidget;
private:
QList<RegisterRefDescription> *registerRefs;
public:
enum Column { RegColumn = 0, ValueColumn, RefColumn, CommentColumn, ColumnCount };
enum Role { RegisterRefDescriptionRole = Qt::UserRole };
RegisterRefModel(QList<RegisterRefDescription> *registerRefs, QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
};
class RegisterRefProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
RegisterRefProxyModel(RegisterRefModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class RegisterRefsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit RegisterRefsWidget(MainWindow *main);
~RegisterRefsWidget();
private slots:
void on_registerRefTreeView_doubleClicked(const QModelIndex &index);
void refreshRegisterRef();
void copyClip(int column);
void customMenuRequested(QPoint pos);
void onCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous);
private:
std::unique_ptr<Ui::RegisterRefsWidget> ui;
RegisterRefModel *registerRefModel;
RegisterRefProxyModel *registerRefProxyModel;
QList<RegisterRefDescription> registerRefs;
CutterTreeWidget *tree;
void setScrollMode();
RefreshDeferrer *refreshDeferrer;
QAction *actionCopyValue;
QAction *actionCopyRef;
AddressableItemContextMenu addressableItemContextMenu;
};
| 2,418
|
C++
|
.h
| 71
| 30.746479
| 100
| 0.798536
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,736
|
QuickFilterView.h
|
rizinorg_cutter/src/widgets/QuickFilterView.h
|
#ifndef QUICKFILTERVIEW_H
#define QUICKFILTERVIEW_H
#include "core/CutterCommon.h"
#include <memory>
#include <QWidget>
#include <QTimer>
namespace Ui {
class QuickFilterView;
}
class CUTTER_EXPORT QuickFilterView : public QWidget
{
Q_OBJECT
public:
explicit QuickFilterView(QWidget *parent = nullptr, bool defaultOn = true);
~QuickFilterView();
public slots:
void showFilter();
void closeFilter();
void clearFilter();
signals:
void filterTextChanged(const QString &text);
void filterClosed();
private:
std::unique_ptr<Ui::QuickFilterView> ui;
QTimer *debounceTimer;
};
#endif // QUICKFILTERVIEW_H
| 649
|
C++
|
.h
| 27
| 21.148148
| 79
| 0.761047
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,737
|
AddressableDockWidget.h
|
rizinorg_cutter/src/widgets/AddressableDockWidget.h
|
#ifndef ADDRESSABLE_DOCK_WIDGET_H
#define ADDRESSABLE_DOCK_WIDGET_H
#include "CutterDockWidget.h"
#include "core/Cutter.h"
#include <QAction>
class CutterSeekable;
class AddressableDockWidget : public CutterDockWidget
{
Q_OBJECT
public:
AddressableDockWidget(MainWindow *parent);
~AddressableDockWidget() override {}
CutterSeekable *getSeekable() const;
QVariantMap serializeViewProprties() override;
void deserializeViewProperties(const QVariantMap &properties) override;
public slots:
void updateWindowTitle();
protected:
CutterSeekable *seekable = nullptr;
QAction syncAction;
QMenu *dockMenu = nullptr;
virtual QString getWindowTitle() const = 0;
void contextMenuEvent(QContextMenuEvent *event) override;
};
#endif // ADDRESSABLE_DOCK_WIDGET_H
| 805
|
C++
|
.h
| 25
| 28.92
| 75
| 0.79118
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,738
|
GraphvizLayout.h
|
rizinorg_cutter/src/widgets/GraphvizLayout.h
|
#ifndef GRAPHVIZLAYOUT_H
#define GRAPHVIZLAYOUT_H
#include "core/Cutter.h"
#include "GraphLayout.h"
class GraphvizLayout : public GraphLayout
{
public:
enum class LayoutType {
DotOrtho,
DotPolyline,
Sfdp,
Neato,
TwoPi,
Circo,
};
enum class Direction { TB, LR };
GraphvizLayout(LayoutType layoutType, Direction direction = Direction::TB);
virtual void CalculateLayout(std::unordered_map<ut64, GraphBlock> &blocks, ut64 entry,
int &width, int &height) const override;
private:
Direction direction;
LayoutType layoutType;
};
#endif // GRAPHVIZLAYOUT_H
| 662
|
C++
|
.h
| 24
| 21.875
| 90
| 0.675079
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,739
|
StringsWidget.h
|
rizinorg_cutter/src/widgets/StringsWidget.h
|
#ifndef STRINGSWIDGET_H
#define STRINGSWIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "common/StringsTask.h"
#include "CutterTreeWidget.h"
#include "AddressableItemModel.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidgetItem;
class StringsWidget;
namespace Ui {
class StringsWidget;
}
class StringsModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend StringsWidget;
private:
QList<StringDescription> *strings;
public:
enum Column {
OffsetColumn = 0,
StringColumn,
TypeColumn,
LengthColumn,
SizeColumn,
SectionColumn,
CommentColumn,
ColumnCount
};
static const int StringDescriptionRole = Qt::UserRole;
StringsModel(QList<StringDescription> *strings, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
const StringDescription *description(const QModelIndex &index) const;
};
class StringsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
StringsProxyModel(StringsModel *sourceModel, QObject *parent = nullptr);
void setSelectedSection(QString section);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
QString selectedSection;
};
class StringsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit StringsWidget(MainWindow *main);
~StringsWidget();
private slots:
void refreshStrings();
void stringSearchFinished(const QList<StringDescription> &strings);
void refreshSectionCombo();
void on_actionCopy();
private:
std::unique_ptr<Ui::StringsWidget> ui;
QSharedPointer<StringsTask> task;
StringsModel *model;
StringsProxyModel *proxyModel;
QList<StringDescription> strings;
CutterTreeWidget *tree;
};
#endif // STRINGSWIDGET_H
| 2,372
|
C++
|
.h
| 74
| 27.797297
| 84
| 0.761549
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,740
|
BreakpointWidget.h
|
rizinorg_cutter/src/widgets/BreakpointWidget.h
|
#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "AddressableItemModel.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
namespace Ui {
class BreakpointWidget;
}
class MainWindow;
class QTreeWidgetItem;
class BreakpointWidget;
class BreakpointModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend BreakpointWidget;
private:
QList<BreakpointDescription> breakpoints;
public:
enum Column {
AddrColumn = 0,
NameColumn,
TypeColumn,
TraceColumn,
EnabledColumn,
CommentColumn,
ColumnCount
};
enum Role { BreakpointDescriptionRole = Qt::UserRole };
BreakpointModel(QObject *parent = nullptr);
void refresh();
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
RVA address(const QModelIndex &index) const override;
};
class BreakpointProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
BreakpointProxyModel(BreakpointModel *sourceModel, QObject *parent = nullptr);
};
class BreakpointWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit BreakpointWidget(MainWindow *main);
~BreakpointWidget();
private slots:
void delBreakpoint();
void toggleBreakpoint();
void editBreakpoint();
void addBreakpointDialog();
void refreshBreakpoint();
private:
std::unique_ptr<Ui::BreakpointWidget> ui;
BreakpointModel *breakpointModel;
BreakpointProxyModel *breakpointProxyModel;
QList<BreakpointDescription> breakpoints;
QAction *actionDelBreakpoint = nullptr;
QAction *actionToggleBreakpoint = nullptr;
QAction *actionEditBreakpoint = nullptr;
void setScrollMode();
QVector<RVA> getSelectedAddresses() const;
RefreshDeferrer *refreshDeferrer;
bool editing = false;
};
| 2,361
|
C++
|
.h
| 74
| 27.554054
| 100
| 0.757844
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,741
|
CutterTreeWidget.h
|
rizinorg_cutter/src/widgets/CutterTreeWidget.h
|
#ifndef CUTTERTREEWIDGET_H
#define CUTTERTREEWIDGET_H
#include "core/CutterCommon.h"
#include <QStatusBar>
#include <QVBoxLayout>
class MainWindow;
class CUTTER_EXPORT CutterTreeWidget : public QObject
{
Q_OBJECT
public:
explicit CutterTreeWidget(QObject *parent = nullptr);
~CutterTreeWidget();
void addStatusBar(QVBoxLayout *pos);
void showItemsNumber(int count);
void showStatusBar(bool show);
private:
QStatusBar *bar;
};
#endif // CUTTERTREEWIDGET_H
| 490
|
C++
|
.h
| 19
| 22.947368
| 57
| 0.782328
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,742
|
StackWidget.h
|
rizinorg_cutter/src/widgets/StackWidget.h
|
#pragma once
#include <QJsonObject>
#include <memory>
#include <QStandardItem>
#include <QTableView>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "menus/AddressableItemContextMenu.h"
class MainWindow;
namespace Ui {
class StackWidget;
}
class StackModel : public QAbstractTableModel
{
Q_OBJECT
public:
struct Item
{
RVA offset;
QString value;
RefDescription refDesc;
};
enum Column { OffsetColumn = 0, ValueColumn, DescriptionColumn, CommentColumn, ColumnCount };
enum Role { StackDescriptionRole = Qt::UserRole };
StackModel(QObject *parent = nullptr);
void reload();
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
private:
QVector<Item> values;
};
Q_DECLARE_METATYPE(StackModel::Item)
class StackWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit StackWidget(MainWindow *main);
~StackWidget();
private slots:
void updateContents();
void setStackGrid();
void fontsUpdatedSlot();
void onDoubleClicked(const QModelIndex &index);
void customMenuRequested(QPoint pos);
void editStack();
void onCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous);
private:
std::unique_ptr<Ui::StackWidget> ui;
QTableView *viewStack = new QTableView(this);
StackModel *modelStack = new StackModel(this);
QAction *editAction;
QAction menuText;
RefreshDeferrer *refreshDeferrer;
AddressableItemContextMenu addressableItemContextMenu;
};
| 1,971
|
C++
|
.h
| 60
| 28.65
| 97
| 0.747757
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,743
|
SearchWidget.h
|
rizinorg_cutter/src/widgets/SearchWidget.h
|
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "AddressableItemList.h"
class MainWindow;
class QTreeWidgetItem;
class SearchWidget;
class SearchModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend SearchWidget;
private:
QList<SearchDescription> *search;
public:
enum Columns { OFFSET = 0, SIZE, CODE, DATA, COMMENT, COUNT };
static const int SearchDescriptionRole = Qt::UserRole;
SearchModel(QList<SearchDescription> *search, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
};
class SearchSortFilterProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
SearchSortFilterProxyModel(SearchModel *source_model, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
namespace Ui {
class SearchWidget;
}
class SearchWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit SearchWidget(MainWindow *main);
~SearchWidget();
private slots:
void searchChanged();
void updateSearchBoundaries();
void refreshSearchspaces();
private:
std::unique_ptr<Ui::SearchWidget> ui;
SearchModel *search_model;
SearchSortFilterProxyModel *search_proxy_model;
QList<SearchDescription> search;
void refreshSearch();
void checkSearchResultEmpty();
void enableSearch();
void disableSearch();
void setScrollMode();
void updatePlaceholderText(int index);
};
#endif // SEARCHWIDGET_H
| 2,101
|
C++
|
.h
| 63
| 29.634921
| 85
| 0.770223
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,744
|
SymbolsWidget.h
|
rizinorg_cutter/src/widgets/SymbolsWidget.h
|
#ifndef SYMBOLSWIDGET_H
#define SYMBOLSWIDGET_H
#include <memory>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/ListDockWidget.h"
class MainWindow;
class QTreeWidgetItem;
class SymbolsWidget;
class SymbolsModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend SymbolsWidget;
private:
QList<SymbolDescription> *symbols;
public:
enum Column { AddressColumn = 0, TypeColumn, NameColumn, CommentColumn, ColumnCount };
enum Role { SymbolDescriptionRole = Qt::UserRole };
SymbolsModel(QList<SymbolDescription> *exports, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
class SymbolsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
SymbolsProxyModel(SymbolsModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class SymbolsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit SymbolsWidget(MainWindow *main);
~SymbolsWidget();
private slots:
void refreshSymbols();
private:
QList<SymbolDescription> symbols;
SymbolsModel *symbolsModel;
SymbolsProxyModel *symbolsProxyModel;
};
#endif // SYMBOLSWIDGET_H
| 1,838
|
C++
|
.h
| 52
| 31.75
| 90
| 0.779287
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,745
|
BacktraceWidget.h
|
rizinorg_cutter/src/widgets/BacktraceWidget.h
|
#pragma once
#include <QJsonObject>
#include <memory>
#include <QStandardItem>
#include <QTableView>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
class MainWindow;
namespace Ui {
class BacktraceWidget;
}
class BacktraceWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit BacktraceWidget(MainWindow *main);
~BacktraceWidget();
private slots:
void updateContents();
void setBacktraceGrid();
void fontsUpdatedSlot();
private:
std::unique_ptr<Ui::BacktraceWidget> ui;
QStandardItemModel *modelBacktrace = new QStandardItemModel(1, 5, this);
QTableView *viewBacktrace = new QTableView(this);
RefreshDeferrer *refreshDeferrer;
};
| 691
|
C++
|
.h
| 27
| 22.814815
| 76
| 0.777439
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,746
|
FunctionsWidget.h
|
rizinorg_cutter/src/widgets/FunctionsWidget.h
|
#ifndef FUNCTIONSWIDGET_H
#define FUNCTIONSWIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/ListDockWidget.h"
class MainWindow;
class FunctionsTask;
class FunctionsWidget;
class FunctionModel : public AddressableItemModel<>
{
Q_OBJECT
friend FunctionsWidget;
private:
QList<FunctionDescription> *functions;
QSet<RVA> *importAddresses;
ut64 *mainAdress;
QFont highlightFont;
QFont defaultFont;
bool nested;
int currentIndex;
QIcon iconFuncImpDark;
QIcon iconFuncImpLight;
QIcon iconFuncMainDark;
QIcon iconFuncMainLight;
QIcon iconFuncDark;
QIcon iconFuncLight;
bool functionIsImport(ut64 addr) const;
bool functionIsMain(ut64 addr) const;
public:
static const int FunctionDescriptionRole = Qt::UserRole;
static const int IsImportRole = Qt::UserRole + 1;
enum Column {
NameColumn = 0,
SizeColumn,
ImportColumn,
OffsetColumn,
NargsColumn,
NlocalsColumn,
NbbsColumn,
CalltypeColumn,
EdgesColumn,
FrameColumn,
CommentColumn,
ColumnCount
};
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *importAddresses,
ut64 *mainAdress, bool nested, QFont defaultFont, QFont highlightFont,
QObject *parent = nullptr);
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
/**
* @return true if the index changed
*/
bool updateCurrentIndex();
void setNested(bool nested);
bool isNested() { return nested; }
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
private slots:
void seekChanged(RVA addr);
void functionRenamed(const RVA offset, const QString &new_name);
};
class FunctionSortFilterProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
FunctionSortFilterProxyModel(FunctionModel *source_model, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class FunctionsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit FunctionsWidget(MainWindow *main);
~FunctionsWidget() override;
void changeSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver);
private slots:
void onActionFunctionsRenameTriggered();
void onActionFunctionsUndefineTriggered();
void onActionHorizontalToggled(bool enable);
void onActionVerticalToggled(bool enable);
void showTitleContextMenu(const QPoint &pt);
void setTooltipStylesheet();
void refreshTree();
private:
QSharedPointer<FunctionsTask> task;
QList<FunctionDescription> functions;
QSet<RVA> importAddresses;
ut64 mainAdress;
FunctionModel *functionModel;
FunctionSortFilterProxyModel *functionProxyModel;
QMenu *titleContextMenu;
QAction actionRename;
QAction actionUndefine;
QAction actionHorizontal;
QAction actionVertical;
};
#endif // FUNCTIONSWIDGET_H
| 3,662
|
C++
|
.h
| 107
| 28.869159
| 89
| 0.741277
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,747
|
DisassemblyWidget.h
|
rizinorg_cutter/src/widgets/DisassemblyWidget.h
|
#ifndef DISASSEMBLYWIDGET_H
#define DISASSEMBLYWIDGET_H
#include "core/Cutter.h"
#include "MemoryDockWidget.h"
#include "common/CutterSeekable.h"
#include "common/RefreshDeferrer.h"
#include "common/CachedFontMetrics.h"
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QShortcut>
#include <QAction>
#include <vector>
class DisassemblyTextEdit;
class DisassemblyScrollArea;
class DisassemblyContextMenu;
class DisassemblyLeftPanel;
class DisassemblyWidget : public MemoryDockWidget
{
Q_OBJECT
public:
explicit DisassemblyWidget(MainWindow *main);
QWidget *getTextWidget();
static QString getWidgetType();
public slots:
/**
* @brief Highlights the currently selected line and updates the
* highlighting of the same words under the cursor in the visible screen.
* This overrides all previous highlighting.
*/
void highlightCurrentLine();
/**
* @brief Adds the PC line highlighting to the other current highlighting.
* This should be called after highlightCurrentLine since that function
* overrides all previous highlighting.
*/
void highlightPCLine();
void showDisasContextMenu(const QPoint &pt);
void fontsUpdatedSlot();
void colorsUpdatedSlot();
void scrollInstructions(int count);
void seekPrev();
void setPreviewMode(bool previewMode);
QFontMetrics getFontMetrics();
QList<DisassemblyLine> getLines();
protected slots:
void on_seekChanged(RVA offset, CutterCore::SeekHistoryType type);
void refreshIfInRange(RVA offset);
void instructionChanged(RVA offset);
void refreshDisasm(RVA offset = RVA_INVALID);
bool updateMaxLines();
void cursorPositionChanged();
protected:
DisassemblyContextMenu *mCtxMenu;
DisassemblyScrollArea *mDisasScrollArea;
DisassemblyTextEdit *mDisasTextEdit;
DisassemblyLeftPanel *leftPanel;
QList<DisassemblyLine> lines;
private:
RVA topOffset;
RVA bottomOffset;
int maxLines;
QString curHighlightedWord;
/**
* offset of lines below the first line of the current seek
*/
int cursorLineOffset;
int cursorCharOffset;
bool seekFromCursor;
RefreshDeferrer *disasmRefresh;
RVA readCurrentDisassemblyOffset();
bool eventFilter(QObject *obj, QEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
QString getWindowTitle() const override;
int topOffsetHistoryPos = 0;
QList<RVA> topOffsetHistory;
QList<RVA> breakpoints;
void setupFonts();
void setupColors();
void updateCursorPosition();
void connectCursorPositionChanged(bool disconnect);
void moveCursorRelative(bool up, bool page);
void jumpToOffsetUnderCursor(const QTextCursor &);
};
class DisassemblyScrollArea : public QAbstractScrollArea
{
Q_OBJECT
public:
explicit DisassemblyScrollArea(QWidget *parent = nullptr);
signals:
void scrollLines(int lines);
void disassemblyResized();
protected:
bool viewportEvent(QEvent *event) override;
private:
void resetScrollBars();
};
class DisassemblyTextEdit : public QPlainTextEdit
{
Q_OBJECT
public:
explicit DisassemblyTextEdit(QWidget *parent = nullptr)
: QPlainTextEdit(parent), lockScroll(false)
{
}
void setLockScroll(bool lock) { this->lockScroll = lock; }
qreal textOffset() const;
protected:
bool viewportEvent(QEvent *event) override;
void scrollContentsBy(int dx, int dy) override;
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
private:
bool lockScroll;
};
/**
* This class is used to draw the left pane of the disassembly
* widget. Its goal is to draw proper arrows for the jumps of the disassembly.
*/
class DisassemblyLeftPanel : public QFrame
{
public:
DisassemblyLeftPanel(DisassemblyWidget *disas);
void paintEvent(QPaintEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void clearArrowFrom(RVA offset);
private:
DisassemblyWidget *disas;
struct Arrow
{
Arrow(RVA v1, RVA v2) : min(v1), max(v2), level(0), up(false)
{
if (min > max) {
std::swap(min, max);
up = true;
}
}
inline bool contains(RVA point) const { return min <= point && max >= point; }
inline bool intersects(const Arrow &other) const
{
return std::max(min, other.min) <= std::min(max, other.max);
}
ut64 length() const { return max - min; }
RVA jmpFromOffset() const { return up ? max : min; }
RVA jmpToffset() const { return up ? min : max; }
RVA min;
RVA max;
uint32_t level;
bool up;
};
const size_t arrowsSize = 128;
const uint32_t maxLevelBeforeFlush = 32;
RVA lastBeginOffset = 0;
std::vector<Arrow> arrows;
};
#endif // DISASSEMBLYWIDGET_H
| 4,939
|
C++
|
.h
| 155
| 27.006452
| 86
| 0.722304
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,748
|
FlirtWidget.h
|
rizinorg_cutter/src/widgets/FlirtWidget.h
|
#ifndef FLIRT_WIDGET_H
#define FLIRT_WIDGET_H
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "menus/FlirtContextMenu.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class QTreeWidgetItem;
class FlirtWidget;
namespace Ui {
class FlirtWidget;
}
class FlirtModel : public QAbstractListModel
{
Q_OBJECT
friend FlirtWidget;
public:
enum Column {
BinTypeColumn = 0,
ArchNameColumn,
ArchBitsColumn,
NumModulesColumn,
NameColumn,
DetailsColumn,
ColumnCount
};
enum Role { FlirtDescriptionRole = Qt::UserRole };
FlirtModel(QList<FlirtDescription> *sigdb, QObject *parent = 0);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
private:
QList<FlirtDescription> *sigdb;
};
class FlirtProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
FlirtProxyModel(FlirtModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class FlirtWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit FlirtWidget(MainWindow *main);
~FlirtWidget();
private slots:
void refreshFlirt();
void onSelectedItemChanged(const QModelIndex &index);
void showItemContextMenu(const QPoint &pt);
private:
std::unique_ptr<Ui::FlirtWidget> ui;
FlirtModel *model;
FlirtProxyModel *proxyModel;
QList<FlirtDescription> sigdb;
FlirtContextMenu *blockMenu;
void setScrollMode();
};
#endif // FLIRT_WIDGET_H
| 1,956
|
C++
|
.h
| 66
| 25.818182
| 100
| 0.755353
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,749
|
HeapDockWidget.h
|
rizinorg_cutter/src/widgets/HeapDockWidget.h
|
#ifndef HEAPDOCKWIDGET_H
#define HEAPDOCKWIDGET_H
#include <QDockWidget>
#include "CutterDockWidget.h"
namespace Ui {
class HeapDockWidget;
}
class HeapDockWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit HeapDockWidget(MainWindow *main);
~HeapDockWidget();
private slots:
void onAllocatorSelected(int index);
private:
enum Allocator { Glibc = 0, AllocatorCount };
Ui::HeapDockWidget *ui;
MainWindow *main;
QWidget *currentHeapWidget = nullptr;
};
#endif // HEAPDOCKWIDGET_H
| 525
|
C++
|
.h
| 22
| 21.136364
| 49
| 0.772636
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,750
|
SectionsWidget.h
|
rizinorg_cutter/src/widgets/SectionsWidget.h
|
#ifndef SECTIONSWIDGET_H
#define SECTIONSWIDGET_H
#include <memory>
#include <map>
#include <QtWidgets/QToolButton>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <QGraphicsScene>
#include <QLabel>
#include <QHash>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/ListDockWidget.h"
class QAbstractItemView;
class SectionsWidget;
class AbstractAddrDock;
class AddrDockScene;
class QGraphicsSceneMouseEvent;
class RawAddrDock;
class VirtualAddrDock;
class QuickFilterView;
class QGraphicsView;
class QGraphicsRectItem;
class SectionsModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend SectionsWidget;
private:
QList<SectionDescription> *sections;
public:
enum Column {
NameColumn = 0,
SizeColumn,
AddressColumn,
EndAddressColumn,
VirtualSizeColumn,
PermissionsColumn,
EntropyColumn,
CommentColumn,
ColumnCount
};
enum Role { SectionDescriptionRole = Qt::UserRole };
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
class SectionsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
SectionsProxyModel(SectionsModel *sourceModel, QObject *parent = nullptr);
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class SectionsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit SectionsWidget(MainWindow *main);
~SectionsWidget();
private slots:
void refreshSections();
void refreshDocks();
protected:
void resizeEvent(QResizeEvent *event) override;
private:
QList<SectionDescription> sections;
SectionsModel *sectionsModel;
SectionsProxyModel *proxyModel;
QWidget *addrDockWidget;
RawAddrDock *rawAddrDock;
VirtualAddrDock *virtualAddrDock;
QToolButton *toggleButton;
/**
* RefreshDeferrer for loading the section data
*/
RefreshDeferrer *sectionsRefreshDeferrer;
/**
* RefreshDeferrer for updating the visualization docks
*/
RefreshDeferrer *dockRefreshDeferrer;
void initSectionsTable();
void initQuickFilter();
void initConnects();
void initAddrMapDocks();
void drawIndicatorOnAddrDocks();
void updateToggle();
};
class AbstractAddrDock : public QDockWidget
{
Q_OBJECT
friend SectionsWidget;
public:
explicit AbstractAddrDock(SectionsModel *model, QWidget *parent = nullptr);
~AbstractAddrDock();
virtual void updateDock();
protected:
int indicatorHeight;
int indicatorParamPosY;
float heightThreshold;
float heightDivisor;
int rectOffset;
int rectWidthMin;
int rectWidthMax;
QColor indicatorColor;
QColor textColor;
AddrDockScene *addrDockScene;
QGraphicsView *graphicsView;
SectionsProxyModel *proxyModel;
void addTextItem(QColor color, QPoint pos, QString string);
int getAdjustedSize(int size, int validMinSize);
int getRectWidth();
int getIndicatorWidth();
int getValidMinSize();
virtual RVA getSizeOfSection(const SectionDescription §ion) = 0;
virtual RVA getAddressOfSection(const SectionDescription §ion) = 0;
private:
void drawIndicator(QString name, float ratio);
};
class AddrDockScene : public QGraphicsScene
{
Q_OBJECT
public:
explicit AddrDockScene(QWidget *parent = nullptr);
~AddrDockScene();
bool disableCenterOn;
QHash<QString, RVA> nameAddrMap;
QHash<QString, RVA> nameAddrSizeMap;
QHash<QString, RVA> seekAddrMap;
QHash<QString, RVA> seekAddrSizeMap;
QHash<QString, int> namePosYMap;
QHash<QString, int> nameHeightMap;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
private:
RVA getAddrFromPos(int posY, bool seek);
};
class RawAddrDock : public AbstractAddrDock
{
Q_OBJECT
public:
explicit RawAddrDock(SectionsModel *model, QWidget *parent = nullptr);
~RawAddrDock() = default;
void updateDock() override;
protected:
RVA getSizeOfSection(const SectionDescription §ion) override { return section.size; };
RVA getAddressOfSection(const SectionDescription §ion) override { return section.paddr; };
};
class VirtualAddrDock : public AbstractAddrDock
{
Q_OBJECT
public:
explicit VirtualAddrDock(SectionsModel *model, QWidget *parent = nullptr);
~VirtualAddrDock() = default;
void updateDock() override;
protected:
RVA getSizeOfSection(const SectionDescription §ion) override { return section.vsize; };
RVA getAddressOfSection(const SectionDescription §ion) override { return section.vaddr; };
};
#endif // SECTIONSWIDGET_H
| 5,268
|
C++
|
.h
| 166
| 27.608434
| 98
| 0.76459
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,751
|
AddressableItemList.h
|
rizinorg_cutter/src/widgets/AddressableItemList.h
|
#ifndef ADDRESSABLE_ITEM_LIST_H
#define ADDRESSABLE_ITEM_LIST_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QAbstractItemView>
#include <QMenu>
#include "core/Cutter.h"
#include "common/AddressableItemModel.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include "menus/AddressableItemContextMenu.h"
#include "CutterTreeView.h"
class MainWindow;
template<class BaseListWidget = CutterTreeView>
class AddressableItemList : public BaseListWidget
{
static_assert(std::is_base_of<QAbstractItemView, BaseListWidget>::value,
"ParentModel needs to inherit from QAbstractItemModel");
public:
explicit AddressableItemList(QWidget *parent = nullptr) : BaseListWidget(parent)
{
this->connect(this, &QWidget::customContextMenuRequested, this,
&AddressableItemList<BaseListWidget>::showItemContextMenu);
this->setContextMenuPolicy(Qt::CustomContextMenu);
this->connect(this, &QAbstractItemView::activated, this,
&AddressableItemList<BaseListWidget>::onItemActivated);
}
void setModel(AddressableItemModelI *addressableItemModel)
{
this->addressableModel = addressableItemModel;
BaseListWidget::setModel(this->addressableModel->asItemModel());
this->connect(this->selectionModel(), &QItemSelectionModel::currentChanged, this,
&AddressableItemList<BaseListWidget>::onSelectedItemChanged);
}
void setMainWindow(MainWindow *mainWindow)
{
this->mainWindow = mainWindow;
setItemContextMenu(new AddressableItemContextMenu(this, mainWindow));
this->addActions(this->getItemContextMenu()->actions());
}
AddressableItemContextMenu *getItemContextMenu() { return itemContextMenu; }
void setItemContextMenu(AddressableItemContextMenu *menu)
{
if (itemContextMenu != menu && itemContextMenu) {
itemContextMenu->deleteLater();
}
itemContextMenu = menu;
}
/**
* If this is set to true, the context menu will also be shown if no item
* is currently selected.
*/
void setShowItemContextMenuWithoutAddress(bool val) { showItemContextMenuWithoutAddress = val; }
protected:
virtual void showItemContextMenu(const QPoint &pt)
{
if (!itemContextMenu) {
return;
}
auto index = this->currentIndex();
if (index.isValid()) {
auto offset = addressableModel->address(index);
auto name = addressableModel->name(index);
itemContextMenu->setTarget(offset, name);
} else {
if (!showItemContextMenuWithoutAddress) {
return;
}
itemContextMenu->clearTarget();
}
itemContextMenu->exec(this->mapToGlobal(pt));
}
virtual void onItemActivated(const QModelIndex &index)
{
if (!index.isValid())
return;
auto offset = addressableModel->address(index);
Core()->seekAndShow(offset);
}
virtual void onSelectedItemChanged(const QModelIndex &index) { updateMenuFromItem(index); }
void updateMenuFromItem(const QModelIndex &index)
{
if (index.isValid()) {
auto offset = addressableModel->address(index);
auto name = addressableModel->name(index);
itemContextMenu->setTarget(offset, name);
} else {
itemContextMenu->clearTarget();
}
}
private:
bool showItemContextMenuWithoutAddress = false;
AddressableItemModelI *addressableModel = nullptr;
AddressableItemContextMenu *itemContextMenu = nullptr;
MainWindow *mainWindow = nullptr;
};
#endif // ADDRESSABLE_ITEM_LIST_H
| 3,776
|
C++
|
.h
| 98
| 31.346939
| 100
| 0.691237
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,752
|
RelocsWidget.h
|
rizinorg_cutter/src/widgets/RelocsWidget.h
|
#ifndef RELOCSWIDGET_H
#define RELOCSWIDGET_H
#include <memory>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "CutterDockWidget.h"
#include "core/Cutter.h"
#include "widgets/ListDockWidget.h"
class MainWindow;
class RelocsWidget;
class RelocsModel : public AddressableItemModel<QAbstractTableModel>
{
Q_OBJECT
friend RelocsWidget;
private:
QList<RelocDescription> relocs;
public:
enum Column { VAddrColumn = 0, TypeColumn, NameColumn, CommentColumn, ColumnCount };
enum Role { RelocDescriptionRole = Qt::UserRole, AddressRole };
RelocsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
void reload();
};
class RelocsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
RelocsProxyModel(RelocsModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class RelocsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit RelocsWidget(MainWindow *main);
~RelocsWidget();
private slots:
void refreshRelocs();
private:
RelocsModel *relocsModel;
RelocsProxyModel *relocsProxyModel;
};
#endif // RELOCSWIDGET_H
| 1,679
|
C++
|
.h
| 50
| 30.34
| 91
| 0.785581
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,753
|
SegmentsWidget.h
|
rizinorg_cutter/src/widgets/SegmentsWidget.h
|
#ifndef SEGMENTSWIDGET_H
#define SEGMENTSWIDGET_H
#include <memory>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "widgets/ListDockWidget.h"
class QAbstractItemView;
class SegmentsWidget;
class SegmentsModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend SegmentsWidget;
private:
QList<SegmentDescription> *segments;
public:
enum Column {
NameColumn = 0,
SizeColumn,
AddressColumn,
EndAddressColumn,
PermColumn,
CommentColumn,
ColumnCount
};
enum Role { SegmentDescriptionRole = Qt::UserRole };
SegmentsModel(QList<SegmentDescription> *segments, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int segment, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
class SegmentsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
SegmentsProxyModel(SegmentsModel *sourceModel, QObject *parent = nullptr);
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class SegmentsWidget : public ListDockWidget
{
Q_OBJECT
public:
explicit SegmentsWidget(MainWindow *main);
~SegmentsWidget();
private slots:
void refreshSegments();
private:
QList<SegmentDescription> segments;
SegmentsModel *segmentsModel;
};
#endif // SEGMENTSWIDGET_H
| 1,786
|
C++
|
.h
| 56
| 27.535714
| 84
| 0.756725
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,754
|
ProcessesWidget.h
|
rizinorg_cutter/src/widgets/ProcessesWidget.h
|
#pragma once
#include <QJsonObject>
#include <memory>
#include <QStandardItem>
#include <QTableView>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
class MainWindow;
namespace Ui {
class ProcessesWidget;
}
class ProcessesFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
ProcessesFilterModel(QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
};
class ProcessesWidget : public CutterDockWidget
{
Q_OBJECT
public:
enum ColumnIndex {
COLUMN_PID = 0,
COLUMN_UID,
COLUMN_STATUS,
COLUMN_PATH,
};
explicit ProcessesWidget(MainWindow *main);
~ProcessesWidget();
private slots:
void updateContents();
void setProcessesGrid();
void fontsUpdatedSlot();
void onActivated(const QModelIndex &index);
private:
QString translateStatus(const char status);
std::unique_ptr<Ui::ProcessesWidget> ui;
QStandardItemModel *modelProcesses;
ProcessesFilterModel *modelFilter;
RefreshDeferrer *refreshDeferrer;
};
| 1,116
|
C++
|
.h
| 44
| 21.818182
| 77
| 0.760377
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,755
|
GlobalsWidget.h
|
rizinorg_cutter/src/widgets/GlobalsWidget.h
|
#ifndef GLOBALSWIDGET_H
#define GLOBALSWIDGET_H
#include <memory>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "widgets/ListDockWidget.h"
class MainWindow;
class QTreeWidget;
class GlobalsWidget;
namespace Ui {
class GlobalsWidget;
}
class MainWindow;
class QTreeWidgetItem;
class GlobalsModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
friend GlobalsWidget;
private:
QList<GlobalDescription> *globals;
public:
enum Column { AddressColumn = 0, TypeColumn, NameColumn, CommentColumn, ColumnCount };
enum Role { GlobalDescriptionRole = Qt::UserRole };
GlobalsModel(QList<GlobalDescription> *exports, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
};
class GlobalsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
GlobalsProxyModel(GlobalsModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class GlobalsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit GlobalsWidget(MainWindow *main);
~GlobalsWidget();
private slots:
void refreshGlobals();
void editGlobal();
void deleteGlobal();
private:
std::unique_ptr<Ui::GlobalsWidget> ui;
QList<GlobalDescription> globals;
GlobalsModel *globalsModel;
GlobalsProxyModel *globalsProxyModel;
CutterTreeWidget *tree;
QAction *actionEditGlobal;
QAction *actionDeleteGlobal;
};
#endif // GLOBALSWIDGET_H
| 2,103
|
C++
|
.h
| 63
| 29.777778
| 90
| 0.776786
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,756
|
GlibcHeapWidget.h
|
rizinorg_cutter/src/widgets/GlibcHeapWidget.h
|
#ifndef GLIBCHEAPWIDGET_H
#define GLIBCHEAPWIDGET_H
#include <QDockWidget>
#include "CutterDockWidget.h"
#include "core/Cutter.h"
#include <QTableView>
#include <QComboBox>
#include <AddressableItemContextMenu.h>
namespace Ui {
class GlibcHeapWidget;
}
class GlibcHeapModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit GlibcHeapModel(QObject *parent = nullptr);
enum Column { OffsetColumn = 0, SizeColumn, StatusColumn, ColumnCount };
void reload();
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
RVA arena_addr = 0;
private:
QVector<Chunk> values;
};
class GlibcHeapWidget : public QWidget
{
Q_OBJECT
public:
explicit GlibcHeapWidget(MainWindow *main, QWidget *parent);
~GlibcHeapWidget();
private slots:
void updateContents();
void onDoubleClicked(const QModelIndex &index);
void onArenaSelected(int index);
void customMenuRequested(QPoint pos);
void onCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous);
void viewChunkInfo();
void viewBinInfo();
void viewArenaInfo();
private:
void updateArenas();
void updateChunks();
Ui::GlibcHeapWidget *ui;
QTableView *viewHeap;
QComboBox *arenaSelectorView;
GlibcHeapModel *modelHeap = new GlibcHeapModel(this);
QVector<Arena> arenas;
QAction *chunkInfoAction;
QAction *binInfoAction;
AddressableItemContextMenu addressableItemContextMenu;
RefreshDeferrer *refreshDeferrer {};
MainWindow *main;
};
#endif // GLIBCHEAPWIDGET_H
| 1,762
|
C++
|
.h
| 56
| 27.964286
| 91
| 0.767962
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,757
|
EntrypointWidget.h
|
rizinorg_cutter/src/widgets/EntrypointWidget.h
|
#ifndef ENTRYPOINTWIDGET_H
#define ENTRYPOINTWIDGET_H
#include <memory>
#include <QStyledItemDelegate>
#include <QTreeWidgetItem>
#include "CutterDockWidget.h"
class MainWindow;
class QTreeWidget;
namespace Ui {
class EntrypointWidget;
}
class EntrypointWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit EntrypointWidget(MainWindow *main);
~EntrypointWidget();
private slots:
void on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void fillEntrypoint();
private:
std::unique_ptr<Ui::EntrypointWidget> ui;
void setScrollMode();
};
#endif // ENTRYPOINTWIDGET_H
| 637
|
C++
|
.h
| 25
| 22.92
| 86
| 0.803661
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,758
|
OverviewView.h
|
rizinorg_cutter/src/widgets/OverviewView.h
|
#ifndef OVERVIEWVIEW_H
#define OVERVIEWVIEW_H
#include <QWidget>
#include <QPainter>
#include <QRect>
#include "widgets/GraphView.h"
#include "widgets/DisassemblerGraphView.h"
class OverviewView : public GraphView
{
Q_OBJECT
signals:
/**
* @brief signal when mouse is pressed or moved so that
* Graph can refresh its contents corresponded with Overview
*/
void mouseMoved();
public:
OverviewView(QWidget *parent);
~OverviewView() override;
/**
* @brief Graph access this function to set minimum set of the data
* @param baseWidth width of Graph when it computed the blocks
* @param baseHeigh height of Graph when it computed the blocks
* @param baseBlocks computed blocks passed by Graph
* @param baseEdgeConfigurations computed by DisassamblerGraphview
*/
void setData(int baseWidth, int baseHeight, std::unordered_map<ut64, GraphBlock> baseBlocks,
DisassemblerGraphView::EdgeConfigurationMapping baseEdgeConfigurations);
void centreRect();
/**
* @brief keep the current addr of the fcn of Graph
* Everytime overview updates its contents, it compares this value with the one in Graph
* if they aren't same, then Overview needs to update the pixmap cache.
*/
ut64 currentFcnAddr = RVA_INVALID; // TODO: make this less public
public slots:
/**
* @brief scale and center all nodes in, then run update
*/
void refreshView();
private slots:
/**
* @brief update Colors.
* for example this will be called when the theme is changed.
*/
void colorsUpdatedSlot();
protected:
/**
* @brief mousePressEvent to start moving the rect.
*/
void mousePressEvent(QMouseEvent *event) override;
/**
* @brief mouseReleaseEvent to tell not to move the rect anymore.
*/
void mouseReleaseEvent(QMouseEvent *event) override;
/**
* @brief mouseMoveEvent to move the rect.
*/
void mouseMoveEvent(QMouseEvent *event) override;
/**
* @brief override this to prevent scrolling
*/
void wheelEvent(QWheelEvent *event) override;
/**
* @brief override the paintEvent to draw the rect on Overview
*/
void paintEvent(QPaintEvent *event) override;
private:
/**
* @brief this will be handled in mouse events to move the rect properly
* along with the mouse.
*/
bool mouseActive = false;
/**
* @brief save the initial distance
* between the point where the mouse was pressed and the point of the rect
* so as to change the rect point properly along with mouse.
*/
QPointF initialDiff;
/**
* @brief a rect on Overview to show where you are on Graph
*/
QRectF rangeRect;
/**
* @brief calculate the scale to fit the all nodes in and center them in the viewport
*/
void scaleAndCenter();
/**
* @brief draw the computed blocks passed by Graph
*/
virtual void drawBlock(QPainter &p, GraphView::GraphBlock &block, bool interactive) override;
/**
* @brief override the edgeConfiguration so as to
* adjust the width of the edges by the scale
* @return EdgeConfiguration
*/
virtual GraphView::EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from,
GraphView::GraphBlock *to,
bool interactive) override;
/**
* @brief base background color changing depending on the theme
*/
QColor disassemblyBackgroundColor;
/**
* @brief color for each node changing depending on the theme
*/
QColor graphNodeColor;
/**
* @brief fill color of the selection rectangle
*/
QColor graphSelectionFill;
/**
* @brief border color of the selection rectangle
*/
QColor graphSelectionBorder;
/**
* @brief edgeConfigurations edge styles computed by DisassemblerGraphView
*/
DisassemblerGraphView::EdgeConfigurationMapping edgeConfigurations;
public:
QRectF getRangeRect() { return rangeRect; }
void setRangeRect(QRectF rect);
};
#endif // OVERVIEWVIEW_H
| 4,212
|
C++
|
.h
| 124
| 27.927419
| 97
| 0.677983
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,759
|
HexWidget.h
|
rizinorg_cutter/src/widgets/HexWidget.h
|
#ifndef HEXWIDGET_H
#define HEXWIDGET_H
#include "Cutter.h"
#include "dialogs/HexdumpRangeDialog.h"
#include "common/IOModesController.h"
#include <QScrollArea>
#include <QTimer>
#include <QMenu>
#include <memory>
struct BasicCursor
{
uint64_t address;
bool pastEnd;
explicit BasicCursor(uint64_t pos) : address(pos), pastEnd(false) {}
BasicCursor() : address(0), pastEnd(false) {}
BasicCursor &operator+=(int64_t offset)
{
if (offset < 0 && uint64_t(-offset) > address) {
address = 0;
pastEnd = false;
} else if (offset > 0 && uint64_t(offset) > (UINT64_MAX - address)) {
address = UINT64_MAX;
pastEnd = true;
} else {
address += uint64_t(offset);
pastEnd = false;
}
return *this;
}
BasicCursor &operator+=(int offset)
{
*this += int64_t(offset);
return *this;
}
bool moveChecked(int offset)
{
auto oldAddress = address;
*this += offset;
return address - oldAddress == uint64_t(offset);
}
BasicCursor &operator+=(uint64_t offset)
{
if (uint64_t(offset) > (UINT64_MAX - address)) {
address = UINT64_MAX;
pastEnd = true;
} else {
address += offset;
pastEnd = false;
}
return *this;
}
bool operator<(const BasicCursor &r) const
{
return address < r.address || (pastEnd < r.pastEnd);
}
};
struct HexCursor
{
HexCursor()
{
isVisible = false;
onAsciiArea = false;
}
bool isVisible;
bool onAsciiArea;
QTimer blinkTimer;
QRectF screenPos;
uint64_t address;
QString cachedChar;
QColor cachedColor;
void blink() { isVisible = !isVisible; }
void setBlinkPeriod(int msec) { blinkTimer.setInterval(msec / 2); }
void startBlinking() { blinkTimer.start(); }
void stopBlinking() { blinkTimer.stop(); }
};
class AbstractData
{
public:
virtual ~AbstractData() = default;
virtual void fetch(uint64_t addr, int len) = 0;
virtual bool copy(void *out, uint64_t adr, size_t len) = 0;
virtual bool write(const uint8_t *in, uint64_t adr, size_t len) = 0;
virtual uint64_t maxIndex() = 0;
virtual uint64_t minIndex() = 0;
};
class BufferData : public AbstractData
{
public:
BufferData() { m_buffer.fill(0, 1); }
explicit BufferData(const QByteArray &buffer)
{
if (buffer.isEmpty()) {
m_buffer.fill(0, 1);
} else {
m_buffer = buffer;
}
}
~BufferData() override = default;
void fetch(uint64_t, int) override {}
bool copy(void *out, uint64_t addr, size_t len) override
{
if (addr < static_cast<uint64_t>(m_buffer.size())
&& (static_cast<uint64_t>(m_buffer.size()) - addr) < len) {
memcpy(out, m_buffer.constData() + addr, len);
return true;
}
return false;
}
bool write(const uint8_t *in, uint64_t addr, size_t len) override
{
if (addr < static_cast<uint64_t>(m_buffer.size())
&& (static_cast<uint64_t>(m_buffer.size()) - addr) < len) {
memcpy(m_buffer.data() + addr, in, len);
return true;
}
return false;
}
uint64_t maxIndex() override { return m_buffer.size() - 1; }
private:
QByteArray m_buffer;
};
class MemoryData : public AbstractData
{
public:
MemoryData() = default;
~MemoryData() override = default;
static constexpr size_t BLOCK_SIZE = 4096;
void fetch(uint64_t address, int length) override
{
// FIXME: reuse data if possible
const uint64_t blockSize = 0x1000ULL;
uint64_t alignedAddr = address & ~(blockSize - 1);
int offset = address - alignedAddr;
int len = (offset + length + (blockSize - 1)) & ~(blockSize - 1);
m_firstBlockAddr = alignedAddr;
m_lastValidAddr = length ? alignedAddr + len - 1 : 0;
if (m_lastValidAddr < m_firstBlockAddr) {
m_lastValidAddr = -1;
len = m_lastValidAddr - m_firstBlockAddr + 1;
}
m_blocks.clear();
uint64_t addr = alignedAddr;
for (ut64 i = 0; i < len / blockSize; ++i, addr += blockSize) {
m_blocks.append(Core()->ioRead(addr, blockSize));
}
}
bool copy(void *out, uint64_t addr, size_t len) override
{
if (addr < m_firstBlockAddr
|| addr > m_lastValidAddr
/* do not merge with previous check to handle overflows */
|| (m_lastValidAddr - addr + 1) < len || m_blocks.isEmpty()) {
memset(out, 0xff, len);
return false;
}
int totalOffset = addr - m_firstBlockAddr;
int blockId = totalOffset / BLOCK_SIZE;
int blockOffset = totalOffset % BLOCK_SIZE;
size_t first_part = BLOCK_SIZE - blockOffset;
if (first_part >= len) {
memcpy(out, m_blocks.at(blockId).constData() + blockOffset, len);
} else {
memcpy(out, m_blocks.at(blockId).constData() + blockOffset, first_part);
memcpy(static_cast<char *>(out) + first_part, m_blocks.at(blockId + 1).constData(),
len - first_part);
}
return true;
}
void writeToCache(const uint8_t *in, uint64_t adr, size_t len)
{
if (adr < m_firstBlockAddr) {
uint64_t prefix = m_firstBlockAddr - adr;
if (prefix <= len) {
return;
}
in = in + prefix;
adr += prefix;
len -= prefix;
}
if (adr > m_lastValidAddr) {
return;
}
int offset = (int)(adr - m_firstBlockAddr);
int blockId = offset / BLOCK_SIZE;
int blockOffset = offset % BLOCK_SIZE;
while (len > 0 && blockId < m_blocks.size()) {
size_t l = BLOCK_SIZE - blockOffset;
l = std::min(l, len);
memcpy(m_blocks[blockId].data() + blockOffset, in, l);
len -= l;
blockOffset = 0;
adr += l;
in += l;
blockId += 1;
}
}
bool write(const uint8_t *in, uint64_t adr, size_t len) override
{
RzCoreLocked core(Core());
rz_core_write_at(core, adr, in, len);
writeToCache(in, adr, len);
emit Core()->instructionChanged(adr);
return true;
}
uint64_t maxIndex() override { return std::numeric_limits<uint64_t>::max(); }
uint64_t minIndex() override { return m_firstBlockAddr; }
private:
QVector<QByteArray> m_blocks;
uint64_t m_firstBlockAddr = 0;
uint64_t m_lastValidAddr = 0;
};
class HexSelection
{
public:
HexSelection()
{
m_empty = true;
m_start = m_end = 0;
}
inline void init(BasicCursor addr)
{
m_empty = true;
m_init = addr;
}
void set(uint64_t start, uint64_t end)
{
m_empty = false;
m_init = BasicCursor(start);
m_start = start;
m_end = end;
}
void update(BasicCursor addr)
{
m_empty = false;
if (m_init < addr) {
m_start = m_init.address;
m_end = addr.address;
if (!addr.pastEnd)
m_end -= 1;
} else if (addr < m_init) {
m_start = addr.address;
m_end = m_init.address;
if (!m_init.pastEnd)
m_end -= 1;
} else {
m_start = m_end = m_init.address;
m_empty = true;
}
}
bool intersects(uint64_t start, uint64_t end)
{
return !m_empty && m_end >= start && m_start <= end;
}
bool contains(uint64_t pos) const { return !m_empty && m_start <= pos && pos <= m_end; }
uint64_t size() const
{
uint64_t size = 0;
if (!isEmpty())
size = m_end - m_start + 1;
return size;
}
inline bool isEmpty() const { return m_empty; }
inline uint64_t start() const { return m_start; }
inline uint64_t end() const { return m_end; }
private:
BasicCursor m_init;
uint64_t m_start;
uint64_t m_end;
bool m_empty;
};
class HexWidget : public QScrollArea
{
Q_OBJECT
public:
explicit HexWidget(QWidget *parent = nullptr);
~HexWidget() override = default;
void setMonospaceFont(const QFont &font);
enum AddrWidth { AddrWidth32 = 8, AddrWidth64 = 16 };
enum ItemSize { ItemSizeByte = 1, ItemSizeWord = 2, ItemSizeDword = 4, ItemSizeQword = 8 };
enum ItemFormat {
ItemFormatHex,
ItemFormatOct,
ItemFormatDec,
ItemFormatSignedDec,
ItemFormatFloat
};
enum class ColumnMode { Fixed, PowerOf2 };
enum class EditWordState { Read, WriteNotStarted, WriteNotEdited, WriteEdited };
enum class HexNavigationMode { Words, WordChar, AnyChar };
void setItemSize(int nbytes);
void setItemFormat(ItemFormat format);
void setItemEndianness(bool bigEndian);
void setItemGroupSize(int size);
/**
* @brief Sets line size in bytes.
* Changes column mode to fixed. Command can be rejected if current item format is bigger than
* requested size.
* @param bytes line size in bytes.
*/
void setFixedLineSize(int bytes);
void setColumnMode(ColumnMode mode);
/**
* @brief Select non empty inclusive range [start; end]
* @param start
* @param end
*/
void selectRange(RVA start, RVA end);
void clearSelection();
struct Selection
{
bool empty;
RVA startAddress;
RVA endAddress;
};
Selection getSelection();
public slots:
void seek(uint64_t address);
void refresh();
void updateColors();
signals:
void selectionChanged(HexWidget::Selection selection);
void positionChanged(RVA start);
protected:
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
bool event(QEvent *event) override;
private slots:
void onCursorBlinked();
void onHexPairsModeEnabled(bool enable);
void copy();
void copyAddress();
void onRangeDialogAccepted();
void onActionAddCommentTriggered();
void onActionDeleteCommentTriggered();
// Write command slots
void w_writeString();
void w_increaseDecrease();
void w_writeBytes();
void w_writeZeros();
void w_write64();
void w_writeRandom();
void w_duplFromOffset();
void w_writePascalString();
void w_writeWideString();
void w_writeCString();
void onKeyboardEditTriggered(bool enabled);
void onKeyboardEditChanged(bool enabled);
private:
void updateItemLength();
void updateCounts();
void drawHeader(QPainter &painter);
void drawCursor(QPainter &painter, bool shadow = false);
void drawAddrArea(QPainter &painter);
void drawItemArea(QPainter &painter);
void drawAsciiArea(QPainter &painter);
void fillSelectionBackground(QPainter &painter, bool ascii = false);
void updateMetrics();
void updateAreasPosition();
void updateAreasHeight();
enum class OverflowMove { Clamp, Ignore };
bool moveCursor(int offset, bool select = false,
OverflowMove overflowMove = OverflowMove::Clamp);
void moveCursorKeepEditOffset(int byteOffset, bool select, OverflowMove overflowMove);
void setCursorAddr(BasicCursor addr, bool select = false);
void updateCursorMeta();
void setCursorOnAscii(bool ascii);
bool isItemDifferentAt(uint64_t address);
QColor itemColor(uint8_t byte);
QVariant readItem(int offset, QColor *color = nullptr);
QString renderItem(int offset, QColor *color = nullptr);
QChar renderAscii(int offset, QColor *color = nullptr);
QString getFlagsAndComment(uint64_t address);
/**
* @brief Get the location on which operations such as Writing should apply.
* @return Start of selection if multiple bytes are selected. Otherwise, the curren seek of the
* widget.
*/
RVA getLocationAddress();
void fetchData();
/**
* @brief Convert mouse position to address.
* @param point mouse position in widget
* @param middle start next position from middle of symbol. Use middle=true for vertical cursor
* position between symbols, middle=false for insert mode cursor and getting symbol under
* cursor.
* @return
*/
BasicCursor screenPosToAddr(const QPoint &point, bool middle = false,
int *wordOffset = nullptr) const;
BasicCursor asciiPosToAddr(const QPoint &point, bool middle = false) const;
BasicCursor currentAreaPosToAddr(const QPoint &point, bool middle = false) const;
BasicCursor mousePosToAddr(const QPoint &point, bool middle = false) const;
/**
* @brief Rectangle for single item in data area.
* @param offset relative to first byte on screen
* @return
*/
QRectF itemRectangle(int offset);
/**
* @brief Rectangle for single item in ascii area.
* @param offset relative to first byte on screen
* @return
*/
QRectF asciiRectangle(int offset);
QVector<QPolygonF> rangePolygons(RVA start, RVA last, bool ascii);
void updateWidth();
inline qreal itemWidth() const { return itemCharLen * charWidth; }
inline int itemGroupCharLen() const { return itemCharLen * itemGroupSize; }
inline int columnExCharLen() const { return itemGroupCharLen() + columnSpacing; }
inline int itemGroupByteLen() const { return itemByteLen * itemGroupSize; }
inline qreal columnWidth() const { return itemGroupCharLen() * charWidth; }
inline qreal columnExWidth() const { return columnExCharLen() * charWidth; }
inline qreal columnSpacingWidth() const { return columnSpacing * charWidth; }
inline int itemRowCharLen() const { return itemColumns * columnExCharLen() - columnSpacing; }
inline int itemRowByteLen() const { return rowSizeBytes; }
inline int bytesPerScreen() const { return itemRowByteLen() * visibleLines; }
inline qreal itemRowWidth() const { return itemRowCharLen() * charWidth; }
inline qreal asciiRowWidth() const { return itemRowByteLen() * charWidth; }
inline qreal areaSpacingWidth() const { return areaSpacing * charWidth; }
inline uint64_t lastVisibleAddr() const { return (startAddress - 1) + bytesPerScreen(); }
const QRectF ¤tArea() const { return cursorOnAscii ? asciiArea : itemArea; }
bool isFixedWidth() const;
bool canKeyboardEdit();
bool flushCurrentlyEditedWord();
bool finishEditingWord(bool force = true);
void maybeFlushCharEdit();
void cancelEditedWord();
void startEditWord();
bool validCharForEdit(QChar digit);
void movePrevEditCharAny();
void typeOverwriteModeChar(QChar c);
HexNavigationMode defaultNavigationMode();
void refreshWordEditState();
bool parseWord(QString word, uint8_t *buf, size_t bufferSize) const;
bool handleAsciiWrite(QKeyEvent *event);
bool handleNumberWrite(QKeyEvent *event);
void writeZeros(uint64_t address, uint64_t length);
void hideWarningRect();
void showWarningRect(QRectF rect);
bool cursorEnabled;
bool cursorOnAscii;
HexCursor cursor;
HexCursor shadowCursor;
HexSelection selection;
bool updatingSelection;
QRectF addrArea;
QRectF itemArea;
QRectF asciiArea;
int itemByteLen = 1;
int itemGroupSize = 1; ///< Items per group (default: 1), 2 in case of hexpair mode
int rowSizeBytes = 16; ///< Line size in bytes
int itemColumns = 16; ///< Number of columns, single column consists of itemGroupSize items
int itemCharLen = 2;
int itemPrefixLen = 0;
ColumnMode columnMode;
ItemFormat itemFormat;
bool itemBigEndian;
QString itemPrefix;
int visibleLines;
uint64_t startAddress;
qreal charWidth;
qreal lineHeight;
int addrCharLen;
QFont monospaceFont;
bool showHeader;
bool showAscii;
bool showExHex;
bool showExAddr;
QColor borderColor;
QColor backgroundColor;
QColor defColor;
QColor addrColor;
QColor diffColor;
QColor b0x00Color;
QColor b0x7fColor;
QColor b0xffColor;
QColor printableColor;
QColor warningColor;
HexdumpRangeDialog rangeDialog;
/* Spacings in characters */
const int columnSpacing = 1;
const int areaSpacing = 2;
const QString hexPrefix = QStringLiteral("0x");
QMenu *rowSizeMenu;
QAction *actionRowSizePowerOf2;
QList<QAction *> actionsItemSize;
QList<QAction *> actionsItemFormat;
QAction *actionItemBigEndian;
QAction *actionHexPairs;
QAction *actionCopy;
QAction *actionCopyAddress;
QAction *actionComment;
QAction *actionDeleteComment;
QAction *actionSelectRange;
QAction *actionKeyboardEdit;
QList<QAction *> actionsWriteString;
QList<QAction *> actionsWriteOther;
std::unique_ptr<AbstractData> oldData;
std::unique_ptr<AbstractData> data;
IOModesController ioModesController;
int editWordPos = 0;
QString editWord;
EditWordState editWordState = EditWordState::Read;
HexNavigationMode navigationMode = HexNavigationMode::Words;
enum class EarlyEditFlush {
OnFinish,
EditNibble,
EditFixedWidthChar,
/* AllFormats(not implemented) */
};
EarlyEditFlush earlyEditFlush = EarlyEditFlush::EditFixedWidthChar;
bool warningRectVisible = false;
QRectF warningRect;
QTimer warningTimer;
};
#endif // HEXWIDGET_H
| 18,021
|
C++
|
.h
| 523
| 27.885277
| 99
| 0.648636
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,760
|
SimpleTextGraphView.h
|
rizinorg_cutter/src/widgets/SimpleTextGraphView.h
|
#ifndef SIMPLE_TEXT_GRAPHVIEW_H
#define SIMPLE_TEXT_GRAPHVIEW_H
// Based on the DisassemblerGraphView from x64dbg
#include <QWidget>
#include <QPainter>
#include <QShortcut>
#include <QLabel>
#include "widgets/CutterGraphView.h"
#include "menus/AddressableItemContextMenu.h"
#include "common/RichTextPainter.h"
#include "common/CutterSeekable.h"
/**
* @brief Graphview with nodes containing simple plaintext labels.
*/
class SimpleTextGraphView : public CutterGraphView
{
Q_OBJECT
public:
SimpleTextGraphView(QWidget *parent, MainWindow *mainWindow);
~SimpleTextGraphView() override;
virtual void drawBlock(QPainter &p, GraphView::GraphBlock &block, bool interactive) override;
virtual GraphView::EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from,
GraphView::GraphBlock *to,
bool interactive) override;
/**
* @brief Enable or disable block selection.
* Selecting a block highlights it and allows copying the label. Enabled by default.
* @param value
*/
void setBlockSelectionEnabled(bool value);
public slots:
void refreshView() override;
/**
* @brief Select a given block. Requires block selection to be enabled.
*/
void selectBlockWithId(ut64 blockId);
protected:
void paintEvent(QPaintEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
void blockContextMenuRequested(GraphView::GraphBlock &block, QContextMenuEvent *event,
QPoint pos) override;
void blockHelpEvent(GraphView::GraphBlock &block, QHelpEvent *event, QPoint pos) override;
void blockClicked(GraphView::GraphBlock &block, QMouseEvent *event, QPoint pos) override;
void restoreCurrentBlock() override;
/**
* @brief Load the graph to be displayed.
* Needs to cleanup the old graph and use addBlock() to create new nodes.
*/
virtual void loadCurrentGraph() = 0;
virtual void addBlock(GraphLayout::GraphBlock block, const QString &content,
RVA address = RVA_INVALID);
/**
* @brief Enable or disable address interactions for nodes.
* If enabled node addresses need to be specified when calling addBlock(). Adds address related
* items to the node context menu. By default disabled.
* @param enabled
*/
void enableAddresses(bool enabled);
struct BlockContent
{
QString text;
RVA address;
};
std::unordered_map<ut64, BlockContent> blockContent;
QList<QShortcut *> shortcuts;
QMenu *contextMenu;
AddressableItemContextMenu addressableItemContextMenu;
QAction copyAction;
static const ut64 NO_BLOCK_SELECTED = RVA_INVALID;
ut64 selectedBlock = NO_BLOCK_SELECTED;
bool enableBlockSelection = true;
bool haveAddresses = false;
private:
void copyBlockText();
};
#endif // SIMPLE_TEXT_GRAPHVIEW_H
| 3,010
|
C++
|
.h
| 76
| 33.131579
| 99
| 0.705923
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,761
|
CallGraph.h
|
rizinorg_cutter/src/widgets/CallGraph.h
|
#ifndef CALL_GRAPH_WIDGET_H
#define CALL_GRAPH_WIDGET_H
#include "core/Cutter.h"
#include "MemoryDockWidget.h"
#include "widgets/SimpleTextGraphView.h"
#include "common/RefreshDeferrer.h"
class MainWindow;
/**
* @brief Graphview displaying either global or function callgraph.
*/
class CallGraphView : public SimpleTextGraphView
{
Q_OBJECT
public:
CallGraphView(CutterDockWidget *parent, MainWindow *main, bool global);
void showExportDialog() override;
void showAddress(RVA address);
void refreshView() override;
protected:
bool global; ///< is this a global or function callgraph
RVA address = RVA_INVALID; ///< function address if this is not a global callgraph
void loadCurrentGraph() override;
void restoreCurrentBlock() override;
private:
RefreshDeferrer refreshDeferrer;
RVA lastLoadedAddress = RVA_INVALID;
};
class CallGraphWidget : public MemoryDockWidget
{
Q_OBJECT
public:
explicit CallGraphWidget(MainWindow *main, bool global);
~CallGraphWidget();
QString getWidgetType() const;
protected:
QString getWindowTitle() const override;
private:
CallGraphView *graphView;
bool global;
void onSeekChanged(RVA address);
};
#endif // CALL_GRAPH_WIDGET_H
| 1,248
|
C++
|
.h
| 42
| 26.595238
| 86
| 0.770711
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,762
|
Omnibar.h
|
rizinorg_cutter/src/widgets/Omnibar.h
|
#ifndef OMNIBAR_H
#define OMNIBAR_H
#include <QLineEdit>
class MainWindow;
class Omnibar : public QLineEdit
{
Q_OBJECT
public:
explicit Omnibar(MainWindow *main, QWidget *parent = nullptr);
void refresh(const QStringList &flagList);
private slots:
void on_gotoEntry_returnPressed();
void restoreCompleter();
public slots:
void clear();
private:
void setupCompleter();
MainWindow *main;
QStringList flags;
};
#endif // OMNIBAR_H
| 474
|
C++
|
.h
| 21
| 19.380952
| 66
| 0.747178
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,763
|
Dashboard.h
|
rizinorg_cutter/src/widgets/Dashboard.h
|
#ifndef DASHBOARD_H
#define DASHBOARD_H
#include <QFormLayout>
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
QT_BEGIN_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QLineEdit)
QT_FORWARD_DECLARE_CLASS(QJsonObject)
QT_END_NAMESPACE
class MainWindow;
namespace Ui {
class Dashboard;
}
class Dashboard : public CutterDockWidget
{
Q_OBJECT
public:
explicit Dashboard(MainWindow *main);
~Dashboard();
private slots:
void updateContents();
void on_certificateButton_clicked();
void on_versioninfoButton_clicked();
private:
std::unique_ptr<Ui::Dashboard> ui;
void setPlainText(QLineEdit *textBox, const QString &text);
void setRzBinInfo(const RzBinInfo *binInfo);
const char *setBoolText(bool value);
QWidget *hashesWidget = nullptr;
};
#endif // DASHBOARD_H
| 821
|
C++
|
.h
| 32
| 22.96875
| 63
| 0.774069
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,764
|
FlagsWidget.h
|
rizinorg_cutter/src/widgets/FlagsWidget.h
|
#ifndef FLAGSWIDGET_H
#define FLAGSWIDGET_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include "AddressableItemList.h"
#include "AddressableItemModel.h"
class MainWindow;
class QTreeWidgetItem;
class FlagsWidget;
class FlagsModel : public AddressableItemModel<QAbstractListModel>
{
friend FlagsWidget;
private:
QList<FlagDescription> *flags;
public:
enum Columns { OFFSET = 0, SIZE, NAME, REALNAME, COMMENT, COUNT };
static const int FlagDescriptionRole = Qt::UserRole;
FlagsModel(QList<FlagDescription> *flags, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;
const FlagDescription *description(QModelIndex index) const;
};
class FlagsSortFilterProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
public:
FlagsSortFilterProxyModel(FlagsModel *source_model, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
namespace Ui {
class FlagsWidget;
}
class FlagsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit FlagsWidget(MainWindow *main);
~FlagsWidget();
private slots:
void on_flagspaceCombo_currentTextChanged(const QString &arg1);
void on_actionRename_triggered();
void on_actionDelete_triggered();
void flagsChanged();
void refreshFlagspaces();
private:
std::unique_ptr<Ui::FlagsWidget> ui;
MainWindow *main;
bool disableFlagRefresh = false;
FlagsModel *flags_model;
FlagsSortFilterProxyModel *flags_proxy_model;
QList<FlagDescription> flags;
CutterTreeWidget *tree;
void refreshFlags();
void setScrollMode();
};
#endif // FLAGSWIDGET_H
| 2,345
|
C++
|
.h
| 68
| 30.823529
| 84
| 0.772647
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,765
|
AddressableItemContextMenu.h
|
rizinorg_cutter/src/menus/AddressableItemContextMenu.h
|
#ifndef ADDRESSABLEITEMCONTEXTMENU_H
#define ADDRESSABLEITEMCONTEXTMENU_H
#include "core/Cutter.h"
#include <QMenu>
#include <QKeySequence>
class MainWindow;
class CUTTER_EXPORT AddressableItemContextMenu : public QMenu
{
Q_OBJECT
public:
AddressableItemContextMenu(QWidget *parent, MainWindow *mainWindow);
~AddressableItemContextMenu();
/**
* @brief Configure if addressable item refers to whole function or specific address
* @param wholeFunciton
*/
void setWholeFunction(bool wholeFunciton);
public slots:
void setOffset(RVA offset);
void setTarget(RVA offset, QString name = QString());
void clearTarget();
signals:
void xrefsTriggered();
private:
void onActionCopyAddress();
void onActionShowXrefs();
void onActionAddComment();
virtual void aboutToShowSlot();
QMenu *pluginMenu;
QAction *pluginMenuAction;
MainWindow *mainWindow;
RVA offset;
bool hasTarget = false;
protected:
void setHasTarget(bool hasTarget);
QAction *actionShowInMenu;
QAction *actionCopyAddress;
QAction *actionShowXrefs;
QAction *actionAddcomment;
QString name;
bool wholeFunction = false;
};
#endif // ADDRESSABLEITEMCONTEXTMENU_H
| 1,236
|
C++
|
.h
| 43
| 24.813953
| 88
| 0.759729
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,766
|
DisassemblyContextMenu.h
|
rizinorg_cutter/src/menus/DisassemblyContextMenu.h
|
#ifndef DISASSEMBLYCONTEXTMENU_H
#define DISASSEMBLYCONTEXTMENU_H
#include "core/Cutter.h"
#include "common/IOModesController.h"
#include <QMenu>
#include <QKeySequence>
class MainWindow;
class CUTTER_EXPORT DisassemblyContextMenu : public QMenu
{
Q_OBJECT
public:
DisassemblyContextMenu(QWidget *parent, MainWindow *mainWindow);
~DisassemblyContextMenu();
signals:
void copy();
public slots:
void setOffset(RVA offset);
void setCanCopy(bool enabled);
/**
* @brief Sets the value of curHighlightedWord
* @param text The current highlighted word
*/
void setCurHighlightedWord(const QString &text);
private slots:
void aboutToShowSlot();
void aboutToHideSlot();
void on_actionEditFunction_triggered();
void on_actionEditInstruction_triggered();
void on_actionNopInstruction_triggered();
void on_actionJmpReverse_triggered();
void on_actionEditBytes_triggered();
void showReverseJmpQuery();
void on_actionCopy_triggered();
void on_actionCopyAddr_triggered();
void on_actionCopyInstrBytes_triggered();
void on_actionAddComment_triggered();
void on_actionAnalyzeFunction_triggered();
void on_actionRename_triggered();
void on_actionGlobalVar_triggered();
void on_actionSetFunctionVarTypes_triggered();
void on_actionXRefs_triggered();
void on_actionXRefsForVariables_triggered();
void on_actionDisplayOptions_triggered();
void on_actionDeleteComment_triggered();
void on_actionDeleteFlag_triggered();
void on_actionDeleteFunction_triggered();
void on_actionAddBreakpoint_triggered();
void on_actionAdvancedBreakpoint_triggered();
void on_actionContinueUntil_triggered();
void on_actionSetPC_triggered();
void on_actionSetToCode_triggered();
void on_actionSetAsString_triggered();
void on_actionSetAsStringRemove_triggered();
void on_actionSetAsStringAdvanced_triggered();
void on_actionSetToData_triggered();
void on_actionSetToDataEx_triggered();
/**
* @brief Executed on selecting an offset from the structureOffsetMenu
* Uses the applyStructureOffset() function of CutterCore to apply the
* structure offset
* \param action The action which trigered the event
*/
void on_actionStructureOffsetMenu_triggered(QAction *action);
private:
QKeySequence getCopySequence() const;
QKeySequence getCommentSequence() const;
QKeySequence getCopyAddressSequence() const;
QKeySequence getCopyInstrBytesSequence() const;
QKeySequence getGlobalVarSequence() const;
QKeySequence getSetToCodeSequence() const;
QKeySequence getSetAsStringSequence() const;
QKeySequence getSetAsStringAdvanced() const;
QKeySequence getSetToDataSequence() const;
QKeySequence getSetToDataExSequence() const;
QKeySequence getRenameSequence() const;
QKeySequence getRetypeSequence() const;
QKeySequence getXRefSequence() const;
QKeySequence getDisplayOptionsSequence() const;
QKeySequence getDefineNewFunctionSequence() const;
QKeySequence getUndefineFunctionSequence() const;
QKeySequence getEditFunctionSequence() const;
QList<QKeySequence> getAddBPSequence() const;
RVA offset;
bool canCopy;
QString curHighlightedWord; // The current highlighted word
MainWindow *mainWindow;
IOModesController ioModesController;
QList<QAction *> anonymousActions;
QMenu *editMenu;
QAction actionEditInstruction;
QAction actionNopInstruction;
QAction actionJmpReverse;
QAction actionEditBytes;
QAction actionCopy;
QAction *copySeparator;
QAction actionCopyAddr;
QAction actionCopyInstrBytes;
QAction actionAddComment;
QAction actionAnalyzeFunction;
QAction actionEditFunction;
QAction actionRename;
QAction actionGlobalVar;
QAction actionSetFunctionVarTypes;
QAction actionXRefs;
QAction actionXRefsForVariables;
QAction actionDisplayOptions;
QAction actionDeleteComment;
QAction actionDeleteFlag;
QAction actionDeleteFunction;
QMenu *structureOffsetMenu;
QMenu *setBaseMenu;
QAction actionSetBaseBinary;
QAction actionSetBaseOctal;
QAction actionSetBaseDecimal;
QAction actionSetBaseHexadecimal;
QAction actionSetBasePort;
QAction actionSetBaseIPAddr;
QAction actionSetBaseSyscall;
QAction actionSetBaseString;
QMenu *setBitsMenu;
QAction actionSetBits16;
QAction actionSetBits32;
QAction actionSetBits64;
QMenu *debugMenu;
QAction actionContinueUntil;
QAction actionSetPC;
QMenu *breakpointMenu;
QAction actionAddBreakpoint;
QAction actionAdvancedBreakpoint;
QAction actionSetToCode;
QAction actionSetAsStringAuto;
QAction actionSetAsStringRemove;
QAction actionSetAsStringAdvanced;
QMenu *setToDataMenu;
QMenu *setAsMenu;
QMenu *setAsString;
QAction actionSetToDataEx;
QAction actionSetToDataByte;
QAction actionSetToDataWord;
QAction actionSetToDataDword;
QAction actionSetToDataQword;
QAction showInSubmenu;
QList<QAction *> showTargetMenuActions;
QMenu *pluginMenu = nullptr;
QAction *pluginActionMenuAction = nullptr;
/**
* \return widget that should be used as parent for presenting dialogs
*/
QWidget *parentForDialog();
// For creating anonymous entries (that are always visible)
QAction *addAnonymousAction(QString name, const char *slot, QKeySequence shortcut);
void initAction(QAction *action, QString name, const char *slot = nullptr);
void initAction(QAction *action, QString name, const char *slot, QKeySequence keySequence);
void initAction(QAction *action, QString name, const char *slot,
QList<QKeySequence> keySequence);
void setBase(QString base);
void setToData(int size, int repeat = 1);
void setBits(int bits);
void addSetBaseMenu();
void addSetBitsMenu();
void addSetAsMenu();
void addSetToDataMenu();
void addEditMenu();
void addAddAtMenu();
void addBreakpointMenu();
void addDebugMenu();
enum DoRenameAction {
RENAME_FUNCTION,
RENAME_FLAG,
RENAME_ADD_FLAG,
RENAME_LOCAL,
RENAME_DO_NOTHING,
};
struct DoRenameInfo
{
ut64 addr;
QString name;
};
DoRenameAction doRenameAction = RENAME_DO_NOTHING;
DoRenameInfo doRenameInfo = {};
/*
* @brief Setups up the "Rename" option in the context menu
*
* This function takes into account cursor location so it can choose between current address and
* pointed value i.e. `0x000040f3 lea rdi, [0x000199b1]` -> does the user want to add a flag at
* 0x40f3 or at 0x199b1? and for that we will rely on |curHighlightedWord| which is the
* currently selected word.
*/
void setupRenaming();
/**
* @brief Checks if the currently highlighted word in the disassembly widget
* is a local variable or function paramter.
* @return Return true if the highlighted word is the name of a local variable or function
* parameter, return false otherwise.
*/
bool isHighlightedWordLocalVar();
struct ThingUsedHere
{
QString name;
RVA offset;
enum class Type { Var, Function, Flag, Address };
Type type;
};
QVector<ThingUsedHere> getThingUsedHere(RVA offset);
/*
* @brief This function checks if the given address contains a function,
* a flag or if it is just an address.
*/
ThingUsedHere getThingAt(ut64 address);
/*
* @brief This function will set the text for the renaming menu given a ThingUsedHere
* and provide information on how to handle the renaming of this specific thing.
* Indeed, selected dialogs are different when it comes to adding a flag, renaming an existing
* function, renaming a local variable...
*
* This function handles every possible object.
*/
void buildRenameMenu(ThingUsedHere *tuh);
};
#endif // DISASSEMBLYCONTEXTMENU_H
| 8,085
|
C++
|
.h
| 220
| 31.440909
| 100
| 0.746326
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,767
|
DecompilerContextMenu.h
|
rizinorg_cutter/src/menus/DecompilerContextMenu.h
|
#ifndef DECOMPILERCONTEXTMENU_H
#define DECOMPILERCONTEXTMENU_H
#include "core/Cutter.h"
#include <QMenu>
#include <QKeySequence>
#include <rz_util/rz_annotated_code.h>
class MainWindow;
class DecompilerContextMenu : public QMenu
{
Q_OBJECT
public:
DecompilerContextMenu(QWidget *parent, MainWindow *mainWindow);
~DecompilerContextMenu();
bool getIsTogglingBreakpoints();
void setAnnotationHere(RzCodeAnnotation *annotation);
RVA getFirstOffsetInLine();
signals:
void copy();
public slots:
void setCurHighlightedWord(QString word);
void setOffset(RVA newOffset);
void setDecompiledFunctionAddress(RVA functionAddr);
void setFirstOffsetInLine(RVA firstOffset);
void setAvailableBreakpoints(QVector<RVA> offsetList);
private slots:
void aboutToShowSlot();
void aboutToHideSlot();
void actionCopyTriggered();
void actionCopyInstructionAddressTriggered();
void actionCopyReferenceAddressTriggered();
void actionAddCommentTriggered();
void actionDeleteCommentTriggered();
void actionRenameThingHereTriggered();
void actionDeleteNameTriggered();
void actionEditFunctionVariablesTriggered();
void actionXRefsTriggered();
void actionToggleBreakpointTriggered();
void actionAdvancedBreakpointTriggered();
void actionContinueUntilTriggered();
void actionSetPCTriggered();
private:
// Private variables
MainWindow *mainWindow;
QString curHighlightedWord;
RVA offset;
RVA decompiledFunctionAddress;
/**
* Lowest offset among all offsets present in the line under cursor in the decompiler widget.
*/
RVA firstOffsetInLine;
/**
* When the actionToggleBreakpoint has been triggered, and it hasn't finished executing,
* the value of this variable will be true, otherwise false
*/
bool isTogglingBreakpoints;
/**
* List of the offsets of all the breakpoints (enabled and disabled) that are present in the
* line under cursor.
*/
QVector<RVA> availableBreakpoints;
/**
* Context-related annotation for the data under cursor in the decompiler widget.
* If such an annotation doesn't exist, its value is nullptr.
*/
RzCodeAnnotation *annotationHere;
// Actions and menus in the context menu
QAction actionCopy;
QAction actionCopyInstructionAddress;
QAction actionCopyReferenceAddress;
QAction *copySeparator;
QAction actionShowInSubmenu;
QList<QAction *> showTargetMenuActions;
QAction actionAddComment;
QAction actionDeleteComment;
QAction actionRenameThingHere;
QAction actionDeleteName;
QAction actionEditFunctionVariables;
QAction actionXRefs;
QMenu *breakpointMenu;
QAction actionToggleBreakpoint;
QAction actionAdvancedBreakpoint;
QMenu *breakpointsInLineMenu;
QMenu *debugMenu;
QAction actionContinueUntil;
QAction actionSetPC;
// Private Functions
/**
* \return widget that should be used as parent for presenting dialogs
*/
QWidget *parentForDialog();
/**
* @brief Sets the shortcut context in all the actions contained
* in the specified QMenu to Qt::WidgetWithChildrenShortcut.
*
* @param menu - QMenu specified
*/
void setShortcutContextInActions(QMenu *menu);
void setupBreakpointsInLineMenu();
void setIsTogglingBreakpoints(bool isToggling);
// Set actions
void setActionCopy();
void setActionShowInSubmenu();
void setActionAddComment();
void setActionDeleteComment();
void setActionXRefs();
void setActionRenameThingHere();
void setActionDeleteName();
void setActionEditFunctionVariables();
void setActionToggleBreakpoint();
void setActionAdvancedBreakpoint();
void setActionContinueUntil();
void setActionSetPC();
// Add Menus
void addBreakpointMenu();
void addDebugMenu();
/**
* @brief Updates targeted "Show in" menu.
*
* Removes all actions from the existing targeted "show in" menu. If annotationHere
* represents an item that has an address assigned to it, insert actions compatible with the
* type of this item in the targeted "Show in" menu.
*/
void updateTargetMenuActions();
/**
* @brief Check if annotationHere is a reference (function name,
* global variable, constant variable with an address).
*
* @return True if annotationHere is a reference, otherwise false.
*/
bool isReference();
/**
* @brief Check if annotationHere is a function variable
* (local variable or function parameter).
*
* @return True if annotationHere is a function variable, otherwise false.
*/
bool isFunctionVariable();
/**
* @brief Check if the function variable annotated by annotationHere is
* present in Rizin.
*
* @return True if the variable is present, otherwise false
*/
bool variablePresentInRizin();
};
#endif // DECOMPILERCONTEXTMENU_H
| 5,029
|
C++
|
.h
| 146
| 29.335616
| 97
| 0.738951
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,768
|
FlirtContextMenu.h
|
rizinorg_cutter/src/menus/FlirtContextMenu.h
|
#ifndef FLIRT_CONTEXTMENU_H
#define FLIRT_CONTEXTMENU_H
#include "core/Cutter.h"
#include <QMenu>
#include <QKeySequence>
class MainWindow;
class CUTTER_EXPORT FlirtContextMenu : public QMenu
{
Q_OBJECT
public:
FlirtContextMenu(QWidget *parent, MainWindow *mainWindow);
~FlirtContextMenu();
public slots:
void setTarget(const FlirtDescription &flirt);
void clearTarget();
private:
void onActionCopyLine();
void onActionApplySignature();
QMenu *pluginMenu;
QAction *pluginMenuAction;
MainWindow *mainWindow;
bool hasTarget = false;
protected:
void setHasTarget(bool hasTarget);
QAction *actionApplySignature;
QAction *actionCopyLine;
FlirtDescription entry;
};
#endif // FLIRT_CONTEXTMENU_H
| 760
|
C++
|
.h
| 29
| 22.793103
| 62
| 0.769764
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,769
|
Metrics.h
|
rizinorg_cutter/src/common/Metrics.h
|
#ifndef METRICS_H
#define METRICS_H
#include <QtGlobal>
class QRect;
class QRectF;
class QFontMetrics;
class QFontMetricsF;
template<typename T>
struct Metrics
{
};
template<>
struct Metrics<int>
{
using Rect = QRect;
using FontMetrics = QFontMetrics;
};
template<>
struct Metrics<qreal>
{
using Rect = QRectF;
using FontMetrics = QFontMetricsF;
};
#endif // METRICS_H
| 392
|
C++
|
.h
| 24
| 14.375
| 38
| 0.770083
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,771
|
DecompilerHighlighter.h
|
rizinorg_cutter/src/common/DecompilerHighlighter.h
|
#ifndef DECOMPILER_HIGHLIGHTER_H
#define DECOMPILER_HIGHLIGHTER_H
#include "CutterCommon.h"
#include <rz_util/rz_annotated_code.h>
#include <QSyntaxHighlighter>
#include <QTextDocument>
#include <QTextCharFormat>
#include <array>
/**
* \brief SyntaxHighlighter based on annotations from decompiled code.
* Can be only used in combination with DecompilerWidget.
*/
class CUTTER_EXPORT DecompilerHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
DecompilerHighlighter(QTextDocument *parent = nullptr);
virtual ~DecompilerHighlighter() = default;
/**
* @brief Set the code with annotations to be used for highlighting.
*
* It is callers responsibility to ensure that it is synchronized with currentTextDocument and
* has sufficiently long lifetime.
*
* @param code
*/
void setAnnotations(RzAnnotatedCode *code);
protected:
void highlightBlock(const QString &text) override;
private:
void setupTheme();
static const int HIGHLIGHT_COUNT = RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE + 1;
std::array<QTextCharFormat, HIGHLIGHT_COUNT> format;
RzAnnotatedCode *code = nullptr;
};
#endif
| 1,171
|
C++
|
.h
| 36
| 29.138889
| 98
| 0.763088
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,772
|
BasicBlockHighlighter.h
|
rizinorg_cutter/src/common/BasicBlockHighlighter.h
|
#ifndef BASICKBLOCKHIGHLIGHTER_H
#define BASICKBLOCKHIGHLIGHTER_H
class BasicBlockHighlighter;
#include "Cutter.h"
#include <map>
class BasicBlockHighlighter
{
public:
struct BasicBlock
{
RVA address;
QColor color;
};
BasicBlockHighlighter();
void highlight(RVA address, const QColor &color);
void clear(RVA address);
BasicBlock *getBasicBlock(RVA address);
private:
std::map<RVA, BasicBlock> bbMap;
};
#endif // BASICBLOCKHIGHLIGHTER_H
| 492
|
C++
|
.h
| 21
| 19.809524
| 53
| 0.747845
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,773
|
DisassemblyPreview.h
|
rizinorg_cutter/src/common/DisassemblyPreview.h
|
#ifndef DISASSEMBLYPREVIEW_H
#define DISASSEMBLYPREVIEW_H
#include <QTextBlockUserData>
#include "core/CutterDescriptions.h"
class QWidget;
class DisassemblyTextBlockUserData : public QTextBlockUserData
{
public:
DisassemblyLine line;
explicit DisassemblyTextBlockUserData(const DisassemblyLine &line);
};
DisassemblyTextBlockUserData *getUserData(const QTextBlock &block);
/**
* @brief Namespace to define relevant functions
*
* @ingroup DisassemblyPreview
*/
namespace DisassemblyPreview {
/*!
* @brief Get the QString that defines the stylesheet for tooltip
* @return A QString for the stylesheet
*/
QString getToolTipStyleSheet();
/*!
* @brief Show a QToolTip that previews the disassembly that is pointed to
* It works for GraphWidget and DisassemblyWidget
* @return True if the tooltip is shown
*/
bool showDisasPreview(QWidget *parent, const QPoint &pointOfEvent, const RVA offsetFrom);
/*!
* @brief Reads the offset for the cursor position
* @return The disassembly offset of the hovered asm text
*/
RVA readDisassemblyOffset(QTextCursor tc);
/**
* @brief Show a QToolTip that shows the value of the highlighted register, variable, or memory
* @return True if the tooltip is shown
*/
bool showDebugValueTooltip(QWidget *parent, const QPoint &pointOfEvent, const QString &selectedText,
const RVA offset);
}
#endif
| 1,384
|
C++
|
.h
| 42
| 30.452381
| 100
| 0.788881
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,774
|
PythonManager.h
|
rizinorg_cutter/src/common/PythonManager.h
|
#ifndef PYTHONMANAGER_H
#define PYTHONMANAGER_H
#ifdef CUTTER_ENABLE_PYTHON
# include <QObject>
typedef struct _ts PyThreadState;
typedef struct _object PyObject;
class PythonManager : public QObject
{
Q_OBJECT
public:
static PythonManager *getInstance();
PythonManager();
~PythonManager();
void setPythonHome(const QString &pythonHome) { customPythonHome = pythonHome; }
void initPythonHome();
void initialize();
void shutdown();
void addPythonPath(char *path);
void restoreThread();
void saveThread();
/**
* @brief RAII Helper class to call restoreThread() and saveThread() automatically
*
* As long as an object of this class is in scope, the Python thread will remain restored.
*/
class ThreadHolder
{
public:
ThreadHolder() { getInstance()->restoreThread(); }
~ThreadHolder() { getInstance()->saveThread(); }
};
signals:
void willShutDown();
private:
QString customPythonHome;
wchar_t *pythonHome = nullptr;
PyThreadState *pyThreadState = nullptr;
int pyThreadStateCounter = 0;
};
# define Python() (PythonManager::getInstance())
#endif // CUTTER_ENABLE_PYTHON
#endif // PYTHONMANAGER_H
| 1,234
|
C++
|
.h
| 42
| 25.142857
| 94
| 0.709184
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,775
|
Configuration.h
|
rizinorg_cutter/src/common/Configuration.h
|
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <QSettings>
#include <QFont>
#include <core/Cutter.h>
#define Config() (Configuration::instance())
#define ConfigColor(x) Config()->getColor(x)
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
namespace KSyntaxHighlighting {
class Repository;
class Theme;
}
#endif
class QSyntaxHighlighter;
class QTextDocument;
enum ColorFlags {
LightFlag = 1,
DarkFlag = 2,
};
struct CutterInterfaceTheme
{
QString name;
ColorFlags flag;
};
class CUTTER_EXPORT Configuration : public QObject
{
Q_OBJECT
private:
QPalette nativePalette;
QSettings s;
static Configuration *mPtr;
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
KSyntaxHighlighting::Repository *kSyntaxHighlightingRepository;
#endif
bool outputRedirectEnabled = true;
Configuration();
// Colors
void loadBaseThemeNative();
void loadBaseThemeDark();
void loadNativeStylesheet();
void loadLightStylesheet();
void loadDarkStylesheet();
void loadMidnightStylesheet();
// Asm Options
void applySavedAsmOptions();
public:
static const QList<CutterInterfaceTheme> &cutterInterfaceThemesList();
static const QHash<QString, ColorFlags> relevantThemes;
static const QHash<QString, QHash<ColorFlags, QColor>> cutterOptionColors;
// Functions
static Configuration *instance();
void loadInitial();
void resetAll();
// Auto update
bool getAutoUpdateEnabled() const;
void setAutoUpdateEnabled(bool au);
// Languages
QLocale getCurrLocale() const;
void setLocale(const QLocale &l);
bool setLocaleByName(const QString &language);
QStringList getAvailableTranslations();
// Fonts
/**
* @brief Gets the configured font set by the font selection box
* @return the configured font
*/
const QFont getBaseFont() const;
/**
* @brief Gets the configured font with the point size adjusted by the configured zoom
* level (minimum of 10%)
* @return the configured font size adjusted by zoom level
*/
const QFont getFont() const;
void setFont(const QFont &font);
qreal getZoomFactor() const;
void setZoomFactor(qreal zoom);
// Colors
bool windowColorIsDark();
static bool nativeWindowIsDark();
void setLastThemeOf(const CutterInterfaceTheme &currInterfaceTheme, const QString &theme);
QString getLastThemeOf(const CutterInterfaceTheme &currInterfaceTheme) const;
void setInterfaceTheme(int theme);
int getInterfaceTheme() { return s.value("ColorPalette", 0).toInt(); }
const CutterInterfaceTheme *getCurrentTheme();
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
KSyntaxHighlighting::Repository *getKSyntaxHighlightingRepository();
KSyntaxHighlighting::Theme getKSyntaxHighlightingTheme();
#endif
QSyntaxHighlighter *createSyntaxHighlighter(QTextDocument *document);
QString getRecentFolder();
void setRecentFolder(const QString &dir);
void setNewFileLastClicked(int lastClicked);
int getNewFileLastClicked();
// Images
QString getLogoFile();
// Asm Options
void resetToDefaultAsmOptions();
QString getColorTheme() const { return s.value("theme", "cutter").toString(); }
void setColorTheme(const QString &theme);
/**
* @brief Change current color theme if it doesn't much native theme's darkness.
*/
void adjustColorThemeDarkness();
int colorThemeDarkness(const QString &colorTheme) const;
void setColor(const QString &name, const QColor &color);
const QColor getColor(const QString &name) const;
/**
* @brief Get the value of a config var either from Rizin or settings, depending on the key.
*/
QVariant getConfigVar(const QString &key);
bool getConfigBool(const QString &key);
int getConfigInt(const QString &key);
QString getConfigString(const QString &key);
/**
* @brief Set the value of a config var either to Rizin or settings, depending on the key.
*/
void setConfig(const QString &key, const QVariant &value);
bool isFirstExecution();
/**
* @return id of the last selected decompiler (see CutterCore::getDecompilerById)
*/
QString getSelectedDecompiler();
void setSelectedDecompiler(const QString &id);
bool getDecompilerAutoRefreshEnabled();
void setDecompilerAutoRefreshEnabled(bool enabled);
void enableDecompilerAnnotationHighlighter(bool useDecompilerHighlighter);
bool isDecompilerAnnotationHighlighterEnabled();
// Graph
int getGraphBlockMaxChars() const { return s.value("graph.maxcols", 100).toInt(); }
void setGraphBlockMaxChars(int ch) { s.setValue("graph.maxcols", ch); }
int getGraphMinFontSize() const { return s.value("graph.minfontsize", 4).toInt(); }
void setGraphMinFontSize(int sz) { s.setValue("graph.minfontsize", sz); }
/**
* @brief Get the boolean setting for preview in Graph
* @return True if preview checkbox is checked, false otherwise
*/
bool getGraphPreview() { return s.value("graph.preview").toBool(); }
/**
* @brief Set the boolean setting for preview in Graph
* @param checked is a boolean that represents the preview checkbox
*/
void setGraphPreview(bool checked) { s.setValue("graph.preview", checked); }
/**
* @brief Getters and setters for the transaparent option state and scale factor for bitmap
* graph exports.
*/
bool getBitmapTransparentState();
double getBitmapExportScaleFactor();
void setBitmapTransparentState(bool inputValueGraph);
void setBitmapExportScaleFactor(double inputValueGraph);
void setGraphSpacing(QPoint blockSpacing, QPoint edgeSpacing);
QPoint getGraphBlockSpacing();
QPoint getGraphEdgeSpacing();
/**
* @brief Gets whether the entry offset of each block has to be displayed or not
* @return true if the entry offset has to be displayed, false otherwise
*/
bool getGraphBlockEntryOffset();
/**
* @brief Enable or disable the displaying of the entry offset in each graph block
* @param enabled set this to true for displaying the entry offset in each graph block, false
* otherwise
*/
void setGraphBlockEntryOffset(bool enabled);
/**
* @brief Enable or disable Cutter output redirection.
* Output redirection state can only be changed early during Cutter initialization.
* Changing it later will have no effect
* @param enabled set this to false for disabling output redirection
*/
void setOutputRedirectionEnabled(bool enabled);
bool getOutputRedirectionEnabled() const;
void setPreviewValue(bool checked);
bool getPreviewValue() const;
/**
* @brief Show tooltips for known values of registers, variables, and memory when debugging
*/
void setShowVarTooltips(bool enabled);
bool getShowVarTooltips() const;
/**
* @brief Recently opened binaries, as shown in NewFileDialog.
*/
QStringList getRecentFiles() const;
void setRecentFiles(const QStringList &list);
/**
* @brief Recently opened projects, as shown in NewFileDialog.
*/
QStringList getRecentProjects() const;
void setRecentProjects(const QStringList &list);
void addRecentProject(QString file);
// Functions Widget Layout
/**
* @brief Get the layout of the Functions widget.
* @return The layout.
*/
QString getFunctionsWidgetLayout();
/**
* @brief Set the layout of the Functions widget
* @param layout The layout of the Functions widget, either horizontal or vertical.
*/
void setFunctionsWidgetLayout(const QString &layout);
public slots:
void refreshFont();
signals:
void fontsUpdated();
void colorsUpdated();
void interfaceThemeChanged();
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
void kSyntaxHighlightingThemeChanged();
#endif
};
#endif // CONFIGURATION_H
| 7,953
|
C++
|
.h
| 212
| 32.698113
| 97
| 0.735049
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,776
|
RichTextPainter.h
|
rizinorg_cutter/src/common/RichTextPainter.h
|
/* x64dbg RichTextPainter */
#ifndef RICHTEXTPAINTER_H
#define RICHTEXTPAINTER_H
#include "common/Metrics.h"
#include <QString>
#include <QTextDocument>
#include <QColor>
#include <vector>
class QFontMetricsF;
template<typename T>
class CachedFontMetrics;
class QPainter;
class RichTextPainter
{
public:
// structures
enum CustomRichTextFlags { FlagNone, FlagColor, FlagBackground, FlagAll };
struct CustomRichText_t
{
QString text;
QColor textColor;
QColor textBackground;
CustomRichTextFlags flags;
bool highlight = false;
QColor highlightColor;
int highlightWidth = 2;
bool highlightConnectPrev = false;
};
typedef std::vector<CustomRichText_t> List;
// functions
template<typename T = qreal>
static void paintRichText(QPainter *painter, T x, T y, T w, T h, T xinc, const List &richText,
CachedFontMetrics<T> *fontMetrics);
static void htmlRichText(const List &richText, QString &textHtml, QString &textPlain);
static List fromTextDocument(const QTextDocument &doc);
static List cropped(const List &richText, int maxCols, const QString &indicator = nullptr,
bool *croppedOut = nullptr);
};
#endif // RICHTEXTPAINTER_H
| 1,297
|
C++
|
.h
| 39
| 27.74359
| 98
| 0.707532
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,777
|
CutterSeekable.h
|
rizinorg_cutter/src/common/CutterSeekable.h
|
#pragma once
#include "core/Cutter.h"
class MainWindow;
class CUTTER_EXPORT CutterSeekable : public QObject
{
Q_OBJECT
public:
explicit CutterSeekable(QObject *parent = nullptr);
~CutterSeekable();
/**
* @brief seek changes current offset.
* If the seekable is synchronized with Core, then
* the Core offset will be modified and then the CutterCore::seekChanged
* signal will be emitted.
* In any case, CutterSeekable::seekableSeekChanged is emitted.
* @param addr the location to seek at.
* @param type the type of seek wrt history (Undo, Redo, or New)
*/
void seek(RVA addr, CutterCore::SeekHistoryType type = CutterCore::SeekHistoryType::New)
{
updateSeek(addr, type, false);
}
/**
* @brief setSynchronization sets
* Core seek synchronization.
*/
void setSynchronization(bool sync);
/**
* @brief getOffset returns the seekable offset.
* If the seekable is synchronized with Core, this function
* is similar to Core()->getOffset.
* If it's not synchronized, it will return the seekable current seek.
* @return the seekable current offset.
*/
RVA getOffset();
/**
* @brief isSynchronized tells whether the seekable
* is synchronized with Core or not.
* @return boolean
*/
bool isSynchronized();
/**
* @brief seekToReference will seek to the function or the object which is referenced in a given
* offset
* @param offset - an address that contains a reference to jump to
*/
void seekToReference(RVA offset);
public slots:
/**
* @brief seekPrev seeks to last location.
*/
void seekPrev();
/**
* @brief toggleSyncWithCore toggles
* Core seek synchronization.
*/
void toggleSynchronization();
private slots:
/**
* @brief onCoreSeekChanged
*/
void onCoreSeekChanged(RVA addr, CutterCore::SeekHistoryType type);
private:
/**
* @brief widgetOffset widget seek location.
*/
RVA widgetOffset = RVA_INVALID;
/**
* @brief previousOffset last seek location.
* @todo maybe use an actual history?
*/
RVA previousOffset = RVA_INVALID;
/**
* @brief synchronized tells with the seekable's offset is
* synchronized with core or not.
*/
bool synchronized = true;
/**
* @brief internal method for changing the seek
* @param localOnly whether the seek should be updated globally if synchronized
*/
void updateSeek(RVA addr, CutterCore::SeekHistoryType type, bool localOnly);
signals:
void seekableSeekChanged(RVA addr, CutterCore::SeekHistoryType type);
void syncChanged();
};
| 2,721
|
C++
|
.h
| 86
| 26.406977
| 100
| 0.681054
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,778
|
BugReporting.h
|
rizinorg_cutter/src/common/BugReporting.h
|
#ifndef CRASHREPORTING_H
#define CRASHREPORTING_H
/**
* @brief Opens issue on Cutter's github page
* with current file and system information.
*/
void openIssue();
#endif // CRASHREPORTING_H
| 196
|
C++
|
.h
| 8
| 22.875
| 45
| 0.774194
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,779
|
ResourcePaths.h
|
rizinorg_cutter/src/common/ResourcePaths.h
|
#ifndef RESOURCE_PATHS_H
#define RESOURCE_PATHS_H
#include <QStandardPaths>
/**
* \file ResourcePaths.h
* Set of functions for obtaining various paths. Some of the functions are wrappers around
* QStandardPaths functions having the same name but with modifications specific to way
* Cutter is packaged.
*/
namespace Cutter {
QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName,
QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
QStringList standardLocations(QStandardPaths::StandardLocation type);
QString writableLocation(QStandardPaths::StandardLocation type);
/**
* @brief Get list of available translation directories (depends on configuration and OS)
* @return list of directories
*/
QStringList getTranslationsDirectories();
}
#endif
| 827
|
C++
|
.h
| 21
| 36.714286
| 90
| 0.803995
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,780
|
InitialOptions.h
|
rizinorg_cutter/src/common/InitialOptions.h
|
#ifndef CUTTER_INITIALOPTIONS_H
#define CUTTER_INITIALOPTIONS_H
#include "core/Cutter.h"
/**
* @brief The CommandDescription struct is a pair of a Rizin command and its description
*/
struct CommandDescription
{
QString command;
QString description;
};
struct InitialOptions
{
enum class Endianness { Auto, Little, Big };
QString filename;
QString projectFile;
bool useVA = true;
RVA binLoadAddr = RVA_INVALID;
RVA mapAddr = RVA_INVALID;
QString arch;
QString cpu;
int bits = 0;
QString os;
Endianness endian;
bool writeEnabled = false;
bool loadBinInfo = true;
QString forceBinPlugin;
bool demangle = true;
QString pdbFile;
QString script;
QList<CommandDescription> analysisCmd = { { "aaa", "Auto analysis" } };
QString shellcode;
};
#endif // CUTTER_INITIALOPTIONS_H
| 869
|
C++
|
.h
| 34
| 21.617647
| 88
| 0.718636
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,781
|
RunScriptTask.h
|
rizinorg_cutter/src/common/RunScriptTask.h
|
#ifndef RUNSCRIPTTHREAD_H
#define RUNSCRIPTTHREAD_H
#include "common/AsyncTask.h"
#include "core/Cutter.h"
class RunScriptTask : public AsyncTask
{
Q_OBJECT
public:
explicit RunScriptTask();
~RunScriptTask();
QString getTitle() override { return tr("Run Script"); }
void setFileName(const QString &fileName) { this->fileName = fileName; }
void interrupt() override;
protected:
void runTask() override;
private:
QString fileName;
};
#endif // RUNSCRIPTTHREAD_H
| 501
|
C++
|
.h
| 19
| 23.210526
| 76
| 0.744186
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,782
|
RizinTask.h
|
rizinorg_cutter/src/common/RizinTask.h
|
#ifndef RZTASK_H
#define RZTASK_H
#include "core/Cutter.h"
class CUTTER_EXPORT RizinTask : public QObject
{
Q_OBJECT
protected:
RzCoreTask *task;
RizinTask() {}
void taskFinished();
public:
using Ptr = QSharedPointer<RizinTask>;
virtual ~RizinTask();
void startTask();
void breakTask();
void joinTask();
signals:
void finished();
};
class CUTTER_EXPORT RizinCmdTask : public RizinTask
{
Q_OBJECT
private:
static void taskFinishedCallback(const char *, void *user);
public:
explicit RizinCmdTask(const QString &cmd, bool transient = true);
QString getResult();
CutterJson getResultJson();
const char *getResultRaw();
};
class CUTTER_EXPORT RizinFunctionTask : public RizinTask
{
Q_OBJECT
private:
std::function<void *(RzCore *)> fcn;
void *res;
static void *runner(RzCore *core, void *user);
public:
explicit RizinFunctionTask(std::function<void *(RzCore *)> fcn, bool transient = true);
void *getResult() { return res; }
};
#endif // RZTASK_H
| 1,050
|
C++
|
.h
| 42
| 21.452381
| 91
| 0.712841
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,783
|
Helpers.h
|
rizinorg_cutter/src/common/Helpers.h
|
#ifndef QHELPERS_H
#define QHELPERS_H
#include "core/CutterCommon.h"
#include <QString>
#include <QColor>
#include <QSizePolicy>
#include <functional>
class QIcon;
class QPlainTextEdit;
class QTextEdit;
class QString;
class QTreeWidget;
class QTreeWidgetItem;
class QAbstractItemView;
class QAbstractItemModel;
class QAbstractButton;
class QWidget;
class QTreeView;
class QAction;
class QMenu;
class QPaintDevice;
class QComboBox;
class QSortFilterProxyModel;
class QMouseEvent;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# define CUTTER_QT_SKIP_EMPTY_PARTS QString::SkipEmptyParts
#else
# define CUTTER_QT_SKIP_EMPTY_PARTS Qt::SkipEmptyParts
#endif
namespace qhelpers {
CUTTER_EXPORT QString formatBytecount(const uint64_t bytecount);
CUTTER_EXPORT void adjustColumns(QTreeView *tv, int columnCount, int padding);
CUTTER_EXPORT void adjustColumns(QTreeWidget *tw, int padding);
CUTTER_EXPORT bool selectFirstItem(QAbstractItemView *itemView);
CUTTER_EXPORT QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str,
const QString &str2 = QString(),
const QString &str3 = QString(),
const QString &str4 = QString(),
const QString &str5 = QString());
CUTTER_EXPORT void setVerticalScrollMode(QAbstractItemView *tw);
CUTTER_EXPORT void setCheckedWithoutSignals(QAbstractButton *button, bool checked);
struct CUTTER_EXPORT SizePolicyMinMax
{
QSizePolicy sizePolicy;
int min;
int max;
void restoreWidth(QWidget *widget);
void restoreHeight(QWidget *widget);
};
CUTTER_EXPORT SizePolicyMinMax forceWidth(QWidget *widget, int width);
CUTTER_EXPORT SizePolicyMinMax forceHeight(QWidget *widget, int height);
CUTTER_EXPORT int getMaxFullyDisplayedLines(QTextEdit *textEdit);
CUTTER_EXPORT int getMaxFullyDisplayedLines(QPlainTextEdit *plainTextEdit);
CUTTER_EXPORT QByteArray applyColorToSvg(const QByteArray &data, QColor color);
CUTTER_EXPORT QByteArray applyColorToSvg(const QString &filename, QColor color);
CUTTER_EXPORT void setThemeIcons(QList<QPair<void *, QString>> supportedIconsNames,
std::function<void(void *, const QIcon &)> setter);
CUTTER_EXPORT void prependQAction(QAction *action, QMenu *menu);
CUTTER_EXPORT qreal devicePixelRatio(const QPaintDevice *p);
/**
* @brief Select comboBox item by value in Qt::UserRole.
* @param comboBox
* @param data - value to search in combobox item data
* @param defaultIndex - item to select in case no match
*/
CUTTER_EXPORT void selectIndexByData(QComboBox *comboBox, QVariant data, int defaultIndex = -1);
/**
* @brief Emit data change signal in a model's column (DisplayRole)
* @param model - model containing data with changes
* @param column - column in the model
*/
CUTTER_EXPORT void emitColumnChanged(QAbstractItemModel *model, int column);
CUTTER_EXPORT bool filterStringContains(const QString &string, const QSortFilterProxyModel *model);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
using ColorFloat = float;
using KeyComb = QKeyCombination;
#else
using ColorFloat = qreal;
using KeyComb = int;
#endif
CUTTER_EXPORT QPointF mouseEventPos(QMouseEvent *ev);
CUTTER_EXPORT QPoint mouseEventGlobalPos(QMouseEvent *ev);
} // qhelpers
#endif // HELPERS_H
| 3,362
|
C++
|
.h
| 84
| 36.107143
| 99
| 0.761583
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,784
|
Colors.h
|
rizinorg_cutter/src/common/Colors.h
|
#ifndef COLORS_H
#define COLORS_H
#include "core/Cutter.h"
#include "common/RichTextPainter.h"
#include <rz_analysis.h>
class Colors
{
public:
Colors();
static void colorizeAssembly(RichTextPainter::List &list, QString opcode, ut64 type_num);
static QString getColor(ut64 type);
};
#endif // COLORS_H
| 316
|
C++
|
.h
| 13
| 22.153846
| 93
| 0.76
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,785
|
FunctionsTask.h
|
rizinorg_cutter/src/common/FunctionsTask.h
|
#ifndef FUNCTIONSTASK_H
#define FUNCTIONSTASK_H
#include "common/AsyncTask.h"
#include "core/Cutter.h"
class FunctionsTask : public AsyncTask
{
Q_OBJECT
public:
QString getTitle() override { return tr("Fetching Functions"); }
signals:
void fetchFinished(const QList<FunctionDescription> &strings);
protected:
void runTask() override
{
auto functions = Core()->getAllFunctions();
emit fetchFinished(functions);
}
};
#endif // FUNCTIONSTASK_H
| 488
|
C++
|
.h
| 19
| 22.210526
| 68
| 0.735931
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,786
|
ColorThemeWorker.h
|
rizinorg_cutter/src/common/ColorThemeWorker.h
|
#ifndef COLORTHEMEWORKER_H
#define COLORTHEMEWORKER_H
#include <QFile>
#include <QColor>
#include <QObject>
#include "Cutter.h"
#include <QJsonDocument>
#include <QJsonObject>
#define ThemeWorker() (ColorThemeWorker::instance())
/**
* @brief The ColorThemeWorker class is a singletone that provides API for working with
* color themes.
*/
class ColorThemeWorker : public QObject
{
Q_OBJECT
public:
typedef QHash<QString, QColor> Theme;
/**
* @brief cutterSpecificOptions is list of all available Cutter-only color options.
*/
static const QStringList cutterSpecificOptions;
/**
* @brief rizinUnusedOptions is a list of all Rizin options that Cutter does not use.
*/
static const QStringList rizinUnusedOptions;
static ColorThemeWorker &instance()
{
static ColorThemeWorker ex;
return ex;
}
virtual ~ColorThemeWorker() {}
/**
* @brief Copies @a srcThemeName with name @a copyThemeName.
* @param srcThemeName
* Name of theme to be copied.
* @param copyThemeName
* Name of copy.
* @return "" on success or error message.
*/
QString copy(const QString &srcThemeName, const QString ©ThemeName) const;
/**
* @brief Saves @a theme as @a themeName theme.
* @param theme
* Theme to be saved.
* @param themeName
* Name of theme to save.
* @return "" on success or error message.
*/
QString save(const Theme &theme, const QString &themeName) const;
/**
* @brief Returns whether or not @a themeName theme is custom (created by user or imported) or
* not.
* @param themeName
* Name of theme to check.
*/
bool isCustomTheme(const QString &themeName) const;
/**
* @brief Returns whether or not @a name theme already exists.
* @return true if theme exists, false - if not.
*/
bool isThemeExist(const QString &name) const;
/**
* @brief Returns theme as QHash where key is option name and value is QColor.
* @param themeName
* Theme to get.
*/
Theme getTheme(const QString &themeName) const;
/**
* @brief Deletes theme named @a themeName.
* @param themeName
* Name of theme to be removed.
* @return "" on success or error message.
*/
QString deleteTheme(const QString &themeName) const;
/**
* @brief Imports theme from @a file.
* @return "" on success or error message.
*/
QString importTheme(const QString &file) const;
/**
* @brief Renames theme from @a themeName to @a newName.
* @return "" on success or error message.
*/
QString renameTheme(const QString &themeName, const QString &newName) const;
/**
* @brief Returns whether or not file at @a filePath is a color theme.
* @param filePath
* Path to file to check.
* @param ok
* Output parameter. Indicates wheter or not check was successful.
* @return true if given file is color theme and ok == true, otherwise returns false.
*/
bool isFileTheme(const QString &filePath, bool *ok) const;
/**
* @brief Returns list of all custom themes.
*/
QStringList customThemes() const;
QString getStandardThemesPath() { return standardRzThemesLocationPath; }
QString getCustomThemesPath() { return customRzThemesLocationPath; }
const QStringList &getRizinSpecificOptions();
private:
/**
* @brief list of all available Rizin-only color options.
*/
QStringList rizinSpecificOptions;
QString standardRzThemesLocationPath;
QString customRzThemesLocationPath;
ColorThemeWorker(QObject *parent = nullptr);
ColorThemeWorker(const ColorThemeWorker &root) = delete;
ColorThemeWorker &operator=(const ColorThemeWorker &) = delete;
QColor mergeColors(const QColor &upper, const QColor &lower) const;
};
#endif // COLORTHEMEWORKER_H
| 3,918
|
C++
|
.h
| 114
| 29.27193
| 98
| 0.688889
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,787
|
QtResImporter.h
|
rizinorg_cutter/src/common/QtResImporter.h
|
#ifndef QTRESIMPORTER_H
#define QTRESIMPORTER_H
PyObject *PyInit_qtres();
PyObject *QtResImport(const char *name);
#define RegQtResImporter() Py_DecRef(QtResImport("reg_qtres_importer"))
#endif // QTRESIMPORTER_H
| 217
|
C++
|
.h
| 6
| 34.5
| 71
| 0.806763
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,788
|
CutterLayout.h
|
rizinorg_cutter/src/common/CutterLayout.h
|
#ifndef CUTTER_LAYOUT_H
#define CUTTER_LAYOUT_H
#include <QByteArray>
#include <QMap>
#include <QString>
#include <QVariantMap>
namespace Cutter {
struct CutterLayout
{
QByteArray geometry;
QByteArray state;
QMap<QString, QVariantMap> viewProperties;
};
const QString LAYOUT_DEFAULT = "Default";
const QString LAYOUT_DEBUG = "Debug";
bool isBuiltinLayoutName(const QString &name);
}
#endif
| 408
|
C++
|
.h
| 18
| 20.666667
| 46
| 0.791667
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,789
|
JsonModel.h
|
rizinorg_cutter/src/common/JsonModel.h
|
#ifndef JSONMODEL_H
#define JSONMODEL_H
#include <QTreeWidgetItem>
#include "CutterJson.h"
namespace Cutter {
QTreeWidgetItem *jsonTreeWidgetItem(const QString &key, const CutterJson &json);
};
#endif // JSONMODEL_H
| 222
|
C++
|
.h
| 8
| 26
| 80
| 0.8125
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,790
|
CachedFontMetrics.h
|
rizinorg_cutter/src/common/CachedFontMetrics.h
|
#ifndef CACHEDFONTMETRICS_H
#define CACHEDFONTMETRICS_H
#include "common/Metrics.h"
#include <QObject>
#include <QFont>
#include <QFontMetrics>
template<typename T>
class CachedFontMetrics
{
public:
explicit CachedFontMetrics(const QFont &font) : mFontMetrics(font)
{
memset(mWidths, 0, sizeof(mWidths));
mHeight = mFontMetrics.height();
}
T width(const QChar &ch)
{
// return mFontMetrics.width(ch);
auto unicode = ch.unicode();
if (unicode >= 0xD800) {
if (unicode >= 0xE000)
unicode -= 0xE000 - 0xD800;
else
// is lonely surrogate
return fetchWidth(ch);
}
if (!mWidths[unicode])
return mWidths[unicode] = fetchWidth(ch);
return mWidths[unicode];
}
T width(const QString &text)
{
T result = 0;
QChar temp;
for (const QChar &ch : text) {
if (ch.isHighSurrogate())
temp = ch;
else if (ch.isLowSurrogate())
result += fetchWidth(QString(temp) + ch);
else
result += width(ch);
}
return result;
}
T height() { return mHeight; }
T position(const QString &text, T offset)
{
T curWidth = 0;
QChar temp;
for (int i = 0; i < text.length(); i++) {
QChar ch = text[i];
if (ch.isHighSurrogate())
temp = ch;
else if (ch.isLowSurrogate())
curWidth += fetchWidth(QString(temp) + ch);
else
curWidth += width(ch);
if (curWidth >= offset) {
return i;
}
}
return -1;
}
private:
typename Metrics<T>::FontMetrics mFontMetrics;
T mWidths[0x10000 - 0xE000 + 0xD800];
T mHeight;
T fetchWidth(QChar c)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return mFontMetrics.width(c);
#else
return mFontMetrics.horizontalAdvance(c);
#endif
}
T fetchWidth(const QString &s)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return mFontMetrics.width(s);
#else
return mFontMetrics.horizontalAdvance(s);
#endif
}
};
#endif // CACHEDFONTMETRICS_H
| 2,290
|
C++
|
.h
| 85
| 19.082353
| 70
| 0.556621
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,791
|
UpdateWorker.h
|
rizinorg_cutter/src/common/UpdateWorker.h
|
#ifndef UPDATEWORKER_H
#define UPDATEWORKER_H
#include <QtGlobal>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
# define CUTTER_UPDATE_WORKER_AVAILABLE 1
#else
# define CUTTER_UPDATE_WORKER_AVAILABLE 0
#endif
#if CUTTER_UPDATE_WORKER_AVAILABLE
# include <QDir>
# include <QTimer>
# include <QObject>
# include <QtNetwork/QNetworkAccessManager>
# include <QVersionNumber>
#endif
#if CUTTER_UPDATE_WORKER_AVAILABLE
class QNetworkReply;
/**
* @class UpdateWorker
* @brief The UpdateWorker class is a class providing API to check for current Cutter version.
*/
class UpdateWorker : public QObject
{
Q_OBJECT
public:
explicit UpdateWorker(QObject *parent = nullptr);
/**
* @fn void UpdateWorker::checkCurrentVersion(time_t timeoutMs)
*
* Sends request to determine current version of Cutter.
* If there is no response in @a timeoutMs milliseconds, emits
* @fn UpdateWorker::checkComplete(const QString& currVerson, const QString& errorMsg)
* with timeout error message.
*
*
* @sa checkComplete(const QString& verson, const QString& errorMsg)
*/
void checkCurrentVersion(time_t timeoutMs);
/**
* @fn void UpdateWorker::showUpdateDialog()
*
* Shows dialog that allows user to download latest version of Cutter from website.
* This dialog also has "Don't check for updates" button which disables on-start update
* checks if @a showDontCheckForUpdatesButton is true.
*/
void showUpdateDialog(bool showDontCheckForUpdatesButton);
/**
* @return the version of this Cutter binary, derived from CUTTER_VERSION_MAJOR,
* CUTTER_VERSION_MINOR and CUTTER_VERSION_PATCH.
*/
static QVersionNumber currentVersionNumber();
signals:
/**
* @fn UpdateWorker::checkComplete(const QString& verson, const QString& errorMsg)
*
* The signal is emitted when check has been done with an empty @a errorMsg string.
* In case of an error @a currVerson is null and @a errorMsg contains description
* of error.
*/
void checkComplete(const QVersionNumber &currVerson, const QString &errorMsg);
private slots:
void serveVersionCheckReply();
private:
QNetworkAccessManager nm;
QVersionNumber latestVersion;
QTimer t;
bool pending;
QNetworkReply *checkReply;
};
#endif // CUTTER_UPDATE_WORKER_AVAILABLE
#endif // UPDATEWORKER_H
| 2,416
|
C++
|
.h
| 71
| 30.112676
| 94
| 0.730472
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,792
|
HighDpiPixmap.h
|
rizinorg_cutter/src/common/HighDpiPixmap.h
|
#ifndef HIGHDPIPIXMAP_H
#define HIGHDPIPIXMAP_H
#include <QPixmap>
class HighDpiPixmap : public QPixmap
{
public:
HighDpiPixmap(int width, int height, qreal devicePixelRatio = -1);
};
#endif // HIGHDPIPIXMAP_H
| 216
|
C++
|
.h
| 9
| 22.333333
| 70
| 0.790244
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,793
|
BasicInstructionHighlighter.h
|
rizinorg_cutter/src/common/BasicInstructionHighlighter.h
|
#ifndef BASICINSTRUCTIONHIGHLIGHTER_H
#define BASICINSTRUCTIONHIGHLIGHTER_H
#include "CutterCommon.h"
#include <map>
#include <QColor>
struct BasicInstruction
{
RVA address;
RVA size;
QColor color;
};
typedef std::map<RVA, BasicInstruction>::iterator BasicInstructionIt;
class BasicInstructionHighlighter
{
public:
void clear(RVA address, RVA size);
void highlight(RVA address, RVA size, QColor color);
BasicInstruction *getBasicInstruction(RVA address);
private:
std::map<RVA, BasicInstruction> biMap;
};
#endif // BASICINSTRUCTIONHIGHLIGHTER_H
| 580
|
C++
|
.h
| 22
| 23.818182
| 69
| 0.79529
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,794
|
AsyncTask.h
|
rizinorg_cutter/src/common/AsyncTask.h
|
#ifndef ASYNCTASK_H
#define ASYNCTASK_H
#include "core/CutterCommon.h"
#include <QRunnable>
#include <QThreadPool>
#include <QMutex>
#include <QElapsedTimer>
#include <QSharedPointer>
#include <QList>
class AsyncTaskManager;
class CUTTER_EXPORT AsyncTask : public QObject, public QRunnable
{
Q_OBJECT
friend class AsyncTaskManager;
public:
using Ptr = QSharedPointer<AsyncTask>;
AsyncTask();
~AsyncTask();
void run() override final;
void wait();
bool wait(int timeout);
virtual void interrupt();
bool isInterrupted() { return interrupted; }
bool isRunning() { return running; }
const QString &getLog() { return logBuffer; }
const QElapsedTimer &getTimer() { return timer; }
qint64 getElapsedTime() { return timer.isValid() ? timer.elapsed() : 0; }
virtual QString getTitle() { return QString(); }
protected:
virtual void runTask() = 0;
void log(QString s);
signals:
void finished();
void logChanged(const QString &log);
private:
bool running;
bool interrupted;
QMutex runningMutex;
QElapsedTimer timer;
QString logBuffer;
void prepareRun();
};
class AsyncTaskManager : public QObject
{
Q_OBJECT
private:
QThreadPool *threadPool;
QList<AsyncTask::Ptr> tasks;
public:
explicit AsyncTaskManager(QObject *parent = nullptr);
~AsyncTaskManager();
void start(AsyncTask::Ptr task);
bool getTasksRunning();
signals:
void tasksChanged();
};
#endif // ASYNCTASK_H
| 1,508
|
C++
|
.h
| 57
| 22.736842
| 77
| 0.721989
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,795
|
LinkedListPool.h
|
rizinorg_cutter/src/common/LinkedListPool.h
|
#ifndef LINKED_LIST_POOL_H
#define LINKED_LIST_POOL_H
#include <vector>
#include <cstdint>
#include <iterator>
/**
* @brief Pool of singly linked lists.
*
* Should not be used as general purpose container. Use only for algorithms that require linked
* lists ability to split and concatenate them. All the data is owned by LinkedListPool.
*
* In contrast to std::list and std::forward_list doesn't allocate each node separately.
* LinkedListPool can reserve all the memory for multiple lists during construction. Uses
* std::vector as backing container.
*/
template<class T>
class LinkedListPool
{
using IndexType = size_t;
struct Item
{
IndexType next;
T value;
};
public:
/**
* @brief List iterator.
*
* Iterators don't get invalidated by adding items to list, but the items may be relocated.
*/
class ListIterator
{
IndexType index = 0;
LinkedListPool<T> *pool = nullptr;
ListIterator(IndexType index, LinkedListPool<T> *pool) : index(index), pool(pool) {}
friend class LinkedListPool<T>;
public:
using iterator_category = std::forward_iterator_tag;
using value_type = T;
using difference_type = size_t;
using pointer = T *;
using reference = T &;
ListIterator() = default;
reference operator*() { return pool->data[index].value; }
pointer operator->() { return &pool->data[index].value; }
ListIterator &operator++()
{
index = pool->data[index].next;
return *this;
}
ListIterator operator++(int)
{
ListIterator tmp(*this);
operator++();
return tmp;
}
bool operator!=(const ListIterator &b) const { return index != b.index || pool != b.pool; };
/**
* @brief Test if iterator points to valid value.
*/
explicit operator bool() const { return index; }
};
/**
* @brief Single list within LinkedListPool.
*
* List only refers to chain of elements. Copying it doesn't copy any element. Item data is
* owned by LinkedListPool.
*
* Use LinkedListPool::makeList to create non-empty list.
*/
class List
{
IndexType head = 0;
IndexType tail = 0;
friend class LinkedListPool;
List(IndexType head, IndexType tail) : head(head), tail(tail) {}
public:
/**
* @brief Create an empty list
*/
List() = default;
bool isEmpty() const { return head == 0; }
};
/**
* @brief Create a linked list pool with capacity for \a initialCapacity list items.
* @param initialCapacity number of elements to preallocate.
*/
LinkedListPool(size_t initialCapacity) : data(1)
{
data.reserve(initialCapacity + 1); // [0] element reserved
}
/**
* @brief Create a list containing single item.
*
* Does not invalidate any iterators, but may cause item relocation when initialCapacity is
* exceeded.
* @param value value of element that will be inserted in the created list
* @return List containing single value \a value .
*/
List makeList(const T &value)
{
size_t position = data.size();
data.push_back(Item { 0, value });
return { position, position };
}
/**
* @brief Split list and return second half.
*
* After performing the operation, list passed as argument and return list point to the same
* items. Modifying them will affect both lists.
*
* @param list The list that needs to be split.
* @param head Iterator to the first item in new list. Needs to be within \a list .
* @return Returns suffix of \a list.
*/
List splitTail(const List &list, const ListIterator &head)
{
return List { head.index, list.tail };
}
/**
* @brief Split list and return first half.
*
* @param list The list that needs to be split.
* @param end Iterator to the first item that should not be included in returned list. Needs to
* be within \a list .
* @return Returns prefix of \a list.
*/
List splitHead(const List &list, const ListIterator &end)
{
if (!end) {
return list;
}
if (end.index == list.head) {
return {};
}
auto last = list.head;
while (data[last].next != end.index) {
last = data[last].next;
}
data[last].next = 0;
return List { list.head, last };
}
/**
* @brief Create list iterator from list.
* @param list
* @return Iterator pointing to the first item in the list.
*/
ListIterator head(const List &list) { return iteratorFromIndex(list.head); }
ListIterator end(const List &list) { return std::next(iteratorFromIndex(list.tail)); }
List append(const List &head, const List &tail)
{
if (head.isEmpty()) {
return tail;
}
if (tail.isEmpty()) {
return head;
}
List result { head.head, tail.tail };
data[head.tail].next = tail.head;
return result;
}
private:
ListIterator iteratorFromIndex(IndexType index) { return ListIterator { index, this }; }
std::vector<Item> data;
};
#endif // LINKED_LIST_POOL
| 5,408
|
C++
|
.h
| 166
| 25.861446
| 100
| 0.615547
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,796
|
Decompiler.h
|
rizinorg_cutter/src/common/Decompiler.h
|
#ifndef DECOMPILER_H
#define DECOMPILER_H
#include "CutterCommon.h"
#include "RizinTask.h"
#include <rz_util/rz_annotated_code.h>
#include <QString>
#include <QObject>
/**
* Implements a decompiler that can be registered using CutterCore::registerDecompiler()
*/
class CUTTER_EXPORT Decompiler : public QObject
{
Q_OBJECT
private:
const QString id;
const QString name;
public:
Decompiler(const QString &id, const QString &name, QObject *parent = nullptr);
virtual ~Decompiler() = default;
static RzAnnotatedCode *makeWarning(QString warningMessage);
QString getId() const { return id; }
QString getName() const { return name; }
virtual bool isRunning() { return false; }
virtual bool isCancelable() { return false; }
virtual void decompileAt(RVA addr) = 0;
virtual void cancel() {}
signals:
void finished(RzAnnotatedCode *codeDecompiled);
};
#endif // DECOMPILER_H
| 929
|
C++
|
.h
| 30
| 27.833333
| 88
| 0.740157
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
4,798
|
RefreshDeferrer.h
|
rizinorg_cutter/src/common/RefreshDeferrer.h
|
#ifndef REFRESHDEFERRER_H
#define REFRESHDEFERRER_H
#include <QObject>
class CutterDockWidget;
class RefreshDeferrer;
using RefreshDeferrerParams = void *;
using RefreshDeferrerParamsResult = void *;
/**
* @brief Abstract class for accumulating params in RefreshDeferrer
*/
class RefreshDeferrerAccumulator
{
friend class RefreshDeferrer;
public:
virtual ~RefreshDeferrerAccumulator() = default;
protected:
/**
* @brief Add a new param to the accumulator
*/
virtual void accumulate(RefreshDeferrerParams params) = 0;
/**
* @brief Ignore the incoming params. Useful for freeing if necessary.
*/
virtual void ignoreParams(RefreshDeferrerParams params) = 0;
/**
* @brief Clear the current accumulator
*/
virtual void clear() = 0;
/**
* @brief Return the final result of the accumulation
*/
virtual RefreshDeferrerParamsResult result() = 0;
};
/**
* @brief Accumulator which simply replaces the current value by an incoming new one
* @tparam T The type of the param to store
*
* This accumulator takes the ownership of all params passed to it and deletes them automatically if
* not needed anymore!
*/
template<class T>
class ReplacingRefreshDeferrerAccumulator : public RefreshDeferrerAccumulator
{
private:
T *value = nullptr;
bool replaceIfNull;
public:
/**
* \param Determines whether, if nullptr is passed, the current value should be replaced or
* kept.
*/
explicit ReplacingRefreshDeferrerAccumulator(bool replaceIfNull = true)
: replaceIfNull(replaceIfNull)
{
}
~ReplacingRefreshDeferrerAccumulator() override { delete value; }
protected:
void accumulate(RefreshDeferrerParams params) override
{
if (!replaceIfNull && !params) {
return;
}
delete value;
value = static_cast<T *>(params);
}
void ignoreParams(RefreshDeferrerParams params) override { delete static_cast<T *>(params); }
void clear() override
{
delete value;
value = nullptr;
}
virtual RefreshDeferrerParamsResult result() override { return value; }
};
/**
* @brief Helper class for deferred refreshing in Widgets
*
* This class can handle the logic necessary to defer the refreshing of widgets when they are not
* visible. It contains an optional RefreshDeferrerAccumulator, which can be used to accumulate
* incoming events while refreshing is deferred.
*
* Example (don't write it like this in practice, use the convenience methods in CutterDockWidget):
* ```
* // in the constructor of a widget
* this->refreshDeferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator(false),
* this); this->refreshDeferrer->registerFor(this); connect(this->refreshDeferrer,
* &RefreshDeferrer::refreshNow, this, [this](MyParam *param) {
* // We attempted a refresh some time before, but it got deferred.
* // Now the RefreshDeferrer tells us to do the refresh and gives us the accumulated param.
* this->doRefresh(*param);
* }
*
* // ...
*
* void MyWidget::doRefresh(MyParam param)
* {
* if (!this->refreshDeferrer->attemptRefresh(new MyParam(param))) {
* // We shouldn't refresh right now.
* // The RefreshDeferrer takes over the param we passed it in attemptRefresh()
* // and gives it to the ReplacingRefreshDeferrerAccumulator.
* return;
* }
* // do the actual refresh depending on param
* }
* ```
*
*/
class RefreshDeferrer : public QObject
{
Q_OBJECT
private:
CutterDockWidget *dockWidget = nullptr;
RefreshDeferrerAccumulator *acc;
bool dirty = false;
public:
/**
* @param acc The accumulator (can be nullptr). The RefreshDeferrer takes the ownership!
*/
explicit RefreshDeferrer(RefreshDeferrerAccumulator *acc, QObject *parent = nullptr);
~RefreshDeferrer() override;
bool attemptRefresh(RefreshDeferrerParams params);
void registerFor(CutterDockWidget *dockWidget);
signals:
void refreshNow(const RefreshDeferrerParamsResult paramsResult);
};
#endif // REFRESHDEFERRER_H
| 4,150
|
C++
|
.h
| 125
| 29.512
| 100
| 0.72089
|
rizinorg/cutter
| 15,656
| 1,143
| 512
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.