Refactoring
This commit is contained in:
@@ -45,10 +45,10 @@ int add_chatroom_member(const string &roomid, const string &wxids)
|
||||
= reinterpret_cast<add_member_to_chatroom_t>(g_WeChatWinDllAddr + OS_ADD_MEMBERS);
|
||||
|
||||
vector<WxString> wx_members = parse_wxids(wxids);
|
||||
WxString *p_wx_roomid = NewWxStringFromStr(roomid);
|
||||
auto wx_roomid = util::new_wx_string(roomid);
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members.front());
|
||||
|
||||
return static_cast<int>(add_members(get_chatroom_mgr(), p_members, reinterpret_cast<QWORD>(p_wx_roomid), 0));
|
||||
return static_cast<int>(add_members(get_chatroom_mgr(), p_members, reinterpret_cast<QWORD>(wx_roomid.get()), 0));
|
||||
}
|
||||
|
||||
int del_chatroom_member(const string &roomid, const string &wxids)
|
||||
@@ -64,10 +64,10 @@ int del_chatroom_member(const string &roomid, const string &wxids)
|
||||
= reinterpret_cast<del_member_from_chatroom_t>(g_WeChatWinDllAddr + OS_DELETE_MEMBERS);
|
||||
|
||||
vector<WxString> wx_members = parse_wxids(wxids);
|
||||
WxString *p_wx_roomid = NewWxStringFromStr(roomid);
|
||||
auto wx_roomid = util::new_wx_string(roomid);
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members.front());
|
||||
|
||||
return static_cast<int>(del_members(get_chatroom_mgr(), p_members, reinterpret_cast<QWORD>(p_wx_roomid)));
|
||||
return static_cast<int>(del_members(get_chatroom_mgr(), p_members, reinterpret_cast<QWORD>(wx_roomid.get())));
|
||||
}
|
||||
|
||||
int invite_chatroom_member(const string &roomid, const string &wxids)
|
||||
@@ -81,11 +81,11 @@ int invite_chatroom_member(const string &roomid, const string &wxids)
|
||||
= reinterpret_cast<invite_member_to_chatroom_t>(g_WeChatWinDllAddr + OS_INVITE_MEMBERS);
|
||||
|
||||
vector<WxString> wx_members = parse_wxids(wxids);
|
||||
WxString *p_wx_roomid = NewWxStringFromStr(roomid);
|
||||
auto wx_roomid = util::new_wx_string(roomid);
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members.front());
|
||||
|
||||
return static_cast<int>(invite_members(reinterpret_cast<QWORD>(p_wx_roomid->wptr), p_members,
|
||||
reinterpret_cast<QWORD>(p_wx_roomid), 0));
|
||||
return static_cast<int>(invite_members(reinterpret_cast<QWORD>(wx_roomid.get()->wptr), p_members,
|
||||
reinterpret_cast<QWORD>(wx_roomid.get()), 0));
|
||||
}
|
||||
|
||||
bool rpc_add_chatroom_member(const string &roomid, const string &wxids, uint8_t *out, size_t *len)
|
||||
|
||||
@@ -51,7 +51,7 @@ static string get_cnt_string(QWORD start, QWORD end, const uint8_t *feat, size_t
|
||||
return "";
|
||||
}
|
||||
|
||||
DWORD lfeat = GET_DWORD(pfeat + len);
|
||||
DWORD lfeat = util::get_dword(pfeat + len);
|
||||
if (lfeat <= 2) {
|
||||
return "";
|
||||
}
|
||||
@@ -78,8 +78,8 @@ vector<RpcContact_t> get_contacts()
|
||||
QWORD pend = addr[2];
|
||||
while (pstart < pend) {
|
||||
RpcContact_t cnt;
|
||||
QWORD pbin = GET_QWORD(pstart + OS_CONTACT_BIN);
|
||||
QWORD lenbin = GET_DWORD(pstart + OS_CONTACT_BIN_LEN);
|
||||
QWORD pbin = util::get_qword(pstart + OS_CONTACT_BIN);
|
||||
QWORD lenbin = util::get_dword(pstart + OS_CONTACT_BIN_LEN);
|
||||
|
||||
cnt.wxid = util::get_str_by_wstr_addr(pstart + OS_CONTACT_WXID);
|
||||
cnt.code = util::get_str_by_wstr_addr(pstart + OS_CONTACT_CODE);
|
||||
@@ -180,7 +180,7 @@ RpcContact_t get_contact_by_wxid(const string &wxid)
|
||||
contact.code = util::get_str_by_wstr_addr(reinterpret_cast<DWORD>(buff) + g_WxCalls.contact.wxCode);
|
||||
contact.remark = util::get_str_by_wstr_addr(reinterpret_cast<DWORD>(buff) + g_WxCalls.contact.wxRemark);
|
||||
contact.name = util::get_str_by_wstr_addr(reinterpret_cast<DWORD>(buff) + g_WxCalls.contact.wxName);
|
||||
contact.gender = GET_DWORD(reinterpret_cast<DWORD>(buff) + 0x148);
|
||||
contact.gender = util::get_dword(reinterpret_cast<DWORD>(buff) + 0x148);
|
||||
|
||||
__asm {
|
||||
PUSHAD
|
||||
|
||||
@@ -31,24 +31,24 @@ static void get_db_handle(QWORD base, QWORD offset)
|
||||
{
|
||||
auto *wsp = reinterpret_cast<wchar_t *>(*(QWORD *)(base + offset + OFFSET_DB_NAME));
|
||||
std::string dbname = util::w2s(std::wstring(wsp));
|
||||
db_map[dbname] = GET_QWORD(base + offset);
|
||||
db_map[dbname] = util::get_qword(base + offset);
|
||||
}
|
||||
|
||||
static void get_msg_db_handle(QWORD msg_mgr_addr)
|
||||
{
|
||||
QWORD db_index = GET_QWORD(msg_mgr_addr + 0x68);
|
||||
QWORD p_start = GET_QWORD(msg_mgr_addr + 0x50);
|
||||
QWORD db_index = util::get_qword(msg_mgr_addr + 0x68);
|
||||
QWORD p_start = util::get_qword(msg_mgr_addr + 0x50);
|
||||
for (uint32_t i = 0; i < db_index; i++) {
|
||||
QWORD db_addr = GET_QWORD(p_start + i * 0x08);
|
||||
QWORD db_addr = util::get_qword(p_start + i * 0x08);
|
||||
if (db_addr) {
|
||||
// MSGi.db
|
||||
std::string dbname = util::w2s(get_pp_wstring(db_addr));
|
||||
db_map[dbname] = GET_QWORD(db_addr + 0x78);
|
||||
std::string dbname = util::w2s(util::get_pp_wstring(db_addr));
|
||||
db_map[dbname] = util::get_qword(db_addr + 0x78);
|
||||
|
||||
// MediaMsgi.db
|
||||
QWORD mmdb_addr = GET_QWORD(db_addr + 0x20);
|
||||
std::string mmdbname = util::w2s(get_pp_wstring(mmdb_addr + 0x78));
|
||||
db_map[mmdbname] = GET_QWORD(mmdb_addr + 0x50);
|
||||
QWORD mmdb_addr = util::get_qword(db_addr + 0x20);
|
||||
std::string mmdbname = util::w2s(util::get_pp_wstring(mmdb_addr + 0x78));
|
||||
db_map[mmdbname] = util::get_qword(mmdb_addr + 0x50);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ static void get_msg_db_handle(QWORD msg_mgr_addr)
|
||||
db_map_t get_db_handles()
|
||||
{
|
||||
db_map.clear();
|
||||
QWORD db_instance_addr = GET_QWORD(g_WeChatWinDllAddr + OFFSET_DB_INSTANCE);
|
||||
QWORD db_instance_addr = util::get_qword(g_WeChatWinDllAddr + OFFSET_DB_INSTANCE);
|
||||
|
||||
get_db_handle(db_instance_addr, OFFSET_DB_MICROMSG); // MicroMsg.db
|
||||
get_db_handle(db_instance_addr, OFFSET_DB_CHAT_MSG); // ChatMsg.db
|
||||
@@ -65,7 +65,7 @@ db_map_t get_db_handles()
|
||||
get_db_handle(db_instance_addr, OFFSET_DB_MEDIA); // Media.db
|
||||
get_db_handle(db_instance_addr, OFFSET_DB_FUNCTION_MSG); // Function.db
|
||||
|
||||
get_msg_db_handle(GET_QWORD(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR)); // MSGi.db & MediaMsgi.db
|
||||
get_msg_db_handle(util::get_qword(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR)); // MSGi.db & MediaMsgi.db
|
||||
|
||||
return db_map;
|
||||
}
|
||||
@@ -189,19 +189,19 @@ int get_local_id_and_dbidx(uint64_t id, uint64_t *local_id, uint32_t *db_idx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
QWORD msg_mgr_addr = GET_QWORD(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR);
|
||||
int db_index = static_cast<int>(GET_QWORD(msg_mgr_addr + 0x68)); // 总不能 int 还不够吧?
|
||||
QWORD p_start = GET_QWORD(msg_mgr_addr + 0x50);
|
||||
QWORD msg_mgr_addr = util::get_qword(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR);
|
||||
int db_index = static_cast<int>(util::get_qword(msg_mgr_addr + 0x68)); // 总不能 int 还不够吧?
|
||||
QWORD p_start = util::get_qword(msg_mgr_addr + 0x50);
|
||||
|
||||
*db_idx = 0;
|
||||
for (int i = db_index - 1; i >= 0; i--) { // 从后往前遍历
|
||||
QWORD db_addr = GET_QWORD(p_start + i * 0x08);
|
||||
QWORD db_addr = util::get_qword(p_start + i * 0x08);
|
||||
if (!db_addr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string dbname = util::w2s(get_pp_wstring(db_addr));
|
||||
db_map[dbname] = GET_QWORD(db_addr + 0x78);
|
||||
std::string dbname = util::w2s(util::get_pp_wstring(db_addr));
|
||||
db_map[dbname] = util::get_qword(db_addr + 0x78);
|
||||
|
||||
std::string sql = "SELECT localId FROM MSG WHERE MsgSvrID=" + std::to_string(id) + ";";
|
||||
DbRows_t rows = exec_db_query(dbname, sql);
|
||||
@@ -223,7 +223,7 @@ int get_local_id_and_dbidx(uint64_t id, uint64_t *local_id, uint32_t *db_idx)
|
||||
continue;
|
||||
}
|
||||
|
||||
*db_idx = static_cast<uint32_t>(GET_QWORD(GET_QWORD(db_addr + 0x28) + 0x1E8) >> 32);
|
||||
*db_idx = static_cast<uint32_t>(util::get_qword(util::get_qword(db_addr + 0x28) + 0x1E8) >> 32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -232,8 +232,8 @@ int get_local_id_and_dbidx(uint64_t id, uint64_t *local_id, uint32_t *db_idx)
|
||||
|
||||
std::vector<uint8_t> get_audio_data(uint64_t id)
|
||||
{
|
||||
QWORD msg_mgr_addr = GET_QWORD(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR);
|
||||
int db_index = static_cast<int>(GET_QWORD(msg_mgr_addr + 0x68));
|
||||
QWORD msg_mgr_addr = util::get_qword(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR);
|
||||
int db_index = static_cast<int>(util::get_qword(msg_mgr_addr + 0x68));
|
||||
|
||||
std::string sql = "SELECT Buf FROM Media WHERE Reserved0=" + std::to_string(id) + ";";
|
||||
for (int i = db_index - 1; i >= 0; i--) {
|
||||
|
||||
+10
-10
@@ -51,7 +51,7 @@ typedef QWORD (*PushAttachTask_t)(QWORD, QWORD, QWORD, QWORD);
|
||||
typedef QWORD (*GetOCRManager_t)();
|
||||
typedef QWORD (*DoOCRTask_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD);
|
||||
|
||||
int IsLogin(void) { return (int)GET_QWORD(g_WeChatWinDllAddr + OS_LOGIN_STATUS); }
|
||||
int IsLogin(void) { return (int)util::get_qword(g_WeChatWinDllAddr + OS_LOGIN_STATUS); }
|
||||
|
||||
static string get_key(uint8_t header1, uint8_t header2, uint8_t *key)
|
||||
{
|
||||
@@ -230,7 +230,7 @@ int DownloadAttach(QWORD id, string thumb, string extra)
|
||||
GetChatMgr();
|
||||
GetMgrByPrefixLocalId(l.QuadPart, pChatMsg);
|
||||
|
||||
QWORD type = GET_QWORD(buff + 0x38);
|
||||
QWORD type = util::get_qword(reinterpret_cast<QWORD>(buff) + 0x38);
|
||||
|
||||
string save_path = "";
|
||||
string thumb_path = "";
|
||||
@@ -262,12 +262,12 @@ int DownloadAttach(QWORD id, string thumb, string extra)
|
||||
// 创建父目录,由于路径来源于微信,不做检查
|
||||
fs::create_directory(fs::path(save_path).parent_path().string());
|
||||
|
||||
int temp = 1;
|
||||
WxString *pSavePath = NewWxStringFromStr(save_path);
|
||||
WxString *pThumbPath = NewWxStringFromStr(thumb_path);
|
||||
int temp = 1;
|
||||
auto wx_save_path = util::new_wx_string(save_path);
|
||||
auto wx_thumb_path = util::new_wx_string(thumb_path);
|
||||
|
||||
memcpy(&buff[0x280], pThumbPath, sizeof(WxString));
|
||||
memcpy(&buff[0x2A0], pSavePath, sizeof(WxString));
|
||||
memcpy(&buff[0x280], wx_thumb_path.get(), sizeof(WxString));
|
||||
memcpy(&buff[0x2A0], wx_save_path.get(), sizeof(WxString));
|
||||
memcpy(&buff[0x40C], &temp, sizeof(temp));
|
||||
|
||||
QWORD mgr = GetPreDownLoadMgr();
|
||||
@@ -354,11 +354,11 @@ OcrResult_t GetOcrResult(string path)
|
||||
QWORD mgr = GetOCRManager();
|
||||
ret.status = (int)DoOCRTask(mgr, (QWORD)&wxPath, unused, (QWORD)buff, (QWORD)&pUnk1, (QWORD)&pUnk2);
|
||||
|
||||
QWORD count = GET_QWORD(buff + 0x8);
|
||||
QWORD count = util::get_qword(buff + 0x8);
|
||||
if (count > 0) {
|
||||
QWORD header = GET_QWORD(buff);
|
||||
QWORD header = util::get_qword(buff);
|
||||
for (QWORD i = 0; i < count; i++) {
|
||||
QWORD content = GET_QWORD(header);
|
||||
QWORD content = util::get_qword(header);
|
||||
ret.result += util::w2s(get_pp_wstring(content + 0x28));
|
||||
ret.result += "\n";
|
||||
header = content;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "stdint.h"
|
||||
#include <string>
|
||||
|
||||
#include "pb_types.h"
|
||||
|
||||
int IsLogin(void);
|
||||
std::string GetAudio(uint64_t id, std::string dir);
|
||||
std::string GetPCMAudio(uint64_t id, std::string dir, int32_t sr);
|
||||
@@ -11,5 +13,5 @@ int RefreshPyq(uint64_t id);
|
||||
int DownloadAttach(uint64_t id, std::string thumb, std::string extra);
|
||||
int RevokeMsg(uint64_t id);
|
||||
OcrResult_t GetOcrResult(std::string path);
|
||||
string GetLoginUrl();
|
||||
std::string GetLoginUrl();
|
||||
int ReceiveTransfer(std::string wxid, std::string transferid, std::string transactionid);
|
||||
|
||||
@@ -38,10 +38,10 @@ QWORD MessageHandler::DispatchMsg(QWORD arg1, QWORD arg2)
|
||||
auto &handler = getInstance();
|
||||
WxMsg_t wxMsg = {};
|
||||
try {
|
||||
wxMsg.id = GET_QWORD(arg2 + OS_RECV_MSG_ID);
|
||||
wxMsg.type = GET_DWORD(arg2 + OS_RECV_MSG_TYPE);
|
||||
wxMsg.is_self = GET_DWORD(arg2 + OS_RECV_MSG_SELF);
|
||||
wxMsg.ts = GET_DWORD(arg2 + OS_RECV_MSG_TS);
|
||||
wxMsg.id = util::get_qword(arg2 + OS_RECV_MSG_ID);
|
||||
wxMsg.type = util::get_dword(arg2 + OS_RECV_MSG_TYPE);
|
||||
wxMsg.is_self = util::get_dword(arg2 + OS_RECV_MSG_SELF);
|
||||
wxMsg.ts = util::get_dword(arg2 + OS_RECV_MSG_TS);
|
||||
wxMsg.content = util::get_str_by_wstr_addr(arg2 + OS_RECV_MSG_CONTENT);
|
||||
wxMsg.sign = util::get_str_by_wstr_addr(arg2 + OS_RECV_MSG_SIGN);
|
||||
wxMsg.xml = util::get_str_by_wstr_addr(arg2 + OS_RECV_MSG_XML);
|
||||
@@ -98,8 +98,8 @@ void MessageHandler::DispatchPyq(QWORD arg1, QWORD arg2, QWORD arg3)
|
||||
wxMsg.type = 0x00;
|
||||
wxMsg.is_self = false;
|
||||
wxMsg.is_group = false;
|
||||
wxMsg.id = GET_QWORD(startAddr);
|
||||
wxMsg.ts = GET_DWORD(startAddr + OS_PYQ_MSG_TS);
|
||||
wxMsg.id = util::get_qword(startAddr);
|
||||
wxMsg.ts = util::get_dword(startAddr + OS_PYQ_MSG_TS);
|
||||
wxMsg.xml = util::get_str_by_wstr_addr(startAddr + OS_PYQ_MSG_XML);
|
||||
wxMsg.sender = util::get_str_by_wstr_addr(startAddr + OS_PYQ_MSG_SENDER);
|
||||
wxMsg.content = util::get_str_by_wstr_addr(startAddr + OS_PYQ_MSG_CONTENT);
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <windows.h>
|
||||
|
||||
#include "MinHook.h"
|
||||
|
||||
#include "pb_types.h"
|
||||
#include "spy_types.h"
|
||||
|
||||
class MessageHandler
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ UINT64 g_WeChatWinDllAddr = 0;
|
||||
|
||||
void InitSpy(LPVOID args)
|
||||
{
|
||||
auto *pp = static_cast<PortPath_t *>(args);
|
||||
auto *pp = static_cast<util::PortPath *>(args);
|
||||
|
||||
Log::InitLogger(pp->path);
|
||||
if (auto dll_addr = GetModuleHandle(L"WeChatWin.dll")) {
|
||||
|
||||
@@ -22,7 +22,7 @@ std::string get_home_path()
|
||||
static std::string home_path;
|
||||
|
||||
std::call_once(flag, [] {
|
||||
std::string path = util::w2s(get_pp_wstring(g_WeChatWinDllAddr + OS_USER_HOME)) + "\\WeChat Files\\";
|
||||
std::string path = util::w2s(util::get_pp_wstring(g_WeChatWinDllAddr + OS_USER_HOME)) + "\\WeChat Files\\";
|
||||
home_path = std::filesystem::absolute(path).string();
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ std::string get_self_wxid()
|
||||
std::call_once(flag, [] {
|
||||
UINT64 wxid_type = 0;
|
||||
try {
|
||||
wxid_type = GET_UINT64(g_WeChatWinDllAddr + OS_USER_WXID + 0x18);
|
||||
wxid_type = util::get_qword(g_WeChatWinDllAddr + OS_USER_WXID + 0x18);
|
||||
if (wxid_type == 0xF) {
|
||||
wxid = util::get_p_string(g_WeChatWinDllAddr + OS_USER_WXID);
|
||||
} else {
|
||||
@@ -58,7 +58,7 @@ UserInfo_t get_user_info()
|
||||
UserInfo_t ui;
|
||||
ui.wxid = get_self_wxid();
|
||||
|
||||
UINT64 name_type = GET_UINT64(g_WeChatWinDllAddr + OS_USER_NAME + 0x18);
|
||||
UINT64 name_type = util::get_qword(g_WeChatWinDllAddr + OS_USER_NAME + 0x18);
|
||||
ui.name = (name_type == 0xF) ? util::get_p_string(g_WeChatWinDllAddr + OS_USER_NAME)
|
||||
: util::get_pp_string(g_WeChatWinDllAddr + OS_USER_NAME);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user