bool
protectMemory(size_t address, size_t size, ProtectFlags flags)
{
   auto baseAddress = reinterpret_cast<LPVOID>(address);
   DWORD oldProtect;
   auto result = VirtualProtect(baseAddress, size, flagsToPageProtect(flags), &oldProtect);
   return (result != 0);
}
bool
commitMemory(size_t address, size_t size, ProtectFlags flags)
{
   auto baseAddress = reinterpret_cast<LPVOID>(address);
   auto result = VirtualAlloc(baseAddress, size, MEM_COMMIT, flagsToPageProtect(flags));

   if (result != baseAddress) {
      return false;
   }

   return true;
}
bool
protectMemory(uintptr_t address,
              size_t size,
              ProtectFlags flags)
{
   auto baseAddress = reinterpret_cast<LPVOID>(address);
   DWORD oldProtect;

   if (!VirtualProtect(baseAddress, size, flagsToPageProtect(flags), &oldProtect)) {
      gLog->error("protectMemory(address: 0x{:X}, size: 0x{:X}, flags: {}) failed with error: {}",
                  address, size, static_cast<int>(flags), GetLastError());
      return false;
   }

   return true;
}
bool
commitMemory(uintptr_t address,
             size_t size,
             ProtectFlags flags)
{
   auto baseAddress = reinterpret_cast<LPVOID>(address);
   auto result = VirtualAlloc(baseAddress,
                              size,
                              MEM_COMMIT,
                              flagsToPageProtect(flags));

   if (result != baseAddress) {
      gLog->error("commitMemory(address: 0x{:X}, size: 0x{:X}, flags: {}) failed with error: {}",
                  address, size, static_cast<int>(flags), GetLastError());
      return false;
   }

   return true;
}