Impl get contacts
This commit is contained in:
+28
-7
@@ -1,6 +1,6 @@
|
||||
#include "sdk.h"
|
||||
#include "rpc_client.h"
|
||||
#include "sdk.h"
|
||||
#include "util.h"
|
||||
#include "rpc_client.h"
|
||||
|
||||
#pragma comment(lib, "Rpcrt4.lib")
|
||||
|
||||
@@ -113,13 +113,13 @@ int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
PPRpcIntBstrPair_t RpcGetMsgTypes(int *pNum)
|
||||
PPRpcIntBstrPair RpcGetMsgTypes(int *pNum)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long ulCode = 0;
|
||||
PPRpcIntBstrPair_t ppRpcMsgTypes = NULL;
|
||||
int ret = 0;
|
||||
unsigned long ulCode = 0;
|
||||
PPRpcIntBstrPair ppRpcMsgTypes = NULL;
|
||||
|
||||
RpcTryExcept{ ret = client_GetMsgTypes(pNum, &ppRpcMsgTypes); }
|
||||
RpcTryExcept { ret = client_GetMsgTypes(pNum, &ppRpcMsgTypes); }
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
@@ -134,6 +134,27 @@ PPRpcIntBstrPair_t RpcGetMsgTypes(int *pNum)
|
||||
return ppRpcMsgTypes;
|
||||
}
|
||||
|
||||
PPRpcContact RpcGetContacts(int *pNum)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long ulCode = 0;
|
||||
PPRpcContact ppRpcContacts = NULL;
|
||||
|
||||
RpcTryExcept { ret = client_GetContacts(pNum, &ppRpcContacts); }
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("RpcGetContacts exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
if (ret != 0) {
|
||||
printf("GetContacts Failed: %d\n", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ppRpcContacts;
|
||||
}
|
||||
|
||||
int server_ReceiveMsg(RpcMessage_t rpcMsg)
|
||||
{
|
||||
WxMessage_t msg;
|
||||
|
||||
+2
-1
@@ -9,4 +9,5 @@ unsigned int __stdcall RpcSetTextMsgCb(void *p);
|
||||
int RpcIsLogin();
|
||||
int RpcSendTextMsg(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t *msg);
|
||||
int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path);
|
||||
RpcIntBstrPair_t** RpcGetMsgTypes(int *pNum);
|
||||
PPRpcIntBstrPair RpcGetMsgTypes(int *pNum);
|
||||
PPRpcContact RpcGetContacts(int *pNum);
|
||||
|
||||
+34
-48
@@ -128,60 +128,46 @@ static int getAddrHandle(DWORD *addr, HANDLE *handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
MsgTypesMap_t WxGetMsgTypes()
|
||||
{
|
||||
static MsgTypesMap_t WxMsgTypes;
|
||||
if (WxMsgTypes.empty()) {
|
||||
int size = 0;
|
||||
PPRpcIntBstrPair pp = RpcGetMsgTypes(&size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
WxMsgTypes.insert(make_pair(pp[i]->key, GetWstringFromBstr(pp[i]->value)));
|
||||
midl_user_free(pp[i]);
|
||||
}
|
||||
if (pp) {
|
||||
midl_user_free(pp);
|
||||
}
|
||||
}
|
||||
|
||||
return WxMsgTypes;
|
||||
}
|
||||
|
||||
ContactMap_t WxGetContacts()
|
||||
{
|
||||
ContactMap_t mContact;
|
||||
DWORD moduleBaseAddress;
|
||||
HANDLE hProcess;
|
||||
int size = 0;
|
||||
PPRpcContact pp = RpcGetContacts(&size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
WxContact_t contact;
|
||||
contact.wxId = GetWstringFromBstr(pp[i]->wxId);
|
||||
contact.wxCode = GetWstringFromBstr(pp[i]->wxCode);
|
||||
contact.wxName = GetWstringFromBstr(pp[i]->wxName);
|
||||
contact.wxCountry = GetWstringFromBstr(pp[i]->wxCountry);
|
||||
contact.wxProvince = GetWstringFromBstr(pp[i]->wxProvince);
|
||||
contact.wxCity = GetWstringFromBstr(pp[i]->wxCity);
|
||||
contact.wxGender = GetWstringFromBstr(pp[i]->wxGender);
|
||||
|
||||
if (getAddrHandle(&moduleBaseAddress, &hProcess) != 0) {
|
||||
return mContact;
|
||||
}
|
||||
printf("WxGetContacts\n");
|
||||
DWORD baseAddr = moduleBaseAddress + 0x23638F4;
|
||||
DWORD tempAddr = GetMemoryIntByAddress(hProcess, baseAddr);
|
||||
DWORD head = GetMemoryIntByAddress(hProcess, tempAddr + 0x4C);
|
||||
DWORD node = GetMemoryIntByAddress(hProcess, head);
|
||||
|
||||
while (node != head) {
|
||||
WxContact_t contactItem;
|
||||
contactItem.wxId = GetUnicodeInfoByAddress(hProcess, node + 0x30);
|
||||
contactItem.wxCode = GetUnicodeInfoByAddress(hProcess, node + 0x44);
|
||||
contactItem.wxName = GetUnicodeInfoByAddress(hProcess, node + 0x8C);
|
||||
contactItem.wxCountry = GetUnicodeInfoByAddress(hProcess, node + 0x1D0);
|
||||
contactItem.wxProvince = GetUnicodeInfoByAddress(hProcess, node + 0x1E4);
|
||||
contactItem.wxCity = GetUnicodeInfoByAddress(hProcess, node + 0x1F8);
|
||||
DWORD gender = GetMemoryIntByAddress(hProcess, node + 0x184);
|
||||
|
||||
if (gender == 1)
|
||||
contactItem.wxGender = L"男";
|
||||
else if (gender == 2)
|
||||
contactItem.wxGender = L"女";
|
||||
else
|
||||
contactItem.wxGender = L"未知";
|
||||
|
||||
mContact.insert(make_pair(contactItem.wxId, contactItem));
|
||||
node = GetMemoryIntByAddress(hProcess, node);
|
||||
mContact.insert(make_pair(contact.wxId, contact));
|
||||
midl_user_free(pp[i]);
|
||||
}
|
||||
|
||||
CloseHandle(hProcess);
|
||||
if (pp) {
|
||||
midl_user_free(pp);
|
||||
}
|
||||
|
||||
return mContact;
|
||||
}
|
||||
|
||||
MsgTypesMap_t WxGetMsgTypes()
|
||||
{
|
||||
static MsgTypesMap_t WxMsgTypes;
|
||||
if (WxMsgTypes.empty()) {
|
||||
int size = 0;
|
||||
PPRpcIntBstrPair_t pp = RpcGetMsgTypes(&size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
WxMsgTypes.insert(make_pair(pp[i]->key, GetWstringFromBstr(pp[i]->value)));
|
||||
midl_user_free(pp[i]);
|
||||
}
|
||||
midl_user_free(pp);
|
||||
}
|
||||
|
||||
return WxMsgTypes;
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -167,12 +167,20 @@ int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size)
|
||||
return strLength;
|
||||
}
|
||||
|
||||
BSTR GetBstrByAddress(DWORD address) { return SysAllocStringLen(GET_WSTRING(address), GET_DWORD(address + 4)); }
|
||||
BSTR GetBstrByAddress(DWORD address)
|
||||
{
|
||||
wchar_t *p = GET_WSTRING(address);
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SysAllocStringLen(GET_WSTRING(address), GET_DWORD(address + 4));
|
||||
}
|
||||
|
||||
wstring GetWstringFromBstr(BSTR p)
|
||||
{
|
||||
wstring ws = L"";
|
||||
if (p != nullptr) {
|
||||
if (p != NULL) {
|
||||
ws = wstring(p);
|
||||
SysFreeString(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user