Add function to convert float to hexadecimal littel endian

This commit is contained in:
2025-09-04 10:56:29 +02:00
parent 766a20760b
commit 4a181c63e0
2 changed files with 14 additions and 0 deletions

View File

@@ -12,6 +12,13 @@
static std::shared_ptr<spdlog::logger> _log; static std::shared_ptr<spdlog::logger> _log;
std::unordered_map<void*, Memory::PatchInfo> Memory::patches; std::unordered_map<void*, Memory::PatchInfo> 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) void Memory::PatchBytes(void* address, const char* bytes, size_t len)
{ {
auto it = patches.find(address); auto it = patches.find(address);

View File

@@ -13,6 +13,13 @@ Memory::WriteInstructions(allocMemory, INSTRUCTIONS, sizeof INSTRUCTIONS, ADDRES
class Memory class Memory
{ {
public: 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. * Patch x bytes in memory.
* *