diff --git a/Memory/Memory.cpp b/Memory/Memory.cpp index ed92598..aa06225 100644 --- a/Memory/Memory.cpp +++ b/Memory/Memory.cpp @@ -12,6 +12,13 @@ static std::shared_ptr _log; std::unordered_map Memory::patches; + +const char* Memory::Float32ToHexBytes(float value) { + static char bytes[4]; // buffer persistant (évite les problèmes de scope) + std::memcpy(bytes, &value, sizeof(float)); + return bytes; // pointeur vers les 4 octets bruts +} + void Memory::PatchBytes(void* address, const char* bytes, size_t len) { auto it = patches.find(address); diff --git a/Memory/Memory.hpp b/Memory/Memory.hpp index 73c16ff..b93aca6 100644 --- a/Memory/Memory.hpp +++ b/Memory/Memory.hpp @@ -13,6 +13,13 @@ Memory::WriteInstructions(allocMemory, INSTRUCTIONS, sizeof INSTRUCTIONS, ADDRES class Memory { public: + /** + * Converts flkoat 32 bits into a char*. + * + * @param value : The value to encode. + */ + static const char* Float32ToHexBytes(float value); + /** * Patch x bytes in memory. *