| 180 | |
| 181 | template<typename T> |
| 182 | void WriteModuleRVA(HMODULE Module, LONG RVA, T Data) { |
| 183 | if (!RVA) { |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | void* Address = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(Module) + RVA); |
| 188 | void* ProtAddress = Address; |
| 189 | SIZE_T ProtSize = sizeof(T); |
| 190 | ULONG Prot; |
| 191 | NtProtectVirtualMemoryNative(NtCurrentProcess(), &ProtAddress, &ProtSize, PAGE_READWRITE, &Prot); |
| 192 | *reinterpret_cast<T*>(Address) = Data; |
| 193 | NtProtectVirtualMemoryNative(NtCurrentProcess(), &ProtAddress, &ProtSize, Prot, nullptr); |
| 194 | } |
| 195 | |
| 196 | void PatchCallChecker() { |
| 197 | // See the comment for CheckCall in Module.S for why this is necessary |