forked from yegord/snowman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdaFrontend.h
192 lines (159 loc) · 5.46 KB
/
IdaFrontend.h
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
/* The file is part of Snowman decompiler. */
/* See doc/licenses.asciidoc for the licensing information. */
/* * SmartDec decompiler - SmartDec is a native code to C/C++ decompiler
* Copyright (C) 2015 Alexander Chernov, Katerina Troshina, Yegor Derevenets,
* Alexander Fokin, Sergey Levin, Leonid Tsvetkov
*
* This file is part of SmartDec decompiler.
*
* SmartDec decompiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SmartDec decompiler 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 SmartDec decompiler. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <nc/config.h>
#include <functional>
#include <utility> /* For std::pair. */
#include <vector>
#include <QString>
#include <nc/common/ByteOrder.h>
#include <nc/common/RangeClass.h>
#include <nc/common/Types.h>
#include <nc/core/image/Platform.h>
QT_BEGIN_NAMESPACE
class QApplication;
class QWidget;
QT_END_NAMESPACE
QT_USE_NAMESPACE
namespace nc {
namespace core {
namespace image {
class Image;
}
}
namespace ida {
typedef Range<ByteAddr> AddressRange;
/**
* This class exposes some of IDA functionality while not polluting the global
* namespace with IDA includes.
*/
class IdaFrontend {
public:
/**
* \param[in] address Address to move cursor in IDA code view to.
*
* \return True on success, false otherwise.
*/
static bool jumpToAddress(ByteAddr address);
/**
* \param[in] address Address of a function.
* \returns Mangled name of a function starting at
* the given address.
*/
static QString functionName(ByteAddr address);
/**
* \param[in] address Address.
* \returns Name for the given address, or empty string
* if the given address does not have a name.
*/
static QString addressName(ByteAddr address);
/**
* \returns Addresses and names of imported functions.
*/
static std::vector<std::pair<ByteAddr, QString> > importedFunctions();
/**
* \returns Addresses of all function starts.
*/
static std::vector<ByteAddr> functionStarts();
/**
* \param[in] mangled Mangled name.
* \returns Demangled name.
*/
static QString demangle(const QString &mangled);
/**
* \returns The name of the archtecture of the current binary.
*/
static QString architecture();
/**
* \returns The byte order of the currently opened executable.
*/
static ByteOrder byteOrder();
/**
* \returns The operating system of the current binary.
*/
static core::image::Platform::OperatingSystem operatingSystem();
/**
* Converts the current image file to nc's internal representation.
*
* \param[in, out] image Valid pointer to the executable file image.
*/
static void createSections(core::image::Image *image);
/**
* \param[in] address Any address in a function.
* \returns All address ranges of a function, including function's tail chunks.
*/
static std::vector<AddressRange> functionAddresses(ByteAddr address);
/**
* \returns The current address of a screen cursor.
*/
static ByteAddr screenAddress();
struct MenuItem;
/**
* Adds a menu item in the IDA's UI.
*
* param[in] path Path to the menu into which the item must be inserted.
* param[in] name Name of the menu item.
* param[in] after Name of the menu item after which to insert the item.
* param[in] hotkey Hotkey for the menu item.
* param[in] handler The function to be called when the user selects the menu item.
*
* \returns A valid pointer to an opaque object to be passed to deleteMenuItem().
*/
static MenuItem *addMenuItem(
const QString &path,
const QString &name,
const QString &after,
const QString &hotkey,
std::function<void()> handler);
/**
* Deletes a menu item in the IDA's UI.
*
* param[in] menuItem Valid pointer to the menu item to delete.
*/
static void deleteMenuItem(MenuItem *menuItem);
/**
* Prints a message to IDA console.
*/
static void print(const QString &message);
/**
* Creates a child MDI widget using IDA's API.
*
* \param caption Title of the widget.
*
* \return Valid pointer to the created widget.
*/
static QWidget *createWidget(const QString &caption);
/**
* Switches focus to the given widget.
*
* \param widget Valid pointer to the IDA's widget.
*/
static void activateWidget(QWidget *widget);
/**
* Closes given IDA's widget.
*
* \param widget Valid pointer to the IDA's widget.
*/
static void closeWidget(QWidget *widget);
};
}} // namespace nc::ida
/* vim:set et sts=4 sw=4: */