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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
#ifndef _COMMONHEADERS_H
#define _COMMONHEADERS_H
//=====================================================
// Includes
//=====================================================
#include <tchar.h>
#include <Windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <io.h>
#include <time.h>
#include <stddef.h>
#include <shlwapi.h>
#include <process.h>
#include <string.h>
#include <win2k.h>
#include <malloc.h>
#include <newpluginapi.h>
#include <m_utils.h>
#include <m_clist.h>
#include <m_clui.h>
#include <m_skin.h>
#include <m_langpack.h>
#include <m_database.h>
#include <m_db_int.h>
#include <m_system.h>
#include <m_protocols.h>
#include <m_userinfo.h>
#include <m_options.h>
#include <m_protosvc.h>
#include <m_popup.h>
#include <m_icolib.h>
#include <m_hotkeys.h>
#include <m_string.h>
#include <m_metacontacts.h>
#include "m_toptoolbar.h"
#include "resource.h"
#include "Version.h"
//=======================================================
// Definitions
//=======================================================
#define modname "DBEditorpp"
#define modFullname "Database Editor++"
#define msg(a) MessageBox(hwnd2mainWindow,a,_A2T(modFullname),MB_OK)
#define dlg(a,b) MessageBox(hwnd2mainWindow,a,_A2T(modFullname),b)
#define FLD_SIZE 256
#define MSG_SIZE 256
#define NAME_SIZE 128
#define WM_FINDITEM (WM_USER + 1) // onyl for the main window, wparam is ItemIfno* lparam is 0
/***********************
ModuleTreeInfoStruct
this gets dumped as the lparam for each module tree item
************************/
// types
#define CONTACT_ROOT_ITEM 0
#define CONTACT 1
#define MODULE 2
#define STUB 4
#define EMPTY 8
struct ModuleTreeInfoStruct {
int type; // from above types
MCONTACT hContact;
};
struct SettingListInfo {
MCONTACT hContact;
int selectedItem; // item that is currently selected
char module[FLD_SIZE];
// for edit
HWND hwnd2Edit;
char setting[FLD_SIZE];
int subitem;
};
struct DBsetting {
MCONTACT hContact;
char *module;
char *setting;
DBVARIANT dbv;
};
typedef struct {
char module[FLD_SIZE];
MCONTACT hContact;
} ModuleAndContact;
// find window
#define FW_MODULE 0
#define FW_SETTINGNAME 1
#define FW_SETTINGVALUE 2
typedef struct {
int type; // above types
MCONTACT hContact;
char module[FLD_SIZE];
char setting[FLD_SIZE];
} ItemInfo;
// watchwindow
struct WatchListArrayStruct {
struct DBsetting *item; // gotta malloc this
int count;
int size;
};
// module setting enum
struct ModSetLinkLinkItem
{
char *name;
ModSetLinkLinkItem *next;
};
struct ModuleSettingLL
{
ModSetLinkLinkItem *first;
ModSetLinkLinkItem *last;
};
struct ColumnsSettings {
TCHAR *name;
int index;
char *dbname;
int defsize;
};
struct ColumnsSortParams {
HWND hList;
int column;
int last;
};
enum ICONS {
IMAGE_EMPTY,
IMAGE_BINARY,
IMAGE_BYTE,
IMAGE_WORD,
IMAGE_DWORD,
IMAGE_STRING,
IMAGE_UNICODE,
IMAGE_HANDLE,
IMAGE_SETTINGS,
IMAGE_CLOSED,
IMAGE_OPENED,
IMAGE_CONTACTS,
IMAGE_ONLINE,
IMAGE_OFFLINE
};
//=======================================================
// Variables
//=======================================================
extern HINSTANCE hInst;
extern HWND hwnd2mainWindow;
extern int g_Mode;
extern int g_Hex;
extern int g_Order;
extern int g_Inline;
extern MCONTACT hRestore;
extern MIDatabase *g_db;
extern BOOL bServiceMode;
extern BOOL usePopups;
#define NAMEORDERCOUNT 8
#define MODE_UNLOADED 1
#define MODE_LOADED 2
#define MODE_ALL 3
#define HEX_BYTE 1
#define HEX_WORD 2
#define HEX_DWORD 4
#ifdef _UNICODE
#define GetValue(a,b,c,d,e) GetValueW(a,b,c,d,e)
#else
#define GetValue(a,b,c,d,e) GetValueA(a,b,c,d,e)
#endif
//main
char *StringFromBlob(BYTE *blob, WORD len);
int WriteBlobFromString(MCONTACT hContact, const char *module, const char *setting, const char *value, int len);
TCHAR *DBVType(BYTE type);
DWORD getNumericValue(DBVARIANT *dbv);
int setNumericValue(MCONTACT hContact, const char *module, const char *setting, DWORD value, int type);
int IsRealUnicode(TCHAR *value);
int setTextValue(MCONTACT hContact, const char *module, const char *setting, TCHAR *value, int type);
int GetValueA(MCONTACT hContact, const char *module, const char *setting, char *value, int length);
int GetValueW(MCONTACT hContact, const char *module, const char *setting, WCHAR *value, int length);
int GetContactName(MCONTACT hContact, const char *proto, TCHAR *value, int maxlen);
int ApplyProtoFilter(MCONTACT hContact);
void loadListSettings(HWND hwnd, ColumnsSettings *cs);
void saveListSettings(HWND hwnd, ColumnsSettings *cs);
INT_PTR CALLBACK ColumnsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam);
// main_window
void openMainWindow();
// deletemodules
int deleteModule(MCONTACT hContact, const char *module, int confirm);
void deleteModuleDlg();
// renamemodule
int renameModule(MCONTACT hContact, const char *oldName, const char *newName);
void renameModuleDlg();
void addModuleDlg(MCONTACT hContact);
// moduletree
void insertItem(MCONTACT hContact, const char *module, HTREEITEM hParent);
HTREEITEM findItemInTree(MCONTACT hContact, const char *module);
void replaceTreeItem(MCONTACT hContact, const char *module, const char *newModule);
void refreshTree(BOOL restore);
void freeTree(MCONTACT hContact);
// settinglist
int ListView_GetItemTextA(HWND hwndLV, int i, int iSubItem, char *pszText, int cchTextMax);
int ListView_SetItemTextA(HWND hwndLV, int i, int iSubItem, const char *pszText);
void ClearListView();
void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *setting);
void addListHandle(MCONTACT hContact);
void PopulateSettings(MCONTACT hContact, const char *module);
void SelectSetting(const char *setting);
void settingChanged(MCONTACT hContact, const char *module, const char *setting, DBVARIANT *dbv);
// settingsdlg
void editSetting(MCONTACT hContact, const char *module, const char *setting);
void copySetting(MCONTACT hContact, const char *module, const char *setting);
void newSetting(MCONTACT hContact, const char *module, int type);
// exportimport
void exportDB(MCONTACT hContact, const char *module); // hContact == -1 export entire db. module == NULL export entire contact
void ImportSettingsMenuItem(MCONTACT hContact);
void ImportSettingsFromFileMenuItem(MCONTACT hContact, const char *filePath); // ansi!
// find window
void newFindWindow();
// copymodule
void copyModuleMenuItem(MCONTACT hContact, const char *module);
void copyModule(const char *module, MCONTACT hContactFrom, MCONTACT hContactTo);
int CloneContact(MCONTACT hContact);
// options
int OptInit(WPARAM wParam, LPARAM lParam);
// watchedvars
int WatchedArrayIndex(MCONTACT hContact, const char *module, const char *setting, int strict);
int addSettingToWatchList(MCONTACT hContact, const char *module, const char *setting);
void freeWatchListItem(int item);
void PopulateWatchedWindow();
void freeAllWatches();
void openWatchedVarWindow();
void popupWatchedVar(MCONTACT hContact, const char *module, const char *setting);
// modsettingenum
int EnumModules(ModuleSettingLL *msll);
int EnumSettings(MCONTACT hContact, const char *module, ModuleSettingLL *msll);
void FreeModuleSettingLL(ModuleSettingLL *msll);
int IsModuleEmpty(MCONTACT hContact, const char *module);
int LoadResidentSettings();
void FreeResidentSettings();
int IsResidentSetting(const char *module, const char *setting);
int EnumResidentSettings(const char *module, ModuleSettingLL *msll);
int EnumResidentModules(ModuleSettingLL *msll);
int fixResidentSettings();
// icons
HANDLE GetIcoLibHandle(int icon);
void IcoLibRegister();
HICON LoadSkinnedDBEIcon(int icon);
HIMAGELIST LoadIcons();
int GetProtoIconIndex(const char *proto);
#endif //_COMMONHEADERS_H
|