-
Notifications
You must be signed in to change notification settings - Fork 6
/
Highlightfish.cpp
302 lines (265 loc) · 9.3 KB
/
Highlightfish.cpp
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
299
300
301
302
#include <windows.h>
#include <stdio.h>
//----------------- From original plugin PDK (begin) -----------------//
#define PLUG_EXP __declspec(dllexport)
#define PLUG_IMP __declspec(dllimport)
//default structure alignments forced
#ifdef _WIN64
#pragma pack(push, 16)
#else //x86
#pragma pack(push, 8)
#endif //_WIN64
//defines
#define PLUG_SDKVERSION 1
//structures
typedef struct {
//provided by the debugger
int pluginHandle;
//provided by the pluginit function
int sdkVersion;
int pluginVersion;
char pluginName[256];
} PLUG_INITSTRUCT;
typedef struct {
//provided by the debugger
HWND hwndDlg; //gui window handle
int hMenu; //plugin menu handle
int hMenuDisasm; //plugin disasm menu handle
int hMenuDump; //plugin dump menu handle
int hMenuStack; //plugin stack menu handle
} PLUG_SETUPSTRUCT;
//callback structures
typedef struct {
const char *szFileName;
} PLUG_CB_INITDEBUG;
typedef struct {
int hEntry;
} PLUG_CB_MENUENTRY;
//enums
typedef enum {
CB_INITDEBUG, //PLUG_CB_INITDEBUG
CB_STOPDEBUG, //PLUG_CB_STOPDEBUG
CB_CREATEPROCESS, //PLUG_CB_CREATEPROCESS
CB_EXITPROCESS, //PLUG_CB_EXITPROCESS
CB_CREATETHREAD, //PLUG_CB_CREATETHREAD
CB_EXITTHREAD, //PLUG_CB_EXITTHREAD
CB_SYSTEMBREAKPOINT, //PLUG_CB_SYSTEMBREAKPOINT
CB_LOADDLL, //PLUG_CB_LOADDLL
CB_UNLOADDLL, //PLUG_CB_UNLOADDLL
CB_OUTPUTDEBUGSTRING, //PLUG_CB_OUTPUTDEBUGSTRING
CB_EXCEPTION, //PLUG_CB_EXCEPTION
CB_BREAKPOINT, //PLUG_CB_BREAKPOINT
CB_PAUSEDEBUG, //PLUG_CB_PAUSEDEBUG
CB_RESUMEDEBUG, //PLUG_CB_RESUMEDEBUG
CB_STEPPED, //PLUG_CB_STEPPED
CB_ATTACH, //PLUG_CB_ATTACHED (before attaching, after CB_INITDEBUG)
CB_DETACH, //PLUG_CB_DETACH (before detaching, before CB_STOPDEBUG)
CB_DEBUGEVENT, //PLUG_CB_DEBUGEVENT (called on any debug event)
CB_MENUENTRY, //PLUG_CB_MENUENTRY
CB_WINEVENT, //PLUG_CB_WINEVENT
CB_WINEVENTGLOBAL, //PLUG_CB_WINEVENTGLOBAL
CB_LOADDB, //PLUG_CB_LOADSAVEDB
CB_SAVEDB, //PLUG_CB_LOADSAVEDB
CB_FILTERSYMBOL, //PLUG_CB_FILTERSYMBOL
CB_TRACEEXECUTE, //PLUG_CB_TRACEEXECUTE
CB_SELCHANGED, //PLUG_CB_SELCHANGED
CB_ANALYZE, //PLUG_CB_ANALYZE
CB_ADDRINFO, //PLUG_CB_ADDRINFO
CB_VALFROMSTRING, //PLUG_CB_VALFROMSTRING
CB_VALTOSTRING, //PLUG_CB_VALTOSTRING
CB_LAST
} CBTYPE;
typedef enum {
FORMAT_ERROR, //generic failure (no message)
FORMAT_SUCCESS, //success
FORMAT_ERROR_MESSAGE, //formatting failed but an error was put in the buffer (there are always at least 511 characters available).
FORMAT_BUFFER_TOO_SMALL //buffer too small (x64dbg will retry until the buffer is big enough)
} FORMATRESULT;
//typedefs
typedef void (*CBPLUGIN)(CBTYPE cbType, void *callbackInfo);
//exports
#ifdef __cplusplus
extern "C" {
#endif
PLUG_IMP void _plugin_registercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin);
PLUG_IMP bool _plugin_unregistercallback(int pluginHandle, CBTYPE cbType);
PLUG_IMP bool _plugin_menuaddentry(int hMenu, int hEntry, const char *title);
PLUG_IMP bool _plugin_menuaddseparator(int hMenu);
PLUG_IMP bool _plugin_menuclear(int hMenu);
#ifdef __cplusplus
}
#endif
#pragma pack(pop)
//----------------- From original plugin PDK (end) -----------------//
//----------------- Highlightfish plugin core (begin) -----//
#include "ColorSchemeName.h"
#include "GrayAngelfishScheme.h"
#include "WhiteAngelfishScheme.h"
#include "CypherScheme.h"
#include "DarkScheme.h"
#define PLUGIN_NAME "Highlightfish"
#define PLUGIN_VERSION 140
#define CYPHER_SCHEME_MENU 0
#define DARK_SCHEME_MENU 1
#define GRAY_ANGELFISH_SCHEME_MENU 2
#define WHITE_ANGELFISH_SCHEME_MENU 3
#define RESET_SCHEME_MENU 4
#define ABOUT_MENU 5
#ifdef _WIN64
#define INI_FILENAME ".\\x64dbg.ini"
#define DBG_FILENAME "x64dbg.exe"
#pragma comment(lib, "x64dbg.lib")
#else
#define INI_FILENAME ".\\x32dbg.ini"
#define DBG_FILENAME "x32dbg.exe"
#pragma comment(lib, "x32dbg.lib")
#endif
#define INI_SECTION_NAME "Colors"
#define COLOR_SCHEME_NAME_COUNT 199
int pluginHandle;
HWND hwndDlg;
int hMenu;
static void cbInitDebug(CBTYPE cbType, void *callbackInfo) {
PLUG_CB_INITDEBUG *info = (PLUG_CB_INITDEBUG *)callbackInfo;
}
bool ConfirmationMsg() {
if (MessageBoxA(hwndDlg,
"Set new Scheme and Restart the Debugger?\n\n"
"[YES] to Restart or [NO] to Cancel.\n",
"CONFIRMATION",
MB_YESNO | MB_ICONQUESTION) == IDYES)
return true;
else
return false;
}
void PluginStop() {
_plugin_unregistercallback(pluginHandle, CB_INITDEBUG);
_plugin_unregistercallback(pluginHandle, CB_MENUENTRY);
_plugin_menuclear(hMenu);
}
static void ExitDbg() {
WinExec(DBG_FILENAME, SW_SHOWNORMAL);
PluginStop();
ExitProcess(0);
}
static void cbMenuEntry(CBTYPE cbType, void *callbackInfo) {
PLUG_CB_MENUENTRY *info = (PLUG_CB_MENUENTRY *)callbackInfo;
switch(info->hEntry) {
case CYPHER_SCHEME_MENU: {
if (ConfirmationMsg() == true) {
for(unsigned long i = 0; i < COLOR_SCHEME_NAME_COUNT; ++i) {
WritePrivateProfileString(INI_SECTION_NAME,
ColorSchemeName[i],
CypherSchemeValue[i],
INI_FILENAME);
}
ExitDbg();
}
break;
}
case DARK_SCHEME_MENU: {
if (ConfirmationMsg() == true) {
for(unsigned long i = 0; i < COLOR_SCHEME_NAME_COUNT; ++i) {
WritePrivateProfileString(INI_SECTION_NAME,
ColorSchemeName[i],
DarkSchemeValue[i],
INI_FILENAME);
}
ExitDbg();
}
break;
}
case GRAY_ANGELFISH_SCHEME_MENU: {
if (ConfirmationMsg() == true) {
for(unsigned long i = 0; i < COLOR_SCHEME_NAME_COUNT; ++i) {
WritePrivateProfileString(INI_SECTION_NAME,
ColorSchemeName[i],
GrayAngelfishSchemeValue[i],
INI_FILENAME);
}
ExitDbg();
}
break;
}
case WHITE_ANGELFISH_SCHEME_MENU: {
if (ConfirmationMsg() == true) {
for(unsigned long i = 0; i < COLOR_SCHEME_NAME_COUNT; ++i) {
WritePrivateProfileString(INI_SECTION_NAME,
ColorSchemeName[i],
WhiteAngelfishSchemeValue[i],
INI_FILENAME);
}
ExitDbg();
}
break;
}
case RESET_SCHEME_MENU: {
if (ConfirmationMsg() == true) {
WritePrivateProfileString(INI_SECTION_NAME,
NULL,
NULL,
INI_FILENAME);
ExitDbg();
}
break;
}
case ABOUT_MENU: {
MessageBoxA(hwndDlg,
"Highlightfish v1.40 Build Date 29/08/2017 \n"
"Released by Insid3Code Team\n\n"
"C)2014-2017 I3CT",
"About",
MB_ICONINFORMATION);
break;
}
break;
}
}
void PluginInit(PLUG_INITSTRUCT *initStruct) {
_plugin_registercallback(pluginHandle, CB_INITDEBUG, cbInitDebug);
_plugin_registercallback(pluginHandle, CB_MENUENTRY, cbMenuEntry);
}
void PluginSetup() {
_plugin_menuaddentry(hMenu, CYPHER_SCHEME_MENU, "&Cypher Scheme...");
_plugin_menuaddentry(hMenu, DARK_SCHEME_MENU, "&Dark Scheme...");
_plugin_menuaddseparator(hMenu);
_plugin_menuaddentry(hMenu, GRAY_ANGELFISH_SCHEME_MENU, "&GrayAngelFish Scheme...");
_plugin_menuaddentry(hMenu, WHITE_ANGELFISH_SCHEME_MENU, "&WhiteAngelFish Scheme...");
_plugin_menuaddseparator(hMenu);
_plugin_menuaddentry(hMenu, RESET_SCHEME_MENU, "&Reset Default Scheme...");
_plugin_menuaddseparator(hMenu);
_plugin_menuaddentry(hMenu, ABOUT_MENU, "&About...");
}
extern "C" {
PLUG_EXP bool pluginit(PLUG_INITSTRUCT *initStruct) {
initStruct->pluginVersion = PLUGIN_VERSION;
initStruct->sdkVersion = PLUG_SDKVERSION;
strcpy_s(initStruct->pluginName, PLUGIN_NAME);
pluginHandle = initStruct->pluginHandle;
PluginInit(initStruct);
return true;
}
PLUG_EXP bool plugstop() {
PluginStop();
return true;
}
PLUG_EXP void plugsetup(PLUG_SETUPSTRUCT *setupStruct) {
hwndDlg = setupStruct->hwndDlg;
hMenu = setupStruct->hMenu;
PluginSetup();
}
}
//----------------- Highlightfish plugin core (end) -----//
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}