Skip to content

Commit

Permalink
Merge pull request #120 from ljc545w/fix/known_bugs
Browse files Browse the repository at this point in the history
Fix/known bugs
  • Loading branch information
ljc545w authored Sep 21, 2022
2 parents 0d67151 + 72c20b6 commit 17f8151
Show file tree
Hide file tree
Showing 32 changed files with 524 additions and 112 deletions.
35 changes: 35 additions & 0 deletions CWeChatRobot/GetA8Key.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "pch.h"

struct GetA8KeyRespStruct
{
DWORD message;
DWORD length;
};

wstring GetA8Key(DWORD pid, wchar_t *url)
{
WeChatProcess hp(pid);
if (!hp.m_init)
return L"";
DWORD GetA8KeyReomteAddr = hp.GetProcAddr(GetA8KeyRemote);
if (GetA8KeyReomteAddr == 0)
{
return L"";
}
WeChatData<wchar_t *> r_url(hp.GetHandle(), url, TEXTLENGTH(url));
if (!r_url.GetAddr())
{
return L"";
}
DWORD dwRet = CallRemoteFunction(hp.GetHandle(), GetA8KeyReomteAddr, r_url.GetAddr());
DWORD dwReadSize;
GetA8KeyRespStruct ret_info = {0};
ReadProcessMemory(hp.GetHandle(), (LPCVOID)dwRet, &ret_info, sizeof(ret_info), &dwReadSize);
if (ret_info.message == 0)
return L"";
unique_ptr<char[]> buffer(new char[ret_info.length + 1]());
ReadProcessMemory(hp.GetHandle(), (LPCVOID)ret_info.message, buffer.get(), ret_info.length, &dwReadSize);
string result(buffer.get(), ret_info.length);
wstring wresult = gb2312_to_unicode(result.c_str());
return wresult;
}
5 changes: 5 additions & 0 deletions CWeChatRobot/GetA8Key.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
#include <iostream>
using namespace std;
wstring GetA8Key(DWORD pid, wchar_t *url);
11 changes: 11 additions & 0 deletions CWeChatRobot/WeChatRobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,14 @@ STDMETHODIMP CWeChatRobot::CGetQrcodeImage(DWORD pid, VARIANT *__result)
*__result = GetQrcodeImage(pid);
return S_OK;
}

/*
* 参数0:目标进程pid
* 参数1:公众号文章链接
* 参数2:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CGetA8Key(DWORD pid, BSTR url, BSTR *__result)
{
*__result = (_bstr_t)GetA8Key(pid, url).c_str();
return S_OK;
}
1 change: 1 addition & 0 deletions CWeChatRobot/WeChatRobot.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class ATL_NO_VTABLE CWeChatRobot : public CComObjectRootEx<CComSingleThreadModel
STDMETHODIMP CGetHistoryPublicMsg(DWORD pid, BSTR PublicId, BSTR Offset, VARIANT *__result);
STDMETHODIMP CForwardMessage(DWORD pid, BSTR wxid, ULONG64 msgid, int *__result);
STDMETHODIMP CGetQrcodeImage(DWORD pid, VARIANT *__result);
STDMETHODIMP CGetA8Key(DWORD pid, BSTR url, BSTR *__result);
};

OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
1 change: 1 addition & 0 deletions CWeChatRobot/WeChatRobotCOM.idl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface IWeChatRobot : IDispatch
[id(47), helpstring("获取公众号历史消息")] HRESULT CGetHistoryPublicMsg([in] DWORD pid, [in] BSTR PublicId, [in] BSTR Offset, [out, retval] VARIANT * __result);
[id(48), helpstring("转发消息") ] HRESULT CForwardMessage([in] DWORD pid, [in] BSTR wxid, [in] unsigned long long localId, [out, retval] int * __result);
[id(49), helpstring("获取二维码")] HRESULT CGetQrcodeImage([in] DWORD pid, [out, retval] VARIANT * __result);
[id(50), helpstring("获取二维码")] HRESULT CGetA8Key([in] DWORD pid, [in] BSTR url, [ out, retval ] BSTR * __result);
};
[
object,
Expand Down
2 changes: 2 additions & 0 deletions CWeChatRobot/WeChatRobotCOM.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
<ClInclude Include="ForwardMessage.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="FriendList.h" />
<ClInclude Include="GetA8Key.h" />
<ClInclude Include="GetChatRoomMemberNickname.h" />
<ClInclude Include="GetChatRoomMembers.h" />
<ClInclude Include="GetDbHandles.h" />
Expand Down Expand Up @@ -280,6 +281,7 @@
<ClCompile Include="EditRemark.cpp" />
<ClCompile Include="ForwardMessage.cpp" />
<ClCompile Include="FriendList.cpp" />
<ClCompile Include="GetA8Key.cpp" />
<ClCompile Include="GetChatRoomMemberNickname.cpp" />
<ClCompile Include="GetChatRoomMembers.cpp" />
<ClCompile Include="GetDbHandles.cpp" />
Expand Down
9 changes: 9 additions & 0 deletions CWeChatRobot/WeChatRobotCOM.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<Filter Include="二维码">
<UniqueIdentifier>{fb5a07d9-648d-4e1c-aed3-158f872c3d3e}</UniqueIdentifier>
</Filter>
<Filter Include="浏览器相关\获取A8Key">
<UniqueIdentifier>{caeac105-0e3b-497e-a73e-f1233b3888aa}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
Expand Down Expand Up @@ -268,6 +271,9 @@
<ClInclude Include="GetQrcodeImage.h">
<Filter>二维码</Filter>
</ClInclude>
<ClInclude Include="GetA8Key.h">
<Filter>浏览器相关\获取A8Key</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
Expand Down Expand Up @@ -405,6 +411,9 @@
<ClCompile Include="GetQrcodeImage.cpp">
<Filter>二维码</Filter>
</ClCompile>
<ClCompile Include="GetA8Key.cpp">
<Filter>浏览器相关\获取A8Key</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
Expand Down
14 changes: 14 additions & 0 deletions CWeChatRobot/WeChatRobotCOM_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ DWORD pid,
/* [retval][out] */ VARIANT *__result) = 0;

virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CGetA8Key(
/* [in] */ DWORD pid,
/* [in] */ BSTR url,
/* [retval][out] */ BSTR *__result) = 0;

};


Expand Down Expand Up @@ -700,6 +705,12 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ DWORD pid,
/* [retval][out] */ VARIANT *__result);

/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *CGetA8Key )(
IWeChatRobot * This,
/* [in] */ DWORD pid,
/* [in] */ BSTR url,
/* [retval][out] */ BSTR *__result);

END_INTERFACE
} IWeChatRobotVtbl;

Expand Down Expand Up @@ -874,6 +885,9 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CGetQrcodeImage(This,pid,__result) \
( (This)->lpVtbl -> CGetQrcodeImage(This,pid,__result) )

#define IWeChatRobot_CGetA8Key(This,pid,url,__result) \
( (This)->lpVtbl -> CGetA8Key(This,pid,url,__result) )

#endif /* COBJMACROS */


Expand Down
Loading

0 comments on commit 17f8151

Please sign in to comment.