-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.cpp
More file actions
93 lines (76 loc) · 1.84 KB
/
misc.cpp
File metadata and controls
93 lines (76 loc) · 1.84 KB
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
#include "generator.h"
#include "misc.h"
#include "sigmaker.h"
// idasdk
#include <diskio.hpp>
#include <fpro.h>
#include <funcs.hpp>
Settings_t Settings;
void Settings_t::Save()
{
qstring path;
path.sprnt("%s\\" PLUGIN_NAME PLUGIN_VERSION ".bin", get_user_idadir());
FILE* file = qfopen(path.c_str(), "wb");
if (file)
{
qfwrite(file, this, sizeof(Settings_t));
qfclose(file);
}
}
void Settings_t::Load()
{
qstring path;
path.sprnt("%s\\" PLUGIN_NAME PLUGIN_VERSION ".bin", get_user_idadir());
FILE* file = qfopen(path.c_str(), "rb");
if (file)
{
qfread(file, this, sizeof(Settings_t));
qfclose(file);
}
else
{
this->Save();
}
}
void Stage(const char* text)
{
static const char CHAR = '=';
static const int WIDTH = 64;
size_t len = strlen(text);
if (WIDTH <= len)
{
msg("%s\n", text);
return;
}
size_t total = WIDTH - len,
left = total / 2,
right = total - left;
msg("%s%s%s\n", qstring(left, CHAR).c_str(), text, qstring(right, CHAR).c_str());
}
bool SigRange(qstring& outSig)
{
twinpos_t pos1, pos2;
if (!read_selection(get_current_viewer(), &pos1, &pos2))
return false;
ea_t start = pos1.at->toea(),
end = pos2.at->toea() + 1;
if (end - start < SIG_MIN_LEN)
{
msg("Your selection is too short\n");
return false;
}
insn_t ins;
func_item_iterator_t iter;
iter.set_range(start, end);
ea_t current = iter.current();
while ((current = iter.current()) != BADADDR && decode_insn(&ins, current) != 0)
{
if (ins.size < 5)
AddBytesToSig(outSig, current, ins.size);
else
AddInsToSig(&ins, outSig);
if (iter.next_not_tail() == false)
break;
}
return true;
}