SelfInfo.cpp 2.1 KB
Newer Older
G
Gogs 已提交
1 2 3 4 5 6 7 8 9 10 11 12
#include "pch.h"
#include <vector>

wstring selfinfo = L"";

struct SelfInfoStruct {
	DWORD message;
	DWORD length;
} ret;

DWORD GetSelfInfoRemote() {
	DWORD WeChatWinBase = GetWeChatWinBase();
G
Gogs 已提交
13
	vector<DWORD> SelfInfoAddr = {
L
ljc545w 已提交
14 15 16 17 18 19 20 21 22 23
		*(DWORD*)(WeChatWinBase + 0x222EB3C),
		WeChatWinBase + 0x222ED30,
		WeChatWinBase + 0x222EBB4,
		*(DWORD*)(WeChatWinBase + 0x222ECEC),
		*(DWORD*)(WeChatWinBase + 0x222EE94),
		*(DWORD*)(WeChatWinBase + 0x222EEAC),
		WeChatWinBase + 0x222EF30,
		WeChatWinBase + 0x222ECBC,
		WeChatWinBase + 0x222ECD4,
		WeChatWinBase + 0x222EBE8
G
Gogs 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37
	};

	vector<wstring> SelfInfoKey = {
		L"\"wxId\"",
		L"\"wxNumber\"",
		L"\"wxNickName\"",
		L"\"wxSignature\"",
		L"\"wxBigAvatar\"",
		L"\"wxSmallAvatar\"",
		L"\"wxNation\"",
		L"\"wxProvince\"",
		L"\"wxCity\"",
		L"\"PhoneNumber\""
	};
L
ljc545w 已提交
38 39 40
#ifdef _DEBUG
	wcout.imbue(locale("chs"));
#endif
G
Gogs 已提交
41 42 43 44
	selfinfo = selfinfo + L"{";
	for (unsigned int i = 0; i < SelfInfoAddr.size(); i++) {
		selfinfo = selfinfo + SelfInfoKey[i] + L":";
		selfinfo = selfinfo + L"\"";
G
Gogs 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58
		char* temp = NULL;
		if (!SelfInfoKey[i].compare(L"\"wxNickName\"")) {
			if (*(DWORD*)(SelfInfoAddr[i] + 0x14) == 0xF) {
				temp = (*((DWORD*)SelfInfoAddr[i]) != 0) ? (char*)SelfInfoAddr[i] : (char*)"null";
			}
			else {
				temp = (*((DWORD*)SelfInfoAddr[i]) != 0) ? (char*)(*(DWORD*)SelfInfoAddr[i]) : (char*)"null";
			}
		}
		else {
			temp = (char*)SelfInfoAddr[i];
			if (strlen(temp) == 0)
				temp = (char*)"null";
		}
G
Gogs 已提交
59
		wchar_t* wtemp = new wchar_t[strlen(temp) + 1];
L
ljc545w 已提交
60
		ZeroMemory(wtemp, (strlen(temp) + 1) * 2);
L
ljc545w 已提交
61
		MultiByteToWideChar(CP_UTF8, 0, temp, -1, wtemp, strlen(temp) + 1);
G
Gogs 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
		selfinfo = selfinfo + wtemp;
		selfinfo = selfinfo + L"\"";
		if(i!= SelfInfoAddr.size() - 1)
			selfinfo = selfinfo + L",";
		delete[] wtemp;
		wtemp = NULL;
	}
	selfinfo = selfinfo + L"}";
	ret.message = (DWORD)selfinfo.c_str();
	ret.length = selfinfo.length();
#ifdef _DEBUG
	wcout << selfinfo << endl;
	DeleteSelfInfoCacheRemote();
#endif
	return (DWORD)&ret;
}

VOID DeleteSelfInfoCacheRemote() {
	if (ret.length) {
		ZeroMemory((wchar_t*)ret.message, ret.length*2 + 2);
		ret.length = 0;
		selfinfo = L"";
	}
}