diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 0cd55c7..3da7df2 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -97,5 +97,20 @@ namespace ToolBox { return tmp; } + bool WritePString(uint32_t address, const std::string &s) + { + int length = s.length(); + if (length > 255) return false; + if (address == 0) return false; + + uint8_t *ptr = memoryPointer(address); + *ptr++ = (uint8_t)length; + for (char c : s) + { + *ptr++ = (uint8_t)c; + } + return true; + } + } \ No newline at end of file diff --git a/toolbox/toolbox.h b/toolbox/toolbox.h index 600391c..2800f4c 100644 --- a/toolbox/toolbox.h +++ b/toolbox/toolbox.h @@ -10,6 +10,8 @@ namespace ToolBox std::string ReadCString(uint32_t address); std::string ReadPString(uint32_t address); + bool WritePString(uint32_t address, const std::string &s); + }