Refactoring

This commit is contained in:
Changhua 2024-07-02 00:50:20 +08:00
parent 7a4f406220
commit db08382e56
5 changed files with 63 additions and 64 deletions

View File

@ -12,10 +12,10 @@ using namespace std;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern QWORD g_WeChatWinDllAddr; extern QWORD g_WeChatWinDllAddr;
typedef QWORD (*funcGetChatRoomMgr_t)(); typedef QWORD (*GetChatRoomMgr_t)();
typedef QWORD (*funcAddMemberToChatRoom_t)(QWORD, QWORD, QWORD, QWORD); typedef QWORD (*AddMemberToChatRoom_t)(QWORD, QWORD, QWORD, QWORD);
typedef QWORD (*funcDelMemberFromChatRoom_t)(QWORD, QWORD, QWORD); typedef QWORD (*DelMemberFromChatRoom_t)(QWORD, QWORD, QWORD);
typedef QWORD (*funcInviteMemberToChatRoom_t)(QWORD, QWORD, QWORD, QWORD); typedef QWORD (*InviteMemberToChatRoom_t)(QWORD, QWORD, QWORD, QWORD);
int AddChatroomMember(string roomid, string wxids) int AddChatroomMember(string roomid, string wxids)
{ {
@ -26,8 +26,8 @@ int AddChatroomMember(string roomid, string wxids)
return status; return status;
} }
funcGetChatRoomMgr_t GetChatRoomMgr = (funcGetChatRoomMgr_t)(g_WeChatWinDllAddr + g_WxCalls.arm.call1); GetChatRoomMgr_t GetChatRoomMgr = (GetChatRoomMgr_t)(g_WeChatWinDllAddr + g_WxCalls.arm.call1);
funcAddMemberToChatRoom_t AddMembers = (funcAddMemberToChatRoom_t)(g_WeChatWinDllAddr + g_WxCalls.arm.call2); AddMemberToChatRoom_t AddMembers = (AddMemberToChatRoom_t)(g_WeChatWinDllAddr + g_WxCalls.arm.call2);
vector<wstring> vMembers; vector<wstring> vMembers;
vector<WxString> vWxMembers; vector<WxString> vWxMembers;
@ -58,8 +58,8 @@ int DelChatroomMember(string roomid, string wxids)
return status; return status;
} }
funcGetChatRoomMgr_t GetChatRoomMgr = (funcGetChatRoomMgr_t)(g_WeChatWinDllAddr + g_WxCalls.drm.call1); GetChatRoomMgr_t GetChatRoomMgr = (GetChatRoomMgr_t)(g_WeChatWinDllAddr + g_WxCalls.drm.call1);
funcDelMemberFromChatRoom_t DelMembers = (funcDelMemberFromChatRoom_t)(g_WeChatWinDllAddr + g_WxCalls.drm.call2); DelMemberFromChatRoom_t DelMembers = (DelMemberFromChatRoom_t)(g_WeChatWinDllAddr + g_WxCalls.drm.call2);
vector<wstring> vMembers; vector<wstring> vMembers;
vector<WxString> vWxMembers; vector<WxString> vWxMembers;
@ -89,8 +89,7 @@ int InviteChatroomMember(string roomid, string wxids)
return status; return status;
} }
funcInviteMemberToChatRoom_t InviteMembers InviteMemberToChatRoom_t InviteMembers = (InviteMemberToChatRoom_t)(g_WeChatWinDllAddr + g_WxCalls.irm.call1);
= (funcInviteMemberToChatRoom_t)(g_WeChatWinDllAddr + g_WxCalls.irm.call1);
vector<wstring> vMembers; vector<wstring> vMembers;
vector<WxString> vWxMembers; vector<WxString> vWxMembers;

View File

@ -9,8 +9,8 @@ using namespace std;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern QWORD g_WeChatWinDllAddr; extern QWORD g_WeChatWinDllAddr;
typedef QWORD (*funcGetContactMgr_t)(); typedef QWORD (*GetContactMgr_t)();
typedef QWORD (*funcGetContactList_t)(QWORD, QWORD); typedef QWORD (*GetContactList_t)(QWORD, QWORD);
#define FEAT_LEN 5 #define FEAT_LEN 5
static const uint8_t FEAT_COUNTRY[FEAT_LEN] = { 0xA4, 0xD9, 0x02, 0x4A, 0x18 }; static const uint8_t FEAT_COUNTRY[FEAT_LEN] = { 0xA4, 0xD9, 0x02, 0x4A, 0x18 };
@ -48,8 +48,8 @@ static string GetCntString(QWORD start, QWORD end, const uint8_t *feat, size_t l
vector<RpcContact_t> GetContacts() vector<RpcContact_t> GetContacts()
{ {
vector<RpcContact_t> contacts; vector<RpcContact_t> contacts;
funcGetContactMgr_t funcGetContactMgr = (funcGetContactMgr_t)(g_WeChatWinDllAddr + 0x1C0BDE0); GetContactMgr_t funcGetContactMgr = (GetContactMgr_t)(g_WeChatWinDllAddr + 0x1C0BDE0);
funcGetContactList_t funcGetContactList = (funcGetContactList_t)(g_WeChatWinDllAddr + 0x2265540); GetContactList_t funcGetContactList = (GetContactList_t)(g_WeChatWinDllAddr + 0x2265540);
QWORD mgr = funcGetContactMgr(); QWORD mgr = funcGetContactMgr();
QWORD addr[3] = { 0 }; QWORD addr[3] = { 0 };

View File

@ -25,10 +25,10 @@ extern bool gIsListeningPyq;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern QWORD g_WeChatWinDllAddr; extern QWORD g_WeChatWinDllAddr;
typedef QWORD (*funcGetSNSDataMgr_t)(); typedef QWORD (*GetSNSDataMgr_t)();
typedef QWORD (*funcGetSnsTimeLineMgr_t)(); typedef QWORD (*GetSnsTimeLineMgr_t)();
typedef QWORD (*funcGetSNSFirstPage_t)(QWORD, QWORD, QWORD); typedef QWORD (*GetSNSFirstPage_t)(QWORD, QWORD, QWORD);
typedef QWORD (*funcGetSNSNextPageScene_t)(QWORD, QWORD); typedef QWORD (*GetSNSNextPageScene_t)(QWORD, QWORD);
typedef QWORD (*GetChatMgr_t)(); typedef QWORD (*GetChatMgr_t)();
typedef QWORD (*NewChatMsg_t)(QWORD); typedef QWORD (*NewChatMsg_t)(QWORD);
typedef QWORD (*FreeChatMsg_t)(QWORD); typedef QWORD (*FreeChatMsg_t)(QWORD);
@ -131,8 +131,8 @@ static int GetFirstPage()
{ {
int status = -1; int status = -1;
funcGetSNSDataMgr_t GetSNSDataMgr = (funcGetSNSDataMgr_t)(g_WeChatWinDllAddr + 0x22A91C0); GetSNSDataMgr_t GetSNSDataMgr = (GetSNSDataMgr_t)(g_WeChatWinDllAddr + 0x22A91C0);
funcGetSNSFirstPage_t GetSNSFirstPage = (funcGetSNSFirstPage_t)(g_WeChatWinDllAddr + 0x2ED9080); GetSNSFirstPage_t GetSNSFirstPage = (GetSNSFirstPage_t)(g_WeChatWinDllAddr + 0x2ED9080);
QWORD buff[16] = { 0 }; QWORD buff[16] = { 0 };
QWORD mgr = GetSNSDataMgr(); QWORD mgr = GetSNSDataMgr();
@ -145,8 +145,8 @@ static int GetNextPage(QWORD id)
{ {
int status = -1; int status = -1;
funcGetSnsTimeLineMgr_t GetSnsTimeLineMgr = (funcGetSnsTimeLineMgr_t)(g_WeChatWinDllAddr + 0x2E6B110); GetSnsTimeLineMgr_t GetSnsTimeLineMgr = (GetSnsTimeLineMgr_t)(g_WeChatWinDllAddr + 0x2E6B110);
funcGetSNSNextPageScene_t GetSNSNextPageScene = (funcGetSNSNextPageScene_t)(g_WeChatWinDllAddr + 0x2EFEC00); GetSNSNextPageScene_t GetSNSNextPageScene = (GetSNSNextPageScene_t)(g_WeChatWinDllAddr + 0x2EFEC00);
QWORD mgr = GetSnsTimeLineMgr(); QWORD mgr = GetSnsTimeLineMgr();
status = (int)GetSNSNextPageScene(mgr, id); status = (int)GetSNSNextPageScene(mgr, id);

View File

@ -22,16 +22,16 @@ extern queue<WxMsg_t> gMsgQueue;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern QWORD g_WeChatWinDllAddr; extern QWORD g_WeChatWinDllAddr;
typedef QWORD (*funcRecvMsg_t)(QWORD, QWORD); typedef QWORD (*RecvMsg_t)(QWORD, QWORD);
typedef QWORD (*funcWxLog_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD); typedef QWORD (*WxLog_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD);
typedef QWORD (*funcRecvPyq_t)(QWORD, QWORD, QWORD); typedef QWORD (*RecvPyq_t)(QWORD, QWORD, QWORD);
static funcRecvMsg_t funcRecvMsg = nullptr; static RecvMsg_t funcRecvMsg = nullptr;
static funcRecvMsg_t realRecvMsg = nullptr; static RecvMsg_t realRecvMsg = nullptr;
static funcWxLog_t funcWxLog = nullptr; static WxLog_t funcWxLog = nullptr;
static funcWxLog_t realWxLog = nullptr; static WxLog_t realWxLog = nullptr;
static funcRecvPyq_t funcRecvPyq = nullptr; static RecvPyq_t funcRecvPyq = nullptr;
static funcRecvPyq_t realRecvPyq = nullptr; static RecvPyq_t realRecvPyq = nullptr;
static bool isMH_Initialized = false; static bool isMH_Initialized = false;
MsgTypes_t GetMsgTypes() MsgTypes_t GetMsgTypes()
@ -183,7 +183,7 @@ void EnableLog()
LOG_WARN("g_WeChatWinDllAddr == 0"); LOG_WARN("g_WeChatWinDllAddr == 0");
return; return;
} }
funcWxLog_t funcWxLog = (funcWxLog_t)(g_WeChatWinDllAddr + 0x26DA2D0); WxLog_t funcWxLog = (WxLog_t)(g_WeChatWinDllAddr + 0x26DA2D0);
if (!isMH_Initialized) { if (!isMH_Initialized) {
status = MH_Initialize(); status = MH_Initialize();
@ -238,7 +238,7 @@ void ListenMessage()
LOG_WARN("gIsListening || (g_WeChatWinDllAddr == 0)"); LOG_WARN("gIsListening || (g_WeChatWinDllAddr == 0)");
return; return;
} }
funcRecvMsg = (funcRecvMsg_t)(g_WeChatWinDllAddr + g_WxCalls.recvMsg.call); funcRecvMsg = (RecvMsg_t)(g_WeChatWinDllAddr + g_WxCalls.recvMsg.call);
if (!isMH_Initialized) { if (!isMH_Initialized) {
status = MH_Initialize(); status = MH_Initialize();
@ -300,7 +300,7 @@ void ListenPyq()
LOG_WARN("gIsListeningPyq || (g_WeChatWinDllAddr == 0)"); LOG_WARN("gIsListeningPyq || (g_WeChatWinDllAddr == 0)");
return; return;
} }
funcRecvPyq = (funcRecvPyq_t)(g_WeChatWinDllAddr + 0x2EFAA10); funcRecvPyq = (RecvPyq_t)(g_WeChatWinDllAddr + 0x2EFAA10);
if (!isMH_Initialized) { if (!isMH_Initialized) {
status = MH_Initialize(); status = MH_Initialize();

View File

@ -13,18 +13,18 @@ extern WxCalls_t g_WxCalls;
extern QWORD g_WeChatWinDllAddr; extern QWORD g_WeChatWinDllAddr;
extern string GetSelfWxid(); // Defined in spy.cpp extern string GetSelfWxid(); // Defined in spy.cpp
typedef QWORD (*funcNew_t)(QWORD); typedef QWORD (*New_t)(QWORD);
typedef QWORD (*funcFree_t)(QWORD); typedef QWORD (*Free_t)(QWORD);
typedef QWORD (*funcSendMsgMgr_t)(); typedef QWORD (*SendMsgMgr_t)();
typedef QWORD (*funcGetAppMsgMgr_t)(); typedef QWORD (*GetAppMsgMgr_t)();
typedef QWORD (*funcSendTextMsg_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD); typedef QWORD (*SendTextMsg_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD);
typedef QWORD (*funcSendImageMsg_t)(QWORD, QWORD, QWORD, QWORD, QWORD); typedef QWORD (*SendImageMsg_t)(QWORD, QWORD, QWORD, QWORD, QWORD);
typedef QWORD (*funcSendFileMsg_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD *, QWORD, QWORD *, QWORD, QWORD *, QWORD, typedef QWORD (*SendFileMsg_t)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD *, QWORD, QWORD *, QWORD, QWORD *, QWORD,
QWORD); QWORD);
typedef QWORD (*funcSendRichTextMsg_t)(QWORD, QWORD, QWORD); typedef QWORD (*SendRichTextMsg_t)(QWORD, QWORD, QWORD);
typedef QWORD (*funcSendPatMsg_t)(QWORD, QWORD); typedef QWORD (*SendPatMsg_t)(QWORD, QWORD);
typedef QWORD (*funcForwardMsg_t)(QWORD, QWORD, QWORD, QWORD); typedef QWORD (*ForwardMsg_t)(QWORD, QWORD, QWORD, QWORD);
void SendTextMessage(string wxid, string msg, string atWxids) void SendTextMessage(string wxid, string msg, string atWxids)
{ {
@ -53,9 +53,9 @@ void SendTextMessage(string wxid, string msg, string atWxids)
QWORD wxAters = (QWORD) & ((RawVector_t *)&vWxAtWxids)->start; QWORD wxAters = (QWORD) & ((RawVector_t *)&vWxAtWxids)->start;
char buffer[0x460] = { 0 }; char buffer[0x460] = { 0 };
funcSendMsgMgr_t funcSendMsgMgr = (funcSendMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.sendText.call1); SendMsgMgr_t funcSendMsgMgr = (SendMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.sendText.call1);
funcSendTextMsg_t funcSendTextMsg = (funcSendTextMsg_t)(g_WeChatWinDllAddr + g_WxCalls.sendText.call2); SendTextMsg_t funcSendTextMsg = (SendTextMsg_t)(g_WeChatWinDllAddr + g_WxCalls.sendText.call2);
funcFree_t funcFree = (funcFree_t)(g_WeChatWinDllAddr + g_WxCalls.sendText.call3); Free_t funcFree = (Free_t)(g_WeChatWinDllAddr + g_WxCalls.sendText.call3);
funcSendMsgMgr(); funcSendMsgMgr();
success = funcSendTextMsg((QWORD)(&buffer), (QWORD)(&wxWxid), (QWORD)(&wxMsg), wxAters, 1, 1, 0, 0); success = funcSendTextMsg((QWORD)(&buffer), (QWORD)(&wxWxid), (QWORD)(&wxMsg), wxAters, 1, 1, 0, 0);
funcFree((QWORD)(&buffer)); funcFree((QWORD)(&buffer));
@ -69,10 +69,10 @@ void SendImageMessage(string wxid, string path)
WxString wxWxid(wsWxid); WxString wxWxid(wsWxid);
WxString wxPath(wsPath); WxString wxPath(wsPath);
funcNew_t funcNew = (funcNew_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call1); New_t funcNew = (New_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call1);
funcFree_t funcFree = (funcFree_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call2); Free_t funcFree = (Free_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call2);
funcSendMsgMgr_t funcSendMsgMgr = (funcSendMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call3); SendMsgMgr_t funcSendMsgMgr = (SendMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call3);
funcSendImageMsg_t funcSendImage = (funcSendImageMsg_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call4); SendImageMsg_t funcSendImage = (SendImageMsg_t)(g_WeChatWinDllAddr + g_WxCalls.sendImg.call4);
char msg[0x460] = { 0 }; char msg[0x460] = { 0 };
char msgTmp[0x460] = { 0 }; char msgTmp[0x460] = { 0 };
@ -99,10 +99,10 @@ void SendFileMessage(string wxid, string path)
WxString wxWxid(wsWxid); WxString wxWxid(wsWxid);
WxString wxPath(wsPath); WxString wxPath(wsPath);
funcNew_t funcNew = (funcNew_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call1); New_t funcNew = (New_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call1);
funcFree_t funcFree = (funcFree_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call2); Free_t funcFree = (Free_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call2);
funcGetAppMsgMgr_t funcGetAppMsgMgr = (funcGetAppMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call3); GetAppMsgMgr_t funcGetAppMsgMgr = (GetAppMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call3);
funcSendFileMsg_t funcSendFile = (funcSendFileMsg_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call4); SendFileMsg_t funcSendFile = (SendFileMsg_t)(g_WeChatWinDllAddr + g_WxCalls.sendFile.call4);
char msg[0x460] = { 0 }; char msg[0x460] = { 0 };
QWORD tmp1[4] = { 0 }; QWORD tmp1[4] = { 0 };
@ -120,10 +120,10 @@ int SendRichTextMessage(RichText_t &rt)
#define SRTM_SIZE 0x3F0 #define SRTM_SIZE 0x3F0
QWORD status = -1; QWORD status = -1;
funcNew_t funcNew = (funcNew_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call1); New_t funcNew = (New_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call1);
funcFree_t funcFree = (funcFree_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call2); Free_t funcFree = (Free_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call2);
funcGetAppMsgMgr_t funcGetAppMsgMgr = (funcGetAppMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call3); GetAppMsgMgr_t funcGetAppMsgMgr = (GetAppMsgMgr_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call3);
funcSendRichTextMsg_t funcForwordPublicMsg = (funcSendRichTextMsg_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call4); SendRichTextMsg_t funcForwordPublicMsg = (SendRichTextMsg_t)(g_WeChatWinDllAddr + g_WxCalls.rt.call4);
char *buff = (char *)HeapAlloc(GetProcessHeap(), 0, SRTM_SIZE); char *buff = (char *)HeapAlloc(GetProcessHeap(), 0, SRTM_SIZE);
if (buff == NULL) { if (buff == NULL) {
@ -164,7 +164,7 @@ int SendPatMessage(string roomid, string wxid)
WxString wxRoomid(wsRoomid); WxString wxRoomid(wsRoomid);
WxString wxWxid(wsWxid); WxString wxWxid(wsWxid);
funcSendPatMsg_t funcSendPatMsg = (funcSendPatMsg_t)(g_WeChatWinDllAddr + g_WxCalls.pm.call1); SendPatMsg_t funcSendPatMsg = (SendPatMsg_t)(g_WeChatWinDllAddr + g_WxCalls.pm.call1);
status = funcSendPatMsg((QWORD)(&wxRoomid), (QWORD)(&wxWxid)); status = funcSendPatMsg((QWORD)(&wxRoomid), (QWORD)(&wxWxid));
return (int)status; return (int)status;
@ -176,7 +176,7 @@ int ForwardMessage(QWORD msgid, string receiver)
uint32_t dbIdx = 0; uint32_t dbIdx = 0;
QWORD localId = 0; QWORD localId = 0;
funcForwardMsg_t funcForwardMsg = (funcForwardMsg_t)(g_WeChatWinDllAddr + g_WxCalls.fm.call1); ForwardMsg_t funcForwardMsg = (ForwardMsg_t)(g_WeChatWinDllAddr + g_WxCalls.fm.call1);
if (GetLocalIdandDbidx(msgid, &localId, &dbIdx) != 0) { if (GetLocalIdandDbidx(msgid, &localId, &dbIdx) != 0) {
LOG_ERROR("Failed to get localId, Please check id: {}", to_string(msgid)); LOG_ERROR("Failed to get localId, Please check id: {}", to_string(msgid));
return status; return status;