forked from jmpoep/vmprotect-3.5.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
objects.cc
39 lines (35 loc) · 831 Bytes
/
objects.cc
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
/**
* Support of object hierarchy.
*/
#include "objects.h"
#ifdef __APPLE__
#define _vsnprintf_s(dest, dest_sz, cnt, fmt, args) _vsnprintf((dest), (dest_sz), (fmt), (args))
#endif // __APPLE__
std::string string_format(const char *format, ...)
{
va_list args;
va_start(args, format);
int size = 100;
std::string res;
for (;;) {
res.resize(size);
va_start(args, format);
int n = _vsnprintf_s(&res[0], size, _TRUNCATE, format, args);
if (n > -1 && n < size) {
res.resize(n);
break;
}
if (n > -1)
size = n + 1;
else
size *= 2;
}
va_end(args);
return res;
}
int AddressableObject::CompareWith(const AddressableObject &other) const
{
if (address_ > other.address_) return 1;
if (address_ < other.address_) return -1;
return 0;
}