-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiabhack.h
280 lines (242 loc) · 6.9 KB
/
diabhack.h
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
* Diablo Hacking Utility
*
* Copyright (C)1997 Trojan Consulting Ltd.
*
* andy@trojanco.demon.co.uk
*
* $Header: /diabhack/diabhack.h 1 2/03/99 21:21 Andy $
*/
#ifndef _DIABHACK_H_
#define _DIABHACK_H_
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "resource.h"
/*
* CProc provides a wrapper for the Win32 process open, read,
* write and close API functions.
*/
class CProc {
private:
static BOOL m_fReportMemIoErrors;
public:
static HWND GetWindowHandle(LPCSTR pszWindowName);
static HANDLE Open(LPCSTR pszWindowName);
static void Close(HANDLE &hProc);
static BOOL Read(HANDLE hProc, DWORD dwOffset,
LPBYTE pBuffer, DWORD dwLen);
static BOOL Write(HANDLE hProc, DWORD dwOffset,
LPBYTE pBuffer, DWORD dwLen);
static void ReportMemIoErrors(BOOL fReport) {
m_fReportMemIoErrors = fReport;
}
};
/*
* CHack holds a list of CHackNodes and a description of the hack
*/
class CHackNode; // Forward
class CHack {
public:
enum State {
STATE_UNKNOWN,
STATE_ACTIVE,
STATE_INACTIVE,
STATE_ERROR
};
private:
LPSTR m_pszDesc;
LPSTR m_pszVersion;
CHackNode *m_pRootNode;
CHack *m_pNext;
State m_State;
void Init();
public:
CHack();
CHack(LPCSTR pszDesc, LPCSTR pszVersion);
~CHack();
void desc(LPCSTR pszDesc);
LPCSTR desc() const;
void version(LPCSTR pszVersion);
LPCSTR version() const;
void addNode(CHackNode *pNode);
CHackNode *findNode(DWORD dwOffset, DWORD dwLen) const;
CHackNode *rootNode() const;
void next(class CHack *pNext);
class CHack *next() const;
void state(State State);
State state() const;
static BOOL IsDiabloRunning();
BOOL getState();
BOOL activateHack();
BOOL deactivateHack();
void dumpContents(LPSTR pszBuffer);
};
/*
* CHackList manages a list of hacks
*/
class CHackList {
private:
CHack *m_pRootHack;
public:
CHackList();
~CHackList();
CHack *rootHack() {
return m_pRootHack;
}
void add(CHack *pHack);
CHack *find(LPCSTR pszDesc);
CHack *find(DWORD dwOffset, DWORD dwLen);
void remove(CHack *pHack);
void removeAll();
#ifdef _DEBUG
void dump();
#endif // _DEBUG
};
/*
* CHackNode holds information about a single
* program modification.
*/
class CHackNode {
private:
DWORD m_dwOffset;
DWORD m_dwLen;
LPBYTE m_pOldData;
LPBYTE m_pNewData;
class CHackNode *m_pNext;
public:
CHackNode();
CHackNode(DWORD dwOffset, DWORD dwLen, LPBYTE pOldData, LPBYTE pNewData,
class CHackNode *pNext = NULL);
~CHackNode();
void offset(DWORD dwOffset);
DWORD offset() const;
void len(DWORD dwLen);
DWORD len() const;
void oldData(LPBYTE pOldData);
LPBYTE oldData() const;
void newData(LPBYTE pNewData);
LPBYTE newData() const;
void next(class CHackNode *pNext);
class CHackNode *next() const;
CHack::State getState(HANDLE hDiablo);
BOOL activateHack(HANDLE hDiablo);
BOOL deactivateHack(HANDLE hDiablo);
void dumpContents(LPSTR szBuffer);
};
/*
* Image indexes used in listview window
*/
enum LVImageIndex {
IDX_STATEUNKNOWN,
IDX_STATEACTIVE,
IDX_STATEINACTIVE,
IDX_STATEERROR
};
/*
* main.cpp
*/
extern char g_szTitle[];
extern int g_nMainX, g_nMainY, g_nMainCX, g_nMainCY;
extern int g_nLV0CX, g_nLV1CX, g_nLV2CX;
extern DWORD g_dwDiabloNotRunningNotifyFlag;
extern DWORD g_dwDangerousCommandNotifyFlag;
extern HWND g_hwndMain;
extern HINSTANCE g_hInst;
extern CHackList g_HackList;
/*
* dialog.cpp
*/
extern CHack *g_pHackDisplayProps;
extern BOOL CALLBACK ReadDiabloMemoryDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK WriteDiabloMemoryDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK DisplayHackPropsDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK HelpCreatingDatfilesDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK HelpSofticeCodesDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK DiabloNotRunningDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK DangerousCommandDlgProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
/*
* listview.cpp
*/
extern HWND CreateListView();
extern void RefreshListView(HWND hwnd);
extern void DblClkListView(HWND hwnd);
extern void RClickListView(HWND hwnd);
extern void ColumnClickListView(HWND hwnd, int nColumn);
extern void ActivateHacks(HWND hwnd, BOOL fAll);
extern void DeactivateHacks(HWND hwnd, BOOL fAll);
extern void RemoveSelectedHacks(HWND hwnd);
extern void UpdateHackState(HWND hwnd, CHack *pHack);
extern void DisplayHackProperties(HWND hwnd);
extern void InterpretHackState(CHack *pHack, LPCSTR &pszState,
int &nImageIndex);
/*
* toolbar.cpp
*/
extern HWND CreateToolbar();
extern void EnableHackButtons(HWND hwnd, BOOL fEnable);
extern void EnableRemoveAllButton(HWND hwnd, BOOL fEnable);
/*
* datfile.cpp
*/
extern BOOL LoadDatFile(LPCSTR pszFileName);
extern BOOL SaveDatFile(LPCSTR pszFileName);
extern BOOL SkipToNextHack(FILE *fp, UINT &uLine);
extern int ParseLine(LPSTR pszLine, LPSTR pszWord[], int nMaxWords);
/*
* registry.cpp
*/
extern BOOL LoadCurrentWindowPositions();
extern BOOL SaveCurrentWindowPositions(HWND hwndMain, HWND hwndLV);
extern BOOL LoadNotifyFlags();
extern BOOL SaveNotifyFlags();
extern HKEY OpenRegistry();
/*
* utils.cpp
*/
extern BOOL GetDlgItemHex(HWND hwndDlg, int nItemId, LPCSTR pszItemText,
DWORD &dwValue);
extern BOOL SetDlgItemHex(HWND hwndDlg, int nItemId, DWORD dwValue);
extern int MsgBox(UINT uType, LPCSTR pszFmt, ...);
extern BOOL GetFileName(LPSTR pszBuffer, DWORD dwBufLen, LPCSTR pszFilter,
LPCSTR pszDefExt, BOOL fSave);
extern LPSTR BinToAscii(LPBYTE pBuffer, DWORD dwBufLen);
extern BOOL ParseHexValue(LPCSTR pszString, DWORD &dwValue);
extern DWORD ParseHexData(LPCSTR pszString, LPBYTE pBuffer, DWORD dwBufLen);
extern BOOL ParseHexDigit(LPCSTR pszString, BYTE &Byte);
extern DWORD GetErrorText(DWORD dwErrorCode, LPTSTR pszBuffer, DWORD dwBufLen);
extern LPCSTR GetLastErrorText();
/*
* debug.cpp
*/
extern void MyTrace(LPCSTR pszFmt, ...);
extern void MyAssert(LPCSTR pszFile, unsigned uLine, LPCSTR pszExpr);
#ifdef _DEBUG
#define TRACE MyTrace
#define ASSERT(f) if (!(f)) MyAssert(__FILE__, __LINE__, #f)
#define VERIFY(f) if (!(f)) MyAssert(__FILE__, __LINE__, #f)
#else /* !_DEBUG */
#define ASSERT(f) ((void)0)
#define VERIFY(f) ((void)(f))
#define TRACE 1 ? (void)0 : MyTrace
#endif /* _DEBUG */
/*
* data.cpp
*/
extern char g_szCreatingDatfiles[];
extern char g_szSofticeCodes[];
extern char g_szDiabloNotRunningMsg[];
extern char g_szDangerousCommandMsg[];
#endif /* _DIABHACK_H_ */