From aee6d1d35618e78431cf3d8d65503bd0d4a30c12 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 9 Mar 2016 20:38:13 +0100 Subject: [PATCH] Fix protected data segment bug --- src/Utils/Hooking.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Utils/Hooking.cpp b/src/Utils/Hooking.cpp index e887bca0..0405de47 100644 --- a/src/Utils/Hooking.cpp +++ b/src/Utils/Hooking.cpp @@ -120,7 +120,12 @@ namespace Utils void Hook::SetString(void* place, const char* string, size_t length) { + DWORD oldProtect; + VirtualProtect(place, length + 1, PAGE_EXECUTE_READWRITE, &oldProtect); + strncpy(static_cast(place), string, length); + + VirtualProtect(place, length + 1, oldProtect, &oldProtect); } void Hook::SetString(DWORD place, const char* string, size_t length)