| 92 | } |
| 93 | |
| 94 | bool vdm_ctx::valid_syscall(void* syscall_addr) const |
| 95 | { |
| 96 | static std::mutex syscall_mutex; |
| 97 | syscall_mutex.lock(); |
| 98 | |
| 99 | static const auto proc = |
| 100 | GetProcAddress( |
| 101 | LoadLibraryA(syscall_hook.second), |
| 102 | syscall_hook.first |
| 103 | ); |
| 104 | |
| 105 | // 0: 48 31 c0 xor rax, rax |
| 106 | // 3 : c3 ret |
| 107 | std::uint8_t shellcode[] = { 0x48, 0x31, 0xC0, 0xC3 }; |
| 108 | std::uint8_t orig_bytes[sizeof shellcode]; |
| 109 | |
| 110 | // save original bytes and install shellcode... |
| 111 | read_phys(syscall_addr, orig_bytes, sizeof orig_bytes); |
| 112 | write_phys(syscall_addr, shellcode, sizeof shellcode); |
| 113 | |
| 114 | auto result = reinterpret_cast<NTSTATUS(__fastcall*)(void)>(proc)(); |
| 115 | write_phys(syscall_addr, orig_bytes, sizeof orig_bytes); |
| 116 | syscall_mutex.unlock(); |
| 117 | return result == STATUS_SUCCESS; |
| 118 | } |
| 119 | } |
nothing calls this directly
no test coverage detected