aboutsummaryrefslogtreecommitdiffstats
path: root/regtrack.h
blob: 8cad1128ff01a560ab0e9d325f6e6662a0498c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/****************************************************************************
 *                                                                          *
 *   Copyright (C) 2005  Michael Buesch <mbuesch@freenet.de>                *
 *                                                                          *
 *   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 <stdint.h>

#include <qwidget.h>
#include <qlayout.h>
#include <qspinbox.h>
#include <qstring.h>


#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<QByteArray *> blobs;
	QValueList<QString> 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_
bues.ch cgit interface