1 /** \file CutterCommon.h
2  * This file contains any definition that is useful in the whole project.
3  * For example, it may contain custom types (RVA, ut64), list iterators, etc.
4  */
5 #ifndef CUTTERCORE_H
6 #define CUTTERCORE_H
7 
8 #include "r_core.h"
9 #include <QString>
10 
11 // Workaround for compile errors on Windows
12 #ifdef Q_OS_WIN
13 #undef min
14 #undef max
15 #endif // Q_OS_WIN
16 
17 // radare2 list iteration macros
18 #define CutterRListForeach(list, it, type, x) \
19     if (list) for (it = list->head; it && ((x=static_cast<type*>(it->data))); it = it->n)
20 
21 #define CutterRVectorForeach(vec, it, type) \
22 	if ((vec) && (vec)->a) \
23 		for (it = (type *)(vec)->a; (char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); it = (type *)((char *)it + (vec)->elem_size))
24 
25 // Global information for Cutter
26 #define APPNAME "Cutter"
27 
28 /**
29  * @brief Type to be used for all kinds of addresses/offsets in r2 address space.
30  */
31 typedef ut64 RVA;
32 
33 /**
34  * @brief Maximum value of RVA. Do NOT use this for specifying invalid values, use RVA_INVALID instead.
35  */
36 #define RVA_MAX UT64_MAX
37 
38 /**
39  * @brief Value for specifying an invalid RVA.
40  */
41 #define RVA_INVALID RVA_MAX
42 
RAddressString(RVA addr)43 inline QString RAddressString(RVA addr)
44 {
45     return QString::asprintf("%#010llx", addr);
46 }
47 
RSizeString(RVA size)48 inline QString RSizeString(RVA size)
49 {
50     return QString::asprintf("%#llx", size);
51 }
52 
RHexString(RVA size)53 inline QString RHexString(RVA size)
54 {
55     return QString::asprintf("%#llx", size);
56 }
57 
58 #ifdef CUTTER_SOURCE_BUILD
59 #define CUTTER_EXPORT Q_DECL_EXPORT
60 #else
61 #define CUTTER_EXPORT Q_DECL_IMPORT
62 #endif
63 
64 
65 #if defined(__has_cpp_attribute)
66     #if __has_cpp_attribute(deprecated)
67         #define CUTTER_DEPRECATED(msg) [[deprecated(msg)]]
68     #endif
69 #endif
70 #if !defined(CUTTER_DEPRECATED)
71 #define CUTTER_DEPRECATED(msg)
72 #endif
73 
74 #endif // CUTTERCORE_H
75 
76