Compare commits

...
Author SHA1 Message Date
ttttupup 2eb798458c feat:补充好友标签,增加打开url 2024-01-06 13:56:51 +08:00
ttttupup 28db38b45e feat: 语音转换 2023-12-26 18:00:05 +08:00
14 changed files with 5737 additions and 3 deletions
+2 -1
View File
@@ -3,4 +3,5 @@ cmake_minimum_required(VERSION 3.10...3.27)
add_subdirectory(base64)
add_subdirectory(lz4)
add_subdirectory(mongoose)
add_subdirectory(spdlog)
add_subdirectory(spdlog)
add_subdirectory(tinyxml2)
+15
View File
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10...3.27)
aux_source_directory(. TINYXML2_SOURCE)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
#add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
add_library(tinyxml2 ${TINYXML2_SOURCE})
add_library(tinyxml2::tinyxml2 ALIAS tinyxml2)
target_include_directories(tinyxml2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+2994
View File
File diff suppressed because it is too large Load Diff
+2380
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -38,6 +38,7 @@ target_include_directories(wxhelper
PRIVATE ../3rdparty/base64
PRIVATE ../3rdparty/lz4
PRIVATE ../3rdparty/mongoose
PRIVATE ../3rdparty/tinyxml2
PRIVATE ../base/src/include
)
@@ -49,6 +50,7 @@ target_link_libraries(wxhelper
PRIVATE mongoose
PRIVATE nlohmann_json::nlohmann_json
PRIVATE base
PRIVATE tinyxml2
)
SET_TARGET_PROPERTIES(wxhelper PROPERTIES LINKER_LANGUAGE C
+18
View File
@@ -492,4 +492,22 @@ std::string DB::GetPublicMsgCompressContentByMsgId(ULONG64 msgid) {
return result[1][0];
}
std::string DB::GetChatMsgStrContentByMsgId(ULONG64 msgid) {
char sql[260] = {0};
sprintf_s(sql, "select StrContent from MSG where MsgSvrID=%llu;", msgid);
wchar_t dbname[20] = {0};
for (int i = 0;; i++) {
swprintf_s(dbname, L"MSG%d.db", i);
UINT64 handle = GetDbHandleByDbName(dbname);
if (handle == 0) {
SPDLOG_INFO("MSG db handle is null");
return {};
}
std::vector<std::vector<std::string>> result;
int ret = Select(handle, (const char *)sql, result);
if (result.size() == 0) continue;
return result[1][0];
}
return {};
}
} // namespace wxhelper
+2
View File
@@ -24,6 +24,8 @@ class DB : public base::Singleton<DB> {
std::string GetPublicMsgCompressContentByMsgId(ULONG64 msgid);
std::string GetChatMsgStrContentByMsgId(ULONG64 msgid);
private:
int ExecSelect(UINT64 db, const char *sql,
std::vector<std::vector<common::SqlResult>> &data);
+3
View File
@@ -41,6 +41,9 @@ void GlobalManager::initialize(HMODULE module) {
http_server->AddHttpApiUrl("/api/sendAtText", SendAtText);
http_server->AddHttpApiUrl("/api/sendMultiAtText", SendMultiAtText);
http_server->AddHttpApiUrl("/api/getLoginUrl", GetLoginUrl);
http_server->AddHttpApiUrl("/api/translateVoice", TranslateVoice);
http_server->AddHttpApiUrl("/api/getTranslateVoiceText", GetTranslateVoiceText);
http_server->AddHttpApiUrl("/api/openUrlByWeChat", OpenUrlByWeChat);
http_server->Start();
base::ThreadPool::GetInstance().Create(2, 8);
+36
View File
@@ -103,6 +103,10 @@ std::string GetContacts(mg_http_message* hm) {
{"pinyinAll", vec[i].pinyin_all},
{"reserved1", vec[i].reserved1},
{"reserved2", vec[i].reserved2},
{"remark",vec[i].remark},
{"remarkPinyin",vec[i].remark_pinyin},
{"remarkPinyinAll",vec[i].remark_pinyin_all},
{"labelIds",vec[i].label_ids},
};
ret_data["data"].push_back(item);
}
@@ -301,4 +305,36 @@ std::string GetLoginUrl(struct mg_http_message* hm) {
return ret_data.dump();
}
std::string TranslateVoice(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");
INT64 success = wxhelper::WechatService::GetInstance().TranslateVoice(msg_id);
nlohmann::json ret_data = {
{"code", success}, {"msg", "success"}, {"data", {}}};
return ret_data.dump();
}
std::string GetTranslateVoiceText(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::string content =
wxhelper::WechatService::GetInstance().GetTranslateVoiceText(msg_id);
nlohmann::json ret_data = {
{"code", 1}, {"msg", "success"}, {"data", {{"transtext", content}}}};
return ret_data.dump();
}
std::string OpenUrlByWeChat(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 url = GetWStringParam(j_param, "url");
int flag = GetIntParam(j_param, "flag");
INT64 success =
wxhelper::WechatService::GetInstance().OpenUrlByWeChatBrowser(url,flag);
nlohmann::json ret_data = {
{"code", success}, {"msg", "success"}, {"data", {}}};
return ret_data.dump();
}
} // namespace wxhelper
+3
View File
@@ -21,6 +21,9 @@ 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);
std::string TranslateVoice(struct mg_http_message* hm);
std::string GetTranslateVoiceText(struct mg_http_message* hm);
std::string OpenUrlByWeChat(struct mg_http_message* hm);
} // namespace wxhelper
#endif
+29 -2
View File
@@ -142,6 +142,10 @@ struct ContactInner {
std::string nickname;
std::string pinyin;
std::string pinyin_all;
std::string remark;
std::string remark_pinyin;
std::string remark_pinyin_all;
std::string label_ids;
DWORD type;
DWORD verify_flag;
DWORD reserved1;
@@ -153,6 +157,10 @@ struct ContactInner {
nickname = "";
pinyin = "";
pinyin_all = "";
remark = "";
remark_pinyin = "";
remark_pinyin_all = "";
label_ids = "";
type = -1;
verify_flag = -1;
reserved1 = -1;
@@ -292,6 +300,15 @@ typedef UINT64 (*__RequestLockWechat)(UINT64);
typedef UINT64 (*__RequestUnLockWechat)(UINT64);
typedef UINT64 (*__OnLoginBtnClick)(UINT64);
typedef UINT64 (*__GetQRCodeLoginMgr)();
typedef UINT64 (*__UpdateMsg)(UINT64,UINT64,UINT64);
typedef UINT64 (*__GetVoiceMgr)();
typedef UINT64 (*__ChatMsg2NetSceneSendMsg)(UINT64,UINT64);
typedef UINT64 (*__TranslateVoice)(UINT64,UINT64,UINT64);
typedef UINT64 (*__ShowWebView)(UINT64,UINT64,UINT64,UINT64,UINT64,UINT64);
typedef UINT64 (*__NewWebViewPageConfig)(UINT64);
typedef UINT64 (*__FreeWebViewPageConfig)(UINT64);
typedef UINT64 (*__GetWebViewMgr)();
typedef UINT64 (*__SetUrl)(UINT64,UINT64,UINT64);
} // namespace function
namespace prototype {
@@ -420,9 +437,9 @@ const UINT64 kSNSGetFirstPage = 0x1a51dd0;
const UINT64 kSNSGetNextPageScene = 0x1a77240;
const UINT64 kSNSDataMgr = 0xeebda0;
const UINT64 kSNSTimeLineMgr = 0x19e83a0;
const UINT64 kGetMgrByPrefixLocalId = 0xe4add0;
const UINT64 kGetMgrByPrefixLocalId = 0xf0ea60;
const UINT64 kAddFavFromMsg = 0x1601520;
const UINT64 kGetChatMgr = 0x8f0400;
const UINT64 kGetChatMgr = 0x97e4d0;
const UINT64 kGetFavoriteMgr = 0x8c69b0;
const UINT64 kAddFavFromImage = 0x160b920;
const UINT64 kGetContact = 0xf67060;
@@ -458,6 +475,16 @@ const UINT64 kOnLoginBtnClick = 0xe0cf70;
const UINT64 kGetQRCodeLoginMgr = 0xdff6d0;
const UINT64 kUpdateMsg = 0xf15c40;
const UINT64 kGetVoiceMgr = 0xbf78f0;
const UINT64 kChatMsg2NetSceneSendMsg = 0x96e8d0;
const UINT64 kTranslateVoice = 0x11217e0;
const UINT64 kNewWebViewPageConfig = 0x9512f0;
const UINT64 kFreeWebViewPageConfig = 0x951520;
const UINT64 kGetWebViewMgr = 0x9412d0;
const UINT64 kShowWebView = 0x1d236b0;
const UINT64 kSetUrl = 0x13dd410;
} // namespace offset
} // namespace V3_9_8_15
+111
View File
@@ -3,6 +3,8 @@
#include "utils.h"
#include "memory.h"
#include "db.h"
#include "tinyxml2.h"
#include "spdlog/spdlog.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;
@@ -356,6 +358,10 @@ INT64 WechatService::GetContacts(std::vector<common::ContactInner>& vec) {
temp.wxid = wxutils::ReadWstringThenConvert(start + 0x10);
temp.custom_account = wxutils::ReadWstringThenConvert(start + 0x30);
temp.encrypt_name = wxutils::ReadWstringThenConvert(start + 0x50);
temp.remark = wxutils::ReadWstringThenConvert(start + 0x80);
temp.remark_pinyin = wxutils::ReadWstringThenConvert(start + 0x148);
temp.remark_pinyin_all = wxutils::ReadWstringThenConvert(start + 0x168);
temp.label_ids = wxutils::ReadWstringThenConvert(start + 0xc0);
temp.nickname = wxutils::ReadWstringThenConvert(start + 0xA0);
temp.pinyin = wxutils::ReadWstringThenConvert(start + 0x108);
temp.pinyin_all = wxutils::ReadWstringThenConvert(start + 0x128);
@@ -671,5 +677,110 @@ void WechatService::SetBaseAddr(UINT64 addr) { base_addr_ = addr; }
void WechatService::SetJsApiAddr(UINT64 addr) { js_api_addr_ = addr; }
INT64 WechatService::TranslateVoice(UINT64 msg_id){
INT64 success = -1;
UINT64 get_by_local_id_addr = base_addr_ + offset::kGetMgrByPrefixLocalId;
func::__GetMgrByPrefixLocalId get_by_local_id =
(func::__GetMgrByPrefixLocalId)get_by_local_id_addr;
UINT64 get_chat_mgr_addr = base_addr_ + offset::kGetChatMgr;
func::__GetChatMgr get_chat_mgr = (func::__GetChatMgr)get_chat_mgr_addr;
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
func::__FreeChatMsg free_chat_msg = (func::__FreeChatMsg)free_chat_msg_addr;
UINT64 new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter;
func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr;
UINT64 update_addr = base_addr_ + offset::kUpdateMsg;
func::__UpdateMsg update = (func::__UpdateMsg)update_addr;
UINT64 get_voice_mgr_addr = base_addr_ + offset::kGetVoiceMgr;
func::__GetVoiceMgr get_voice_mgr = (func::__GetVoiceMgr)get_voice_mgr_addr;
UINT64 to_msg_addr = base_addr_ + offset::kChatMsg2NetSceneSendMsg;
func::__ChatMsg2NetSceneSendMsg to_msg =
(func::__ChatMsg2NetSceneSendMsg)to_msg_addr;
UINT64 trans_addr = base_addr_ + offset::kTranslateVoice;
func::__TranslateVoice translate_voice = (func::__TranslateVoice)trans_addr;
char temp_msg[0x460] = {0};
char *chat_msg = base::utils::WxHeapAlloc<char>(0x460);
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;
UINT64 p_chat_msg = new_chat_msg(reinterpret_cast<UINT64>(chat_msg));
get_chat_mgr();
get_by_local_id(l.QuadPart, p_chat_msg);
UINT64 mgr = get_chat_mgr();
update(mgr, p_chat_msg, 0);
UINT64 voice_mgr = get_voice_mgr();
UINT64 msg = to_msg(reinterpret_cast<UINT64>(&temp_msg), p_chat_msg);
success = translate_voice(voice_mgr, msg, 0);
return success;
}
std::string WechatService::GetTranslateVoiceText(UINT64 msg_id) {
std::string content = DB::GetInstance().GetChatMsgStrContentByMsgId(msg_id);
if (content.empty()) {
return {};
}
tinyxml2::XMLDocument doc;
if (doc.Parse(content.c_str(), content.size()) != 0) {
SPDLOG_INFO("tinyxml2 parse error");
return {};
}
tinyxml2::XMLElement *msg = doc.FirstChildElement("msg");
if (msg != nullptr) {
tinyxml2::XMLElement *voicetrans = msg->FirstChildElement("voicetrans");
if (voicetrans != nullptr) {
const char *value = voicetrans->Attribute("transtext",nullptr);
return value;
}
}
return "";
}
INT64 WechatService::OpenUrlByWeChatBrowser(const std::wstring &url, int flag) {
INT64 success = -1;
UINT64 config_addr = base_addr_ + offset::kNewWebViewPageConfig;
func::__NewWebViewPageConfig config =(func::__NewWebViewPageConfig)config_addr;
UINT64 free_config_addr = base_addr_ + offset::kFreeWebViewPageConfig;
func::__FreeWebViewPageConfig free_config =(func::__FreeWebViewPageConfig)free_config_addr;
UINT64 web_view_mgr_addr = base_addr_ + offset::kGetWebViewMgr;
func::__GetWebViewMgr web_view_mgr = (func::__GetWebViewMgr)web_view_mgr_addr;
UINT64 show_addr = base_addr_ + offset::kShowWebView;
func::__ShowWebView show_web_view = (func::__ShowWebView)show_addr;
UINT64 set_url_addr = base_addr_ + offset::kSetUrl;
func::__SetUrl set_url = (func::__SetUrl)set_url_addr;
int a = flag >> 4;
int b = flag & 0x1;
int c = flag & 0x2;
int d = flag & 0x4;
int e = flag & 0x8;
char* web_config= (char*)HeapAlloc(GetProcessHeap(),0,0xA20);
UINT64 ptr = config(reinterpret_cast<UINT64>(web_config));
set_url( ptr + 0x868,reinterpret_cast<UINT64>(url.c_str()),url.size());
web_view_mgr();
success = show_web_view(ptr,a,b,c,d,e);
free_config(ptr);
return success;
}
} // namespace wxhelper
+3
View File
@@ -79,6 +79,9 @@ class WechatService : public base::Singleton<WechatService> {
std::string GetLoginUrl();
void SetBaseAddr(UINT64 addr);
void SetJsApiAddr(UINT64 addr);
INT64 TranslateVoice(UINT64 msg_id);
std::string GetTranslateVoiceText(UINT64 msg_id);
INT64 OpenUrlByWeChatBrowser(const std::wstring& url, int flag);
private:
UINT64 base_addr_;
+139
View File
@@ -288,6 +288,10 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。
|&#8194;&#8194;nickname|string|昵称|
|&#8194;&#8194;pinyin|string|简拼|
|&#8194;&#8194;pinyinAll|string|全拼|
|&#8194;&#8194;remark|string|备注|
|&#8194;&#8194;remark_pinyin|string|备注拼音|
|&#8194;&#8194;remark_pinyin_all|string|备注全拼|
|&#8194;&#8194;label_ids|string|标签id|
|&#8194;&#8194;reserved1|number|未知|
|&#8194;&#8194;reserved2|number|未知|
|&#8194;&#8194;type|number|未知|
@@ -312,6 +316,10 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。
"nickname": "文件传输助手",
"pinyin": "WJCSZS",
"pinyinAll": "wenjianchuanshuzhushou",
"remark":"",
"remark_pinyin":"",
"remark_pinyin_all":"",
"label_ids":"",
"reserved1": 1,
"reserved2": 1,
"type": 3,
@@ -862,4 +870,135 @@ enableHttp=0时,使用ip,port的tcp服务回传消息。
},
"msg": "success"
}
```
#### 17.语音转文本**
###### 接口功能
> 语音消息转换文本
###### 接口地址
> [/api/translateVoice](/api/translateVoice)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
|msgId|string|消息id|
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,大于0成功, -1失败|
|msg|string|成功提示|
|data|object|返回内容|
###### 接口示例
入参:
``` javascript
{
"msgId":"23206240123137465"
}
```
响应:
``` javascript
{
"code": 1,
"data": null,
"msg": "success"
}
```
#### 18.获取语音转文本结果**
###### 接口功能
> 获取语音转文本结果 (可以使用数据库查询功能查询,该接口只是为了方便减少hook)
###### 接口地址
> [/api/getTranslateVoiceText](/api/getTranslateVoiceText)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
|msgId|string|消息id|
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,大于0成功, -1失败|
|msg|string|成功提示|
|data|object|返回内容|
|&#8194;&#8194;transtext|string|转换文本|
###### 接口示例
入参:
``` javascript
{
"msgId":"23206212223137465"
}
```
响应:
``` javascript
{
"code": 1,
"data": {
"transtext": "冲冲,冲冲。"
},
"msg": "success"
}
```
#### 19.通过浏览器打开url**
###### 接口功能
> 微信内置浏览器打开url,或者本地浏览器打开url
###### 接口地址
> [/api/openUrlByWeChat](/api/openUrlByWeChat)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
|url|string|需要打开的链接|
|flag|number|内置或者本地浏览器mask ,后四位按位取值,具体参数意义自行尝试,简单可直接传0,1,2|
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,大于0成功, -1失败|
|msg|string|成功提示|
|data|object|返回内容|
###### 接口示例
入参:
``` javascript
{
"url":"http://mp.weixin.qq.com/s?__biz=MzUzMTA",
"flag":2
}
```
响应:
``` javascript
{
"code": 1,
"data": null,
"msg": "success"
}
```