2019-01-13 14:20:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2019-01-13 14:20:07 +00:00
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
|
2020-08-01 14:14:30 +00:00
|
|
|
class CUTTER_EXPORT CutterSeekable : public QObject
|
2019-01-13 14:20:07 +00:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
2019-01-20 11:19:51 +00:00
|
|
|
void seek(RVA addr) { updateSeek(addr, false); }
|
2019-01-13 14:20:07 +00:00
|
|
|
|
|
|
|
/**
|
2019-06-18 13:02:41 +00:00
|
|
|
* @brief setSynchronization sets
|
2019-01-13 14:20:07 +00:00
|
|
|
* Core seek synchronization.
|
|
|
|
*/
|
2019-06-18 13:02:41 +00:00
|
|
|
void setSynchronization(bool sync);
|
2019-01-13 14:20:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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();
|
|
|
|
|
2019-12-14 12:57:36 +00:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
|
2019-01-13 14:20:07 +00:00
|
|
|
public slots:
|
|
|
|
/**
|
|
|
|
* @brief seekPrev seeks to last location.
|
|
|
|
*/
|
|
|
|
void seekPrev();
|
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
/**
|
|
|
|
* @brief toggleSyncWithCore toggles
|
|
|
|
* Core seek synchronization.
|
|
|
|
*/
|
|
|
|
void toggleSynchronization();
|
|
|
|
|
2019-01-13 14:20:07 +00:00
|
|
|
private slots:
|
|
|
|
/**
|
|
|
|
* @brief onCoreSeekChanged
|
|
|
|
*/
|
|
|
|
void onCoreSeekChanged(RVA addr);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-01-20 11:19:51 +00:00
|
|
|
/**
|
|
|
|
* @brief internal method for changing the seek
|
|
|
|
* @param localOnly whether the seek should be updated globally if synchronized
|
|
|
|
*/
|
|
|
|
void updateSeek(RVA addr, bool localOnly);
|
|
|
|
|
2019-01-13 14:20:07 +00:00
|
|
|
signals:
|
|
|
|
void seekableSeekChanged(RVA addr);
|
2019-06-18 13:02:41 +00:00
|
|
|
void syncChanged();
|
2019-01-13 14:20:07 +00:00
|
|
|
};
|