2019-02-22 16:50:45 +00:00
|
|
|
/** \file CutterCommon.h
|
|
|
|
* This file contains any definition that is useful in the whole project.
|
|
|
|
* For example, it may contain custom types (RVA, ut64), list iterators, etc.
|
|
|
|
*/
|
|
|
|
#ifndef CUTTERCORE_H
|
|
|
|
#define CUTTERCORE_H
|
|
|
|
|
|
|
|
#include "r_core.h"
|
2019-03-08 23:01:24 +00:00
|
|
|
#include <QString>
|
2019-02-22 16:50:45 +00:00
|
|
|
|
|
|
|
// Workaround for compile errors on Windows
|
|
|
|
#ifdef _WIN32
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
#endif //_WIN32
|
|
|
|
|
|
|
|
// radare2 list iteration macros
|
|
|
|
#define CutterRListForeach(list, it, type, x) \
|
|
|
|
if (list) for (it = list->head; it && ((x=static_cast<type*>(it->data))); it = it->n)
|
|
|
|
|
|
|
|
#define CutterRVectorForeach(vec, it, type) \
|
|
|
|
if ((vec) && (vec)->a) \
|
|
|
|
for (it = (type *)(vec)->a; (char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); it = (type *)((char *)it + (vec)->elem_size))
|
|
|
|
|
|
|
|
// Global information for Cutter
|
|
|
|
#define APPNAME "Cutter"
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Type to be used for all kinds of addresses/offsets in r2 address space.
|
2019-02-22 16:50:45 +00:00
|
|
|
*/
|
|
|
|
typedef ut64 RVA;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Maximum value of RVA. Do NOT use this for specifying invalid values, use RVA_INVALID instead.
|
2019-02-22 16:50:45 +00:00
|
|
|
*/
|
|
|
|
#define RVA_MAX UT64_MAX
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Value for specifying an invalid RVA.
|
2019-02-22 16:50:45 +00:00
|
|
|
*/
|
|
|
|
#define RVA_INVALID RVA_MAX
|
|
|
|
|
|
|
|
inline QString RAddressString(RVA addr)
|
|
|
|
{
|
|
|
|
return QString::asprintf("%#010llx", addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QString RSizeString(RVA size)
|
|
|
|
{
|
2019-05-16 12:05:12 +00:00
|
|
|
return QString::asprintf("%#llx", size);
|
2019-02-22 16:50:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline QString RHexString(RVA size)
|
|
|
|
{
|
|
|
|
return QString::asprintf("%#llx", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CUTTERCORE_H
|
|
|
|
|