diff --git a/CWeChatRobot/FriendList.cpp b/CWeChatRobot/FriendList.cpp index 287bee9cc3a49a18f5576a637da3b55d35c8ff30..3e2907bd65e5cebf44620ab45641517c5e563927 100644 --- a/CWeChatRobot/FriendList.cpp +++ b/CWeChatRobot/FriendList.cpp @@ -70,6 +70,12 @@ void ReadFriendMessageByAddress(WxFriendAddrStruct* lpWxFriendAddr, WxFriendStru ZeroMemory(lpWxFriend->wxRemark, sizeof(wchar_t) * (length + 1)); ReadProcessMemory(hProcess, (LPCVOID)lpWxFriendAddr->wxRemarkAddr, &bufferaddr, sizeof(DWORD), 0); ReadProcessMemory(hProcess, (LPCVOID)bufferaddr, lpWxFriend->wxRemark, length * sizeof(wchar_t), 0); + wstring wswxRemark = wreplace(lpWxFriend->wxRemark,L'\"',L"\\\""); + delete[] lpWxFriend->wxRemark; + lpWxFriend->wxRemark = new wchar_t[wswxRemark.length() + 1]; + ZeroMemory(lpWxFriend->wxRemark, sizeof(wchar_t) * (wswxRemark.length() + 1)); + memcpy(lpWxFriend->wxRemark, wswxRemark.c_str(), wswxRemark.length() * 2); + wcout << lpWxFriend->wxRemark << endl; } } else { diff --git a/CWeChatRobot/pch.cpp b/CWeChatRobot/pch.cpp index 802dfa8d6f056b6f0de14cbed96c3d87019efbad..1fe5b2092f013566c8d7963099cbc999a795243d 100644 --- a/CWeChatRobot/pch.cpp +++ b/CWeChatRobot/pch.cpp @@ -32,7 +32,7 @@ bool isFileExists_stat(string& name) { return (stat(name.c_str(), &buffer) == 0); } -BOOL CreateConsole(void) { +BOOL CreateConsole() { if (AllocConsole()) { AttachConsole(GetCurrentProcessId()); FILE* retStream; @@ -169,4 +169,17 @@ wstring GetComWorkPath() { int pos = wpath.find_last_of(L"\\"); wpath = wpath.substr(0,pos); return wpath; +} + +wstring wreplace(wstring source, wchar_t replaced, wstring replaceto) { + wstring temp = L""; + wchar_t* buffer = (wchar_t*)source.c_str(); + for (unsigned int i = 0; i < source.length(); i++) { + if (buffer[i] == replaced) { + temp += replaceto; + continue; + } + temp += buffer[i]; + } + return temp; } \ No newline at end of file diff --git a/CWeChatRobot/pch.h b/CWeChatRobot/pch.h index 73c70bf3ab18016c45ef61a16de11c8b776244a2..cc930da9cbbde0e4538c88ad6bf631b012b1e77e 100644 --- a/CWeChatRobot/pch.h +++ b/CWeChatRobot/pch.h @@ -34,5 +34,6 @@ DWORD GetWeChatRobotBase(); DWORD GetWeChatPid(); DWORD StartRobotService(); DWORD StopRobotService(); -BOOL CreateConsole(void); -wstring GetComWorkPath(); \ No newline at end of file +BOOL CreateConsole(); +wstring GetComWorkPath(); +wstring wreplace(wstring source, wchar_t replaced, wstring replaceto); \ No newline at end of file diff --git a/DWeChatRobot/SelfInfo.cpp b/DWeChatRobot/SelfInfo.cpp index 66138101a2aab7171e750e0bfa068037068667e1..9d95de813afb5064caf15118e76e9ecaf5e2c41c 100644 --- a/DWeChatRobot/SelfInfo.cpp +++ b/DWeChatRobot/SelfInfo.cpp @@ -59,7 +59,8 @@ DWORD GetSelfInfoRemote() { wchar_t* wtemp = new wchar_t[strlen(temp) + 1]; ZeroMemory(wtemp, (strlen(temp) + 1) * 2); MultiByteToWideChar(CP_UTF8, 0, temp, -1, wtemp, strlen(temp) + 1); - selfinfo = selfinfo + wtemp; + wstring wrtemp = wreplace(wtemp,L'\"',L"\\\""); + selfinfo = selfinfo + wrtemp; selfinfo = selfinfo + L"\""; if(i!= SelfInfoAddr.size() - 1) selfinfo = selfinfo + L","; diff --git a/DWeChatRobot/UserInfo.cpp b/DWeChatRobot/UserInfo.cpp index 27f3f4feaa9b419e0c16d4cd96815b4165bf56f9..5f218349dc7a08974867038c52b2271180d16c11 100644 --- a/DWeChatRobot/UserInfo.cpp +++ b/DWeChatRobot/UserInfo.cpp @@ -24,6 +24,7 @@ VOID WxUserInfo(DWORD address) { address + 0x10, address + 0x24, address + 0x38, + address + 0x58, address + 0x6C, address + 0xFC, address + 0x110, @@ -37,6 +38,7 @@ VOID WxUserInfo(DWORD address) { (WCHAR*)L"\"wxId\"", (WCHAR*)L"\"wxNumber\"", (WCHAR*)L"\"wxV3\"", + (WCHAR*)L"\"wxRemark\"", (WCHAR*)L"\"wxNickName\"", (WCHAR*)L"\"wxBigAvatar\"", (WCHAR*)L"\"wxSmallAvatar\"", @@ -49,7 +51,8 @@ VOID WxUserInfo(DWORD address) { wUserInfo += L"{"; for (unsigned int i = 0; i < InfoType.size(); i++) { wchar_t* wstemp = ((*((DWORD*)InfoType[i])) != 0) ? (WCHAR*)(*((LPVOID*)InfoType[i])) : (WCHAR*)L"null"; - wUserInfo = wUserInfo + InfoTypeName[i] + L":\"" + wstemp + L"\""; + wstring wsrtemp = wreplace(wstemp,L'\"',L"\\\""); + wUserInfo = wUserInfo + InfoTypeName[i] + L":\"" + wsrtemp + L"\""; if (i != InfoType.size() - 1) { wUserInfo += L","; } diff --git a/DWeChatRobot/pch.cpp b/DWeChatRobot/pch.cpp index b7a83825c465bd672a22b015609ff8304c0378c1..7298de51514ef3b27e9f1e0bcebf222590d268ff 100644 --- a/DWeChatRobot/pch.cpp +++ b/DWeChatRobot/pch.cpp @@ -65,4 +65,17 @@ void UnHookAnyAddress(DWORD dwHookAddr, char* originalRecieveCode) void UnHookAll() { UnHookLogMsgInfo(); return; +} + +wstring wreplace(wstring source, wchar_t replaced, wstring replaceto) { + wstring temp = L""; + wchar_t* buffer = (wchar_t*)source.c_str(); + for (unsigned int i = 0; i < source.length(); i++) { + if (buffer[i] == replaced) { + temp += replaceto; + continue; + } + temp += buffer[i]; + } + return temp; } \ No newline at end of file diff --git a/DWeChatRobot/pch.h b/DWeChatRobot/pch.h index 213d7e7cf93f5b5b0ce6ed1617cb2ca69fc1d766..d3a6383d489430a61305b918c8997b703f07d0cc 100644 --- a/DWeChatRobot/pch.h +++ b/DWeChatRobot/pch.h @@ -59,3 +59,4 @@ void Wchar_tToString(std::string& szDst, wchar_t* wchar); void HookAnyAddress(DWORD dwHookAddr, LPVOID dwJmpAddress, char* originalRecieveCode); void UnHookAnyAddress(DWORD dwHookAddr, char* originalRecieveCode); DLLEXPORT void UnHookAll(); +wstring wreplace(wstring source, wchar_t replaced, wstring replaceto); diff --git a/Release/CWeChatRobot.exe b/Release/CWeChatRobot.exe index be8417b3810006a0b0ad2b3fb68b08cc50c4b5b1..f9c8f5c114ab3987854b66369300f9b19dc06da1 100644 Binary files a/Release/CWeChatRobot.exe and b/Release/CWeChatRobot.exe differ diff --git a/Release/DWeChatRobot.dll b/Release/DWeChatRobot.dll index cefe23fd874e314094dea2e5535e91b27b97ca14..43536dde33e1e7441a53ec169d4e6f2e401fbe86 100644 Binary files a/Release/DWeChatRobot.dll and b/Release/DWeChatRobot.dll differ diff --git a/wxRobot.py b/wxRobot.py index 16dbb9cf536a8c220000a6ebd65e851c2e5948bf..ab608035056b1820e2afbc9edd626ece067b9fe3 100644 --- a/wxRobot.py +++ b/wxRobot.py @@ -189,5 +189,4 @@ def test_FriendStatus(): wx.StopService() if __name__ == '__main__': - test_SendText() - + test_SendText() \ No newline at end of file