-
Notifications
You must be signed in to change notification settings - Fork 2
/
pluginmain.cpp
216 lines (188 loc) · 4.3 KB
/
pluginmain.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
/**
* @file
* Sets up plugin structures and forwards plugin notifications from Ollydbg.
*/
#include <cstring>
#include <windows.h>
#include <ollydbg.h>
#include "FireFly.h"
#include "Dialogs.h"
extern HMODULE g_Instance; // in dllmain.cpp
const wchar_t PLUGINNAME[SHORTNAME] = L"FireFly";
const int MINOLLYDBGVERSION = 201;
FireFly* FF_instance = NULL;
int Menu_Run(t_table* pt, wchar_t* name, ulong index, int mode);
int Menu_About(t_table* pt, wchar_t* name, ulong index, int mode);
t_menu mainmenu[] =
{
{
L"FireFly",
L"Start FireFly",
K_NONE, &Menu_Run, NULL, 0
},
{
L"|About",
L"About Firefly",
K_NONE, &Menu_About, NULL, 0
},
{
NULL, NULL, K_NONE, NULL, NULL, 0
}
};
int Menu_Run(t_table* pt, wchar_t* name, ulong index, int mode)
{
switch(mode)
{
case MENU_VERIFY:
return MENU_NORMAL;
case MENU_EXECUTE:
{
DlgMain main(g_Instance, _hwollymain, *FF_instance);
main.modal();
}
return MENU_NOREDRAW;
default:
return MENU_ABSENT;
}
}
int Menu_About(t_table* pt, wchar_t* name, ulong index, int mode)
{
switch(mode)
{
case MENU_VERIFY:
return MENU_NORMAL;
case MENU_EXECUTE:
{
DlgAbout about(g_Instance, _hwollymain);
about.modal();
}
return MENU_NOREDRAW;
default:
return MENU_ABSENT;
}
}
/**
* Called when Ollydbg loads this plugin and requests information.
*
* @param ollydbgversion
* The version of this instance of Ollydbg.
* @param pluginname
* String buffer that should hold the plugin name on return.
* @param pluginversion
* String buffer that should hold the plugin version on return.
*
* @return
* The supported plugin version, should always be PLUGIN_VERSION.
* 0 to report an error and abort loading the plugin.
*/
extc _export int cdecl ODBG2_Pluginquery(int ollydbgversion, wchar_t pluginname[SHORTNAME], wchar_t pluginversion[SHORTNAME])
{
// plugin load
if(ollydbgversion < MINOLLYDBGVERSION)
return 0;
FF_instance = new FireFly(g_Instance, _hwollymain);
wcscpy(pluginname, PLUGINNAME);
wcscpy(pluginversion, FireFly::VERSION);
return PLUGIN_VERSION;
}
/**
* Called by Ollydbg to ask us to add ourselves to the plugin menu.
*
* @param type
*
* @return
* Pointer to an array of t_menu items, terminated by an empty t_menu.
* NULL if we don't add any items.
*/
extc _export t_menu* cdecl ODBG2_Pluginmenu(wchar_t* type)
{
if(!wcscmp(type, PWM_MAIN))
return mainmenu;
//else if(!wcscmp(type, PWM_DISASM))
// return disasmmenu;
return NULL;
}
/**
* Called when Ollydbg encounters a debug event in the debugged process.
*
* This information comes from the main Windows debug loop.
* Not all events are reported if command emulation is active, use ODBG2_Pluginexception in that case.
* Only use this callback if you need to as it may have an impact on speed.
*
* This callback is optional.
*
* @param debugevent
*/
extc void _export cdecl ODBG2_Pluginmainloop(DEBUG_EVENT* debugevent)
{
}
/**
* Called when Ollydbg encounters an exception.
*
* @param preg
*/
extc void _export cdecl ODBG2_Pluginexception(t_reg* preg)
{
}
/**
* Called when Ollydbg finished analysis of a module.
*
* This callback is optional.
*
* @param pmod
*/
extc void _export cdecl ODBG2_Pluginanalyse(t_module* pmod)
{
}
/**
* Called when Ollydbg is about to save internal data to a .udd file.
*
* @param psave
* @param pmod
* @param ismainmodule
*/
extc void _export cdecl ODBG2_Pluginsaveudd(t_uddsave* psave, t_module* pmod, int ismainmodule)
{
}
/**
* Called when Ollydbg finds data belonging to this plugin in a .udd file.
*
* The data submitted may be corrupted or incomplete. Don't rely on its correctness.
*
* @param pmod
* @param ismainmodule
* @param tag
* @param size
* @param data
*/
extc void _export cdecl ODBG2_Pluginuddrecord(t_module* pmod, int ismainmodule, ulong tag, ulong size, void* data)
{
// check pointers and size
}
/**
* Called when a process was (re)started.
*/
extc void _export cdecl ODBG2_Pluginreset()
{
}
/**
* Called when Ollydbg is requesting to quit.
*
* This callback is optional.
*
* @return
* 0 if it's safe to quit, non-0 to abort termination.
*/
extc int _export cdecl ODBG2_Pluginclose()
{
return 0;
}
/**
* Called when Ollydbg is about to quit.
*/
extc void _export cdecl ODBG2_Plugindestroy()
{
//FF_instance->close();
delete FF_instance;
FF_instance = NULL;
}