22static uint8_t
const gMmapCode[] = {
23 0xb8, 0x00, 0x00, 0x00, 0x00,
25 0xb9, 0x00, 0x00, 0x00, 0x00,
26 0xba, 0x00, 0x00, 0x00, 0x00,
27 0xbe, 0x00, 0x00, 0x00, 0x00,
28 0xbf, 0xff, 0xff, 0xff, 0xff,
34static uint8_t
const gMunmapCode[] = {
35 0xb8, 0x00, 0x00, 0x00, 0x00,
36 0xbb, 0x00, 0x00, 0x00, 0x00,
37 0xb9, 0x00, 0x00, 0x00, 0x00,
43static inline void PrepareMmapCode(
size_t size,
int protection,
44 ByteVector &codestr) {
45 codestr.assign(&gMmapCode[0], &gMmapCode[
sizeof(gMmapCode)]);
47 uint8_t *code = &codestr[0];
48 *
reinterpret_cast<uint32_t *
>(code + 0x01) = 192;
49 *
reinterpret_cast<uint32_t *
>(code + 0x08) = size;
50 *
reinterpret_cast<uint32_t *
>(code + 0x0d) = protection;
51 *
reinterpret_cast<uint32_t *
>(code + 0x12) = MAP_ANON | MAP_PRIVATE;
54static inline void PrepareMunmapCode(uint32_t address,
size_t size,
55 ByteVector &codestr) {
56 codestr.assign(&gMunmapCode[0], &gMunmapCode[
sizeof(gMunmapCode)]);
58 uint8_t *code = &codestr[0];
59 *
reinterpret_cast<uint32_t *
>(code + 0x01) = 91;
60 *
reinterpret_cast<uint32_t *
>(code + 0x06) = address;
61 *
reinterpret_cast<uint32_t *
>(code + 0x0b) = size;