From 1ba2ed87b70651a324206b97b3e2bb6f01248cc6 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Thu, 31 Aug 2023 08:44:24 +0800 Subject: [PATCH] =?UTF-8?q?'feat:=E6=8B=8D=E4=B8=80=E6=8B=8D=EF=BC=8Cocr'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/3.9.5.81.md | 91 ++++++++++++++++++++++++++++++++++++- src/http_server_callback.cc | 17 +++++++ src/manager.cc | 43 ++++++++++++++++++ src/manager.h | 4 +- src/wechat_function.h | 6 +++ 5 files changed, 159 insertions(+), 2 deletions(-) diff --git a/doc/3.9.5.81.md b/doc/3.9.5.81.md index 4cbe307..e6462b4 100644 --- a/doc/3.9.5.81.md +++ b/doc/3.9.5.81.md @@ -1688,7 +1688,7 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。 > 发送小程序(待完善,不稳定),相关参数可以参考示例的滴滴小程序的内容自行组装。 ###### 接口地址 -> [/api/sendCustomEmotion](/api/sendApplet) +> [/api/sendApplet](/api/sendApplet) ###### HTTP请求方式 > POST JSON @@ -1737,4 +1737,93 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。 "data": {}, "msg": "success" } +``` + + +#### 35.拍一拍** +###### 接口功能 +> 拍一拍 + +###### 接口地址 +> [/api/sendPatMsg](/api/sendPatMsg) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|wxid|string|被拍人id| +|receiver|string|接收人id,可以是自己wxid,私聊好友wxid,群id| + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,大于0成功, -1失败| +|msg|string|成功提示| +|data|object|null| + +###### 接口示例 + +入参: +``` javascript + +{ +"wxid":"wxid_1234", +"receiver":"wxid_1234", + +} + +``` +响应: +``` javascript +{ + "code": 1, + "data": {}, + "msg": "success" +} +``` + + +#### 36.OCR** +###### 接口功能 +> OCR识别文字,非0时再调用一次,一般需要调用2次 + +###### 接口地址 +> [/api/ocr](/api/ocr) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|imagePath|string|图片全路径| + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,0成功, 非0时再调用一次| +|msg|string|成功提示| +|data|object|识别得结果| + +###### 接口示例 + +入参: +``` javascript + +{ + + "imagePath":"C:\\var\\123.jpg" +} +``` +响应: +``` javascript +{ + "code": 0, + "data": "17 硬卧下铺别人能不能坐?12306回应\r\n18 中南财大被解聘女讲师已失联4个多月\r\n19 新一轮存款利率下调即将落地\r\n", + "msg": "success" +} ``` \ No newline at end of file diff --git a/src/http_server_callback.cc b/src/http_server_callback.cc index 1d81a6f..381b0ed 100644 --- a/src/http_server_callback.cc +++ b/src/http_server_callback.cc @@ -579,6 +579,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/sendPatMsg")) { + std::wstring room_id = GetWStringParam(j_param, "receiver"); + std::wstring wxid = GetWStringParam(j_param, "wxid"); + INT64 success = + wxhelper::GlobalContext::GetInstance().mgr->SendPatMsg(room_id, wxid); + nlohmann::json ret_data = { + {"code", success}, {"msg", "success"}, {"data", {}}}; + ret = ret_data.dump(); + return ret; + } else if (mg_http_match_uri(hm, "/api/ocr")) { + std::wstring image_path = GetWStringParam(j_param, "imagePath"); + std::string text(""); + INT64 success = wxhelper::GlobalContext::GetInstance().mgr->DoOCRTask(image_path,text); + nlohmann::json ret_data = { + {"code", success}, {"msg", "success"}, {"data", text}}; + ret = ret_data.dump(); + return ret; } else if (mg_http_match_uri(hm, "/api/test")) { INT64 success = wxhelper::GlobalContext::GetInstance().mgr->Test(); nlohmann::json ret_data = { diff --git a/src/manager.cc b/src/manager.cc index 46605cf..8140466 100644 --- a/src/manager.cc +++ b/src/manager.cc @@ -1213,6 +1213,49 @@ INT64 Manager::SendApplet(const std::wstring &recv_wxid, return success; } +INT64 Manager::SendPatMsg(const std::wstring &room_id, + const std::wstring &wxid) { + INT64 success = -1; + UINT64 send_pat_msg_addr = base_addr_ + offset::kSendPatMsg; + func::__SendPatMsg send_pat_msg =(func::__SendPatMsg)send_pat_msg_addr; + prototype::WeChatString chat_room(room_id); + prototype::WeChatString target(wxid); + success = send_pat_msg(reinterpret_cast(&chat_room),reinterpret_cast(&target)); + return success; +} + +INT64 Manager::DoOCRTask(const std::wstring &img_path, std::string &result) { + INT64 success = -1; + UINT64 ocr_manager_addr = base_addr_ + offset::kGetOCRManager; + func::__GetOCRManager ocr_manager = (func::__GetOCRManager)ocr_manager_addr; + + UINT64 do_ocr_task_addr = base_addr_ + offset::kDoOCRTask; + func::__DoOCRTask do_ocr_task = (func::__DoOCRTask)do_ocr_task_addr; + + prototype::WeChatString img(img_path); + std::vector *temp = Utils::WxHeapAlloc>(0x20); + INT64 unkonwn = 0; + common::VectorInner *list = (common::VectorInner *)temp; + list->start = reinterpret_cast(&list->start); + list->finsh = list->start; + char buff[0x28] = {0}; + memcpy(buff, &list->start, sizeof(INT64)); + UINT64 mgr = ocr_manager(); + success = do_ocr_task(mgr, reinterpret_cast(&img),1, + reinterpret_cast(buff),reinterpret_cast(&unkonwn)); + INT64 number = *(INT64 *)(buff + 0x8); + if (number > 0) { + INT64 header = list->start; + for (unsigned int i = 0; i < number - 1; i++) { + INT64 content = *(INT64 *)header; + result += Utils::ReadWstringThenConvert(content + 0x28); + result += "\r\n"; + header = content; + } + } + return success; +} + INT64 Manager::Test() { auto vec = Utils::QWordScan(base_addr_ + 0x32D1318, 0x1, L"WeChatWin.dll"); for (int i = 0; i < vec.size(); i++) { diff --git a/src/manager.h b/src/manager.h index eea98f4..95ed1fd 100644 --- a/src/manager.h +++ b/src/manager.h @@ -56,12 +56,14 @@ class Manager { INT64 GetVoiceByDB(ULONG64 msg_id, const std::wstring& dir); INT64 SendCustomEmotion(const std::wstring& file_path, const std::wstring& wxid); - INT64 Manager::SendApplet( + INT64 SendApplet( const std::wstring& recv_wxid, const std::wstring& waid_suff, const std::wstring& waid_w, const std::string& waid_s, const std::string& wa_wxid, const std::string& json_param, const std::string& head_image, const std::string& big_image, const std::string& index_page); + INT64 SendPatMsg(const std::wstring& room_id, const std::wstring& wxid); + INT64 DoOCRTask(const std::wstring& img_path, std::string &result); INT64 Test(); private: UINT64 base_addr_; diff --git a/src/wechat_function.h b/src/wechat_function.h index aa78d6d..9aeff1f 100644 --- a/src/wechat_function.h +++ b/src/wechat_function.h @@ -282,6 +282,9 @@ typedef UINT64 (*__GetAppInfoByWaid)(UINT64,UINT64); typedef UINT64 (*__CopyShareAppMessageRequest)(UINT64,UINT64); typedef UINT64 (*__NewWAUpdatableMsgInfo)(UINT64); typedef UINT64 (*__FreeWAUpdatableMsgInfo)(UINT64); +typedef UINT64 (*__SendPatMsg)(UINT64,UINT64); +typedef UINT64 (*__GetOCRManager)(); +typedef UINT64 (*__DoOCRTask)(UINT64,UINT64,UINT64,UINT64,UINT64); } // namespace function @@ -440,6 +443,9 @@ const UINT64 kGetAppInfoByWaid = 0x13c5790; const UINT64 kCopyShareAppMessageRequest = 0x13c0670; const UINT64 kNewWAUpdatableMsgInfo = 0x919ca0; const UINT64 kFreeWAUpdatableMsgInfo = 0x8fc230; +const UINT64 kSendPatMsg = 0x195f340; +const UINT64 kGetOCRManager = 0x999780; +const UINT64 kDoOCRTask = 0x190b2a0; } // namespace offset } // namespace V3_9_5_81