Merge pull request #10 from lich0821/fix_self_wxid

Fix GetSelfWxid
This commit is contained in:
Changhua 2023-03-21 00:14:51 +08:00 committed by GitHub
commit d5cff6f733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 10 deletions

View File

@ -110,6 +110,7 @@
<DisableSpecificWarnings>4251;4819</DisableSpecificWarnings> <DisableSpecificWarnings>4251;4819</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/EHa %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -123,6 +124,9 @@
<PostBuildEvent> <PostBuildEvent>
<Command>if not exist $(SolutionDir)Out md $(SolutionDir)Out <Command>if not exist $(SolutionDir)Out md $(SolutionDir)Out
xcopy /y $(OutDir)$(TargetFileName) $(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</Command> xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)python\wcferry</Command>
</PostBuildEvent> </PostBuildEvent>
<PostBuildEvent> <PostBuildEvent>
@ -236,6 +240,7 @@ C:\Tools\nanopb\protoc --nanopb_out=. wcf.proto
<ClInclude Include="send_msg.h" /> <ClInclude Include="send_msg.h" />
<ClInclude Include="spy.h" /> <ClInclude Include="spy.h" />
<ClInclude Include="spy_types.h" /> <ClInclude Include="spy_types.h" />
<ClInclude Include="user_info.h" />
<ClInclude Include="util.h" /> <ClInclude Include="util.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -255,6 +260,7 @@ C:\Tools\nanopb\protoc --nanopb_out=. wcf.proto
<ClCompile Include="rpc_server.cpp" /> <ClCompile Include="rpc_server.cpp" />
<ClCompile Include="send_msg.cpp" /> <ClCompile Include="send_msg.cpp" />
<ClCompile Include="spy.cpp" /> <ClCompile Include="spy.cpp" />
<ClCompile Include="user_info.cpp" />
<ClCompile Include="util.cpp" /> <ClCompile Include="util.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -78,6 +78,9 @@
<ClInclude Include="add_chatroom_member.h"> <ClInclude Include="add_chatroom_member.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="user_info.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
@ -131,6 +134,9 @@
<ClCompile Include="add_chatroom_member.cpp"> <ClCompile Include="add_chatroom_member.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="user_info.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="spy.def"> <None Include="spy.def">

View File

@ -28,6 +28,7 @@
#include "send_msg.h" #include "send_msg.h"
#include "spy.h" #include "spy.h"
#include "spy_types.h" #include "spy_types.h"
#include "user_info.h"
#include "util.h" #include "util.h"
#define G_BUF_SIZE (16 * 1024 * 1024) #define G_BUF_SIZE (16 * 1024 * 1024)
@ -35,7 +36,6 @@
#define MSG_URL "tcp://0.0.0.0:10087" #define MSG_URL "tcp://0.0.0.0:10087"
extern int IsLogin(void); // Defined in spy.cpp extern int IsLogin(void); // Defined in spy.cpp
extern string GetSelfWxid(); // Defined in spy.cpp
bool gIsListening; bool gIsListening;
mutex gMutex; mutex gMutex;

View File

@ -37,5 +37,3 @@ void CleanupSpy()
} }
int IsLogin(void) { return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login); } int IsLogin(void) { return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login); }
std::string GetSelfWxid() { return GET_STRING(g_WeChatWinDllAddr + g_WxCalls.ui.wxid); }

25
spy/user_info.cpp Normal file
View File

@ -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";
}
}

5
spy/user_info.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <string>
std::string GetSelfWxid();

View File

@ -11,6 +11,7 @@
#define GET_DWORD(addr) ((DWORD) * (DWORD *)(addr)) #define GET_DWORD(addr) ((DWORD) * (DWORD *)(addr))
#define GET_STRING(addr) ((CHAR *)(*(DWORD *)(addr))) #define GET_STRING(addr) ((CHAR *)(*(DWORD *)(addr)))
#define GET_WSTRING(addr) ((WCHAR *)(*(DWORD *)(addr))) #define GET_WSTRING(addr) ((WCHAR *)(*(DWORD *)(addr)))
#define GET_STRING_FROM_P(addr) ((CHAR *)(addr))
DWORD GetWeChatPid(); DWORD GetWeChatPid();
int OpenWeChat(DWORD *pid); int OpenWeChat(DWORD *pid);