diff --git a/src/Prospect.Agent/SDK.h b/src/Prospect.Agent/SDK.h index 86cea59..d79019e 100644 --- a/src/Prospect.Agent/SDK.h +++ b/src/Prospect.Agent/SDK.h @@ -48,13 +48,21 @@ namespace SDK { FString(const wchar_t* other) { - Max = Count = *other ? std::wcslen(other) + 1 : 0; + const size_t charLen = std::wcslen(other); - if (Count) + if (charLen == 0) { - Data = static_cast(GMalloc->Malloc(Count)); - - wcscpy_s(Data, Count, other); + Count = 0; + Max = 0; + Data = nullptr; + } + else + { + Count = charLen + 1; + Max = Count; + Data = static_cast((*GMalloc)->Malloc(Count * 2)); + + memcpy(Data, other, charLen * 2); } } diff --git a/src/Prospect.Agent/SDK_Memory.h b/src/Prospect.Agent/SDK_Memory.h index af651a9..8927b14 100644 --- a/src/Prospect.Agent/SDK_Memory.h +++ b/src/Prospect.Agent/SDK_Memory.h @@ -75,5 +75,5 @@ namespace SDK virtual const TCHAR* GetDescriptiveName() = 0; }; - FMalloc* GMalloc; + FMalloc** GMalloc; } diff --git a/src/Prospect.Agent/main.cpp b/src/Prospect.Agent/main.cpp index 1351fd4..d22c5c3 100644 --- a/src/Prospect.Agent/main.cpp +++ b/src/Prospect.Agent/main.cpp @@ -38,10 +38,7 @@ DWORD WINAPI OnDllAttach(LPVOID base) const auto hModulePtr = reinterpret_cast(hModule); // Initialize GMalloc. - do - { - SDK::GMalloc = *reinterpret_cast(hModulePtr + OffsetGMalloc); - } while (SDK::GMalloc == nullptr); + SDK::GMalloc = reinterpret_cast(hModulePtr + OffsetGMalloc); // Initialize MinHook. if (MH_Initialize() != MH_OK)