diff --git a/spy/Spy.vcxproj b/spy/Spy.vcxproj
index 764898b..3673c19 100644
--- a/spy/Spy.vcxproj
+++ b/spy/Spy.vcxproj
@@ -110,6 +110,7 @@
4251;4819
MultiThreaded
stdcpp17
+ /EHa %(AdditionalOptions)
Windows
@@ -123,6 +124,9 @@
if not exist $(SolutionDir)Out md $(SolutionDir)Out
xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)Out
+xcopy /y $(OutDir)$(TargetName).exp $(SolutionDir)Out
+xcopy /y $(OutDir)$(TargetName).lib $(SolutionDir)Out
+xcopy /y $(OutDir)$(TargetName).pdb $(SolutionDir)Out
xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)python\wcferry
@@ -236,6 +240,7 @@ C:\Tools\nanopb\protoc --nanopb_out=. wcf.proto
+
@@ -255,6 +260,7 @@ C:\Tools\nanopb\protoc --nanopb_out=. wcf.proto
+
diff --git a/spy/Spy.vcxproj.filters b/spy/Spy.vcxproj.filters
index ccdf03c..d8c9371 100644
--- a/spy/Spy.vcxproj.filters
+++ b/spy/Spy.vcxproj.filters
@@ -78,6 +78,9 @@
头文件
+
+ 头文件
+
@@ -131,6 +134,9 @@
源文件
+
+ 源文件
+
diff --git a/spy/rpc_server.cpp b/spy/rpc_server.cpp
index ac7761f..431ccb9 100644
--- a/spy/rpc_server.cpp
+++ b/spy/rpc_server.cpp
@@ -28,14 +28,14 @@
#include "send_msg.h"
#include "spy.h"
#include "spy_types.h"
+#include "user_info.h"
#include "util.h"
#define G_BUF_SIZE (16 * 1024 * 1024)
#define CMD_URL "tcp://0.0.0.0:10086"
#define MSG_URL "tcp://0.0.0.0:10087"
-extern int IsLogin(void); // Defined in spy.cpp
-extern string GetSelfWxid(); // Defined in spy.cpp
+extern int IsLogin(void); // Defined in spy.cpp
bool gIsListening;
mutex gMutex;
diff --git a/spy/spy.cpp b/spy/spy.cpp
index f33d3a3..eeca874 100644
--- a/spy/spy.cpp
+++ b/spy/spy.cpp
@@ -11,18 +11,18 @@ void InitSpy()
{
wchar_t version[16] = { 0 };
InitLogger();
- g_WeChatWinDllAddr = (DWORD)GetModuleHandle(L"WeChatWin.dll"); //获取wechatWin模块地址
+ g_WeChatWinDllAddr = (DWORD)GetModuleHandle(L"WeChatWin.dll"); // 获取wechatWin模块地址
if (g_WeChatWinDllAddr == 0) {
LOG_ERROR("获取wechatWin.dll模块地址失败");
return;
}
- if (!GetWeChatVersion(version)) { //获取微信版本
+ if (!GetWeChatVersion(version)) { // 获取微信版本
LOG_ERROR("获取微信版本失败");
return;
}
LOG_DEBUG("WeChat version: {}", Wstring2String(version).c_str());
- if (LoadCalls(version, &g_WxCalls) != 0) { //加载微信版本对应的Call地址
+ if (LoadCalls(version, &g_WxCalls) != 0) { // 加载微信版本对应的Call地址
LOG_ERROR("不支持当前版本");
return;
}
@@ -37,5 +37,3 @@ void CleanupSpy()
}
int IsLogin(void) { return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login); }
-
-std::string GetSelfWxid() { return GET_STRING(g_WeChatWinDllAddr + g_WxCalls.ui.wxid); }
diff --git a/spy/user_info.cpp b/spy/user_info.cpp
new file mode 100644
index 0000000..e2e69e1
--- /dev/null
+++ b/spy/user_info.cpp
@@ -0,0 +1,25 @@
+#include "user_info.h"
+#include "load_calls.h"
+#include "log.h"
+#include "util.h"
+
+extern WxCalls_t g_WxCalls;
+extern DWORD g_WeChatWinDllAddr;
+
+std::string GetSelfWxid()
+{
+ DWORD wxidType = 0;
+ try {
+ wxidType = GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.ui.wxid + 0x14);
+ LOG_DEBUG("WeChatWinDll: {:#x}, wxid type: {:#x}", g_WeChatWinDllAddr, wxidType);
+ if (wxidType == 0xF) {
+ return GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.wxid);
+ } else {
+ return GET_STRING(g_WeChatWinDllAddr + g_WxCalls.ui.wxid);
+ }
+ } catch (...) {
+ LOG_ERROR("wxid type: {:#x}", wxidType);
+ LOG_BUFFER((uint8_t *)(g_WeChatWinDllAddr + g_WxCalls.ui.wxid), 20);
+ return "empty_wxid";
+ }
+}
diff --git a/spy/user_info.h b/spy/user_info.h
new file mode 100644
index 0000000..ce4aa31
--- /dev/null
+++ b/spy/user_info.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include
+
+std::string GetSelfWxid();
diff --git a/spy/util.h b/spy/util.h
index 56eab0e..147f706 100644
--- a/spy/util.h
+++ b/spy/util.h
@@ -8,9 +8,10 @@
#define WECHATINJECTDLL L"spy.dll"
#define WECHATINJECTDLL_DEBUG L"spy_debug.dll"
-#define GET_DWORD(addr) ((DWORD) * (DWORD *)(addr))
-#define GET_STRING(addr) ((CHAR *)(*(DWORD *)(addr)))
-#define GET_WSTRING(addr) ((WCHAR *)(*(DWORD *)(addr)))
+#define GET_DWORD(addr) ((DWORD) * (DWORD *)(addr))
+#define GET_STRING(addr) ((CHAR *)(*(DWORD *)(addr)))
+#define GET_WSTRING(addr) ((WCHAR *)(*(DWORD *)(addr)))
+#define GET_STRING_FROM_P(addr) ((CHAR *)(addr))
DWORD GetWeChatPid();
int OpenWeChat(DWORD *pid);