diff --git a/WeChatFerry/com/util.cpp b/WeChatFerry/com/util.cpp index e52790c..273a1bd 100644 --- a/WeChatFerry/com/util.cpp +++ b/WeChatFerry/com/util.cpp @@ -8,6 +8,7 @@ #include #include +#include "log.h" #include "util.h" #pragma comment(lib, "shlwapi") @@ -296,3 +297,23 @@ void DbgMsg(const char *zcFormat, ...) OutputDebugStringA(strText.c_str()); } + +WxString *NewWxStringFromStr(const string &str) { return NewWxStringFromWstr(String2Wstring(str)); } + +WxString *NewWxStringFromWstr(const wstring &ws) +{ + WxString *p = (WxString *)HeapAlloc(GetProcessHeap(), 0, sizeof(WxString)); + wchar_t *pWstring = (wchar_t *)HeapAlloc(GetProcessHeap(), 0, (ws.size() + 1) * 2); + if (p == NULL || pWstring == NULL) { + LOG_ERROR("Out of Memory..."); + return NULL; + } + + wmemcpy(pWstring, ws.c_str(), ws.size() + 1); + p->wptr = pWstring; + p->size = (DWORD)ws.size(); + p->capacity = (DWORD)ws.size(); + p->ptr = 0; + p->clen = 0; + return p; +} diff --git a/WeChatFerry/com/util.h b/WeChatFerry/com/util.h index 8339464..00e50bb 100644 --- a/WeChatFerry/com/util.h +++ b/WeChatFerry/com/util.h @@ -2,6 +2,8 @@ #include +#include "spy_types.h" + #define WECHAREXE L"WeChat.exe" #define WECHATWINDLL L"WeChatWin.dll" #define WCFSDKDLL L"sdk.dll" @@ -34,3 +36,5 @@ std::string GetStringByAddress(UINT64 address); std::string GetStringByStrAddr(UINT64 addr); std::string GetStringByWstrAddr(UINT64 addr); void DbgMsg(const char *zcFormat, ...); +WxString *NewWxStringFromStr(const std::string &str); +WxString *NewWxStringFromWstr(const std::wstring &ws);