-
Notifications
You must be signed in to change notification settings - Fork 26
/
options.cpp
97 lines (70 loc) · 2.05 KB
/
options.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
/*
Patchdiff2
Portions (C) 2010 - 2011 Nicolas Pouvesle
Portions (C) 2007 - 2009 Tenable Network Security, Inc.
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. If not, see <http://www.gnu.org/licenses/>.
*/
#include "precomp.hpp"
#include "options.hpp"
#include "system.hpp"
static bool idaapi pdiff_menu_callback(void *ud)
{
ushort option = 0, prev = 0;
options_t * opt = (options_t *)ud;
const char format[] =
"STARTITEM 0\n"
"PatchDiff2 options\n"
"<##Settings #>\n"
"<#Uses 'pipe' with the second IDA instance to speed up graph display#Keep second IDB open :C>\n"
"<#Saves PatchDiff2 results into the current IDB#Save results to IDB :C>>\n\n"
;
option |= opt->ipc ? 1 : 0;
option |= opt->save_db ? 2 : 0;
prev = opt->ipc;
if (AskUsingForm_c(format, &option))
{
opt->ipc = !!(option & 1);
opt->save_db = !!(option & 2);
if (prev && !option)
ipc_close();
}
return true;
}
options_t * options_init()
{
options_t * opt;
int ipc, db;
opt = (options_t *)qalloc(sizeof(*opt));
if (!opt) return NULL;
if (system_get_pref("IPC", (void *)&ipc, SPREF_INT))
opt->ipc = !!ipc;
else
opt->ipc = true;
if (system_get_pref("DB", (void *)&db, SPREF_INT))
opt->save_db = !!db;
else
opt->save_db = true;
add_menu_item("Options/", "PatchDiff2", NULL, SETMENU_APP, pdiff_menu_callback, opt);
return opt;
}
void options_close(options_t * opt)
{
del_menu_item("Options/PatchDiff2");
if (opt) qfree(opt);
}
bool options_use_ipc(options_t * opt)
{
return opt->ipc;
}
bool options_save_db(options_t * opt)
{
return opt->save_db;
}