mirror of
https://github.com/ttttupup/wxhelper.git
synced 2024-11-22 18:29:23 +08:00
feat:基础发送接口
This commit is contained in:
parent
012008f243
commit
84611a8b33
@ -62,6 +62,12 @@ bool IsDigit(const std::string &str);
|
||||
std::string Bytes2Hex(const BYTE *bytes, const int length);
|
||||
|
||||
bool IsTextUtf8(const char *str, INT64 length);
|
||||
|
||||
template <typename T>
|
||||
static T *WxHeapAlloc(size_t n) {
|
||||
return (T *)HeapAlloc(GetProcessHeap(), 0, n);
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
} // namespace base
|
||||
#endif
|
@ -34,6 +34,13 @@ void GlobalManager::initialize(HMODULE module) {
|
||||
http_server->AddHttpApiUrl("/api/execSql", ExecSql);
|
||||
http_server->AddHttpApiUrl("/api/lockWeChat", LockWeChat);
|
||||
http_server->AddHttpApiUrl("/api/unlockWeChat", UnLockWeChat);
|
||||
http_server->AddHttpApiUrl("/api/clickEnterWeChat", EnterWeChat);
|
||||
http_server->AddHttpApiUrl("/api/forwardMsg", ForwardMsg);
|
||||
http_server->AddHttpApiUrl("/api/sendImagesMsg", SendImageMsg);
|
||||
http_server->AddHttpApiUrl("/api/sendFileMsg", SendFileMsg);
|
||||
http_server->AddHttpApiUrl("/api/sendAtText", SendAtText);
|
||||
http_server->AddHttpApiUrl("/api/sendMultiAtText", SendMultiAtText);
|
||||
http_server->AddHttpApiUrl("/api/getLoginUrl", GetLoginUrl);
|
||||
|
||||
http_server->Start();
|
||||
base::ThreadPool::GetInstance().Create(2, 8);
|
||||
|
@ -11,10 +11,18 @@
|
||||
#define STR2LL(str) (base::utils::IsDigit(str) ? stoll(str) : 0)
|
||||
#define STR2I(str) (base::utils::IsDigit(str) ? stoi(str) : 0)
|
||||
namespace wxhelper {
|
||||
|
||||
std::wstring GetWStringParam(nlohmann::json data, std::string key) {
|
||||
return base::utils::Utf8ToWstring(data[key].get<std::string>());
|
||||
}
|
||||
|
||||
std::vector<std::wstring> GetArrayParam(nlohmann::json data, std::string key) {
|
||||
std::vector<std::wstring> result;
|
||||
std::wstring param = GetWStringParam(data, key);
|
||||
result = base::utils::split(param, L',');
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetIntParam(nlohmann::json data, std::string key) {
|
||||
int result;
|
||||
try {
|
||||
@ -206,4 +214,91 @@ std::string UnLockWeChat(struct mg_http_message* hm) {
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
|
||||
std::string EnterWeChat(struct mg_http_message* hm) {
|
||||
INT64 success = WechatService::GetInstance().EnterWeChat();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string ForwardMsg(struct mg_http_message* hm){
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
INT64 msg_id = GetInt64Param(j_param, "msgId");
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
INT64 success =
|
||||
wxhelper::WechatService::GetInstance().ForwardMsg(msg_id, wxid);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendImageMsg(struct mg_http_message* hm){
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
std::wstring path = GetWStringParam(j_param, "imagePath");
|
||||
INT64 success =
|
||||
wxhelper::WechatService::GetInstance().SendImageMsg(wxid, path);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendFileMsg(struct mg_http_message* hm){
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
std::wstring path = GetWStringParam(j_param, "filePath");
|
||||
INT64 success =
|
||||
wxhelper::WechatService::GetInstance().SendFileMsg(wxid, path);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendAtText(struct mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring chat_room_id = GetWStringParam(j_param, "chatRoomId");
|
||||
std::vector<std::wstring> wxids = GetArrayParam(j_param, "wxids");
|
||||
std::wstring msg = GetWStringParam(j_param, "msg");
|
||||
std::vector<std::wstring> wxid_list;
|
||||
for (unsigned int i = 0; i < wxids.size(); i++) {
|
||||
wxid_list.push_back(wxids[i]);
|
||||
}
|
||||
INT64 success = wxhelper::WechatService::GetInstance().SendAtText(
|
||||
chat_room_id, wxid_list, msg);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendMultiAtText(struct mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
nlohmann::json array = j_param["at"];
|
||||
std::vector<std::pair<std::wstring, std::wstring>> at_vector;
|
||||
if (array.is_array()) {
|
||||
for (const auto& item : array) {
|
||||
at_vector.push_back(std::make_pair(GetWStringParam(item, "wxid"),
|
||||
GetWStringParam(item, "msg")));
|
||||
}
|
||||
}
|
||||
std::wstring chat_room_id = GetWStringParam(j_param, "chatRoomId");
|
||||
INT64 success = wxhelper::WechatService::GetInstance().SendMultiAtText(
|
||||
chat_room_id, at_vector);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string GetLoginUrl(struct mg_http_message* hm) {
|
||||
std::string url = wxhelper::WechatService::GetInstance().GetLoginUrl();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", 1}, {"msg", "success"}, {"data", {{"loginUrl", url}}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
} // namespace wxhelper
|
@ -14,6 +14,13 @@ std::string GetDBInfo(struct mg_http_message *hm);
|
||||
std::string ExecSql(struct mg_http_message *hm);
|
||||
std::string LockWeChat(struct mg_http_message *hm);
|
||||
std::string UnLockWeChat(struct mg_http_message *hm);
|
||||
std::string EnterWeChat(struct mg_http_message* hm);
|
||||
std::string ForwardMsg(struct mg_http_message* hm);
|
||||
std::string SendImageMsg(struct mg_http_message* hm);
|
||||
std::string SendFileMsg(struct mg_http_message* hm);
|
||||
std::string SendAtText(struct mg_http_message* hm);
|
||||
std::string SendMultiAtText(struct mg_http_message* hm);
|
||||
std::string GetLoginUrl(struct mg_http_message* hm);
|
||||
} // namespace wxhelper
|
||||
|
||||
#endif
|
@ -290,6 +290,8 @@ typedef UINT64 (*__DoOCRTask)(UINT64, UINT64, UINT64, UINT64, UINT64);
|
||||
typedef UINT64 (*__GetLockWechatMgr)();
|
||||
typedef UINT64 (*__RequestLockWechat)(UINT64);
|
||||
typedef UINT64 (*__RequestUnLockWechat)(UINT64);
|
||||
typedef UINT64 (*__OnLoginBtnClick)(UINT64);
|
||||
typedef UINT64 (*__GetQRCodeLoginMgr)();
|
||||
|
||||
} // namespace function
|
||||
namespace prototype {
|
||||
@ -360,10 +362,10 @@ const UINT64 kSendTextMsg = 0x1091F70;
|
||||
const UINT64 kFreeChatMsg = 0x94e590;
|
||||
|
||||
const UINT64 kDoAddMsg = 0x10d9450;
|
||||
const UINT64 kSendImageMsg = 0xfc3d30;
|
||||
const UINT64 kChatMsgInstanceCounter = 0x8c7fd0;
|
||||
const UINT64 kSendFileMsg = 0xdd27f0;
|
||||
const UINT64 kGetAppMsgMgr = 0x8c33f0;
|
||||
const UINT64 kSendImageMsg = 0x1087950;
|
||||
const UINT64 kChatMsgInstanceCounter = 0x956e00;
|
||||
const UINT64 kSendFileMsg = 0xea0850;
|
||||
const UINT64 kGetAppMsgMgr = 0x951cb0;
|
||||
const UINT64 kGetContactMgr = 0x93a570;
|
||||
const UINT64 kGetContactList = 0xf6cb70;
|
||||
|
||||
@ -411,7 +413,7 @@ const UINT64 kHookLog = 0x1304e60;
|
||||
|
||||
const UINT64 kCreateChatRoom = 0xe63340;
|
||||
const UINT64 kQuitChatRoom = 0xe6e3b0;
|
||||
const UINT64 kForwardMsg = 0xfcd0f0;
|
||||
const UINT64 kForwardMsg = 0x1091660;
|
||||
|
||||
const UINT64 kOnSnsTimeLineSceneFinish = 0x1a73150;
|
||||
const UINT64 kSNSGetFirstPage = 0x1a51dd0;
|
||||
@ -423,9 +425,9 @@ const UINT64 kAddFavFromMsg = 0x1601520;
|
||||
const UINT64 kGetChatMgr = 0x8f0400;
|
||||
const UINT64 kGetFavoriteMgr = 0x8c69b0;
|
||||
const UINT64 kAddFavFromImage = 0x160b920;
|
||||
const UINT64 kGetContact = 0xEA5F90;
|
||||
const UINT64 kNewContact = 0x1212e40;
|
||||
const UINT64 kFreeContact = 0x12134e0;
|
||||
const UINT64 kGetContact = 0xf67060;
|
||||
const UINT64 kNewContact = 0x12e01f0;
|
||||
const UINT64 kFreeContact = 0x12e08a0;
|
||||
const UINT64 kNewMMReaderItem = 0x8c79a0;
|
||||
const UINT64 kFreeMMReaderItem = 0x8c6da0;
|
||||
const UINT64 kForwordPublicMsg = 0xddc6c0;
|
||||
@ -452,6 +454,10 @@ const UINT64 kGetLockWechatMgr = 0xa727b0;
|
||||
const UINT64 kRequestLockWechat = 0xa2cc70;
|
||||
const UINT64 kRequestUnLockWechat = 0xa2cf10;
|
||||
|
||||
const UINT64 kOnLoginBtnClick = 0xe0cf70;
|
||||
|
||||
const UINT64 kGetQRCodeLoginMgr = 0xdff6d0;
|
||||
|
||||
} // namespace offset
|
||||
} // namespace V3_9_8_15
|
||||
|
||||
|
@ -1,10 +1,27 @@
|
||||
#include "wechat_service.h"
|
||||
#include "wxutils.h"
|
||||
#include "utils.h"
|
||||
#include "memory.h"
|
||||
#include "db.h"
|
||||
namespace offset = wxhelper::V3_9_8_25::offset;
|
||||
namespace prototype = wxhelper::V3_9_8_25::prototype;
|
||||
namespace func = wxhelper::V3_9_8_25::function;
|
||||
namespace wxhelper {
|
||||
|
||||
prototype::WeChatString *BuildWechatString(const std::wstring &ws) {
|
||||
prototype::WeChatString *p =
|
||||
base::utils::WxHeapAlloc<prototype::WeChatString>(
|
||||
sizeof(prototype::WeChatString));
|
||||
wchar_t *p_chat_room_id =
|
||||
base::utils::WxHeapAlloc<wchar_t>((ws.size() + 1) * 2);
|
||||
wmemcpy(p_chat_room_id, ws.c_str(), ws.size() + 1);
|
||||
p->ptr = p_chat_room_id;
|
||||
p->length = static_cast<DWORD>(ws.size());
|
||||
p->max_length = static_cast<DWORD>(ws.size());
|
||||
p->c_len = 0;
|
||||
p->c_ptr = 0;
|
||||
return p;
|
||||
}
|
||||
WechatService::~WechatService() {}
|
||||
|
||||
INT64 WechatService::CheckLogin() {
|
||||
@ -20,7 +37,7 @@ INT64 WechatService::CheckLogin() {
|
||||
}
|
||||
|
||||
INT64 WechatService::GetSelfInfo(common::SelfInfoInner& out) {
|
||||
INT64 success = -1;
|
||||
INT64 success = -1;
|
||||
UINT64 accout_service_addr = base_addr_ + offset::kGetAccountServiceMgr;
|
||||
UINT64 get_app_data_save_path_addr = base_addr_ + offset::kGetAppDataSavePath;
|
||||
UINT64 get_current_data_path_addr = base_addr_ + offset::kGetCurrentDataPath;
|
||||
@ -225,12 +242,99 @@ INT64 WechatService::SendTextMsg(const std::wstring& wxid,
|
||||
|
||||
INT64 WechatService::SendImageMsg(const std::wstring& wxid,
|
||||
const std::wstring& image_path) {
|
||||
return INT64();
|
||||
INT64 success = -1;
|
||||
prototype::WeChatString to_user(wxid);
|
||||
prototype::WeChatString image_full_path(image_path);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_img_addr = base_addr_ + offset::kSendImageMsg;
|
||||
UINT64 new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr;
|
||||
func::__GetSendMessageMgr mgr =
|
||||
(func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendImageMsg send_img = (func::__SendImageMsg)send_img_addr;
|
||||
func::__FreeChatMsg free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
|
||||
char chat_msg[0x460] = {0};
|
||||
char chat_msg_temp[0x460] = {0};
|
||||
|
||||
UINT64 p_chat_msg_temp = new_chat_msg(reinterpret_cast<UINT64>(&chat_msg_temp));
|
||||
UINT64 temp1 =0;
|
||||
UINT64 temp2 =0;
|
||||
UINT64* flag[10] = {};
|
||||
flag[8] = &temp1;
|
||||
flag[9] = &temp2;
|
||||
flag[1] = reinterpret_cast<UINT64*>(p_chat_msg_temp);
|
||||
|
||||
UINT64 p_chat_msg = new_chat_msg(reinterpret_cast<UINT64>(&chat_msg));
|
||||
UINT64 send_mgr = mgr();
|
||||
send_img(send_mgr, p_chat_msg,
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&image_full_path),
|
||||
reinterpret_cast<UINT64>(&flag));
|
||||
free(p_chat_msg);
|
||||
free(p_chat_msg_temp);
|
||||
success = 1;
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::SendFileMsg(const std::wstring& wxid,
|
||||
const std::wstring& file_path) {
|
||||
return INT64();
|
||||
INT64 success = -1;
|
||||
prototype::WeChatString* to_user= (prototype::WeChatString*)HeapAlloc(GetProcessHeap(),0,sizeof(prototype::WeChatString));
|
||||
wchar_t * ptr_wxid = (wchar_t*)HeapAlloc(GetProcessHeap(),0,(wxid.length()+1)*2);
|
||||
wmemcpy(ptr_wxid,wxid.c_str(),wxid.length()+1);
|
||||
to_user->ptr = ptr_wxid;
|
||||
to_user->length = static_cast<DWORD>(wxid.length());
|
||||
to_user->max_length = static_cast<DWORD>(wxid.length());
|
||||
to_user->c_len=0;
|
||||
to_user->c_ptr=0;
|
||||
prototype::WeChatString* file_full_path= (prototype::WeChatString*)HeapAlloc(GetProcessHeap(),0,sizeof(prototype::WeChatString));
|
||||
wchar_t * ptr_path = (wchar_t*)HeapAlloc(GetProcessHeap(),0,(file_path.length()+1)*2);
|
||||
wmemcpy(ptr_path,file_path.c_str(),file_path.length()+1);
|
||||
file_full_path->ptr = ptr_path;
|
||||
file_full_path->length = static_cast<DWORD>(file_path.length());
|
||||
file_full_path->max_length = static_cast<DWORD>(file_path.length());
|
||||
file_full_path->c_len = 0;
|
||||
file_full_path->c_ptr = 0;
|
||||
|
||||
UINT64 get_app_msg_mgr_addr = base_addr_ + offset::kGetAppMsgMgr;
|
||||
UINT64 send_file_addr = base_addr_ + offset::kSendFileMsg;
|
||||
UINT64 new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr;
|
||||
func::__GetAppMsgMgr get_app_mgr =
|
||||
(func::__GetAppMsgMgr)get_app_msg_mgr_addr;
|
||||
func::__SendFile send_file = (func::__SendFile)send_file_addr;
|
||||
func::__FreeChatMsg free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
|
||||
|
||||
char* chat_msg= (char*)HeapAlloc(GetProcessHeap(),0,0x460);
|
||||
|
||||
UINT64* temp1 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
UINT64* temp2 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
UINT64* temp3 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
UINT64* temp4 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp1,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp2,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp3,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp4,sizeof(UINT64)*4);
|
||||
*temp4=0x1F;
|
||||
UINT64 app_mgr = get_app_mgr();
|
||||
send_file(app_mgr, reinterpret_cast<UINT64>(chat_msg),
|
||||
reinterpret_cast<UINT64>(to_user),
|
||||
reinterpret_cast<UINT64>(file_full_path), 1,
|
||||
reinterpret_cast<UINT64>(temp1), 0, reinterpret_cast<UINT64>(temp2),
|
||||
0, reinterpret_cast<UINT64>(temp3), 0, 0);
|
||||
free(reinterpret_cast<UINT64>(chat_msg));
|
||||
HeapFree(GetProcessHeap(),0,to_user);
|
||||
HeapFree(GetProcessHeap(),0,file_full_path);
|
||||
HeapFree(GetProcessHeap(),0,temp1);
|
||||
HeapFree(GetProcessHeap(),0,temp2);
|
||||
HeapFree(GetProcessHeap(),0,temp3);
|
||||
HeapFree(GetProcessHeap(),0,temp4);
|
||||
success = 1;
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetContacts(std::vector<common::ContactInner>& vec) {
|
||||
@ -311,7 +415,21 @@ INT64 WechatService::QuitChatRoom(const std::wstring& room_id) {
|
||||
}
|
||||
|
||||
INT64 WechatService::ForwardMsg(UINT64 msg_id, const std::wstring& wxid) {
|
||||
return INT64();
|
||||
INT64 success = -1;
|
||||
UINT64 forward_addr = base_addr_ + offset::kForwardMsg;
|
||||
func::__ForwardMsg forward_msg = (func::__ForwardMsg)forward_addr;
|
||||
INT64 index = 0;
|
||||
INT64 local_id = wxhelper::DB::GetInstance().GetLocalIdByMsgId(msg_id, index);
|
||||
if (local_id <= 0 || index >> 32 == 0) {
|
||||
success = -2;
|
||||
return success;
|
||||
}
|
||||
LARGE_INTEGER l;
|
||||
l.HighPart = index >> 32;
|
||||
l.LowPart = (DWORD)local_id;
|
||||
prototype::WeChatString *recv = BuildWechatString(wxid);
|
||||
success = forward_msg(reinterpret_cast<UINT64>(recv), l.QuadPart, 0x4, 0x0);
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetSNSFirstPage() { return INT64(); }
|
||||
@ -328,12 +446,74 @@ INT64 WechatService::AddFavFromImage(const std::wstring& wxid,
|
||||
INT64 WechatService::SendAtText(const std::wstring& room_id,
|
||||
const std::vector<std::wstring>& wxids,
|
||||
const std::wstring& msg) {
|
||||
return INT64();
|
||||
INT64 success = -1;
|
||||
std::vector<prototype::WeChatString> wxid_list;
|
||||
common::VectorInner *list = (common::VectorInner *)&wxid_list;
|
||||
std::wstring at_msg = L"";
|
||||
int number = 0;
|
||||
for (unsigned int i = 0; i < wxids.size(); i++) {
|
||||
std::wstring nickname;
|
||||
std::wstring at_all = L"notify@all";
|
||||
if (at_all.compare(wxids[i]) == 0) {
|
||||
nickname = L"\u6240\u6709\u4eba";
|
||||
} else {
|
||||
nickname = GetContactOrChatRoomNickname(wxids[i]);
|
||||
}
|
||||
if (nickname.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
prototype::WeChatString id(wxids[i]);
|
||||
wxid_list.push_back(id);
|
||||
at_msg = at_msg + L"@" + nickname + L" ";
|
||||
number++;
|
||||
}
|
||||
if (number < 1) {
|
||||
return success;
|
||||
}
|
||||
at_msg += msg;
|
||||
|
||||
INT64 head = (INT64)&list->start;
|
||||
prototype::WeChatString to_user(room_id);
|
||||
prototype::WeChatString text_msg(at_msg);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_text_msg_addr = base_addr_ + offset::kSendTextMsg;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
char chat_msg[0x460] = {0};
|
||||
func::__GetSendMessageMgr mgr= (func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendTextMsg send= (func::__SendTextMsg)send_text_msg_addr;
|
||||
func::__FreeChatMsg free= (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
mgr();
|
||||
success = send(reinterpret_cast<UINT64>(&chat_msg),
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&text_msg), head, 1, 1, 0, 0);
|
||||
free(reinterpret_cast<UINT64>(&chat_msg));
|
||||
return success;
|
||||
}
|
||||
|
||||
std::wstring WechatService::GetContactOrChatRoomNickname(
|
||||
const std::wstring& wxid) {
|
||||
return std::wstring();
|
||||
prototype::WeChatString to_user(wxid);
|
||||
UINT64 get_contact_mgr_addr = base_addr_ + offset::kGetContactMgr;
|
||||
UINT64 new_contact_addr = base_addr_ + offset::kNewContact;
|
||||
UINT64 get_contact_addr = base_addr_ + offset::kGetContact;
|
||||
UINT64 free_contact_addr = base_addr_ + offset::kFreeContact;
|
||||
func::__GetContactMgr get_contact_mgr =
|
||||
(func::__GetContactMgr)get_contact_mgr_addr;
|
||||
func::__GetContact get_contact = (func::__GetContact)get_contact_addr;
|
||||
func::__NewContact new_contact = (func::__NewContact)new_contact_addr;
|
||||
func::__FreeContact free_contact = (func::__FreeContact)free_contact_addr;
|
||||
char buff[0x6A9] = {0};
|
||||
UINT64 contact = new_contact(reinterpret_cast<UINT64>(&buff));
|
||||
UINT64 mgr = get_contact_mgr();
|
||||
INT64 success = get_contact(mgr, reinterpret_cast<UINT64>(&to_user), contact);
|
||||
if (success == 1) {
|
||||
std::wstring nickname = wxutils::ReadWstring(contact + 0xA0);
|
||||
free_contact(contact);
|
||||
return nickname;
|
||||
} else {
|
||||
free_contact(contact);
|
||||
return L"";
|
||||
}
|
||||
}
|
||||
|
||||
INT64 WechatService::GetContactByWxid(const std::wstring& wxid,
|
||||
@ -415,6 +595,78 @@ INT64 WechatService::UnLockWeChat() {
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::EnterWeChat() {
|
||||
INT64 success = -1;
|
||||
UINT64 click_cb_addr = base_addr_ + offset::kOnLoginBtnClick;
|
||||
func::__OnLoginBtnClick cb = (func::__OnLoginBtnClick)click_cb_addr;
|
||||
auto vec =
|
||||
base::memory::ScanAndMatchValue(base_addr_ + 0x34e0c18, 0x1000, 0x8);
|
||||
for (int i = 0; i < vec.size(); i++) {
|
||||
INT64 ptr = vec.at(i);
|
||||
if (*(INT64 *)ptr == base_addr_ + 0x34e0c18) {
|
||||
INT64 login_wnd = ptr;
|
||||
success = cb(ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::SendMultiAtText(
|
||||
const std::wstring &room_id,
|
||||
const std::vector<std::pair<std::wstring, std::wstring>> &at) {
|
||||
INT64 success = -1;
|
||||
std::vector<prototype::WeChatString> wxid_list;
|
||||
common::VectorInner *list = (common::VectorInner *)&wxid_list;
|
||||
std::wstring at_msg = L"";
|
||||
int number = 0;
|
||||
for (unsigned int i = 0; i < at.size(); i++) {
|
||||
std::wstring nickname;
|
||||
std::wstring at_all = L"notify@all";
|
||||
if (at_all.compare(at[i].first) == 0) {
|
||||
nickname = L"\u6240\u6709\u4eba";
|
||||
} else {
|
||||
nickname = GetContactOrChatRoomNickname(at[i].first);
|
||||
}
|
||||
if (nickname.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
prototype::WeChatString id(at[i].first);
|
||||
wxid_list.push_back(id);
|
||||
at_msg = at_msg + L"@" + nickname + L" "+ at[i].second + L" ";
|
||||
number++;
|
||||
}
|
||||
if (number < 1) {
|
||||
return success;
|
||||
}
|
||||
INT64 head = (INT64)&list->start;
|
||||
prototype::WeChatString to_user(room_id);
|
||||
prototype::WeChatString text_msg(at_msg);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_text_msg_addr = base_addr_ + offset::kSendTextMsg;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
char chat_msg[0x460] = {0};
|
||||
func::__GetSendMessageMgr mgr =
|
||||
(func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendTextMsg send = (func::__SendTextMsg)send_text_msg_addr;
|
||||
func::__FreeChatMsg free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
mgr();
|
||||
success = send(reinterpret_cast<UINT64>(&chat_msg),
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&text_msg), head, 1, 1, 0, 0);
|
||||
free(reinterpret_cast<UINT64>(&chat_msg));
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string WechatService::GetLoginUrl(){
|
||||
INT64 success = -1;
|
||||
UINT64 login_mgr_addr = base_addr_ + offset::kGetQRCodeLoginMgr;
|
||||
func::__GetQRCodeLoginMgr get = (func::__GetQRCodeLoginMgr)login_mgr_addr;
|
||||
UINT64 addr = get();
|
||||
std::string login_url = wxutils::ReadWeChatStr(addr + 0x68);
|
||||
return "http://weixin.qq.com/x/" + login_url;
|
||||
}
|
||||
|
||||
void WechatService::SetBaseAddr(UINT64 addr) { base_addr_ = addr; }
|
||||
|
||||
void WechatService::SetJsApiAddr(UINT64 addr) { js_api_addr_ = addr; }
|
||||
|
@ -72,6 +72,11 @@ class WechatService : public base::Singleton<WechatService> {
|
||||
INT64 DoOCRTask(const std::wstring& img_path, std::string& result);
|
||||
INT64 LockWeChat();
|
||||
INT64 UnLockWeChat();
|
||||
INT64 EnterWeChat();
|
||||
INT64 SendMultiAtText(
|
||||
const std::wstring& room_id,
|
||||
const std::vector<std::pair<std::wstring, std::wstring>>& at);
|
||||
std::string GetLoginUrl();
|
||||
void SetBaseAddr(UINT64 addr);
|
||||
void SetJsApiAddr(UINT64 addr);
|
||||
|
||||
|
@ -93,6 +93,9 @@ std::string ReadWstringThenConvert(INT64 addr) {
|
||||
return base::utils::WstringToUtf8(wstr);
|
||||
}
|
||||
|
||||
INT64 DecodeImage(const wchar_t* file_path, const wchar_t* save_dir){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
} // namespace wxutils
|
||||
|
313
doc/3.9.8.25.md
313
doc/3.9.8.25.md
@ -25,7 +25,7 @@ cmake --build ..
|
||||
```
|
||||
如果有错误按错误提示修正即可。
|
||||
|
||||
## 3.9.5.81版本,http接口文档,文档仅供参考。
|
||||
## 3.9.8.25版本,http接口文档,文档仅供参考。
|
||||
|
||||
### 简单说明:
|
||||
所有接口只支持post方法。
|
||||
@ -486,7 +486,7 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。
|
||||
> 锁定微信
|
||||
|
||||
###### 接口地址
|
||||
> [/api/execSql](/api/lockWeChat)
|
||||
> [/api/lockWeChat](/api/lockWeChat)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
@ -524,7 +524,7 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。
|
||||
> 锁定微信
|
||||
|
||||
###### 接口地址
|
||||
> [/api/execSql](/api/unlockWeChat)
|
||||
> [/api/unlockWeChat](/api/unlockWeChat)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
@ -556,3 +556,310 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 10.进入微信**
|
||||
###### 接口功能
|
||||
> 打开微信时的进入微信按钮
|
||||
|
||||
###### 接口地址
|
||||
> [/api/clickEnterWeChat](/api/clickEnterWeChat)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, 小于0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 11.转发消息**
|
||||
###### 接口功能
|
||||
> 转发微信消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/forwardMsg](/api/forwardMsg)
|
||||
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid|string|接收人id|
|
||||
|msgId|string|消息id|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,1成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"wxid":"filehelper",
|
||||
"msgId":"1233312233123"
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 12.发送图片**
|
||||
###### 接口功能
|
||||
> 发送图片
|
||||
|
||||
###### 接口地址I
|
||||
> [/api/sendImagesMsg](/api/sendImagesMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid|string|wxid|
|
||||
|imagePath|string|图片路径|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
{
|
||||
"wxid":"filehelper",
|
||||
"imagePath":"C:\\test.png"
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 13.发送文件消息**
|
||||
###### 接口功能
|
||||
> 发送文件消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendFileMsg](/api/sendFileMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid |true |string| 接收人wxid |
|
||||
|filePath|true |string|文件绝对路径|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,不为0成功, 0失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"wxid": "filehelper",
|
||||
"filePath": "c:\\test.zip"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":345686720,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 14.发送@消息**
|
||||
###### 接口功能
|
||||
> 发送@消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendAtText](/api/sendAtText)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxids|string|wxid字符串,多个用,分隔,发送所有人传值"notify@all"|
|
||||
|chatRoomId|string|群id|
|
||||
|msg|string|消息内容|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
|
||||
"wxids":"notify@all",
|
||||
"chatRoomId":"123@chatroom",
|
||||
"msg":"你们好啊"
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 67316444768,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 15.发送多个不同@消息**
|
||||
###### 接口功能
|
||||
> 发送多个不同@消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendMultiAtText](/api/sendMultiAtText)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|chatRoomId|string|群id|
|
||||
|at|array|消息数组|
|
||||
|  msg|string|消息内容|
|
||||
|  wxid|string|wxid字符串,多个用,分隔,发送所有人传值"notify@all"|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"chatRoomId": "213111111004@chatroom",
|
||||
"at": [
|
||||
{
|
||||
"wxid": "wxid_123",
|
||||
"msg": "1112"
|
||||
},
|
||||
{
|
||||
"wxid": "notify@all",
|
||||
"msg": "2223"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 67316444768,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 16.获取扫码登录地址**
|
||||
###### 接口功能
|
||||
> 未登录状态下,获取登录地址,转换成二维码,手机扫码登录
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getLoginUrl](/api/getLoginUrl)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|返回内容|
|
||||
|  loginUrl|string|登录地址|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {
|
||||
"loginUrl": "http://weixin.qq.com/x/extdevn1pwd_1YtY3pVY0FBTnhia1dScEtleDJ6Tl122231xJAWFVCcDAzSG5maXpjb2N0T3VmeZOUZlb0ZwdVKbFVN"
|
||||
},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user