diff options
| author | auth12 <[email protected]> | 2020-07-24 10:56:14 -0700 |
|---|---|---|
| committer | auth12 <[email protected]> | 2020-07-24 10:56:14 -0700 |
| commit | e487ffe1671ba807528d4039ef66f8f8f7eeb853 (patch) | |
| tree | c65cc4dd529f8e37f9cca81d38c749dece13a574 /client/src/util/util.cpp | |
| parent | Injection and server changes. (diff) | |
| download | loader-e487ffe1671ba807528d4039ef66f8f8f7eeb853.tar.xz loader-e487ffe1671ba807528d4039ef66f8f8f7eeb853.zip | |
Injection process changes and server improvements.
Diffstat (limited to 'client/src/util/util.cpp')
| -rw-r--r-- | client/src/util/util.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/client/src/util/util.cpp b/client/src/util/util.cpp index 3dba550..b79f6cd 100644 --- a/client/src/util/util.cpp +++ b/client/src/util/util.cpp @@ -7,45 +7,37 @@ std::unordered_map<std::string, pe::virtual_image> util::loaded_modules; std::string util::wide_to_multibyte(const std::wstring& str) { std::string ret; - int32_t str_len; + size_t str_len; // check if not empty str if (str.empty()) return{}; // count size - str_len = WideCharToMultiByte(CP_UTF8, 0, &str[0], (int32_t)str.size(), 0, 0, 0, 0); + str_len = WideCharToMultiByte(CP_UTF8, 0, &str[0], str.size(), 0, 0, 0, 0); // setup return value ret = std::string(str_len, 0); // final conversion - WideCharToMultiByte(CP_UTF8, 0, &str[0], (int32_t)str.size(), &ret[0], str_len, 0, 0); + WideCharToMultiByte(CP_UTF8, 0, &str[0], str.size(), &ret[0], str_len, 0, 0); return ret; } -std::wstring util::multibyte_to_wide(const std::string &str) { - std::wstring ret; - int32_t size; - wchar_t *wstr; - const char *buf = str.c_str(); +std::wstring util::multibyte_to_wide(const std::string& str) { + size_t size; + std::wstring out; // get size - size = MultiByteToWideChar(CP_UTF8, 0, buf, int32_t(strlen(buf) + 1), 0, 0); + size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.size() + 1, 0, 0); - // alloc new wchars - wstr = new wchar_t[size]; + out.resize(size); // finally convert - MultiByteToWideChar(CP_UTF8, 0, buf, int32_t(strlen(buf) + 1), wstr, size); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.size() + 1, &out[0], size); - // construct return string - ret = std::wstring(wstr); - - // cleanup - delete[] wstr; - return ret; + return out; } |