From 50e53d36fa032f199cf40875e8a310acd10d85f5 Mon Sep 17 00:00:00 2001 From: Changhua Date: Tue, 28 Feb 2023 20:40:12 +0800 Subject: [PATCH] Refactoring --- spy/send_msg.cpp | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/spy/send_msg.cpp b/spy/send_msg.cpp index 8570ab7..8cd9e2c 100644 --- a/spy/send_msg.cpp +++ b/spy/send_msg.cpp @@ -38,33 +38,25 @@ void SendTextMessage(string wxid, string msg, string atWxids) txtWxid.size = wsWxid.size(); txtWxid.capacity = wsWxid.capacity(); + vector vTxtAtWxids; if (!atWxids.empty()) { - int i = 0; - wstring tmp = String2Wstring(atWxids); - wstring wstr; vector vAtWxids; - wstringstream wss(tmp); + wstringstream wss(String2Wstring(atWxids)); while (wss.good()) { + wstring wstr; getline(wss, wstr, L','); vAtWxids.push_back(wstr); + TextStruct_t txtAtWxid = { 0 }; + txtAtWxid.text = (wchar_t *)vAtWxids.back().c_str(); + txtAtWxid.size = vAtWxids.back().size(); + txtAtWxid.capacity = vAtWxids.back().capacity(); + vTxtAtWxids.push_back(txtAtWxid); } - tsArray = new TextStruct_t[vAtWxids.size() + 1]; - // memset(tsArray, 0, (vAtWxids.size() + 1) * sizeof(TextStruct_t)); - for (auto it = vAtWxids.begin(); it != vAtWxids.end(); it++) { - tsArray[i].text = (wchar_t *)it->c_str(); - tsArray[i].size = it->size(); - tsArray[i].capacity = it->capacity(); - i++; - } - - atList.start = (DWORD)tsArray; - atList.end1 = (DWORD)&tsArray[i]; - atList.end2 = (DWORD)&tsArray[i]; } __asm { - lea eax, atList; + lea eax, vTxtAtWxids; push 0x01; push eax; lea edi, txtMsg; @@ -74,12 +66,6 @@ void SendTextMessage(string wxid, string msg, string atWxids) call sendCallAddress; add esp, 0xC; } - - if (tsArray) - { - delete[] tsArray; - tsArray = NULL; - } } void SendImageMessage(string wxid, string path)