diff --git a/CWeChatRobot/GetTransfer.cpp b/CWeChatRobot/GetTransfer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb7c7d62ae2c548b1332a08e3510c34f19d24b4e --- /dev/null +++ b/CWeChatRobot/GetTransfer.cpp @@ -0,0 +1,27 @@ +#include "pch.h" + +struct GetTransferStruct +{ + DWORD wxid = 0; + DWORD transcationid = 0; + DWORD transferid = 0; +}; + +int GetTransfer(DWORD pid, wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid) +{ + WeChatProcess hp(pid); + if (hp.m_init == false) + return 1; + DWORD GetTransferRemoteAddr = hp.GetProcAddr(GetTransferRemote); + if (GetTransferRemoteAddr == 0) + return 1; + WeChatData r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid)); + WeChatData r_transcationid(hp.GetHandle(), transcationid, TEXTLENGTH(transcationid)); + WeChatData r_transferid(hp.GetHandle(), transferid, TEXTLENGTH(transferid)); + GetTransferStruct param = {(DWORD)r_wxid.GetAddr(), (DWORD)r_transcationid.GetAddr(), (DWORD)r_transferid.GetAddr()}; + WeChatData r_param(hp.GetHandle(), ¶m, sizeof(GetTransferStruct)); + if (!r_param.GetAddr() || !r_wxid.GetAddr() || !r_transcationid.GetAddr() || !r_transferid.GetAddr()) + return 1; + DWORD dwRet = CallRemoteFunction(hp.GetHandle(), GetTransferRemoteAddr, r_param.GetAddr()); + return (dwRet != 1); +} diff --git a/CWeChatRobot/GetTransfer.h b/CWeChatRobot/GetTransfer.h new file mode 100644 index 0000000000000000000000000000000000000000..4e3593ad5a8f74828cb413c2dec09d997aa4780d --- /dev/null +++ b/CWeChatRobot/GetTransfer.h @@ -0,0 +1,3 @@ +#pragma once +#include +int GetTransfer(DWORD pid, wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid); diff --git a/CWeChatRobot/SendImage.cpp b/CWeChatRobot/SendImage.cpp index 73463899f8a5f98a0915d446446a76b6cc8fb0e9..732d5b87761ef5ec403369ceb6a8bc4cff4fa95f 100644 --- a/CWeChatRobot/SendImage.cpp +++ b/CWeChatRobot/SendImage.cpp @@ -1,27 +1,32 @@ #include "pch.h" -struct ImageParamStruct { +struct ImageParamStruct +{ DWORD wxid; DWORD imagepath; }; -int SendImage(DWORD pid,wchar_t* wxid, wchar_t* imagepath) { +int SendImage(DWORD pid, wchar_t *wxid, wchar_t *imagepath) +{ WeChatProcess hp(pid); - if (!hp.m_init) return 1; + if (!hp.m_init) + return 1; DWORD SendImageRemoteAddr = hp.GetProcAddr(SendImageRemote); - if (SendImageRemoteAddr == 0) { + if (SendImageRemoteAddr == 0) + { return 1; } - ImageParamStruct params = { 0 }; - WeChatData r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid)); - WeChatData r_imagepath(hp.GetHandle(), imagepath, TEXTLENGTH(imagepath)); + ImageParamStruct params = {0}; + WeChatData r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid)); + WeChatData r_imagepath(hp.GetHandle(), imagepath, TEXTLENGTH(imagepath)); params.wxid = (DWORD)r_wxid.GetAddr(); params.imagepath = (DWORD)r_imagepath.GetAddr(); - WeChatData r_params(hp.GetHandle(), ¶ms, sizeof(params)); - if (!params.wxid || !params.imagepath || !r_params.GetAddr()) { + WeChatData r_params(hp.GetHandle(), ¶ms, sizeof(params)); + if (!params.wxid || !params.imagepath || !r_params.GetAddr()) + { return 1; } DWORD dwRet = CallRemoteFunction(hp.GetHandle(), SendImageRemoteAddr, r_params.GetAddr()); - return 0; + return (dwRet != 1); } diff --git a/CWeChatRobot/WeChatRobot.cpp b/CWeChatRobot/WeChatRobot.cpp index 85a224b279e2c146c782a0b37fd5e38c1cb2b897..cdef7186fe30adc66156366789d447299af8e5c4 100644 --- a/CWeChatRobot/WeChatRobot.cpp +++ b/CWeChatRobot/WeChatRobot.cpp @@ -613,3 +613,16 @@ STDMETHODIMP CWeChatRobot::CLogout(DWORD pid, int *__result) *__result = Logout(pid); return S_OK; } + +/* + * 参数0:目标进程pid + * 参数1:转账人wxid + * 参数2:从xml中获取的transcationid + * 参数3:从xml中获取的transferid + * 参数4:预返回的值,调用时无需提供 + */ +STDMETHODIMP CWeChatRobot::CGetTransfer(DWORD pid, BSTR wxid, BSTR transcationid, BSTR transferid, int *__result) +{ + *__result = GetTransfer(pid, wxid, transcationid, transferid); + return S_OK; +} diff --git a/CWeChatRobot/WeChatRobot.h b/CWeChatRobot/WeChatRobot.h index 82683e38bb105bb85327245b90548ba4abdf08a9..f0b730e35dda06d8a68baaaab92d40261370df3b 100644 --- a/CWeChatRobot/WeChatRobot.h +++ b/CWeChatRobot/WeChatRobot.h @@ -90,6 +90,7 @@ public: STDMETHODIMP CGetA8Key(DWORD pid, BSTR url, BSTR *__result); STDMETHODIMP CSendXmlMsg(DWORD pid, BSTR wxid, BSTR xml, BSTR imgpath, int *__result); STDMETHODIMP CLogout(DWORD pid, int *__result); + STDMETHODIMP CGetTransfer(DWORD pid, BSTR wxid, BSTR transcationid, BSTR transferid, int *__result); }; OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot) diff --git a/CWeChatRobot/WeChatRobotCOM.idl b/CWeChatRobot/WeChatRobotCOM.idl index 4f91aa1d20f382d0a94d8f39126ca5d8ac3f7d1f..8c097ed038c2a4c277492863fd93d832eaaebb60 100644 --- a/CWeChatRobot/WeChatRobotCOM.idl +++ b/CWeChatRobot/WeChatRobotCOM.idl @@ -65,6 +65,7 @@ interface IWeChatRobot : IDispatch [id(50), helpstring("获取A8Key")] HRESULT CGetA8Key([in] DWORD pid, [in] BSTR url, [ out, retval ] BSTR * __result); [id(51), helpstring("发送xml消息")] HRESULT CSendXmlMsg([in] DWORD pid, [in] BSTR wxid, [in] BSTR xml, [in] BSTR imgpath,[out, retval] int *__result); [id(52), helpstring("退出登录")] HRESULT CLogout([in] DWORD pid,[out, retval] int *__result); + [id(53), helpstring("收款")] HRESULT CGetTransfer([in] DWORD pid, [in] BSTR wxid, [in] BSTR transcationid, [in] BSTR transferid, [out, retval] int *__result); }; [ object, diff --git a/CWeChatRobot/WeChatRobotCOM.vcxproj b/CWeChatRobot/WeChatRobotCOM.vcxproj index 9c6f00ad5093862a2d3bbb038973fecc2e66bb38..ac30117f528a9cb41e5b60253d0bb644f50b8981 100644 --- a/CWeChatRobot/WeChatRobotCOM.vcxproj +++ b/CWeChatRobot/WeChatRobotCOM.vcxproj @@ -237,6 +237,7 @@ + @@ -288,6 +289,7 @@ + diff --git a/CWeChatRobot/WeChatRobotCOM.vcxproj.filters b/CWeChatRobot/WeChatRobotCOM.vcxproj.filters index d3e4ed26eea7097e4c27d116847990d474fb44a1..db211ef66ab901a6d690c636a0bf3493c194aaee 100644 --- a/CWeChatRobot/WeChatRobotCOM.vcxproj.filters +++ b/CWeChatRobot/WeChatRobotCOM.vcxproj.filters @@ -143,6 +143,12 @@ {33279923-8158-4b6f-af06-e7f093852e5d} + + {26820c31-881e-44a6-8c53-b26379ce9b39} + + + {79bb1058-041b-4bdc-8678-0369c294e570} + @@ -289,6 +295,9 @@ 登录相关\退出登录 + + 未分类\收款 + @@ -435,6 +444,9 @@ 登录相关\退出登录 + + 未分类\收款 + diff --git a/CWeChatRobot/WeChatRobotCOM_i.h b/CWeChatRobot/WeChatRobotCOM_i.h index 4a9b7ad1ddde9cdbd29e4fa181310cbb5b0d586a..7cca1a4ac9ec138738487b64e8d16b147dd8fe3f 100644 --- a/CWeChatRobot/WeChatRobotCOM_i.h +++ b/CWeChatRobot/WeChatRobotCOM_i.h @@ -371,6 +371,13 @@ EXTERN_C const IID IID_IWeChatRobot; /* [in] */ DWORD pid, /* [retval][out] */ int *__result) = 0; + virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CGetTransfer( + /* [in] */ DWORD pid, + /* [in] */ BSTR wxid, + /* [in] */ BSTR transcationid, + /* [in] */ BSTR transferid, + /* [retval][out] */ int *__result) = 0; + }; @@ -735,6 +742,14 @@ EXTERN_C const IID IID_IWeChatRobot; /* [in] */ DWORD pid, /* [retval][out] */ int *__result); + /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *CGetTransfer )( + IWeChatRobot * This, + /* [in] */ DWORD pid, + /* [in] */ BSTR wxid, + /* [in] */ BSTR transcationid, + /* [in] */ BSTR transferid, + /* [retval][out] */ int *__result); + END_INTERFACE } IWeChatRobotVtbl; @@ -918,6 +933,9 @@ EXTERN_C const IID IID_IWeChatRobot; #define IWeChatRobot_CLogout(This,pid,__result) \ ( (This)->lpVtbl -> CLogout(This,pid,__result) ) +#define IWeChatRobot_CGetTransfer(This,pid,wxid,transcationid,transferid,__result) \ + ( (This)->lpVtbl -> CGetTransfer(This,pid,wxid,transcationid,transferid,__result) ) + #endif /* COBJMACROS */ diff --git a/CWeChatRobot/WeChatRobotCOM_p.c b/CWeChatRobot/WeChatRobotCOM_p.c index 740526263f3c91a0a3a764e954d9ba7399c11a92..4231a991968567540bc6d1583cc8d169d2bf680c 100644 --- a/CWeChatRobot/WeChatRobotCOM_p.c +++ b/CWeChatRobot/WeChatRobotCOM_p.c @@ -49,7 +49,7 @@ #include "WeChatRobotCOM_i.h" #define TYPE_FORMAT_STRING_SIZE 1239 -#define PROC_FORMAT_STRING_SIZE 2533 +#define PROC_FORMAT_STRING_SIZE 2593 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 #define WIRE_MARSHAL_TABLE_SIZE 2 @@ -2331,14 +2331,14 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor /* 2422 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure CPostMessage */ + /* Procedure CGetTransfer */ /* 2424 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 2426 */ NdrFcLong( 0x0 ), /* 0 */ -/* 2430 */ NdrFcShort( 0x7 ), /* 7 */ -/* 2432 */ NdrFcShort( 0x20 ), /* x86 Stack size/offset = 32 */ -/* 2434 */ NdrFcShort( 0x20 ), /* 32 */ +/* 2430 */ NdrFcShort( 0x38 ), /* 56 */ +/* 2432 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */ +/* 2434 */ NdrFcShort( 0x8 ), /* 8 */ /* 2436 */ NdrFcShort( 0x24 ), /* 36 */ /* 2438 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ 0x6, /* 6 */ @@ -2355,55 +2355,53 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor /* 2452 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Parameter msgtype */ + /* Parameter wxid */ -/* 2454 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 2454 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ /* 2456 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ -/* 2458 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ +/* 2458 */ NdrFcShort( 0x2a ), /* Type Offset=42 */ - /* Parameter msgid */ + /* Parameter transcationid */ -/* 2460 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 2460 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ /* 2462 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ -/* 2464 */ 0xb, /* FC_HYPER */ - 0x0, /* 0 */ +/* 2464 */ NdrFcShort( 0x2a ), /* Type Offset=42 */ - /* Parameter msg */ + /* Parameter transferid */ -/* 2466 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ -/* 2468 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ -/* 2470 */ NdrFcShort( 0x4cc ), /* Type Offset=1228 */ +/* 2466 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ +/* 2468 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 2470 */ NdrFcShort( 0x2a ), /* Type Offset=42 */ /* Parameter __result */ /* 2472 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ -/* 2474 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */ +/* 2474 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ /* 2476 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Return value */ /* 2478 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 2480 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */ +/* 2480 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */ /* 2482 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Procedure CRegisterWxPidWithCookie */ + /* Procedure CPostMessage */ /* 2484 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 2486 */ NdrFcLong( 0x0 ), /* 0 */ -/* 2490 */ NdrFcShort( 0x8 ), /* 8 */ -/* 2492 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ -/* 2494 */ NdrFcShort( 0x10 ), /* 16 */ +/* 2490 */ NdrFcShort( 0x7 ), /* 7 */ +/* 2492 */ NdrFcShort( 0x20 ), /* x86 Stack size/offset = 32 */ +/* 2494 */ NdrFcShort( 0x20 ), /* 32 */ /* 2496 */ NdrFcShort( 0x24 ), /* 36 */ -/* 2498 */ 0x44, /* Oi2 Flags: has return, has ext, */ - 0x4, /* 4 */ +/* 2498 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x6, /* 6 */ /* 2500 */ 0x8, /* 8 */ - 0x41, /* Ext Flags: new corr desc, has range on conformance */ + 0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */ /* 2502 */ NdrFcShort( 0x0 ), /* 0 */ -/* 2504 */ NdrFcShort( 0x0 ), /* 0 */ +/* 2504 */ NdrFcShort( 0x1 ), /* 1 */ /* 2506 */ NdrFcShort( 0x0 ), /* 0 */ /* Parameter pid */ @@ -2413,25 +2411,83 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor /* 2512 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Parameter cookie */ + /* Parameter msgtype */ /* 2514 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 2516 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ /* 2518 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ - /* Parameter __result */ + /* Parameter msgid */ -/* 2520 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ +/* 2520 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 2522 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ -/* 2524 */ 0x8, /* FC_LONG */ +/* 2524 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter msg */ + +/* 2526 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 2528 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 2530 */ NdrFcShort( 0x4cc ), /* Type Offset=1228 */ + + /* Parameter __result */ + +/* 2532 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ +/* 2534 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */ +/* 2536 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Return value */ -/* 2526 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ -/* 2528 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ -/* 2530 */ 0x8, /* FC_LONG */ +/* 2538 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 2540 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */ +/* 2542 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure CRegisterWxPidWithCookie */ + +/* 2544 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 2546 */ NdrFcLong( 0x0 ), /* 0 */ +/* 2550 */ NdrFcShort( 0x8 ), /* 8 */ +/* 2552 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 2554 */ NdrFcShort( 0x10 ), /* 16 */ +/* 2556 */ NdrFcShort( 0x24 ), /* 36 */ +/* 2558 */ 0x44, /* Oi2 Flags: has return, has ext, */ + 0x4, /* 4 */ +/* 2560 */ 0x8, /* 8 */ + 0x41, /* Ext Flags: new corr desc, has range on conformance */ +/* 2562 */ NdrFcShort( 0x0 ), /* 0 */ +/* 2564 */ NdrFcShort( 0x0 ), /* 0 */ +/* 2566 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pid */ + +/* 2568 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 2570 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 2572 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter cookie */ + +/* 2574 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 2576 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 2578 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter __result */ + +/* 2580 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ +/* 2582 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 2584 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Return value */ + +/* 2586 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 2588 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 2590 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ 0x0 @@ -3327,7 +3383,8 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] = 2232, 2274, 2322, - 2382 + 2382, + 2424 }; static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo = @@ -3351,7 +3408,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo = 0, 0, 0}; -CINTERFACE_PROXY_VTABLE(56) _IWeChatRobotProxyVtbl = +CINTERFACE_PROXY_VTABLE(57) _IWeChatRobotProxyVtbl = { &IWeChatRobot_ProxyInfo, &IID_IWeChatRobot, @@ -3410,7 +3467,8 @@ CINTERFACE_PROXY_VTABLE(56) _IWeChatRobotProxyVtbl = (void *) (INT_PTR) -1 /* IWeChatRobot::CGetQrcodeImage */ , (void *) (INT_PTR) -1 /* IWeChatRobot::CGetA8Key */ , (void *) (INT_PTR) -1 /* IWeChatRobot::CSendXmlMsg */ , - (void *) (INT_PTR) -1 /* IWeChatRobot::CLogout */ + (void *) (INT_PTR) -1 /* IWeChatRobot::CLogout */ , + (void *) (INT_PTR) -1 /* IWeChatRobot::CGetTransfer */ }; @@ -3468,6 +3526,7 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] = NdrStubCall2, NdrStubCall2, NdrStubCall2, + NdrStubCall2, NdrStubCall2 }; @@ -3475,7 +3534,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl = { &IID_IWeChatRobot, &IWeChatRobot_ServerInfo, - 56, + 57, &IWeChatRobot_table[-3], CStdStubBuffer_DELEGATING_METHODS }; @@ -3491,8 +3550,8 @@ static const unsigned short IRobotEvent_FormatStringOffsetTable[] = (unsigned short) -1, (unsigned short) -1, (unsigned short) -1, - 2424, - 2484 + 2484, + 2544 }; static const MIDL_STUBLESS_PROXY_INFO IRobotEvent_ProxyInfo = diff --git a/CWeChatRobot/robotdata.h b/CWeChatRobot/robotdata.h index 6da486de7ae52d49b26328449a1e83b40f84231f..0b62edde714615021d675cc5d516cb117c6e8aae 100644 --- a/CWeChatRobot/robotdata.h +++ b/CWeChatRobot/robotdata.h @@ -34,6 +34,7 @@ #include "GetA8Key.h" #include "SendXmlMsg.h" #include "Logout.h" +#include "GetTransfer.h" #define DLLNAME L"DWeChatRobot.dll" @@ -97,3 +98,5 @@ #define GetA8KeyRemote "GetA8KeyRemote" #define SendXmlMsgRemote "SendXmlMsgRemote" #define LogoutRemote "Logout" + +#define GetTransferRemote "GetTransferRemote" diff --git a/DWeChatRobot/DWeChatRobot.vcxproj b/DWeChatRobot/DWeChatRobot.vcxproj index a656883e6f48c32247e381959332cb99532f5958..09629f25c2fb85d595e0dd01b442d741742024ba 100644 --- a/DWeChatRobot/DWeChatRobot.vcxproj +++ b/DWeChatRobot/DWeChatRobot.vcxproj @@ -331,6 +331,7 @@ xcopy /y /d "$(OutDir)..\..\Python\http\wxDriver.py" "$(SolutionDir)build\http + @@ -380,6 +381,7 @@ xcopy /y /d "$(OutDir)..\..\Python\http\wxDriver.py" "$(SolutionDir)build\http + diff --git a/DWeChatRobot/DWeChatRobot.vcxproj.filters b/DWeChatRobot/DWeChatRobot.vcxproj.filters index 427ab0ee4e4a3c3d0d107da786f073aeaaef4969..cccb3ce9d5a6a02c666ec263286623ad5bf97272 100644 --- a/DWeChatRobot/DWeChatRobot.vcxproj.filters +++ b/DWeChatRobot/DWeChatRobot.vcxproj.filters @@ -142,6 +142,12 @@ {e00caf3d-a0c2-4915-9ca5-47e429b4fcbf} + + {75895983-2efe-413f-a71b-1b1891b109a3} + + + {f24eb4af-96d0-41a3-ba1a-799d49f2fb4e} + @@ -276,6 +282,9 @@ 登录相关\退出登录 + + 未分类\收款 + @@ -413,5 +422,8 @@ 登录相关\退出登录 + + 未分类\收款 + diff --git a/DWeChatRobot/GetTransfer.cpp b/DWeChatRobot/GetTransfer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ae4cc850b706cf4f1898804730671dddfce33f1 --- /dev/null +++ b/DWeChatRobot/GetTransfer.cpp @@ -0,0 +1,61 @@ +#include "pch.h" + +#define GetTransferCallOffset 0x10CD2770 - 0x10000000 +#define GetTransferHandleOffset 0x5D02F4F4 - 0x5B1B0000 + +struct TransferStruct +{ + DWORD handle = 0; + DWORD unknown_value1 = 0x1; + WxString amount = {0}; + WxString transcationid = {0}; + DWORD time1 = 0; + DWORD time2 = 0; + WxString transferid = {0}; + DWORD unknown_value2 = 0x1; + char null_buf1[0xE0] = {0}; + DWORD unknown_value3 = 0x820000; + char null_buf2[0x64] = {0}; +}; + +#ifndef USE_SOCKET +struct GetTransferStruct +{ + wchar_t *wxid = NULL; + wchar_t *transcationid = NULL; + wchar_t *transferid = NULL; +}; +BOOL GetTransferRemote(LPVOID lpParameter) +{ + GetTransferStruct *gts = (GetTransferStruct *)lpParameter; + return GetTransfer(gts->wxid, gts->transcationid, gts->transferid); +} +#endif + +BOOL __stdcall GetTransfer(wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid) +{ + DWORD WeChatWinBase = GetWeChatWinBase(); + DWORD GetTransferCallAddr = WeChatWinBase + GetTransferCallOffset; + DWORD GetTransferHandleAddr = WeChatWinBase + GetTransferHandleOffset; + TransferStruct tf; + tf.handle = GetTransferHandleAddr; + tf.transcationid.set_value(transcationid); + tf.transferid.set_value(transferid); + WxString p_wxid(wxid); + int isSuccess = 0x0; + __asm { + pushad; + pushfd; + push 0x1; + lea edx,p_wxid; + lea ecx,tf; + sub esp,0x8; + call GetTransferCallAddr; + add esp,0xC; + movzx eax,al; + mov isSuccess,eax; + popfd; + popad; + } + return isSuccess; +} diff --git a/DWeChatRobot/GetTransfer.h b/DWeChatRobot/GetTransfer.h new file mode 100644 index 0000000000000000000000000000000000000000..d3d6c763e84419643999abb9a2969d3c430e74b7 --- /dev/null +++ b/DWeChatRobot/GetTransfer.h @@ -0,0 +1,8 @@ +#pragma once +#include + +BOOL __stdcall GetTransfer(wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid); + +#ifndef USE_SOCKET +extern "C" __declspec(dllexport) BOOL GetTransferRemote(LPVOID lpParameter); +#endif diff --git a/DWeChatRobot/ReceiveMessage.cpp b/DWeChatRobot/ReceiveMessage.cpp index aa545adc75e88cce68cc246fdcb90e7e5a54be1b..90c2d2c730f875e30cce74225a8c61c3fbfcecb9 100644 --- a/DWeChatRobot/ReceiveMessage.cpp +++ b/DWeChatRobot/ReceiveMessage.cpp @@ -25,6 +25,10 @@ using namespace std; // ϢHOOKCALLƫ #define UpdateMessageNextCallOffset 0x5D6D3430 - 0x5D1F0000 +// Ƶͨ +#define VoipAckMessageHookOffset 0x1054A18F - 0x10000000 +#define VoipAckMessageNextCallOffset 0x1022BA60 - 0x10000000 + #define READ_WSTRING(addr, offset) ((*(DWORD *)(addr + offset + 0x4) == 0) ? wstring(L"") : wstring((wchar_t *)(*(DWORD *)(addr + offset)), *(DWORD *)(addr + offset + 0x4))) static int SRVPORT = 0; @@ -35,6 +39,7 @@ BOOL ReceiveMessageHooked = false; static char OldReceiveMessageAsmCode[5] = {0}; static char OldSendMessageAsmCode[5] = {0}; static char OldUpdateMessageAsmCode[5] = {0}; +static char OldVoipAckMessageAsmCode[5] = {0}; static DWORD WeChatWinBase = GetWeChatWinBase(); // ϢHOOKַ static DWORD ReceiveMessageHookAddress = WeChatWinBase + ReceiveMessageHookOffset; @@ -54,6 +59,10 @@ static DWORD UpdateMessageHookAddress = WeChatWinBase + UpdateMessageHookOffset; static DWORD UpdateMessageNextCall = WeChatWinBase + UpdateMessageNextCallOffset; // HOOKתַ static DWORD UpdateMessageJmpBackAddress = UpdateMessageHookAddress + 0x5; +// Ƶͨ +static DWORD VoipAckMessageHookAddress = WeChatWinBase + VoipAckMessageHookOffset; +static DWORD VoipAckMessageNextCall = WeChatWinBase + VoipAckMessageNextCallOffset; +static DWORD VoipAckMessageJmpBackAddress = VoipAckMessageHookAddress + 0x5; struct SocketMessageStruct { @@ -157,7 +166,7 @@ void SendSocketMessageInThread(SocketMessageStruct *param) LOG(INFO) << "msgid: " << jMsg["msgid"].get() << " send end." << endl; } -static void dealMessage(DWORD messageAddr) +static void dealMessage(DWORD messageAddr, int msg_source) { json jMsg; unsigned long long msgid = *(unsigned long long *)(messageAddr + 0x30); @@ -166,7 +175,7 @@ static void dealMessage(DWORD messageAddr) jMsg["isSendMsg"] = *(BOOL *)(messageAddr + 0x3C); if (jMsg["isSendMsg"].get()) { - jMsg["isSendByPhone"] = (int)(*(BYTE *)(messageAddr + 0xD8)); + jMsg["isSendByPhone"] = (msg_source == MSG_SYNC) ? 1 : 0; // (int)(*(BYTE *)(messageAddr + 0xD8)); } jMsg["msgid"] = msgid; // jMsg["localId"] = *(unsigned int *)(messageAddr + 0x20); @@ -210,7 +219,7 @@ void OnReceiveMessage(DWORD messagesAddr) DWORD *messages = (DWORD *)messagesAddr; for (DWORD messageAddr = messages[0]; messageAddr < messages[1]; messageAddr += 0x298) { - dealMessage(messageAddr); + dealMessage(messageAddr, MSG_SYNC); } } @@ -222,7 +231,7 @@ void OnSendMessage(DWORD messageAddr) BOOL isSendMsg = *(BOOL *)(messageAddr + 0x3C); if (!isSendMsg) return; - dealMessage(messageAddr); + dealMessage(messageAddr, MSG_SEND); } /* @@ -231,7 +240,17 @@ void OnSendMessage(DWORD messageAddr) void OnUpdateMessage(DWORD messageAddr) { // DWORD type = *(DWORD *)(messageAddr + 0x38); - dealMessage(messageAddr); + dealMessage(messageAddr, MSG_UPDATE); +} + +/* + * Ƶͨ + */ +void OnVoipAckMessage(DWORD messageAddr) +{ + DWORD type = *(DWORD *)(messageAddr + 0x38); + if (type == 0x32 || type == 0x33 || type == 0x2712) + dealMessage(messageAddr, MSG_SYNC); } /* @@ -288,6 +307,24 @@ _declspec(naked) void dealRevokeMessage() } } +/* + * HOOKľʵ֣յϢô + */ +_declspec(naked) void dealVoipAckMessage() +{ + __asm { + pushad; + pushfd; + push ecx; + call OnVoipAckMessage; + add esp, 0x4; + popfd; + popad; + call VoipAckMessageNextCall; + jmp VoipAckMessageJmpBackAddress; + } +} + /* * ʼϢHOOK * returnvoid @@ -307,9 +344,13 @@ VOID HookReceiveMessage(int port) UpdateMessageHookAddress = WeChatWinBase + UpdateMessageHookOffset; UpdateMessageNextCall = WeChatWinBase + UpdateMessageNextCallOffset; UpdateMessageJmpBackAddress = UpdateMessageHookAddress + 0x5; + VoipAckMessageHookAddress = WeChatWinBase + VoipAckMessageHookOffset; + VoipAckMessageNextCall = WeChatWinBase + VoipAckMessageNextCallOffset; + VoipAckMessageJmpBackAddress = VoipAckMessageHookAddress + 0x5; HookAnyAddress(ReceiveMessageHookAddress, (LPVOID)dealReceiveMessage, OldReceiveMessageAsmCode); HookAnyAddress(SendMessageHookAddress, (LPVOID)dealSendMessage, OldSendMessageAsmCode); HookAnyAddress(UpdateMessageHookAddress, (LPVOID)dealRevokeMessage, OldUpdateMessageAsmCode); + HookAnyAddress(VoipAckMessageHookAddress, (LPVOID)dealVoipAckMessage, OldVoipAckMessageAsmCode); ReceiveMessageHooked = TRUE; } @@ -325,5 +366,6 @@ VOID UnHookReceiveMessage() UnHookAnyAddress(ReceiveMessageHookAddress, OldReceiveMessageAsmCode); UnHookAnyAddress(SendMessageHookAddress, OldSendMessageAsmCode); UnHookAnyAddress(UpdateMessageHookAddress, OldUpdateMessageAsmCode); + UnHookAnyAddress(VoipAckMessageHookAddress, OldVoipAckMessageAsmCode); ReceiveMessageHooked = FALSE; } diff --git a/DWeChatRobot/ReceiveMessage.h b/DWeChatRobot/ReceiveMessage.h index 62ca2e0b44ac76a7cf178f9a2ce14443a31a9964..35fb7a114d543860bd294ba550dbbcc98c974f26 100644 --- a/DWeChatRobot/ReceiveMessage.h +++ b/DWeChatRobot/ReceiveMessage.h @@ -18,3 +18,11 @@ BOOL __stdcall HookImageMsg(wstring save_path); void __stdcall HookVoiceMsg(); void __stdcall HookImageMsg(); + +typedef enum MSG_SOURCE_TYPETag +{ + MSG_SYNC, + MSG_UPDATE, + MSG_SEND, +} MSG_SOURCE, + *PMSG_SOURCE; diff --git a/DWeChatRobot/SendFile.cpp b/DWeChatRobot/SendFile.cpp index f6c01d65277dfc6c48d2af71de95659a1250377d..8b3d9686c06e0f1043c7c088c622ef5a48872f85 100644 --- a/DWeChatRobot/SendFile.cpp +++ b/DWeChatRobot/SendFile.cpp @@ -121,10 +121,10 @@ BOOL __stdcall SendFile(wchar_t *receiver, wchar_t *FilePath) mov al,byte ptr [eax + 0x38]; movzx eax,al; mov isSuccess,eax; - push 200; - call Sleep; - lea ecx, buffer; - call DeleteSendFileCacheCall; + // push 200; + // call Sleep; + // lea ecx, buffer; + // call DeleteSendFileCacheCall; popfd; popad; } diff --git a/DWeChatRobot/SendImage.cpp b/DWeChatRobot/SendImage.cpp index d6cf8f96d664f71c3533b01df8d1c6da1f70bad7..bbe8f11eaef7ce2bbe837d20edd017e344468be2 100644 --- a/DWeChatRobot/SendImage.cpp +++ b/DWeChatRobot/SendImage.cpp @@ -28,10 +28,10 @@ struct ImageParamStruct * returnvoid */ #ifndef USE_SOCKET -void SendImageRemote(LPVOID lpParamStruct) +BOOL SendImageRemote(LPVOID lpParamStruct) { ImageParamStruct *params = (ImageParamStruct *)lpParamStruct; - SendImage((WCHAR *)params->wxid, (WCHAR *)params->imagepath); + return SendImage((WCHAR *)params->wxid, (WCHAR *)params->imagepath); } #endif @@ -77,5 +77,5 @@ BOOL __stdcall SendImage(wchar_t *receiver, wchar_t *ImagePath) call DeleteSendImageCacheCall; popad; } - return isSuccess == 1; + return isSuccess; } diff --git a/DWeChatRobot/SendImage.h b/DWeChatRobot/SendImage.h index 6e8d1c73f3a8271b58d75cfdc4763c0164a11543..a78bfe6745e51112149409cbb8d213fbd21f15de 100644 --- a/DWeChatRobot/SendImage.h +++ b/DWeChatRobot/SendImage.h @@ -3,5 +3,5 @@ BOOL __stdcall SendImage(wchar_t *receiver, wchar_t *ImagePath); #ifndef USE_SOCKET -extern "C" __declspec(dllexport) void SendImageRemote(LPVOID lpParamStruct); +extern "C" __declspec(dllexport) BOOL SendImageRemote(LPVOID lpParamStruct); #endif diff --git a/DWeChatRobot/http_overload.hpp b/DWeChatRobot/http_overload.hpp index 15de7a117b7da7fef5fc44f48926fe56483b6272..933bf53e00673fbef6e3b4fd2c06360027d642b0 100644 --- a/DWeChatRobot/http_overload.hpp +++ b/DWeChatRobot/http_overload.hpp @@ -143,4 +143,9 @@ BOOL __stdcall SendXmlMsg(wstring wxid, wstring xml, wstring imgpath) { return SendXmlMsg(WS2LW(wxid), WS2LW(xml), WS2LW(imgpath)); } + +BOOL __stdcall GetTransfer(wstring wxid, wstring transcationid, wstring transferid) +{ + return GetTransfer(WS2LW(wxid), WS2LW(transcationid), WS2LW(transferid)); +} #endif diff --git a/DWeChatRobot/wxapi.h b/DWeChatRobot/wxapi.h index 2eefb433538738716f27987eea986441a3e3ebbf..cd3b7cf80841e446d0f1b7881148c3321814c457 100644 --- a/DWeChatRobot/wxapi.h +++ b/DWeChatRobot/wxapi.h @@ -36,6 +36,7 @@ #include "GetQrcodeImage.h" #include "GetA8Key.h" #include "Logout.h" +#include "GetTransfer.h" using namespace std; #pragma comment(lib, "version.lib") diff --git a/DWeChatRobot/wxdata.h b/DWeChatRobot/wxdata.h index c1b19ebdb9d0205dd46eb89acbc81ce575bdda1f..b110585bb20e1be26821a1b07038d4a1e4e5e09e 100644 --- a/DWeChatRobot/wxdata.h +++ b/DWeChatRobot/wxdata.h @@ -47,6 +47,12 @@ struct WxString length = wcslen(pStr); maxLength = wcslen(pStr) * 2; } + void set_value(const wchar_t *pStr) + { + buffer = (wchar_t *)pStr; + length = wcslen(pStr); + maxLength = wcslen(pStr) * 2; + } }; /* diff --git a/DWeChatRobot/wxsocket.cpp b/DWeChatRobot/wxsocket.cpp index 617d375c78e96061809a63d26d25f9ff07704500..bcff4d1e3fc4e78ba5dfe2ca95b8f05daa3951b8 100644 --- a/DWeChatRobot/wxsocket.cpp +++ b/DWeChatRobot/wxsocket.cpp @@ -620,6 +620,16 @@ void request_event(mg_http_message *hm, string &ret, struct mg_connection *c) ret = ret_data.dump(); break; } + case WECHAT_GET_TRANSFER: + { + wstring wxid = get_http_param_str(hm, jData, "wxid", method); + wstring transcationid = get_http_param_str(hm, jData, "transcationid", method); + wstring transferid = get_http_param_str(hm, jData, "transferid", method); + BOOL response = GetTransfer(wxid, transcationid, transferid); + json ret_data = {{"msg", response}, {"result", "OK"}}; + ret = ret_data.dump(); + break; + } default: // char* wxid = mg_json_get_str(hm->body, "$.wxid"); break; diff --git a/DWeChatRobot/wxsocketapi.h b/DWeChatRobot/wxsocketapi.h index 22320dbf9d7388266bb74d7a45d551ff14414330..ab3e230d348436ef2d1ca8c71f18ada496e14048 100644 --- a/DWeChatRobot/wxsocketapi.h +++ b/DWeChatRobot/wxsocketapi.h @@ -76,6 +76,7 @@ typedef enum WECHAT_HTTP_APISTag WECHAT_GET_A8KEY, WECHAT_MSG_SEND_XML, WECHAT_LOGOUT, + WECHAT_GET_TRANSFER, } WECHAT_HTTP_APIS, *PWECHAT_HTTP_APIS; #endif diff --git a/Python/com/wxRobot.py b/Python/com/wxRobot.py index 1ded2d4c390dbb67ea506317fd25bf56a2bd148d..a28cb3672d1ec14629b203ac377676e6d6940e7a 100644 --- a/Python/com/wxRobot.py +++ b/Python/com/wxRobot.py @@ -1134,6 +1134,27 @@ class WeChatRobot: """ return self.robot.CLogout(self.pid) + def GetTransfer(self,wxid:str,transcationid:str,transferid:str) -> int: + """ + 收款 + + Parameters + ---------- + wxid : str + 转账人wxid. + transcationid : str + 从转账消息xml中获取. + transferid : str + 从转账消息xml中获取. + + Returns + ------- + int + 成功返回0,失败返回非0值. + + """ + return self.robot.CGetTransfer(self.pid,wxid,transcationid,transferid) + def get_wechat_pid_list() -> list: """ diff --git a/Python/http/wxDriver.py b/Python/http/wxDriver.py index ba35617fdfbf9feb8ddabbe3be9a1099789110e7..c9d3bc0e2a2e9f2bc5675c0f26a160e92bafe47f 100644 --- a/Python/http/wxDriver.py +++ b/Python/http/wxDriver.py @@ -85,7 +85,10 @@ class WECHAT_HTTP_APIS: WECHAT_MSG_FORWARD_MESSAGE = 40 # 转发消息 WECHAT_GET_QRCODE_IMAGE = 41 # 获取二维码 - WECHAT_GET_A8KEY = 42 + WECHAT_GET_A8KEY = 42 # 获取A8Key + WECHAT_MSG_SEND_XML = 43 # 发送xml消息 + WECHAT_LOGOUT = 44 # 退出登录 + WECHAT_GET_TRANSFER = 45 # 收款 APIS = WECHAT_HTTP_APIS @@ -191,7 +194,10 @@ class WECHAT_HTTP_API_PARAM_TEMPLATES: APIS.WECHAT_MSG_FORWARD_MESSAGE: {"wxid": "filehelper","msgid": 2 ** 64 - 1}, APIS.WECHAT_GET_QRCODE_IMAGE: {}, - APIS.WECHAT_GET_A8KEY: {"url":""} + APIS.WECHAT_GET_A8KEY: {"url":""}, + APIS.WECHAT_MSG_SEND_XML: {"wxid":"filehelper","xml":"","img_path":""}, + APIS.WECHAT_LOGOUT: {}, + APIS.WECHAT_GET_TRANSFER: {"wxid":"","transcationid":"","transferid":""} } def get_http_template(self, api_number): @@ -337,8 +343,8 @@ if __name__ == '__main__': if len(pids) == 0: pids.append(new_wechat()) start_listen(pids[0],port) - post_wechat_http_api(APIS.WECHAT_LOG_START_HOOK,8000) - print(post_wechat_http_api(APIS.WECHAT_GET_SELF_INFO, 8000)) - post_wechat_http_api(APIS.WECHAT_MSG_START_HOOK,8000,{"port":10808}) + post_wechat_http_api(APIS.WECHAT_LOG_START_HOOK,port) + print(post_wechat_http_api(APIS.WECHAT_GET_SELF_INFO, port)) + post_wechat_http_api(APIS.WECHAT_MSG_START_HOOK,port,{"port":10808}) start_socket_server() stop_listen(pids[0]) diff --git a/README.md b/README.md index d83cf9f4ab06fb4017976660503a2cdc507dd77f..f079829431afec3734f6d14557827bd1911f3a32 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,10 @@ CWeChatRobot.exe /unregserver 2. 新增退出登录接口 3. 尝试修复文件发送失败和格式化时间戳导致崩溃问题 4. 实时消息新增一个字段,用于获取视频消息缩略图保存位置 +## 2022.10.16 +1. 新增收款接口 +2. 实时消息接口优化,支持获取音视频聊天信息,支持获取手机端切换联系人时的提示信息 +3. 修复部分已知问题 # 打赏作者 请给作者一个star,感谢感谢