feat:退群和转发

This commit is contained in:
hugy 2023-07-31 16:11:47 +08:00
parent 4c3c02283e
commit 1718ddefdd
6 changed files with 57 additions and 9 deletions

View File

@ -17,7 +17,9 @@ GlobalContext::~GlobalContext() {
void GlobalContext::initialize(HMODULE module) { void GlobalContext::initialize(HMODULE module) {
state =GlobalContextState::INITIALIZING; state =GlobalContextState::INITIALIZING;
module_ = module; module_ = module;
// Utils::Hide(module); #ifndef _DEBUG
Utils::Hide(module);
#endif
UINT64 base = Utils::GetWeChatWinBase(); UINT64 base = Utils::GetWeChatWinBase();
config.emplace(); config.emplace();
config->Initialize(); config->Initialize();

View File

@ -24,13 +24,6 @@ class GlobalContext : public Singleton<GlobalContext> {
std::unique_ptr<HttpServer> http_server; std::unique_ptr<HttpServer> http_server;
std::unique_ptr<Manager> mgr; 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; GlobalContextState state = GlobalContextState::NOT_INITIALIZED;
private: private:

View File

@ -183,7 +183,7 @@ std::string HttpDispatch(struct mg_connection *c, struct mg_http_message *hm) {
timeout = GetIntParam(j_param, "timeout"); timeout = GetIntParam(j_param, "timeout");
} }
INT64 success = INT64 success =
wxhelper::hooks::HookSyncMsg(ip, port, url, timeout, false); wxhelper::hooks::HookSyncMsg(ip, port, url, timeout, enable);
nlohmann::json ret_data = { nlohmann::json ret_data = {
{"code", success}, {"data", {}}, {"msg", "success"}}; {"code", success}, {"data", {}}, {"msg", "success"}};
ret = ret_data.dump(); 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", {}}}; {"code", success}, {"msg", "success"}, {"data", {}}};
ret = ret_data.dump(); ret = ret_data.dump();
return ret; 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 { } else {
nlohmann::json ret_data = { nlohmann::json ret_data = {
{"code", 200}, {"data", {}}, {"msg", "not support url"}}; {"code", 200}, {"data", {}}, {"msg", "not support url"}};

View File

@ -573,4 +573,34 @@ INT64 Manager::CreateChatRoom(const std::vector<std::wstring>& wxids){
success = create_chat_room(mgr, head, end); success = create_chat_room(mgr, head, end);
return success; 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 } // namespace wxhelper

View File

@ -30,6 +30,8 @@ class Manager {
INT64 InviteMemberToChatRoom(const std::wstring& room_id, INT64 InviteMemberToChatRoom(const std::wstring& room_id,
const std::vector<std::wstring>& wxids); const std::vector<std::wstring>& wxids);
INT64 CreateChatRoom(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: private:
UINT64 base_addr_; UINT64 base_addr_;

View File

@ -238,6 +238,8 @@ typedef UINT64 (*__RemoveTopMsg)(UINT64,UINT64,UINT64);
typedef UINT64 (*__InviteMemberToChatRoom)(UINT64,UINT64,UINT64,UINT64); typedef UINT64 (*__InviteMemberToChatRoom)(UINT64,UINT64,UINT64,UINT64);
typedef UINT64 (*__CreateChatRoom)(UINT64,UINT64,UINT64); typedef UINT64 (*__CreateChatRoom)(UINT64,UINT64,UINT64);
typedef UINT64 (*__QuitChatRoom)(UINT64,UINT64,UINT64);
typedef UINT64 (*__ForwardMsg)(UINT64,UINT64,UINT64,UINT64);
} // namespace function } // namespace function
@ -342,6 +344,8 @@ const UINT64 kInviteMember = 0xe63650;
const UINT64 kHookLog = 0x1304e60; const UINT64 kHookLog = 0x1304e60;
const UINT64 kCreateChatRoom = 0xe63340; const UINT64 kCreateChatRoom = 0xe63340;
const UINT64 kQuitChatRoom = 0xe6e3b0;
const UINT64 kForwardMsg = 0xfcd0f0;
} // namespace offset } // namespace offset
} // namespace V3_9_5_81 } // namespace V3_9_5_81