mirror of
https://github.com/ttttupup/wxhelper.git
synced 2024-11-05 18:09:24 +08:00
feat: 好友列表
This commit is contained in:
parent
8ab646be96
commit
1ff56fc055
@ -24,6 +24,9 @@ void GlobalManager::initialize(HMODULE module) {
|
||||
new http::HttpServer(config->GetPort()));
|
||||
http_server->AddHttpApiUrl("/api/sendTextMsg", SendTextMsg);
|
||||
http_server->AddHttpApiUrl("/api/hookSyncMsg", HookSyncMsg);
|
||||
http_server->AddHttpApiUrl("/api/getContactList", GetContacts);
|
||||
http_server->AddHttpApiUrl("/api/unhookSyncMsg", UnHookSyncMsg);
|
||||
|
||||
http_server->Start();
|
||||
base::ThreadPool::GetInstance().Create(2, 8);
|
||||
|
||||
|
@ -66,4 +66,34 @@ std::string HookSyncMsg(mg_http_message* hm) {
|
||||
std::string ret = ret_data.dump();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string GetContacts(mg_http_message* hm) {
|
||||
std::vector<common::ContactInner> vec;
|
||||
INT64 success = WechatService::GetInstance().GetContacts(vec);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
for (unsigned int i = 0; i < vec.size(); i++) {
|
||||
nlohmann::json item = {
|
||||
{"customAccount", vec[i].custom_account},
|
||||
{"encryptName", vec[i].encrypt_name},
|
||||
{"type", vec[i].type},
|
||||
{"verifyFlag", vec[i].verify_flag},
|
||||
{"wxid", vec[i].wxid},
|
||||
{"nickname", vec[i].nickname},
|
||||
{"pinyin", vec[i].pinyin},
|
||||
{"pinyinAll", vec[i].pinyin_all},
|
||||
{"reserved1", vec[i].reserved1},
|
||||
{"reserved2", vec[i].reserved2},
|
||||
};
|
||||
ret_data["data"].push_back(item);
|
||||
}
|
||||
std::string ret = ret_data.dump();
|
||||
return ret;
|
||||
}
|
||||
std::string UnHookSyncMsg(mg_http_message* hm) {
|
||||
INT64 success = hook::WechatHook::GetInstance().UnHookSyncMsg();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
} // namespace wxhelper
|
@ -6,6 +6,8 @@
|
||||
namespace wxhelper {
|
||||
std::string SendTextMsg(struct mg_http_message *hm);
|
||||
std::string HookSyncMsg(struct mg_http_message *hm);
|
||||
std::string GetContacts(struct mg_http_message *hm);
|
||||
std::string UnHookSyncMsg(struct mg_http_message *hm);
|
||||
}
|
||||
|
||||
#endif
|
@ -488,12 +488,16 @@ const UINT64 kGetSendMessageMgr = 0x8fe740;
|
||||
const UINT64 kFreeChatMsg = 0x8fffc0;
|
||||
const UINT64 kSendTextMsg = 0x1024370;
|
||||
const UINT64 kDoAddMsg = 0x106b810;
|
||||
const UINT64 kGetContactMgr = 0x8ebfb0;
|
||||
const UINT64 kGetContactList = 0xeff050;
|
||||
} // namespace offset
|
||||
namespace function {
|
||||
typedef UINT64 (*__GetSendMessageMgr)();
|
||||
typedef UINT64 (*__SendTextMsg)(UINT64, UINT64, UINT64, UINT64, UINT64, UINT64,
|
||||
UINT64, UINT64);
|
||||
typedef UINT64 (*__FreeChatMsg)(UINT64);
|
||||
typedef UINT64 (*__GetContactMgr)();
|
||||
typedef UINT64 (*__GetContactList)(UINT64, UINT64);
|
||||
} // namespace function
|
||||
} // namespace V3_9_7_29
|
||||
} // namespace wxhelper
|
||||
|
@ -184,4 +184,22 @@ int WechatHook::HookSyncMsg() {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace hook
|
||||
int WechatHook::UnHookSyncMsg() {
|
||||
if (!sync_msg_flag_) {
|
||||
SPDLOG_INFO("call UnHookSyncMsg but no hooked ");
|
||||
return NO_ERROR;
|
||||
}
|
||||
UINT64 base = wxhelper::wxutils::GetWeChatWinBase();
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach(&(PVOID &)RealDoAddMsg, &HandleSyncMsg);
|
||||
LONG ret = DetourTransactionCommit();
|
||||
if (ret == NO_ERROR) {
|
||||
sync_msg_flag_ = false;
|
||||
strcpy_s(kServerIp, "127.0.0.1");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int WechatHook::HookLog() { return 0; }
|
||||
int WechatHook::UnHookLog() { return 0; }
|
||||
} // namespace hook
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "wechat_service.h"
|
||||
#include "wxutils.h"
|
||||
namespace offset = wxhelper::V3_9_7_29::offset;
|
||||
namespace prototype = wxhelper::V3_9_7_29::prototype;
|
||||
namespace func = wxhelper::V3_9_7_29::function;
|
||||
@ -46,7 +47,35 @@ INT64 WechatService::SendFileMsg(const std::wstring& wxid,
|
||||
}
|
||||
|
||||
INT64 WechatService::GetContacts(std::vector<common::ContactInner>& vec) {
|
||||
return INT64();
|
||||
INT64 success = -1;
|
||||
UINT64 get_contact_mgr_addr = base_addr_ + offset::kGetContactMgr;
|
||||
UINT64 get_contact_list_addr = base_addr_ + offset::kGetContactList;
|
||||
func::__GetContactMgr get_contact_mgr =
|
||||
(func::__GetContactMgr)get_contact_mgr_addr;
|
||||
func::__GetContactList get_contact_list =
|
||||
(func::__GetContactList)get_contact_list_addr;
|
||||
UINT64 mgr = get_contact_mgr();
|
||||
UINT64 contact_vec[3] = {0, 0, 0};
|
||||
success = get_contact_list(mgr, reinterpret_cast<UINT64>(&contact_vec));
|
||||
|
||||
UINT64 start = contact_vec[0];
|
||||
UINT64 end = contact_vec[2];
|
||||
while (start < end) {
|
||||
common::ContactInner temp;
|
||||
temp.wxid = wxutils::ReadWstringThenConvert(start + 0x10);
|
||||
temp.custom_account = wxutils::ReadWstringThenConvert(start + 0x30);
|
||||
temp.encrypt_name = wxutils::ReadWstringThenConvert(start + 0x50);
|
||||
temp.nickname = wxutils::ReadWstringThenConvert(start + 0xA0);
|
||||
temp.pinyin = wxutils::ReadWstringThenConvert(start + 0x108);
|
||||
temp.pinyin_all = wxutils::ReadWstringThenConvert(start + 0x128);
|
||||
temp.verify_flag = *(DWORD *)(start + 0x70);
|
||||
temp.type = *(DWORD *)(start + 0x74);
|
||||
temp.reserved1 = *(DWORD *)(start + 0x1F0);
|
||||
temp.reserved2 = *(DWORD *)(start + 0x1F4);
|
||||
vec.push_back(temp);
|
||||
start += 0x6A8;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetChatRoomDetailInfo(
|
||||
|
Loading…
Reference in New Issue
Block a user