如下所示,使用std:ventor组装atWxid,应该是处理有误,导致消息奔溃,应该如何改进?
struct WxBaseStruct
{
wchar_t* buffer;
DWORD length;
DWORD maxLength;
DWORD fill1;
DWORD fill2;
WxBaseStruct(wchar_t* pStr) {
buffer = pStr;
length = wcslen(pStr);
maxLength = wcslen(pStr) * 2;
fill1 = 0x0;
fill2 = 0x0;
}
};
void __stdcall SendTextAt(wchar_t* groupWxid, wchar_t* atWxid, wchar_t* atNickname, wchar_t* content) {
//组装文本内容
wchar_t tempmsg[500] = { 0 };
swprintf_s(tempmsg, L"@%s %s", atNickname, content);
MessageBox(NULL, tempmsg, TEXT("Title"), MB_YESNO);
// 结构体
WxBaseStruct wxGroupWxid(groupWxid);
WxBaseStruct wxAtWxid(atWxid);
WxBaseStruct wxTextMsg(tempmsg);
// at结构体:数组
std::vector<WxBaseStruct> pAllAtWxid;
pAllAtWxid.push_back(wxAtWxid);
char buffer[0x81C] = { 0 };
DWORD dllBaseAddress = GetWeChatWinBase();
DWORD callAddress = dllBaseAddress + SendTextCallOffset;
__asm {
pushad;
lea eax, pAllAtWxid;
push 0x1;
push eax;
mov edi, wxTextMsg;
push edi;
lea edx, wxGroupWxid;
lea ecx, buffer;
call callAddress;
add esp, 0xC;
popad;
}
}
|