Utils.cpp 360 B

12345678910111213
  1. #include "Utils.h"
  2. #include <Windows.h>
  3. void InjectCode(void* address, const std::vector<uint8_t> data)
  4. {
  5. const size_t byteCount = data.size() * sizeof(uint8_t);
  6. DWORD oldProtect;
  7. VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect);
  8. memcpy(address, data.data(), byteCount);
  9. VirtualProtect(address, byteCount, oldProtect, nullptr);
  10. }