From 18078f31712baf8e3a9ce32b9e75377e01d22d9b Mon Sep 17 00:00:00 2001 From: Changhua Date: Mon, 12 Jun 2023 23:41:51 +0800 Subject: [PATCH] Impl Functions_FUNC_ACCEPT_FRIEND --- spy/accept_new_friend.cpp | 53 ++++++++++++++++----------------------- spy/load_calls.cpp | 6 ++--- spy/rpc_server.cpp | 2 +- spy/spy_types.h | 3 ++- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/spy/accept_new_friend.cpp b/spy/accept_new_friend.cpp index 938cf72..97f6ccc 100644 --- a/spy/accept_new_friend.cpp +++ b/spy/accept_new_friend.cpp @@ -5,36 +5,22 @@ #include "log.h" #include "util.h" -typedef struct NewFriendParam { - DWORD handle; - DWORD *status; - DWORD statusEnd1; - DWORD statusEnd2; - char buffer[0x3C]; -} NewFriendParam_t; - extern WxCalls_t g_WxCalls; extern DWORD g_WeChatWinDllAddr; int AcceptNewFriend(std::string v3, std::string v4, int scene) { - int isSucceeded = 0; + int success = 0; - DWORD acceptNewFriendCall1 = g_WeChatWinDllAddr + g_WxCalls.anf.call1; - DWORD acceptNewFriendCall2 = g_WeChatWinDllAddr + g_WxCalls.anf.call2; - DWORD acceptNewFriendHandle = g_WeChatWinDllAddr + g_WxCalls.anf.handle; + DWORD acceptNewFriendCall1 = g_WeChatWinDllAddr + g_WxCalls.anf.call1; + DWORD acceptNewFriendCall2 = g_WeChatWinDllAddr + g_WxCalls.anf.call2; + DWORD acceptNewFriendCall3 = g_WeChatWinDllAddr + g_WxCalls.anf.call3; + DWORD acceptNewFriendCall4 = g_WeChatWinDllAddr + g_WxCalls.anf.call4; - char buffer[0x94] = { 0 }; - NewFriendParam_t param = { 0 }; - DWORD status[9] = { 0xB2, (DWORD)¶m, 0xB5, (DWORD)¶m, 0xB0, (DWORD)¶m, 0xB1, (DWORD)¶m, 0x00 }; + char buffer[0x40] = { 0 }; + char nullbuffer[0x3CC] = { 0 }; - param.handle = acceptNewFriendHandle; - param.status = status; - param.statusEnd1 = (DWORD)status + 0x20; - param.statusEnd2 = (DWORD)status + 0x20; - NewFriendParam_t *pParam = ¶m; - - LOG_DEBUG("v3: {}\nv4: {}", v3, v4); + LOG_DEBUG("\nv3: {}\nv4: {}\nscene: {}", v3, v4, scene); WxString_t wxV3 = { 0 }; WxString_t wxV4 = { 0 }; std::wstring wsV3 = String2Wstring(v3); @@ -51,26 +37,31 @@ int AcceptNewFriend(std::string v3, std::string v4, int scene) __asm { pushad; pushfd; - push 0x0; - mov eax, scene; - push eax; + lea ecx, buffer; + call acceptNewFriendCall1; + mov esi, 0x0; + mov edi, scene; + push esi; + push edi; sub esp, 0x14; mov ecx, esp; lea eax, wxV4; push eax; - call acceptNewFriendCall1; + call acceptNewFriendCall2; sub esp, 0x8; push 0x0; - lea eax, buffer; + lea eax, nullbuffer; push eax; lea eax, wxV3; push eax; - mov ecx, pParam; - call acceptNewFriendCall2; - mov isSucceeded, eax; + lea ecx, buffer; + call acceptNewFriendCall3; + mov success, eax; + lea ecx, buffer; + call acceptNewFriendCall4; popfd; popad; } - return isSucceeded; // 成功返回 1 + return success; // 成功返回 1 } diff --git a/spy/load_calls.cpp b/spy/load_calls.cpp index 492cb18..b25c339 100644 --- a/spy/load_calls.cpp +++ b/spy/load_calls.cpp @@ -21,9 +21,9 @@ WxCalls_t wxCalls = { /* Exec Sql: Exec, base, start, end, slot, name*/ { 0x141BDF0, 0x2366934, 0x1428, 0x142C, 0x3C, 0x50 }, - { 0x771980, 0x2AE8D0, 0x1EE40E0 }, // Accept New Friend application - { 0xE29F0, 0x771980, 0x43D8D0 }, // Add chatroom members - { 0x771980, 0xCD2A90 } // Receive transfer + { 0xA17D50, 0xF59E40, 0xA18BD0, 0xA17E70 }, // Accept New Friend application + { 0xE29F0, 0x771980, 0x43D8D0 }, // Add chatroom members + { 0x771980, 0xCD2A90 } // Receive transfer }; int LoadCalls(const wchar_t *version, WxCalls_t *calls) diff --git a/spy/rpc_server.cpp b/spy/rpc_server.cpp index 1419c27..6ca982d 100644 --- a/spy/rpc_server.cpp +++ b/spy/rpc_server.cpp @@ -621,12 +621,12 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len ret = func_exec_db_query(req.msg.query.db, req.msg.query.sql, out, out_len); break; } -#if 0 case Functions_FUNC_ACCEPT_FRIEND: { LOG_DEBUG("[Functions_FUNC_ACCEPT_FRIEND]"); ret = func_accept_friend(req.msg.v.v3, req.msg.v.v4, req.msg.v.scene, out, out_len); break; } +#if 0 case Functions_FUNC_ADD_ROOM_MEMBERS: { LOG_DEBUG("[Functions_FUNC_ADD_ROOM_MEMBERS]"); ret = func_add_room_members(req.msg.m.roomid, req.msg.m.wxids, out, out_len); diff --git a/spy/spy_types.h b/spy/spy_types.h index d4ed35b..22a8c81 100644 --- a/spy/spy_types.h +++ b/spy/spy_types.h @@ -61,7 +61,8 @@ typedef struct Sql { typedef struct NewFriend { DWORD call1; DWORD call2; - DWORD handle; + DWORD call3; + DWORD call4; } NewFriend_t; typedef struct RoomMember {