mirror of
https://github.com/ttttupup/wxhelper.git
synced 2024-11-05 09:59:23 +08:00
feat:退群和转发
This commit is contained in:
parent
ae44434662
commit
64ba6007a8
@ -17,7 +17,9 @@ GlobalContext::~GlobalContext() {
|
||||
void GlobalContext::initialize(HMODULE module) {
|
||||
state =GlobalContextState::INITIALIZING;
|
||||
module_ = module;
|
||||
// Utils::Hide(module);
|
||||
#ifndef _DEBUG
|
||||
Utils::Hide(module);
|
||||
#endif
|
||||
UINT64 base = Utils::GetWeChatWinBase();
|
||||
config.emplace();
|
||||
config->Initialize();
|
||||
|
@ -24,13 +24,6 @@ class GlobalContext : public Singleton<GlobalContext> {
|
||||
std::unique_ptr<HttpServer> http_server;
|
||||
std::unique_ptr<Manager> mgr;
|
||||
|
||||
// std::optional<ContactMgr> contact_mgr;
|
||||
// std::optional<MiscMgr> misc_mgr;
|
||||
// std::optional<SendMessageMgr> send_mgr;
|
||||
// std::optional<AccountMgr> account_mgr;
|
||||
// std::optional<ChatRoomMgr> chat_room_mgr;
|
||||
// std::optional<SNSMgr> sns_mgr;
|
||||
|
||||
GlobalContextState state = GlobalContextState::NOT_INITIALIZED;
|
||||
|
||||
private:
|
||||
|
@ -183,7 +183,7 @@ std::string HttpDispatch(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
timeout = GetIntParam(j_param, "timeout");
|
||||
}
|
||||
INT64 success =
|
||||
wxhelper::hooks::HookSyncMsg(ip, port, url, timeout, false);
|
||||
wxhelper::hooks::HookSyncMsg(ip, port, url, timeout, enable);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
ret = ret_data.dump();
|
||||
@ -406,6 +406,23 @@ std::string HttpDispatch(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
ret = ret_data.dump();
|
||||
return ret;
|
||||
} else if (mg_http_match_uri(hm, "/api/quitChatRoom")) {
|
||||
std::wstring room_id = GetWStringParam(j_param, "chatRoomId");
|
||||
INT64 success =
|
||||
wxhelper::GlobalContext::GetInstance().mgr->QuitChatRoom(room_id);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
ret = ret_data.dump();
|
||||
return ret;
|
||||
} else if (mg_http_match_uri(hm, "/api/forwardMsg")) {
|
||||
INT64 msg_id = GetINT64Param(j_param, "msgId");
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
INT64 success =
|
||||
wxhelper::GlobalContext::GetInstance().mgr->ForwardMsg(msg_id,wxid);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
ret = ret_data.dump();
|
||||
return ret;
|
||||
} else {
|
||||
nlohmann::json ret_data = {
|
||||
{"code", 200}, {"data", {}}, {"msg", "not support url"}};
|
||||
|
@ -573,4 +573,34 @@ INT64 Manager::CreateChatRoom(const std::vector<std::wstring>& wxids){
|
||||
success = create_chat_room(mgr, head, end);
|
||||
return success;
|
||||
}
|
||||
INT64 Manager::QuitChatRoom(const std::wstring &room_id) {
|
||||
INT64 success = -1;
|
||||
UINT64 get_chat_room_mgr_addr = base_addr_ + offset::kChatRoomMgr;
|
||||
UINT64 quit_chat_room_addr = base_addr_ + offset::kQuitChatRoom;
|
||||
func::__GetChatRoomMgr get_chat_room_mgr =
|
||||
(func::__GetChatRoomMgr)get_chat_room_mgr_addr;
|
||||
func::__QuitChatRoom quit_chat_room =
|
||||
(func::__QuitChatRoom)quit_chat_room_addr;
|
||||
UINT64 mgr = get_chat_room_mgr();
|
||||
prototype::WeChatString chat_room_id(room_id);
|
||||
success = quit_chat_room(mgr, reinterpret_cast<UINT64>(&chat_room_id), 0);
|
||||
return success;
|
||||
}
|
||||
INT64 Manager::ForwardMsg(UINT64 msg_id, const std::wstring &wxid) {
|
||||
INT64 success = -1;
|
||||
UINT64 forward_addr = base_addr_ + offset::kForwardMsg;
|
||||
func::__ForwardMsg forward_msg = (func::__ForwardMsg)forward_addr;
|
||||
INT64 index = 0;
|
||||
INT64 local_id = 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;
|
||||
}
|
||||
} // namespace wxhelper
|
@ -30,6 +30,8 @@ class Manager {
|
||||
INT64 InviteMemberToChatRoom(const std::wstring& room_id,
|
||||
const std::vector<std::wstring>& wxids);
|
||||
INT64 CreateChatRoom(const std::vector<std::wstring>& wxids);
|
||||
INT64 QuitChatRoom(const std::wstring& room_id);
|
||||
INT64 ForwardMsg(UINT64 msg_id, const std::wstring& wxid);
|
||||
|
||||
private:
|
||||
UINT64 base_addr_;
|
||||
|
@ -238,6 +238,8 @@ typedef UINT64 (*__RemoveTopMsg)(UINT64,UINT64,UINT64);
|
||||
typedef UINT64 (*__InviteMemberToChatRoom)(UINT64,UINT64,UINT64,UINT64);
|
||||
|
||||
typedef UINT64 (*__CreateChatRoom)(UINT64,UINT64,UINT64);
|
||||
typedef UINT64 (*__QuitChatRoom)(UINT64,UINT64,UINT64);
|
||||
typedef UINT64 (*__ForwardMsg)(UINT64,UINT64,UINT64,UINT64);
|
||||
|
||||
|
||||
} // namespace function
|
||||
@ -342,6 +344,8 @@ const UINT64 kInviteMember = 0xe63650;
|
||||
const UINT64 kHookLog = 0x1304e60;
|
||||
|
||||
const UINT64 kCreateChatRoom = 0xe63340;
|
||||
const UINT64 kQuitChatRoom = 0xe6e3b0;
|
||||
const UINT64 kForwardMsg = 0xfcd0f0;
|
||||
|
||||
} // namespace offset
|
||||
} // namespace V3_9_5_81
|
||||
|
Loading…
Reference in New Issue
Block a user