From 6f9fbb2a7d7cab322ae0ac5f2761cd562beb0f12 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Sat, 3 Dec 2022 20:04:48 +0100 Subject: [PATCH] Fix bug --- src/client/loader/loader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/loader/loader.cpp b/src/client/loader/loader.cpp index 950eeff2..4aecad81 100644 --- a/src/client/loader/loader.cpp +++ b/src/client/loader/loader.cpp @@ -144,6 +144,7 @@ namespace loader get_optional_header() ->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress); + auto* target_tls_start = PVOID(target_tls->StartAddressOfRawData); auto* tls_start = PVOID(source_tls->StartAddressOfRawData); const auto tls_size = source_tls->EndAddressOfRawData - source_tls->StartAddressOfRawData; const auto tls_index = *reinterpret_cast(target_tls->AddressOfIndex); @@ -156,11 +157,11 @@ namespace loader } DWORD old_protect; - VirtualProtect(tls_start, tls_size, PAGE_READWRITE, &old_protect); + VirtualProtect(target_tls_start, tls_size, PAGE_READWRITE, &old_protect); auto* const tls_base = *reinterpret_cast(__readgsqword(0x58) + 8ull * tls_index); std::memmove(tls_base, tls_start, tls_size); - std::memmove(PVOID(target_tls->StartAddressOfRawData), tls_start, tls_size); + std::memmove(target_tls_start, tls_start, tls_size); VirtualProtect(target_tls, sizeof(*target_tls), PAGE_READWRITE, &old_protect); *target_tls = *source_tls;