diff --git a/CWeChatRobot/FriendList.h b/CWeChatRobot/FriendList.h index b730a90a92c4cf34bd553c91983a2a7b146c6ab6..9fba1970bb2a43d2e8f2e4108cd2491f8e752289 100644 --- a/CWeChatRobot/FriendList.h +++ b/CWeChatRobot/FriendList.h @@ -1,4 +1,5 @@ #pragma once #include - +#include +using namespace std; std::wstring GetFriendList(); \ No newline at end of file diff --git a/CWeChatRobot/UserInfo.cpp b/CWeChatRobot/UserInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a510e6d79fed467208ab01021e093429f98005dc --- /dev/null +++ b/CWeChatRobot/UserInfo.cpp @@ -0,0 +1,39 @@ +#include "pch.h" + +struct GetUserInfoStruct { + DWORD message; + DWORD length; +}; + +std::wstring GetWxUserInfo(wchar_t* wxid) { + wstring WString = L""; + DWORD GetUserInfoProcAddr = GetWeChatRobotBase() + GetWxUserInfoOffset; + LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE); + DWORD dwWriteSize = 0; + DWORD dwId = 0; + DWORD dwHandle = 0; + GetUserInfoStruct userinfo = { 0 }; + if (!wxidaddr) + return WString; + WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize); + HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetUserInfoProcAddr, wxidaddr, 0, &dwId); + if (hThread) { + WaitForSingleObject(hThread, INFINITE); + GetExitCodeThread(hThread, &dwHandle); + CloseHandle(hThread); + } + + if(dwHandle) + ReadProcessMemory(hProcess, (LPCVOID)dwHandle, &userinfo, sizeof(GetUserInfoStruct), &dwWriteSize); + if (userinfo.length) { + wchar_t* wmessage = new wchar_t[userinfo.length + 1]; + ZeroMemory(wmessage, (userinfo.length + 1) * 2); + ReadProcessMemory(hProcess, (LPCVOID)userinfo.message, wmessage, userinfo.length * 2, &dwWriteSize); + WString += wmessage; + delete[] wmessage; + wmessage = NULL; + } + + VirtualFreeEx(hProcess, wxidaddr, 0, MEM_RELEASE); + return WString; +} \ No newline at end of file diff --git a/CWeChatRobot/UserInfo.h b/CWeChatRobot/UserInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..5f02bcac820e35f88157bd4e0e801ede610f1d98 --- /dev/null +++ b/CWeChatRobot/UserInfo.h @@ -0,0 +1,5 @@ +#pragma once +#include +#include +using namespace std; +std::wstring GetWxUserInfo(wchar_t* wxid); \ No newline at end of file diff --git a/CWeChatRobot/WeChatRobot.cpp b/CWeChatRobot/WeChatRobot.cpp index 6be4e73b330f325e590c236b8c2111061b26aa60..9e52d753dfe6a35a75e133a6128a9b5d1cacfff5 100644 --- a/CWeChatRobot/WeChatRobot.cpp +++ b/CWeChatRobot/WeChatRobot.cpp @@ -59,4 +59,14 @@ STDMETHODIMP CWeChatRobot::CGetFriendList(BSTR* __result) { string smessage = _com_util::ConvertBSTRToString((BSTR)(GetFriendList().c_str())); *__result = _com_util::ConvertStringToBSTR(smessage.c_str()); return S_OK; +} + +/* +* 参数1:要查询的wxid +* 参数2:预返回的值,调用时无需提供 +*/ +STDMETHODIMP CWeChatRobot::CGetWxUserInfo(BSTR wxid,BSTR* __result) { + string smessage = _com_util::ConvertBSTRToString((BSTR)(GetWxUserInfo(wxid).c_str())); + *__result = _com_util::ConvertStringToBSTR(smessage.c_str()); + return S_OK; } \ No newline at end of file diff --git a/CWeChatRobot/WeChatRobot.h b/CWeChatRobot/WeChatRobot.h index 00aa2e294f1c07d99c01532380b69c1709f1592c..d51c6602803325431569900bd704b3a6f63d4817 100644 --- a/CWeChatRobot/WeChatRobot.h +++ b/CWeChatRobot/WeChatRobot.h @@ -57,6 +57,7 @@ public: STDMETHODIMP CSendText(BSTR wxid, BSTR wxmsg, int* __result); STDMETHODIMP CSendFile(BSTR wxid, BSTR filepath, int* __result); STDMETHODIMP CGetFriendList(BSTR* __result); + STDMETHODIMP CGetWxUserInfo(BSTR wxid, BSTR* __result); }; OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot) diff --git a/CWeChatRobot/WeChatRobotCOM.idl b/CWeChatRobot/WeChatRobotCOM.idl index 141ad98f1b8d478368b94360b27d094b1f4139c2..7a5c6777f03ca43e3647805708b9162f73a88b09 100644 --- a/CWeChatRobot/WeChatRobotCOM.idl +++ b/CWeChatRobot/WeChatRobotCOM.idl @@ -22,6 +22,7 @@ interface IWeChatRobot : IDispatch [id(4)] HRESULT CSendImage([in] BSTR wxid, [in] BSTR imagepath, [out, retval] int* __result); [id(5)] HRESULT CSendFile([in] BSTR wxid, [in] BSTR filepath, [out, retval] int* __result); [id(6)] HRESULT CGetFriendList([out, retval] BSTR* __result); + [id(7)] HRESULT CGetWxUserInfo([in] BSTR wxid, [out, retval] BSTR* __result); }; [ uuid(721abb35-141a-4aa2-94f2-762e2833fa6c), diff --git a/CWeChatRobot/WeChatRobotCOM.vcxproj b/CWeChatRobot/WeChatRobotCOM.vcxproj index ddf1220580aa65b6082a5840c39994e610f81756..06ff668ade1902be01b84be141c7d00cee43008e 100644 --- a/CWeChatRobot/WeChatRobotCOM.vcxproj +++ b/CWeChatRobot/WeChatRobotCOM.vcxproj @@ -221,6 +221,7 @@ + @@ -237,6 +238,7 @@ + diff --git a/CWeChatRobot/WeChatRobotCOM.vcxproj.filters b/CWeChatRobot/WeChatRobotCOM.vcxproj.filters index 2186321f4d798065989879f91f518994947a3cb5..50687b8608fa2156ae0868b80623212d9c6466e2 100644 --- a/CWeChatRobot/WeChatRobotCOM.vcxproj.filters +++ b/CWeChatRobot/WeChatRobotCOM.vcxproj.filters @@ -32,9 +32,15 @@ {eb0eba18-3b38-466c-8978-f7d0f2bb756e} - + + {19933e02-50d4-489c-823e-4e7fe6539792} + + {be3e55a9-dd57-4e92-a340-cb558f3cd4f7} + + {cdd9e8b4-4576-499c-b20e-60e05911f6d6} + @@ -68,7 +74,7 @@ 发送消息\发送文本 - 好友列表 + 好友相关\好友列表 发送消息\发送文件 @@ -76,6 +82,9 @@ 头文件 + + 好友相关\好友信息 + @@ -103,11 +112,14 @@ 发送消息\发送文本 - 好友列表 + 好友相关\好友列表 发送消息\发送文件 + + 好友相关\好友信息 + diff --git a/CWeChatRobot/WeChatRobotCOM_i.h b/CWeChatRobot/WeChatRobotCOM_i.h index 28cafe9b2172bfedf46d133c4c1864973ad02978..d327934ca8f7b96eea0a8aaee2b684a9705bbfaf 100644 --- a/CWeChatRobot/WeChatRobotCOM_i.h +++ b/CWeChatRobot/WeChatRobotCOM_i.h @@ -113,6 +113,10 @@ EXTERN_C const IID IID_IWeChatRobot; virtual /* [id] */ HRESULT STDMETHODCALLTYPE CGetFriendList( /* [retval][out] */ BSTR *__result) = 0; + virtual /* [id] */ HRESULT STDMETHODCALLTYPE CGetWxUserInfo( + /* [in] */ BSTR wxid, + /* [retval][out] */ BSTR *__result) = 0; + }; @@ -202,6 +206,11 @@ EXTERN_C const IID IID_IWeChatRobot; IWeChatRobot * This, /* [retval][out] */ BSTR *__result); + /* [id] */ HRESULT ( STDMETHODCALLTYPE *CGetWxUserInfo )( + IWeChatRobot * This, + /* [in] */ BSTR wxid, + /* [retval][out] */ BSTR *__result); + END_INTERFACE } IWeChatRobotVtbl; @@ -256,6 +265,9 @@ EXTERN_C const IID IID_IWeChatRobot; #define IWeChatRobot_CGetFriendList(This,__result) \ ( (This)->lpVtbl -> CGetFriendList(This,__result) ) +#define IWeChatRobot_CGetWxUserInfo(This,wxid,__result) \ + ( (This)->lpVtbl -> CGetWxUserInfo(This,wxid,__result) ) + #endif /* COBJMACROS */ diff --git a/CWeChatRobot/WeChatRobotCOM_p.c b/CWeChatRobot/WeChatRobotCOM_p.c index aecd1541dc60280c486c9cf8019993e5d7ed6764..51fef3ff38a5b2e9e168434ac23bc327961ce2bf 100644 --- a/CWeChatRobot/WeChatRobotCOM_p.c +++ b/CWeChatRobot/WeChatRobotCOM_p.c @@ -49,7 +49,7 @@ #include "WeChatRobotCOM_i.h" #define TYPE_FORMAT_STRING_SIZE 71 -#define PROC_FORMAT_STRING_SIZE 259 +#define PROC_FORMAT_STRING_SIZE 301 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 #define WIRE_MARSHAL_TABLE_SIZE 1 @@ -334,6 +334,42 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor /* 256 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ + /* Procedure CGetWxUserInfo */ + +/* 258 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 260 */ NdrFcLong( 0x0 ), /* 0 */ +/* 264 */ NdrFcShort( 0xd ), /* 13 */ +/* 266 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 268 */ NdrFcShort( 0x0 ), /* 0 */ +/* 270 */ NdrFcShort( 0x8 ), /* 8 */ +/* 272 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */ + 0x3, /* 3 */ +/* 274 */ 0x8, /* 8 */ + 0x47, /* Ext Flags: new corr desc, clt corr check, srv corr check, has range on conformance */ +/* 276 */ NdrFcShort( 0x1 ), /* 1 */ +/* 278 */ NdrFcShort( 0x1 ), /* 1 */ +/* 280 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter wxid */ + +/* 282 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ +/* 284 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 286 */ NdrFcShort( 0x26 ), /* Type Offset=38 */ + + /* Parameter __result */ + +/* 288 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */ +/* 290 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 292 */ NdrFcShort( 0x3c ), /* Type Offset=60 */ + + /* Return value */ + +/* 294 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 296 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 298 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + 0x0 } }; @@ -433,7 +469,8 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] = 78, 126, 174, - 222 + 222, + 258 }; static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo = @@ -457,7 +494,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo = 0, 0, 0}; -CINTERFACE_PROXY_VTABLE(13) _IWeChatRobotProxyVtbl = +CINTERFACE_PROXY_VTABLE(14) _IWeChatRobotProxyVtbl = { &IWeChatRobot_ProxyInfo, &IID_IWeChatRobot, @@ -473,7 +510,8 @@ CINTERFACE_PROXY_VTABLE(13) _IWeChatRobotProxyVtbl = (void *) (INT_PTR) -1 /* IWeChatRobot::CSendText */ , (void *) (INT_PTR) -1 /* IWeChatRobot::CSendImage */ , (void *) (INT_PTR) -1 /* IWeChatRobot::CSendFile */ , - (void *) (INT_PTR) -1 /* IWeChatRobot::CGetFriendList */ + (void *) (INT_PTR) -1 /* IWeChatRobot::CGetFriendList */ , + (void *) (INT_PTR) -1 /* IWeChatRobot::CGetWxUserInfo */ }; @@ -488,6 +526,7 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] = NdrStubCall2, NdrStubCall2, NdrStubCall2, + NdrStubCall2, NdrStubCall2 }; @@ -495,7 +534,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl = { &IID_IWeChatRobot, &IWeChatRobot_ServerInfo, - 13, + 14, &IWeChatRobot_table[-3], CStdStubBuffer_DELEGATING_METHODS }; diff --git a/CWeChatRobot/pch.cpp b/CWeChatRobot/pch.cpp index 2144f5c3f958fdac9e00f657e316eaf2af83cc81..2f7e4379164167b5e9ba7bc2040e8fdfa74935ba 100644 --- a/CWeChatRobot/pch.cpp +++ b/CWeChatRobot/pch.cpp @@ -9,6 +9,7 @@ DWORD SendFileOffset = 0x0; DWORD GetFriendListInitOffset = 0x0; DWORD GetFriendListRemoteOffset = 0x0; DWORD GetFriendListFinishOffset = 0x0; +DWORD GetWxUserInfoOffset = 0x0; HANDLE hProcess = NULL; @@ -83,6 +84,9 @@ void GetProcOffset(wchar_t* workPath) { DWORD GetFriendListFinishProcAddr = (DWORD)GetProcAddress(hd, GetFriendListFinish); GetFriendListFinishOffset = GetFriendListFinishProcAddr - WeChatBase; + DWORD GetWxUserInfoProcAddr = (DWORD)GetProcAddress(hd, GetWxUserInfoRemote); + GetWxUserInfoOffset = GetWxUserInfoProcAddr - WeChatBase; + FreeLibrary(hd); delete[] dllpath; dllpath = NULL; diff --git a/CWeChatRobot/robotdata.h b/CWeChatRobot/robotdata.h index 9889c2103bb4321ba1a6f023a845b712a69b077b..3cd8b3d26b716bd6397d0bf84513b260b0b7f3e1 100644 --- a/CWeChatRobot/robotdata.h +++ b/CWeChatRobot/robotdata.h @@ -4,6 +4,7 @@ #include "SendText.h" #include "SendFile.h" #include "FriendList.h" +#include "UserInfo.h" extern HANDLE hProcess; extern DWORD SendImageOffset; @@ -14,6 +15,8 @@ extern DWORD GetFriendListInitOffset; extern DWORD GetFriendListRemoteOffset; extern DWORD GetFriendListFinishOffset; +extern DWORD GetWxUserInfoOffset; + #define dllname L"DWeChatRobot.dll" #define SendTextRemote "SendTextRemote" @@ -22,4 +25,6 @@ extern DWORD GetFriendListFinishOffset; #define GetFriendListInit "GetFriendListInit" #define GetFriendListRemote "GetFriendListRemote" -#define GetFriendListFinish "GetFriendListFinish" \ No newline at end of file +#define GetFriendListFinish "GetFriendListFinish" + +#define GetWxUserInfoRemote "GetWxUserInfoRemote" \ No newline at end of file diff --git a/DWeChatRobot/DWeChatRobot.vcxproj b/DWeChatRobot/DWeChatRobot.vcxproj index 25d7438dfc4d6f3fb7082fbe192aaf916c526499..96b67a2f8488118dae2567cefb95048267b5ee4d 100644 --- a/DWeChatRobot/DWeChatRobot.vcxproj +++ b/DWeChatRobot/DWeChatRobot.vcxproj @@ -159,6 +159,7 @@ + @@ -174,6 +175,7 @@ + diff --git a/DWeChatRobot/DWeChatRobot.vcxproj.filters b/DWeChatRobot/DWeChatRobot.vcxproj.filters index 87583fe93c9ef90ad7a77065d550ffd2fe0962fa..c4cb5380d98bcb116f29fb4f58c337d7295f09eb 100644 --- a/DWeChatRobot/DWeChatRobot.vcxproj.filters +++ b/DWeChatRobot/DWeChatRobot.vcxproj.filters @@ -25,15 +25,21 @@ {069b8c09-e473-4bba-a49e-571f35f2efef} - - {24dc11dd-cb6a-4c63-bf21-35823cd389ab} - {25f77de8-b12c-4f2b-a3ac-0260b6a16897} {166b9e01-bc1c-4366-abcf-c14ec3fbbfb1} + + {8ad1ff87-550b-4942-8ebd-afbe1cfaddc9} + + + {24dc11dd-cb6a-4c63-bf21-35823cd389ab} + + + {564cc9ef-a939-4bfd-a420-a08b3072d198} + @@ -52,11 +58,14 @@ 发送消息\发送文件 - 好友列表 + 好友相关\好友列表 自动功能\聊天表情 + + 好友相关\好友信息 + @@ -75,13 +84,16 @@ 发送消息\发送文件 - 好友列表 + 好友相关\好友列表 自动功能\聊天表情 - 好友列表 + 好友相关\好友列表 + + + 好友相关\好友信息 \ No newline at end of file diff --git a/DWeChatRobot/UserInfo.cpp b/DWeChatRobot/UserInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8d6adf2e987840911e21225175a55ae583d43ae7 --- /dev/null +++ b/DWeChatRobot/UserInfo.cpp @@ -0,0 +1,177 @@ +#include "pch.h" +#include +#include +#include + +#define GetUserInfoCall1Offset 0x645BD9A0 - 0x64530000 +#define GetUserInfoCall2Offset 0x64C08420 - 0x64530000 +#define GetUserInfoCall3Offset 0x64914260 - 0x64530000 + +struct GetUserInfoStruct { + DWORD message; + DWORD length; +}; + +wstring wUserInfo = L""; +GetUserInfoStruct ret = { 0 }; + +struct GetDetailUserInfoStruct { + WxString* pWxString; + DWORD ptr1 = 0; + DWORD ptr2 = 0; + char fill[0x18] = { 0 }; + GetDetailUserInfoStruct(WxString* pWxString) { + this->pWxString = pWxString; + ptr1 = DWORD(pWxString) + sizeof(WxString); + ptr2 = DWORD(pWxString) + sizeof(WxString); + } +}; + +struct UserInfoBaseStruct { + DWORD data; + DWORD endbuffer1; + DWORD endbuffer2; + char fill[0x18] = { 0 }; +}; + + +VOID WxUserInfo(DWORD address) { + vector InfoType{ + address + 0x10, + address + 0x24, + address + 0x38, + address + 0x6C, + address + 0xFC, + address + 0x110, + address + 0x19C, + address + 0x1B0, + address + 0x1C4, + address + 0x1D8, + address + 0x27C + }; + vector InfoTypeName{ + (WCHAR*)L"\"wxId\"", + (WCHAR*)L"\"wxNumber\"", + (WCHAR*)L"\"wxV3\"", + (WCHAR*)L"\"wxNickName\"", + (WCHAR*)L"\"wxBigAvatar\"", + (WCHAR*)L"\"wxSmallAvatar\"", + (WCHAR*)L"\"wxSignature\"", + (WCHAR*)L"\"wxNation\"", + (WCHAR*)L"\"wxProvince\"", + (WCHAR*)L"\"wxCity\"", + (WCHAR*)L"\"wxBackground\"", + }; + 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"\""; + if (i != InfoType.size() - 1) { + wUserInfo += L","; + } + } + wUserInfo += L"}"; +#ifdef _DEBUG + wcout.imbue(locale("chs")); + wcout << wUserInfo.c_str() << endl; +#endif +} + + +DWORD GetWxUserInfoRemote(LPVOID lparamter) { + wchar_t* userwxid = (wchar_t*)lparamter; + DWORD address = 0; + + if (!GetUserDetailInfoByWxId(userwxid, address)) { + return 0; + } + ret.message = (DWORD)wUserInfo.c_str(); + ret.length = (DWORD)wUserInfo.length(); + return (DWORD)&ret; +} + + +BOOL GetUserDetailInfoByWxId(wchar_t* wxid,DWORD &address) { + DWORD WeChatWinBase = GetWeChatWinBase(); + DWORD GetUserDetailInfoCall1 = WeChatWinBase + 0x5F917490 - 0x5F230000; + DWORD GetUserDetailInfoCall2 = WeChatWinBase + 0x5F2BD9A0 - 0x5F230000; + DWORD GetUserDetailInfoCall3 = WeChatWinBase + 0x5F619F70 - 0x5F230000; + + DWORD DeleteCacheCall1 = WeChatWinBase + 0x56C349A0 - 0x56B80000; + DWORD DeleteCacheCall2 = WeChatWinBase + 0x56D983B0 - 0x56B80000; + WxString* pWxid = new WxString; + pWxid->buffer = wxid; + pWxid->length = wcslen(wxid); + pWxid->maxLength = wcslen(wxid) * 2; + + UserInfoBaseStruct temp = { 0 }; + UserInfoBaseStruct userinfo = { 0 }; + GetDetailUserInfoStruct pUser(pWxid); + DWORD isSuccess = 0; + + __asm { + pushad; + pushfd; + mov eax, 0x7; + lea ecx, pUser; + lea edx, temp; + call GetUserDetailInfoCall1; + call GetUserDetailInfoCall2; + lea ecx, userinfo; + push ecx; + lea ecx, temp; + push ecx; + mov ecx, eax; + call GetUserDetailInfoCall3; + mov isSuccess, eax; + popfd; + popad; + } + address = userinfo.data; + if(isSuccess != 0) + WxUserInfo(address); + __asm { + pushad; + pushfd; + lea ecx, temp; + call DeleteCacheCall1; + lea ecx, userinfo; + call DeleteCacheCall2; + popfd; + popad; + } + delete pWxid; + pWxid = NULL; + return (isSuccess != 0); +} + +BOOL GetWxUserInfoByWxid(wchar_t* wxid, DWORD& address) { + DWORD WeChatWinBase = GetWeChatWinBase(); + DWORD WxUserDataCall1 = WeChatWinBase + GetUserInfoCall1Offset; + DWORD WxUserDataCall2 = WeChatWinBase + GetUserInfoCall2Offset; + DWORD WxUserDataCall3 = WeChatWinBase + GetUserInfoCall3Offset; + char buffer[0xF90] = { 0 }; + WxBaseStruct pWxid(wxid); + DWORD r_ebx = 0; + DWORD isSuccess = 0; + __asm + { + pushad; + call WxUserDataCall1; + lea ebx, buffer; + mov esi, eax; + push ebx; + sub esp, 0x14; + lea eax, pWxid; + mov ecx, esp; + push eax; + call WxUserDataCall2; + mov ecx, esi; + call WxUserDataCall3; + mov r_ebx, ebx; + mov isSuccess, eax; + popad; + } + address = r_ebx; + return isSuccess; +} \ No newline at end of file diff --git a/DWeChatRobot/UserInfo.h b/DWeChatRobot/UserInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..098b46d085778b19f9220d38ea09a898321cf213 --- /dev/null +++ b/DWeChatRobot/UserInfo.h @@ -0,0 +1,5 @@ +#pragma once +#include +BOOL GetWxUserInfoByWxid(wchar_t* wxid, DWORD& address); +BOOL GetUserDetailInfoByWxId(wchar_t* wxid, DWORD& address); +extern "C" __declspec(dllexport) DWORD GetWxUserInfoRemote(LPVOID lparamter); \ No newline at end of file diff --git a/DWeChatRobot/dllmain.cpp b/DWeChatRobot/dllmain.cpp index c2a5abf9235b566281b99edafaa2c6e44a034d9f..db25ebb2866cb479d0c3d0fdc2111d2d21e75b68 100644 --- a/DWeChatRobot/dllmain.cpp +++ b/DWeChatRobot/dllmain.cpp @@ -16,13 +16,19 @@ BOOL APIENTRY DllMain( HMODULE hModule, { #ifdef _DEBUG CreateConsole(); - DWORD base = (DWORD)GetModuleHandleA("MyWeChatRobot.dll"); + DWORD base = (DWORD)GetModuleHandleA("DWeChatRobot.dll"); printf("SendImage 0x%08X\n", (DWORD)SendImage); printf("SendText 0x%08X\n", (DWORD)SendText); printf("SendFile 0x%08X\n", (DWORD)SendFile); printf("GetFriendList 0x%08X\n", (DWORD)GetFriendList); printf("HookExtractExpression 0x%08X\n", (DWORD)HookExtractExpression); + printf("GetWxUserInfoByWxid 0x%08X\n", (DWORD)GetWxUserInfoByWxid); + printf("GetUserDetailInfoByWxId 0x%08X\n", (DWORD)GetUserDetailInfoByWxId); + printf("GetWxUserInfoRemote 0x%08X\n", (DWORD)GetWxUserInfoRemote); + system("pause"); + wchar_t* wxid = (wchar_t*)L"wxid_ltedgfwcw7yu22"; + GetWxUserInfoRemote(wxid); #endif break; } @@ -33,7 +39,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, detach_count++; if (detach_count != 1) { FreeConsole(); - UnHookAll(); + // UnHookAll(); } #endif break; diff --git a/DWeChatRobot/pch.h b/DWeChatRobot/pch.h index a1fc94963c84938575ac7320d6dfc1fde1913b68..11a18109eb1686c897c1db468228e946cbf228f8 100644 --- a/DWeChatRobot/pch.h +++ b/DWeChatRobot/pch.h @@ -16,6 +16,7 @@ #include "SendFile.h" #include "FriendList.h" #include "SaveGif.h" +#include "UserInfo.h" #endif //PCH_H using namespace std; @@ -43,8 +44,8 @@ struct WxString wchar_t* buffer; DWORD length; DWORD maxLength; - DWORD fill1; - DWORD fill2; + DWORD fill1 = 0; + DWORD fill2 = 0; }; diff --git a/Release/CWeChatRobot.exe b/Release/CWeChatRobot.exe index 39b9b985ca855056ba9bff98a198288b0726df9f..628335666e9764ee07d25f8de8b96b86bc7c9450 100644 Binary files a/Release/CWeChatRobot.exe and b/Release/CWeChatRobot.exe differ diff --git a/Release/DWeChatRobot.dll b/Release/DWeChatRobot.dll index 17f6993f003cb19e70624f9a3bdb0e42f135cb56..1096dc81a28a64affc7f9d723836497ee23aaecc 100644 Binary files a/Release/DWeChatRobot.dll and b/Release/DWeChatRobot.dll differ diff --git a/wxRobot.py b/wxRobot.py index 4d9f0ee6756563a6d09b285be36cd8c99be12e14..f8f9a026adb6ef95c3a240d567512cd5802afabf 100644 --- a/wxRobot.py +++ b/wxRobot.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- """ Created on Thu Feb 24 16:19:48 2022 @@ -100,6 +100,9 @@ class WeChatRobot(): def GetChatSession(self,wxid): return ChatSession(self.robot, wxid) + + def GetWxDetailUserInfo(self,wxid): + return self.robot.CGetWxUserInfo(wxid) if __name__ == '__main__': @@ -115,10 +118,14 @@ if __name__ == '__main__': wx = WeChatRobot(dllpath) wx.StartService() - me = wx.GetFriendByWxNickName("文件传输助手") + me = wx.GetFriendByWxNickName("文件传送助手") session = wx.GetChatSession(me.get('wxid')) + print(me.get('wxid')) + session.SendText('来自python的消息') + a = wx.GetWxDetailUserInfo(me.get('wxid')) + print(a) session.SendImage(imgpath) session.SendFile(filepath) session.SendMp4(mp4path)