/**************************************************************************** * * * Copyright (C) 2005 Michael Buesch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. Additionally a copy of the * * GNU General Public License is available here: * * http://passwordmanager.sourceforge.net/gplv2.txt * * http://www.gnu.org/licenses/gpl.txt * * * ****************************************************************************/ #ifndef REGTRACK_H_ #define REGTRACK_H_ #include #include #include #include #include #define VERSION "0.2" class AdvancedWidget; class RegTrack; class StackView; class QPushButton; class QTextEdit; class HexSpinBox : public QSpinBox { Q_OBJECT public: HexSpinBox(QWidget *parent = 0, const char * name = 0) : QSpinBox (parent, name) { setPrefix("0x"); } HexSpinBox(int minValue, int maxValue, int step = 1, QWidget *parent = 0, const char *name = 0) : QSpinBox (minValue, maxValue, step, parent, name) { setPrefix("0x"); } virtual ~HexSpinBox() { } protected: virtual QString mapValueToText(int v) { return QString::number(v, 16); } virtual int mapTextToValue(bool *ok) { return cleanText().toInt(ok, 16); } }; class RegTrackContext { public: RegTrackContext(RegTrack *_rt); virtual ~RegTrackContext(); int count() const; int current() const; QString name(int index) const; int cloneContext(int index, const QString &name); bool deleteContext(int index); bool renameContext(int index, const QString &newName); void switchContext(int index, bool saveCurrent = true); /* Be careful! This clears _all_ contexts. */ void clear(); /* Only used for loading from file. */ int appendEmptyContext(const QString &name); void loadContext(int index); void saveContext(int index); protected: RegTrack *rt; QValueList blobs; QValueList names; int _current; }; class RegTrack : public QWidget { Q_OBJECT friend class AdvancedWidget; friend class StackView; public: RegTrack(QWidget *parent = 0, const char *name = 0, WFlags f = 0); virtual ~RegTrack(); static QFont dataFont; void loadContext(QDataStream &ds); void saveContext(QDataStream &ds); void loadFile(); void saveFile(); QString clipboardGet() const; void clipboardPut(const QString &str) const; RegTrackContext * getContext() const { return context; } protected slots: void stackAllocClicked(); void stackFreeClicked(); void stackPushClicked(); void stackPopClicked(); void resetClicked(); void advancedClicked(bool on); protected: void update(); protected: RegTrackContext *context; AdvancedWidget *advancedWidget; protected: QVBoxLayout *layout; QHBoxLayout *bottomLayout; QLineEdit *eax; QPushButton *eaxClear; QLineEdit *ebx; QPushButton *ebxClear; QLineEdit *ecx; QPushButton *ecxClear; QLineEdit *edx; QPushButton *edxClear; QLineEdit *esi; QPushButton *esiClear; QLineEdit *edi; QPushButton *ediClear; StackView *stack; QLineEdit *ebp; QPushButton *ebpClear; QLineEdit *esp; HexSpinBox *allocSize; QPushButton *stackAlloc; HexSpinBox *freeSize; QPushButton *stackFree; QPushButton *stackPush; QPushButton *stackPop; QPushButton *reset; QPushButton *advanced; QTextEdit *notes; }; #endif // REGTRACK_H_