22static uint8_t
const gMmapCode[] = {
23 0x48, 0xc7, 0xc0, 0x00, 0x00, 0x00, 0x00,
25 0x48, 0xc7, 0xc6, 0x00, 0x00, 0x00, 0x00,
26 0x48, 0xc7, 0xc2, 0x00, 0x00, 0x00, 0x00,
27 0x49, 0xc7, 0xc2, 0x00, 0x00, 0x00, 0x00,
28 0x49, 0xc7, 0xc0, 0xff, 0xff, 0xff, 0xff,
34static uint8_t
const gMunmapCode[] = {
35 0x48, 0xc7, 0xc0, 0x00, 0x00, 0x00, 0x00,
36 0x48, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x48, 0xc7, 0xc6, 0x00, 0x00, 0x00, 0x00,
44static inline void PrepareMmapCode(
size_t size,
int protection,
45 ByteVector &codestr) {
46 codestr.assign(&gMmapCode[0], &gMmapCode[
sizeof(gMmapCode)]);
48 uint8_t *code = &codestr[0];
49 *
reinterpret_cast<uint32_t *
>(code + 0x03) = 9;
50 *
reinterpret_cast<uint32_t *
>(code + 0x0d) = size;
51 *
reinterpret_cast<uint32_t *
>(code + 0x14) = protection;
52 *
reinterpret_cast<uint32_t *
>(code + 0x1b) = MAP_ANON | MAP_PRIVATE;
55static inline void PrepareMunmapCode(uint64_t address,
size_t size,
56 ByteVector &codestr) {
57 codestr.assign(&gMunmapCode[0], &gMunmapCode[
sizeof(gMunmapCode)]);
59 uint8_t *code = &codestr[0];
60 *
reinterpret_cast<uint32_t *
>(code + 0x03) = 11;
61 *
reinterpret_cast<uint64_t *
>(code + 0x09) = address;
62 *
reinterpret_cast<uint32_t *
>(code + 0x14) = size;