Add function to convert float to hexadecimal littel endian
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
static std::shared_ptr<spdlog::logger> _log;
|
||||
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)
|
||||
{
|
||||
auto it = patches.find(address);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user