Impl SendImageMsg
This commit is contained in:
parent
c4d0a521ab
commit
ae8e20c4e7
11
App/App.cpp
11
App/App.cpp
@ -26,10 +26,11 @@ int onTextMsg(WxMessage_t msg)
|
||||
|
||||
int main()
|
||||
{
|
||||
DWORD status = 0;
|
||||
wstring wxid = L"filehelper"; // 微信ID
|
||||
wstring at_wxid = L"";
|
||||
wstring content = L"这里填写消息内容";
|
||||
DWORD status = 0;
|
||||
wstring wxid = L"filehelper"; // 微信ID
|
||||
wstring at_wxid = L"";
|
||||
wstring content = L"这里填写消息内容";
|
||||
wstring img_path = L"test.jpg";
|
||||
|
||||
//_setmode(_fileno(stdout), _O_WTEXT); // 没有这个wcout遇到一些字符会导致console卡死,用了会导致脱离控制台
|
||||
_wsetlocale(LC_ALL, L"chs"); // 这是个大坑,不设置中文直接不见了。。。
|
||||
@ -51,6 +52,8 @@ int main()
|
||||
|
||||
// 测试消息发送
|
||||
WxSendTextMsg(wxid, at_wxid, content);
|
||||
// 发送照片
|
||||
WxSendImageMsg(wxid, img_path);
|
||||
|
||||
while (1) {
|
||||
Sleep(10000); // 休眠,释放CPU
|
||||
|
@ -24,6 +24,10 @@ def main():
|
||||
print("发送文本消息......")
|
||||
sdk.WxSendTextMsg("filehelper", "", "message from WeChatFerry...")
|
||||
|
||||
time.sleep(2)
|
||||
print("发送图片消息......")
|
||||
sdk.WxSendImageMsg("filehelper", "test.jpg")
|
||||
|
||||
# 接收消息。先定义消息处理回调
|
||||
def OnTextMsg(msg: sdk.WxMessage):
|
||||
if msg.self == 1: # 忽略自己发的消息
|
||||
|
@ -123,7 +123,8 @@ xcopy /y $(OutDir)Spy.dll $(OutDir)wx\
|
||||
xcopy /y $(OutDir)SDK.dll $(OutDir)wx\
|
||||
xcopy /y $(OutDir)wcferry.pyd $(OutDir)wx\
|
||||
xcopy /y $(OutDir)App.exe $(OutDir)wx\
|
||||
xcopy /y $(SolutionDir)App\App.py $(OutDir)wx\</Command>
|
||||
xcopy /y $(SolutionDir)App\App.py $(OutDir)wx\
|
||||
xcopy /y $(SolutionDir)App\test.jpg $(OutDir)wx\</Command>
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Message>Copy output</Message>
|
||||
|
BIN
App/test.jpg
Normal file
BIN
App/test.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 399 KiB |
@ -10,6 +10,7 @@ interface ISpy
|
||||
|
||||
int IsLogin();
|
||||
int SendTextMsg([ in, string ] const wchar_t *wxid, [ in, string ] const wchar_t *at_wxid, [ in, string ] const wchar_t *msg);
|
||||
int SendImageMsg([ in, string ] const wchar_t *wxid, [ in, string ] const wchar_t *path);
|
||||
|
||||
void EnableReceiveMsg();
|
||||
[callback] int ReceiveMsg([ in ] RpcMessage_t *msg);
|
||||
|
18
SDK/sdk.cpp
18
SDK/sdk.cpp
@ -225,6 +225,24 @@ int WxSendTextMsg(wstring wxid, wstring at_wxid, wstring msg)
|
||||
return innerWxSendTextMsg(wxid.c_str(), at_wxid.c_str(), msg.c_str());
|
||||
}
|
||||
|
||||
static int innerWxSendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long ulCode = 0;
|
||||
|
||||
RpcTryExcept { ret = client_SendImageMsg(wxid, path); }
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int WxSendImageMsg(wstring wxid, wstring path) { return innerWxSendImageMsg(wxid.c_str(), path.c_str()); }
|
||||
|
||||
static int getAddrHandle(DWORD *addr, HANDLE *handle)
|
||||
{
|
||||
DWORD processID = 0;
|
||||
|
@ -3,3 +3,4 @@ EXPORTS
|
||||
WxSetTextMsgCb
|
||||
WxSendTextMsg
|
||||
WxGetMsgTypes
|
||||
WxSendImageMsg
|
||||
|
@ -22,4 +22,5 @@ typedef map<int, wstring> MsgTypesMap_t;
|
||||
int WxInitSDK();
|
||||
int WxSetTextMsgCb(const std::function<int(WxMessage_t)> &onMsg);
|
||||
int WxSendTextMsg(wstring wxid, wstring at_wxid, wstring msg);
|
||||
int WxSendImageMsg(wstring wxid, wstring path);
|
||||
MsgTypesMap_t WxGetMsgTypes();
|
||||
|
@ -25,6 +25,7 @@ PYBIND11_MODULE(wcferry, m)
|
||||
m.def("WxInitSDK", &WxInitSDK);
|
||||
m.def("WxSetTextMsgCb", &WxSetTextMsgCbPy);
|
||||
m.def("WxSendTextMsg", &WxSendTextMsg);
|
||||
m.def("WxSendImageMsg", &WxSendImageMsg);
|
||||
m.def("WxGetMsgTypes", &WxGetMsgTypes, py::return_value_policy::reference);
|
||||
|
||||
#ifdef VERSION_INFO
|
||||
|
@ -4,14 +4,17 @@
|
||||
#include "load_calls.h"
|
||||
|
||||
#define SUPPORT_VERSION L"3.3.0.115"
|
||||
WxCalls_t wxCalls = { 0x1DDF60C, // Login Status
|
||||
{ 0x1DDF4BC, 0x1DDF534, 0x1DDF568 }, // User Info: wxid, nickname, mobile
|
||||
0x3E3B80, // Send Message
|
||||
/* Receive Message:
|
||||
Hook, call, type, self, id, msgXml, roomId, wxId, content */
|
||||
{ 0x3C0D70, 0x3C0FA0, 0x38, 0x3C, 0x184, 0x1D8, 0x48, 0x170, 0x70 } };
|
||||
WxCalls_t wxCalls = {
|
||||
0x1DDF60C, // Login Status
|
||||
{ 0x1DDF4BC, 0x1DDF534, 0x1DDF568 }, // User Info: wxid, nickname, mobile
|
||||
0x3E3B80, // Send Message
|
||||
/* Receive Message:
|
||||
Hook, call, type, self, id, msgXml, roomId, wxId, content */
|
||||
{ 0x3C0D70, 0x3C0FA0, 0x38, 0x3C, 0x184, 0x1D8, 0x48, 0x170, 0x70 },
|
||||
{ 0x5CCB50, 0x6F5C0, 0x3E3490 } // Send Image Message
|
||||
};
|
||||
|
||||
int LoadCalls(const wchar_t *version, WxCalls_t *calls)
|
||||
int LoadCalls(const wchar_t* version, WxCalls_t* calls)
|
||||
{
|
||||
if (wcscmp(version, SUPPORT_VERSION) != 0) {
|
||||
return -1;
|
||||
|
@ -46,6 +46,13 @@ int server_SendTextMsg(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int server_SendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
||||
{
|
||||
SendImageMessage(wxid, path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
RPC_STATUS CALLBACK SecurityCallback(RPC_IF_HANDLE /*hInterface*/, void * /*pBindingHandle*/)
|
||||
{
|
||||
return RPC_S_OK; // Always allow anyone.
|
||||
|
@ -47,3 +47,48 @@ void SendTextMessage(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t
|
||||
add esp, 0xC
|
||||
}
|
||||
}
|
||||
|
||||
void SendImageMessage(const wchar_t *wxid, const wchar_t *path)
|
||||
{
|
||||
if (g_WeChatWinDllAddr == 0) {
|
||||
return;
|
||||
}
|
||||
char buf1[0x20] = { 0 };
|
||||
char buf2[0x378] = { 0 };
|
||||
TextStruct_t imgWxid = { 0 };
|
||||
TextStruct_t imgPath = { 0 };
|
||||
|
||||
wstring wsWxid = wxid;
|
||||
wstring wsPath = path;
|
||||
|
||||
imgWxid.text = (wchar_t *)wsWxid.c_str();
|
||||
imgWxid.size = wsWxid.size();
|
||||
imgWxid.capacity = wsWxid.capacity();
|
||||
|
||||
imgPath.text = (wchar_t *)wsPath.c_str();
|
||||
imgPath.size = wsPath.size();
|
||||
imgPath.capacity = wsPath.capacity();
|
||||
|
||||
// 发送图片Call地址 = 微信基址 + 偏移
|
||||
DWORD sendCall1 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call1;
|
||||
DWORD sendCall2 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call2;
|
||||
DWORD sendCall3 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call3;
|
||||
|
||||
__asm {
|
||||
pushad
|
||||
sub esp, 0x14
|
||||
lea eax, buf1
|
||||
mov ecx, esp
|
||||
push eax
|
||||
call sendCall1
|
||||
lea ebx, imgPath
|
||||
push ebx
|
||||
lea eax, imgWxid
|
||||
push eax
|
||||
lea eax, buf2
|
||||
push eax
|
||||
call sendCall2
|
||||
mov ecx, eax
|
||||
call sendCall3
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
void SendTextMessage(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t *msg);
|
||||
void SendImageMessage(const wchar_t *wxid, const wchar_t *path);
|
||||
|
@ -34,6 +34,7 @@ typedef struct WxCalls {
|
||||
UserInfoCall_t ui; // 用户信息
|
||||
DWORD sendTextMsg; // 发送消息
|
||||
RecvMsg_t recvMsg; // 接收消息
|
||||
SendImg_t sendImg; // 发送图片
|
||||
} WxCalls_t;
|
||||
|
||||
typedef struct TextStruct {
|
||||
|
Loading…
Reference in New Issue
Block a user