WeChatFerry/spy/spy.cpp

37 lines
1.0 KiB
C++
Raw Normal View History

2022-10-15 20:25:42 +08:00
#include "spy.h"
#include "load_calls.h"
#include "log.h"
2022-08-13 20:03:22 +08:00
#include "rpc_server.h"
#include "util.h"
2022-10-16 22:14:06 +08:00
WxCalls_t g_WxCalls = { 0 };
2022-08-13 20:03:22 +08:00
DWORD g_WeChatWinDllAddr = 0;
2023-04-08 22:52:35 +08:00
void InitSpy(int port)
2022-08-13 20:03:22 +08:00
{
wchar_t version[16] = { 0 };
2022-10-15 20:25:42 +08:00
InitLogger();
2023-03-10 23:47:24 +08:00
g_WeChatWinDllAddr = (DWORD)GetModuleHandle(L"WeChatWin.dll"); // 获取wechatWin模块地址
2022-08-13 20:03:22 +08:00
if (g_WeChatWinDllAddr == 0) {
2022-10-15 20:25:42 +08:00
LOG_ERROR("获取wechatWin.dll模块地址失败");
2022-08-20 15:15:04 +08:00
return;
2022-08-13 20:03:22 +08:00
}
2023-03-10 23:47:24 +08:00
if (!GetWeChatVersion(version)) { // 获取微信版本
2022-10-15 20:25:42 +08:00
LOG_ERROR("获取微信版本失败");
2022-08-20 15:15:04 +08:00
return;
2022-08-13 20:03:22 +08:00
}
2023-02-27 23:56:46 +08:00
LOG_DEBUG("WeChat version: {}", Wstring2String(version).c_str());
2023-03-10 23:47:24 +08:00
if (LoadCalls(version, &g_WxCalls) != 0) { // 加载微信版本对应的Call地址
2022-10-15 20:25:42 +08:00
LOG_ERROR("不支持当前版本");
2023-04-08 18:58:10 +08:00
MessageBox(NULL, L"不支持当前版本", L"错误", 0);
2022-08-20 15:15:04 +08:00
return;
2022-08-13 20:03:22 +08:00
}
2023-04-08 22:52:35 +08:00
RpcStartServer(port);
2022-08-13 20:03:22 +08:00
}
2023-04-08 22:52:35 +08:00
void CleanupSpy() { RpcStopServer(); }
2022-08-13 20:03:22 +08:00
2022-08-13 21:55:08 +08:00
int IsLogin(void) { return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login); }