Impl get contacts

This commit is contained in:
Changhua
2022-08-07 20:50:49 +08:00
parent 48091b8526
commit 3042de5183
10 changed files with 201 additions and 82 deletions
+2
View File
@@ -166,6 +166,7 @@
<ClInclude Include="..\Rpc\rpc_h.h" />
<ClInclude Include="..\SDK\util.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="get_contacts.h" />
<ClInclude Include="load_calls.h" />
<ClInclude Include="monitor.h" />
<ClInclude Include="receive_msg.h" />
@@ -178,6 +179,7 @@
<ClCompile Include="..\Rpc\rpc_s.c" />
<ClCompile Include="..\SDK\util.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="get_contacts.cpp" />
<ClCompile Include="load_calls.cpp" />
<ClCompile Include="monitor.cpp" />
<ClCompile Include="receive_msg.cpp" />
+6
View File
@@ -45,6 +45,9 @@
<ClInclude Include="spy_types.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="get_contacts.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -74,6 +77,9 @@
<ClCompile Include="send_msg.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="get_contacts.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="..\Rpc\rpc.idl">
+39
View File
@@ -0,0 +1,39 @@
#include "get_contacts.h"
#include "load_calls.h"
#include "util.h"
extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr;
std::vector<RpcContact_t> GetContacts()
{
int gender = 0;
vector<RpcContact_t> vContacts;
DWORD baseAddr = g_WeChatWinDllAddr + 0x23638F4;
DWORD tempAddr = GET_DWORD(baseAddr);
DWORD head = GET_DWORD(tempAddr + 0x4C);
DWORD node = GET_DWORD(head);
while (node != head) {
RpcContact_t rpcContact = { 0 };
rpcContact.wxId = GetBstrByAddress(node + 0x30);
rpcContact.wxCode = GetBstrByAddress(node + 0x44);
rpcContact.wxName = GetBstrByAddress(node + 0x8C);
rpcContact.wxCountry = GetBstrByAddress(node + 0x1D0);
rpcContact.wxProvince = GetBstrByAddress(node + 0x1E4);
rpcContact.wxCity = GetBstrByAddress(node + 0x1F8);
gender = GET_DWORD(node + 0x184);
if (gender == 1)
rpcContact.wxGender = SysAllocString(L"");
else if (gender == 2)
rpcContact.wxGender = SysAllocString(L"");
else
rpcContact.wxGender = SysAllocString(L"未知");
vContacts.push_back(rpcContact);
node = GET_DWORD(node);
}
return vContacts;
}
+7
View File
@@ -0,0 +1,7 @@
#pragma once
#include <vector>
#include "rpc_h.h"
std::vector<RpcContact_t> GetContacts();
+57 -21
View File
@@ -1,18 +1,19 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include "get_contacts.h"
#include "monitor.h"
#include "rpc_server.h"
#include "send_msg.h"
#include "spy_types.h"
#include "sdk.h"
#include "send_msg.h"
#include "spy_types.h"
#include "rpc_h.h"
#pragma comment(lib, "Rpcrt4.lib")
#pragma comment(lib, "Rpcrt4.lib")
extern HANDLE g_hEvent;
extern MsgQueue_t g_MsgQueue;
extern const MsgTypesMap_t g_WxMsgTypes;
extern const MsgTypesMap_t g_WxMsgTypes;
int server_IsLogin() { return IsLogin(); }
@@ -54,32 +55,67 @@ int server_SendImageMsg(const wchar_t *wxid, const wchar_t *path)
return 0;
}
int server_GetMsgTypes(int *pNum, PPRpcIntBstrPair_t *msgTypes)
int server_GetMsgTypes(int *pNum, PPRpcIntBstrPair *msgTypes)
{
*pNum = g_WxMsgTypes.size();
PPRpcIntBstrPair_t pp = (PPRpcIntBstrPair_t)midl_user_allocate(*pNum * sizeof(RpcIntBstrPair_t));
*pNum = g_WxMsgTypes.size();
PPRpcIntBstrPair pp = (PPRpcIntBstrPair)midl_user_allocate(*pNum * sizeof(RpcIntBstrPair_t));
if (pp == NULL) {
printf("server_GetMsgTypes midl_user_allocate Failed for pp\n");
return -2;
}
int index = 0;
for (auto it = g_WxMsgTypes.begin(); it != g_WxMsgTypes.end(); ++it) {
PRpcIntBstrPair_t p = (PRpcIntBstrPair_t)midl_user_allocate(sizeof(RpcIntBstrPair_t));
}
int index = 0;
for (auto it = g_WxMsgTypes.begin(); it != g_WxMsgTypes.end(); it++) {
PRpcIntBstrPair p = (PRpcIntBstrPair)midl_user_allocate(sizeof(RpcIntBstrPair_t));
if (p == NULL) {
printf("server_GetMsgTypes midl_user_allocate Failed for p\n");
return -3;
}
}
p->key = it->first;
p->value = SysAllocString(it->second.c_str());
p->key = it->first;
p->value = SysAllocString(it->second.c_str());
pp[index++] = p;
}
*msgTypes = pp;
}
*msgTypes = pp;
return 0;
}
}
int server_GetContacts(int *pNum, PPRpcContact *contacts)
{
std::vector<RpcContact_t> vContacts = GetContacts();
*pNum = vContacts.size();
PPRpcContact pp = (PPRpcContact)midl_user_allocate(*pNum * sizeof(RpcContact_t));
if (pp == NULL) {
printf("server_GetMsgTypes midl_user_allocate Failed for pp\n");
return -2;
}
int index = 0;
for (auto it = vContacts.begin(); it != vContacts.end(); it++) {
PRpcContact p = (PRpcContact)midl_user_allocate(sizeof(RpcContact_t));
if (p == NULL) {
printf("server_GetMsgTypes midl_user_allocate Failed for p\n");
return -3;
}
p->wxId = it->wxId;
p->wxCode = it->wxCode;
p->wxName = it->wxName;
p->wxCountry = it->wxCountry;
p->wxProvince = it->wxProvince;
p->wxCity = it->wxCity;
p->wxGender = it->wxGender;
pp[index++] = p;
}
*contacts = pp;
return 0;
}
RPC_STATUS CALLBACK SecurityCallback(RPC_IF_HANDLE /*hInterface*/, void * /*pBindingHandle*/)
{