| 25 | uint8_t opcodes[16]; |
| 26 | #endif |
| 27 | Shellcode(intptr_t addr) |
| 28 | { |
| 29 | memset(opcodes, 0, sizeof(opcodes)); |
| 30 | #if OS_WIN |
| 31 | // movabs rax [addr] |
| 32 | opcodes[0] = 0x48; |
| 33 | opcodes[1] = 0xB8; |
| 34 | memcpy(&opcodes[2], &addr, sizeof(intptr_t)); |
| 35 | // push rax |
| 36 | opcodes[10] = 0x50; |
| 37 | // ret |
| 38 | opcodes[11] = 0xC3; |
| 39 | #elif OS_MAC |
| 40 | // jmp qword ptr [rip + offset] ; pad 2 |
| 41 | opcodes[0] = 0xFF; |
| 42 | opcodes[1] = 0x25; |
| 43 | memset(&opcodes[2], 0, sizeof(int32_t)); |
| 44 | memcpy(&opcodes[6], &addr, sizeof(intptr_t)); |
| 45 | #endif |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | struct Restorable |
nothing calls this directly
no outgoing calls
no test coverage detected