diff --git a/doc/3.9.5.81.md b/doc/3.9.5.81.md index b0fcce6..f335d5e 100644 --- a/doc/3.9.5.81.md +++ b/doc/3.9.5.81.md @@ -985,6 +985,92 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。 ``` javascript +``` +响应: +``` javascript +{ + "code": 1, + "data": null, + "msg": "success" +} +``` + +#### 20.退群** +###### 接口功能 +> 退群 + +###### 接口地址 +> [/api/quitChatRoom](/api/quitChatRoom) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|chatRoomId|string|群id| + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,大于0成功, -1失败| +|msg|string|成功提示| +|data|object|null| + + +###### 接口示例 + +入参: +``` javascript +{ + "chatRoomId":"123456@chatroom" +} + +``` +响应: +``` javascript +{ + "code": 119536579329, + "data": null, + "msg": "success" +} +``` + +#### 21.转发消息** +###### 接口功能 +> 转发消息 + +###### 接口地址 +> [/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 diff --git a/python/3.9.5.81/http_client.py b/python/3.9.5.81/http_client.py index df84819..dc2317b 100644 --- a/python/3.9.5.81/http_client.py +++ b/python/3.9.5.81/http_client.py @@ -274,6 +274,36 @@ def createChatRoom(): response = requests.request("POST", url, headers=headers, data=payload) print(response.text) +def quitChatRoom(): + print("modify chatRoomId ") + raise RuntimeError("modify chatRoomId then deleted me") + url = "127.0.0.1:19088/api/quitChatRoom" + + payload = json.dumps({ + "chatRoomId": "123@chatroom" + }) + headers = { + 'Content-Type': 'application/json' + } + + response = requests.request("POST", url, headers=headers, data=payload) + print(response.text) + +def forwardMsg(): + print("modify msgId ") + raise RuntimeError("modify msgId then deleted me") + url = "127.0.0.1:19088/api/forwardMsg" + + payload = json.dumps({ + "wxid": "filehelper", + "msgId": "12331" + }) + headers = { + 'Content-Type': 'application/json' + } + response = requests.request("POST", url, headers=headers, data=payload) + print(response.text) + if __name__ == '__main__': checkLogin() diff --git a/src/global_context.cc b/src/global_context.cc index e4524c8..e2fc474 100644 --- a/src/global_context.cc +++ b/src/global_context.cc @@ -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(); diff --git a/src/global_context.h b/src/global_context.h index 8e7e332..0e49dfc 100644 --- a/src/global_context.h +++ b/src/global_context.h @@ -24,13 +24,6 @@ class GlobalContext : public Singleton { std::unique_ptr http_server; std::unique_ptr mgr; - // std::optional contact_mgr; - // std::optional misc_mgr; - // std::optional send_mgr; - // std::optional account_mgr; - // std::optional chat_room_mgr; - // std::optional sns_mgr; - GlobalContextState state = GlobalContextState::NOT_INITIALIZED; private: diff --git a/src/http_server_callback.cc b/src/http_server_callback.cc index 4bafe5a..a495747 100644 --- a/src/http_server_callback.cc +++ b/src/http_server_callback.cc @@ -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"}}; diff --git a/src/manager.cc b/src/manager.cc index 9bf4e53..0bde19b 100644 --- a/src/manager.cc +++ b/src/manager.cc @@ -573,4 +573,34 @@ INT64 Manager::CreateChatRoom(const std::vector& 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(&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(recv), l.QuadPart, 0x4, 0x0); + return success; +} } // namespace wxhelper \ No newline at end of file diff --git a/src/manager.h b/src/manager.h index f1edf3c..3d0fff8 100644 --- a/src/manager.h +++ b/src/manager.h @@ -30,6 +30,8 @@ class Manager { INT64 InviteMemberToChatRoom(const std::wstring& room_id, const std::vector& wxids); INT64 CreateChatRoom(const std::vector& wxids); + INT64 QuitChatRoom(const std::wstring& room_id); + INT64 ForwardMsg(UINT64 msg_id, const std::wstring& wxid); private: UINT64 base_addr_; diff --git a/src/wechat_function.h b/src/wechat_function.h index 9656d40..47bf639 100644 --- a/src/wechat_function.h +++ b/src/wechat_function.h @@ -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