UserInfo.cpp 4.1 KB
Newer Older
L
ljc545w 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
#include "pch.h"
#include <typeinfo>
#include <string>
#include <vector>

#define GetUserInfoCall1Offset 0x645BD9A0 - 0x64530000
#define GetUserInfoCall2Offset 0x64C08420 - 0x64530000
#define GetUserInfoCall3Offset 0x64914260 - 0x64530000

struct GetUserInfoStruct {
	DWORD message;
	DWORD length;
};

wstring wUserInfo = L"";
GetUserInfoStruct ret = { 0 };

struct GetDetailUserInfoStruct {
	WxString* pWxString;
	DWORD ptr1 = 0;
	DWORD ptr2 = 0;
	char fill[0x18] = { 0 };
	GetDetailUserInfoStruct(WxString* pWxString) {
		this->pWxString = pWxString;
		ptr1 = DWORD(pWxString) + sizeof(WxString);
		ptr2 = DWORD(pWxString) + sizeof(WxString);
	}
};

struct UserInfoBaseStruct {
	DWORD data;
	DWORD endbuffer1;
	DWORD endbuffer2;
	char fill[0x18] = { 0 };
};


VOID WxUserInfo(DWORD address) {
	vector<DWORD> InfoType{
		address + 0x10,
		address + 0x24,
		address + 0x38,
		address + 0x6C,
		address + 0xFC,
		address + 0x110,
		address + 0x19C,
		address + 0x1B0,
		address + 0x1C4,
		address + 0x1D8,
		address + 0x27C
	};
	vector<wchar_t*> InfoTypeName{
		(WCHAR*)L"\"wxId\"",
		(WCHAR*)L"\"wxNumber\"",
		(WCHAR*)L"\"wxV3\"",
		(WCHAR*)L"\"wxNickName\"",
		(WCHAR*)L"\"wxBigAvatar\"",
		(WCHAR*)L"\"wxSmallAvatar\"",
		(WCHAR*)L"\"wxSignature\"",
		(WCHAR*)L"\"wxNation\"",
		(WCHAR*)L"\"wxProvince\"",
		(WCHAR*)L"\"wxCity\"",
		(WCHAR*)L"\"wxBackground\"",
	};
	wUserInfo += L"{";
	for (unsigned int i = 0; i < InfoType.size(); i++) {
		wchar_t* wstemp = ((*((DWORD*)InfoType[i])) != 0) ? (WCHAR*)(*((LPVOID*)InfoType[i])) : (WCHAR*)L"null";
		wUserInfo = wUserInfo + InfoTypeName[i] + L":\"" + wstemp + L"\"";
		if (i != InfoType.size() - 1) {
			wUserInfo += L",";
		}
	}
	wUserInfo += L"}";
#ifdef _DEBUG
	wcout.imbue(locale("chs"));
	wcout << wUserInfo.c_str() << endl;
#endif
}


DWORD GetWxUserInfoRemote(LPVOID lparamter) {
	wchar_t* userwxid = (wchar_t*)lparamter;
	DWORD address = 0;
	
	if (!GetUserDetailInfoByWxId(userwxid, address)) {
		return 0;
	}
	ret.message = (DWORD)wUserInfo.c_str();
	ret.length = (DWORD)wUserInfo.length();
	return (DWORD)&ret;
}


BOOL GetUserDetailInfoByWxId(wchar_t* wxid,DWORD &address) {
	DWORD WeChatWinBase = GetWeChatWinBase();
	DWORD GetUserDetailInfoCall1 = WeChatWinBase + 0x5F917490 - 0x5F230000;
	DWORD GetUserDetailInfoCall2 = WeChatWinBase + 0x5F2BD9A0 - 0x5F230000;
	DWORD GetUserDetailInfoCall3 = WeChatWinBase + 0x5F619F70 - 0x5F230000;

	DWORD DeleteCacheCall1 = WeChatWinBase + 0x56C349A0 - 0x56B80000;
	DWORD DeleteCacheCall2 = WeChatWinBase + 0x56D983B0 - 0x56B80000;
	WxString* pWxid = new WxString;
	pWxid->buffer = wxid;
	pWxid->length = wcslen(wxid);
	pWxid->maxLength = wcslen(wxid) * 2;

	UserInfoBaseStruct temp = { 0 };
	UserInfoBaseStruct userinfo = { 0 };
	GetDetailUserInfoStruct pUser(pWxid);
	DWORD isSuccess = 0;

	__asm {
		pushad;
		pushfd;
		mov eax, 0x7;
		lea ecx, pUser;
		lea edx, temp;
		call GetUserDetailInfoCall1;
		call GetUserDetailInfoCall2;
		lea ecx, userinfo;
		push ecx;
		lea ecx, temp;
		push ecx;
		mov ecx, eax;
		call GetUserDetailInfoCall3;
		mov isSuccess, eax;
		popfd;
		popad;
	}
	address = userinfo.data;
	if(isSuccess != 0)
		WxUserInfo(address);
	__asm {
		pushad;
		pushfd;
		lea ecx, temp;
		call DeleteCacheCall1;
		lea ecx, userinfo;
		call DeleteCacheCall2;
		popfd;
		popad;
	}
	delete pWxid;
	pWxid = NULL;
	return (isSuccess != 0);
}

BOOL GetWxUserInfoByWxid(wchar_t* wxid, DWORD& address) {
	DWORD WeChatWinBase = GetWeChatWinBase();
	DWORD WxUserDataCall1 = WeChatWinBase + GetUserInfoCall1Offset;
	DWORD WxUserDataCall2 = WeChatWinBase + GetUserInfoCall2Offset;
	DWORD WxUserDataCall3 = WeChatWinBase + GetUserInfoCall3Offset;
	char buffer[0xF90] = { 0 };
	WxBaseStruct pWxid(wxid);
	DWORD r_ebx = 0;
	DWORD isSuccess = 0;
	__asm
	{
		pushad;
		call WxUserDataCall1;
		lea ebx, buffer;
		mov esi, eax;
		push ebx;
		sub esp, 0x14;
		lea eax, pWxid;
		mov ecx, esp;
		push eax;
		call WxUserDataCall2;
		mov ecx, esi;
		call WxUserDataCall3;
		mov r_ebx, ebx;
		mov isSuccess, eax;
		popad;
	}
	address = r_ebx;
	return isSuccess;
}