Impl Get Contacts
This commit is contained in:
parent
1578720be4
commit
4959b58b23
45
App/App.cpp
45
App/App.cpp
@ -12,25 +12,20 @@
|
|||||||
|
|
||||||
void printContacts(ContactMap_t contacts)
|
void printContacts(ContactMap_t contacts)
|
||||||
{
|
{
|
||||||
wcout << L"contacts number: " << contacts.size() << endl;
|
wprintf(L"contacts number: %ld\n", contacts.size());
|
||||||
for (auto it = contacts.begin(); it != contacts.end(); ++it) {
|
for (auto it = contacts.begin(); it != contacts.end(); ++it) {
|
||||||
wcout << it->second.wxId << L"\t" << it->second.wxCode << L"\t" << it->second.wxName << L"\t"
|
wprintf(L"%s\t%s\t%s\t%s\t%s\t%s\t%s\r\n", it->second.wxId.c_str(), it->second.wxCode.c_str(),
|
||||||
<< it->second.wxGender << L"\t" << it->second.wxCountry << L"\t" << it->second.wxProvince << L"\t"
|
it->second.wxName.c_str(), it->second.wxGender.c_str(), it->second.wxCountry.c_str(),
|
||||||
<< it->second.wxCity << endl;
|
it->second.wxProvince.c_str(), it->second.wxCity.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int onTextMsg(WxMessage_t msg)
|
int onTextMsg(WxMessage_t msg)
|
||||||
{
|
{
|
||||||
try {
|
wprintf(L"%s msgType: %d, msgSource: %d, isSelf: %d\n", msg.id.c_str(), msg.type, msg.source, msg.self);
|
||||||
wcout << msg.id << L" msgType: " << msg.type << L", msgSource: " << msg.source << L", isSelf: " << msg.self
|
wprintf(L"%s[%s] >> %s\n", msg.wxId.c_str(), msg.roomId.c_str(), msg.content.c_str());
|
||||||
<< endl;
|
wprintf(L"msgSourceXml: %s\n", msg.xml.c_str());
|
||||||
wcout << msg.wxId << L"[" << msg.roomId << L"]" << L" >> " << msg.content << endl;
|
|
||||||
wcout << L"msgSourceXml: " << msg.xml << endl;
|
|
||||||
} catch (...) {
|
|
||||||
wcout << "something wrong..." << endl;
|
|
||||||
}
|
|
||||||
wcout.flush();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,37 +37,39 @@ int main()
|
|||||||
wstring content = L"这里填写消息内容";
|
wstring content = L"这里填写消息内容";
|
||||||
wstring img_path = L"test.jpg";
|
wstring img_path = L"test.jpg";
|
||||||
|
|
||||||
_setmode(_fileno(stdout), _O_WTEXT); // 没有这个wcout遇到一些字符会导致console卡死,用了会导致脱离控制台
|
|
||||||
_wsetlocale(LC_ALL, L"chs"); // 这是个大坑,不设置中文直接不见了。。。
|
_wsetlocale(LC_ALL, L"chs"); // 这是个大坑,不设置中文直接不见了。。。
|
||||||
|
|
||||||
// 获取消息类型
|
// 获取消息类型
|
||||||
const MsgTypesMap_t WxMsgTypes = WxGetMsgTypes();
|
const MsgTypesMap_t WxMsgTypes = WxGetMsgTypes();
|
||||||
for (auto it = WxMsgTypes.begin(); it != WxMsgTypes.end(); ++it) {
|
for (auto it = WxMsgTypes.begin(); it != WxMsgTypes.end(); ++it) {
|
||||||
wcout << it->first << L": " << it->second << endl;
|
wprintf(L"%d: %s\n", it->first, it->second.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wprintf(L"WxInitSDK: ");
|
||||||
status = WxInitSDK();
|
status = WxInitSDK();
|
||||||
wcout << L"WxInitSDK: " << status << endl;
|
wcout << status << endl;
|
||||||
|
wprintf(L"%d\n", status);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wcout << L"Message: 接收通知中......" << endl;
|
wprintf(L"Message: 接收通知中......\n");
|
||||||
WxSetTextMsgCb(onTextMsg);
|
WxSetTextMsgCb(onTextMsg);
|
||||||
|
|
||||||
// 测试消息发送
|
// 测试发送消息
|
||||||
wcout << L"测试消息发送" << endl;
|
wprintf(L"测试发送消息\n");
|
||||||
WxSendTextMsg(wxid, at_wxid, content);
|
WxSendTextMsg(wxid, at_wxid, content);
|
||||||
|
|
||||||
// 发送照片
|
// 测试发送照片
|
||||||
wcout << L"测试发送照片" << endl;
|
wprintf(L"测试发送照片\n");
|
||||||
WxSendImageMsg(wxid, img_path);
|
WxSendImageMsg(wxid, img_path);
|
||||||
#if 0
|
|
||||||
Sleep(10000); // 等待10秒
|
Sleep(10000); // 等待10秒
|
||||||
// 测试联系人获取
|
|
||||||
|
// 测试获取联系人
|
||||||
auto mContact = WxGetContacts();
|
auto mContact = WxGetContacts();
|
||||||
printContacts(mContact);
|
printContacts(mContact);
|
||||||
#endif
|
|
||||||
while (1) {
|
while (1) {
|
||||||
Sleep(10000); // 休眠,释放CPU
|
Sleep(10000); // 休眠,释放CPU
|
||||||
}
|
}
|
||||||
|
56
SDK/sdk.cpp
56
SDK/sdk.cpp
@ -306,40 +306,21 @@ ContactMap_t WxGetContacts()
|
|||||||
if (getAddrHandle(&moduleBaseAddress, &hProcess) != 0) {
|
if (getAddrHandle(&moduleBaseAddress, &hProcess) != 0) {
|
||||||
return mContact;
|
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);
|
||||||
|
|
||||||
DWORD Address1 = moduleBaseAddress + 0x1DB9728;
|
while (node != head) {
|
||||||
DWORD Address2 = GetMemoryIntByAddress(hProcess, Address1);
|
|
||||||
DWORD Address3 = GetMemoryIntByAddress(hProcess, Address2 + 0x28 + 0xBC);
|
|
||||||
|
|
||||||
vector<DWORD> nodeAddressList;
|
|
||||||
nodeAddressList.push_back(Address3);
|
|
||||||
|
|
||||||
DWORD nodeAddress1 = GetMemoryIntByAddress(hProcess, Address3 + 0x0);
|
|
||||||
DWORD nodeAddress2 = GetMemoryIntByAddress(hProcess, Address3 + 0x4);
|
|
||||||
DWORD nodeAddress3 = GetMemoryIntByAddress(hProcess, Address3 + 0x8);
|
|
||||||
if (find(nodeAddressList.begin(), nodeAddressList.end(), nodeAddress1) == nodeAddressList.end())
|
|
||||||
nodeAddressList.push_back(nodeAddress1);
|
|
||||||
if (find(nodeAddressList.begin(), nodeAddressList.end(), nodeAddress2) == nodeAddressList.end())
|
|
||||||
nodeAddressList.push_back(nodeAddress2);
|
|
||||||
if (find(nodeAddressList.begin(), nodeAddressList.end(), nodeAddress3) == nodeAddressList.end())
|
|
||||||
nodeAddressList.push_back(nodeAddress3);
|
|
||||||
|
|
||||||
unsigned int index = 1;
|
|
||||||
while (index < nodeAddressList.size()) {
|
|
||||||
WxContact_t contactItem;
|
WxContact_t contactItem;
|
||||||
DWORD nodeAddress = nodeAddressList[index++];
|
contactItem.wxId = GetUnicodeInfoByAddress(hProcess, node + 0x30);
|
||||||
DWORD checkNullResult = GetMemoryIntByAddress(hProcess, nodeAddress + 0xD);
|
contactItem.wxCode = GetUnicodeInfoByAddress(hProcess, node + 0x44);
|
||||||
if (checkNullResult == 0) {
|
contactItem.wxName = GetUnicodeInfoByAddress(hProcess, node + 0x8C);
|
||||||
index++;
|
contactItem.wxCountry = GetUnicodeInfoByAddress(hProcess, node + 0x1D0);
|
||||||
continue;
|
contactItem.wxProvince = GetUnicodeInfoByAddress(hProcess, node + 0x1E4);
|
||||||
}
|
contactItem.wxCity = GetUnicodeInfoByAddress(hProcess, node + 0x1F8);
|
||||||
contactItem.wxId = GetUnicodeInfoByAddress(hProcess, nodeAddress + 0x38);
|
DWORD gender = GetMemoryIntByAddress(hProcess, node + 0x184);
|
||||||
contactItem.wxCode = GetUnicodeInfoByAddress(hProcess, nodeAddress + 0x4C);
|
|
||||||
contactItem.wxName = GetUnicodeInfoByAddress(hProcess, nodeAddress + 0x94);
|
|
||||||
contactItem.wxCountry = GetUnicodeInfoByAddress(hProcess, nodeAddress + 0x1D8);
|
|
||||||
contactItem.wxProvince = GetUnicodeInfoByAddress(hProcess, nodeAddress + 0x1EC);
|
|
||||||
contactItem.wxCity = GetUnicodeInfoByAddress(hProcess, nodeAddress + 0x200);
|
|
||||||
DWORD gender = GetMemoryIntByAddress(hProcess, nodeAddress + 0x18C);
|
|
||||||
|
|
||||||
if (gender == 1)
|
if (gender == 1)
|
||||||
contactItem.wxGender = L"男";
|
contactItem.wxGender = L"男";
|
||||||
@ -349,16 +330,7 @@ ContactMap_t WxGetContacts()
|
|||||||
contactItem.wxGender = L"未知";
|
contactItem.wxGender = L"未知";
|
||||||
|
|
||||||
mContact.insert(make_pair(contactItem.wxId, contactItem));
|
mContact.insert(make_pair(contactItem.wxId, contactItem));
|
||||||
|
node = GetMemoryIntByAddress(hProcess, node);
|
||||||
DWORD nodeAddress1 = GetMemoryIntByAddress(hProcess, nodeAddress + 0x0);
|
|
||||||
DWORD nodeAddress2 = GetMemoryIntByAddress(hProcess, nodeAddress + 0x4);
|
|
||||||
DWORD nodeAddress3 = GetMemoryIntByAddress(hProcess, nodeAddress + 0x8);
|
|
||||||
if (find(nodeAddressList.begin(), nodeAddressList.end(), nodeAddress1) == nodeAddressList.end())
|
|
||||||
nodeAddressList.push_back(nodeAddress1);
|
|
||||||
if (find(nodeAddressList.begin(), nodeAddressList.end(), nodeAddress2) == nodeAddressList.end())
|
|
||||||
nodeAddressList.push_back(nodeAddress2);
|
|
||||||
if (find(nodeAddressList.begin(), nodeAddressList.end(), nodeAddress3) == nodeAddressList.end())
|
|
||||||
nodeAddressList.push_back(nodeAddress3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
CloseHandle(hProcess);
|
||||||
|
Loading…
Reference in New Issue
Block a user