提交 4ec54372 编写于 作者: L ljc545w

新增获取登录状态接口

上级 24f986c8
......@@ -47,4 +47,18 @@ std::wstring GetSelfInfo() {
DeleteSelfInfoCache();
return SelfInfoString;
}
BOOL isWxLogin() {
if (!hProcess)
return false;
DWORD isWxLoginAddr = GetWeChatRobotBase() + isWxLoginOffset;
DWORD dwId, dwRet = 0;
HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)isWxLoginAddr, NULL, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwRet);
CloseHandle(hThread);
}
return dwRet == 1;
}
\ No newline at end of file
......@@ -2,4 +2,5 @@
#include <windows.h>
#include <iostream>
using namespace std;
std::wstring GetSelfInfo();
\ No newline at end of file
std::wstring GetSelfInfo();
BOOL isWxLogin();
\ No newline at end of file
......@@ -341,9 +341,17 @@ STDMETHODIMP CWeChatRobot::CSendAppMsg(BSTR wxid,BSTR appid,int* __result) {
/*
* 参数1:要删除的人wxid
* 参数3:预返回的值,调用时无需提供
* 参数2:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CDeleteUser(BSTR wxid, int* __result) {
*__result = DeleteUser(wxid);
return S_OK;
}
/*
* 参数1:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CIsWxLogin(int* __result) {
*__result = isWxLogin();
return S_OK;
}
\ No newline at end of file
......@@ -85,6 +85,7 @@ public:
STDMETHODIMP CChangeWeChatVer(BSTR verStr, int* __result);
STDMETHODIMP CSendAppMsg(BSTR wxid, BSTR appid, int* __result);
STDMETHODIMP CDeleteUser(BSTR wxid, int* __result);
STDMETHODIMP CIsWxLogin(int* __result);
};
OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
......@@ -50,6 +50,7 @@ interface IWeChatRobot : IDispatch
[id(35), helpstring("修改微信版本号")] HRESULT CChangeWeChatVer([in] BSTR verStr, [out, retval] int* __result);
[id(36), helpstring("发送小程序")] HRESULT CSendAppMsg([in] BSTR wxid, [in] BSTR appid, [out, retval] int* __result);
[id(37), helpstring("删除好友")] HRESULT CDeleteUser([in] BSTR wxid, [out, retval] int* __result);
[id(38), helpstring("获取登录状态")] HRESULT CIsWxLogin([out, retval] int* __result);
};
[
object,
......
......@@ -257,6 +257,9 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR wxid,
/* [retval][out] */ int *__result) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CIsWxLogin(
/* [retval][out] */ int *__result) = 0;
};
......@@ -492,6 +495,10 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR wxid,
/* [retval][out] */ int *__result);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *CIsWxLogin )(
IWeChatRobot * This,
/* [retval][out] */ int *__result);
END_INTERFACE
} IWeChatRobotVtbl;
......@@ -630,6 +637,9 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CDeleteUser(This,wxid,__result) \
( (This)->lpVtbl -> CDeleteUser(This,wxid,__result) )
#define IWeChatRobot_CIsWxLogin(This,__result) \
( (This)->lpVtbl -> CIsWxLogin(This,__result) )
#endif /* COBJMACROS */
......
......@@ -49,7 +49,7 @@
#include "WeChatRobotCOM_i.h"
#define TYPE_FORMAT_STRING_SIZE 1239
#define PROC_FORMAT_STRING_SIZE 1513
#define PROC_FORMAT_STRING_SIZE 1549
#define EXPR_FORMAT_STRING_SIZE 1
#define TRANSMIT_AS_TABLE_SIZE 0
#define WIRE_MARSHAL_TABLE_SIZE 2
......@@ -1409,41 +1409,72 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 1468 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CPostMessage */
/* Procedure CIsWxLogin */
/* 1470 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 1472 */ NdrFcLong( 0x0 ), /* 0 */
/* 1476 */ NdrFcShort( 0x7 ), /* 7 */
/* 1478 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 1476 */ NdrFcShort( 0x29 ), /* 41 */
/* 1478 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 1480 */ NdrFcShort( 0x0 ), /* 0 */
/* 1482 */ NdrFcShort( 0x24 ), /* 36 */
/* 1484 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
0x3, /* 3 */
/* 1484 */ 0x44, /* Oi2 Flags: has return, has ext, */
0x2, /* 2 */
/* 1486 */ 0x8, /* 8 */
0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */
0x41, /* Ext Flags: new corr desc, has range on conformance */
/* 1488 */ NdrFcShort( 0x0 ), /* 0 */
/* 1490 */ NdrFcShort( 0x1 ), /* 1 */
/* 1490 */ NdrFcShort( 0x0 ), /* 0 */
/* 1492 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter msg */
/* Parameter __result */
/* 1494 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
/* 1494 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 1496 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 1498 */ NdrFcShort( 0x4cc ), /* Type Offset=1228 */
/* 1498 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Parameter __result */
/* Return value */
/* 1500 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 1500 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 1502 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 1504 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CPostMessage */
/* 1506 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 1508 */ NdrFcLong( 0x0 ), /* 0 */
/* 1512 */ NdrFcShort( 0x7 ), /* 7 */
/* 1514 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 1516 */ NdrFcShort( 0x0 ), /* 0 */
/* 1518 */ NdrFcShort( 0x24 ), /* 36 */
/* 1520 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
0x3, /* 3 */
/* 1522 */ 0x8, /* 8 */
0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */
/* 1524 */ NdrFcShort( 0x0 ), /* 0 */
/* 1526 */ NdrFcShort( 0x1 ), /* 1 */
/* 1528 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter msg */
/* 1530 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
/* 1532 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 1534 */ NdrFcShort( 0x4cc ), /* Type Offset=1228 */
/* Parameter __result */
/* 1536 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 1538 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 1540 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 1506 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 1508 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 1510 */ 0x8, /* FC_LONG */
/* 1542 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 1544 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 1546 */ 0x8, /* FC_LONG */
0x0, /* 0 */
0x0
......@@ -2324,7 +2355,8 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] =
1302,
1338,
1380,
1428
1428,
1470
};
static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo =
......@@ -2348,7 +2380,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo =
0,
0,
0};
CINTERFACE_PROXY_VTABLE(41) _IWeChatRobotProxyVtbl =
CINTERFACE_PROXY_VTABLE(42) _IWeChatRobotProxyVtbl =
{
&IWeChatRobot_ProxyInfo,
&IID_IWeChatRobot,
......@@ -2392,7 +2424,8 @@ CINTERFACE_PROXY_VTABLE(41) _IWeChatRobotProxyVtbl =
(void *) (INT_PTR) -1 /* IWeChatRobot::CUnHookImageMsg */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CChangeWeChatVer */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CSendAppMsg */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CDeleteUser */
(void *) (INT_PTR) -1 /* IWeChatRobot::CDeleteUser */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CIsWxLogin */
};
......@@ -2435,6 +2468,7 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] =
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2
};
......@@ -2442,7 +2476,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl =
{
&IID_IWeChatRobot,
&IWeChatRobot_ServerInfo,
41,
42,
&IWeChatRobot_table[-3],
CStdStubBuffer_DELEGATING_METHODS
};
......@@ -2458,7 +2492,7 @@ static const unsigned short IRobotEvent_FormatStringOffsetTable[] =
(unsigned short) -1,
(unsigned short) -1,
(unsigned short) -1,
1470
1506
};
static const MIDL_STUBLESS_PROXY_INFO IRobotEvent_ProxyInfo =
......
......@@ -21,6 +21,7 @@ DWORD DeleteUserInfoCacheOffset = 0x0;
DWORD GetSelfInfoOffset = 0x0;
DWORD DeleteSelfInfoCacheOffset = 0x0;
DWORD SearchContactByNetRemoteOffset = 0x0;
DWORD isWxLoginOffset = 0;
DWORD VerifyFriendApplyOffset = 0x0;
......@@ -144,6 +145,8 @@ BOOL GetProcOffset(wchar_t* workPath) {
DeleteSelfInfoCacheOffset = DeleteSelfInfoCacheProcAddr - WeChatBase;
DWORD SearchContactByNetRemoteAddr = (DWORD)GetProcAddress(hd, SearchContactByNetRemote);
SearchContactByNetRemoteOffset = SearchContactByNetRemoteAddr - WeChatBase;
DWORD isWxLoginAddr = (DWORD)GetProcAddress(hd, isWxLoginRemote);
isWxLoginOffset = isWxLoginAddr - WeChatBase;
DWORD CheckFriendStatusRemoteAddr = (DWORD)GetProcAddress(hd, CheckFriendStatusRemote);
CheckFriendStatusRemoteOffset = CheckFriendStatusRemoteAddr - WeChatBase;
......
......@@ -43,6 +43,7 @@ extern DWORD VerifyFriendApplyOffset;
extern DWORD GetSelfInfoOffset;
extern DWORD DeleteSelfInfoCacheOffset;
extern wstring SelfInfoString;
extern DWORD isWxLoginOffset;
extern DWORD CheckFriendStatusRemoteOffset;
......@@ -89,6 +90,7 @@ extern DWORD ChangeWeChatVerRemoteOffset;
#define GetSelfInfoRemote "GetSelfInfoRemote"
#define DeleteSelfInfoCacheRemote "DeleteSelfInfoCacheRemote"
#define SearchContactByNetRemote "SearchContactByNetRemote"
#define isWxLoginRemote "isWxLogin"
#define VerifyFriendApplyRemote "VerifyFriendApplyRemote"
......
#include "pch.h"
#include <vector>
#define CheckLoginOffset 0x2366538
/*
* 外部调用时的返回类型
* message:selfinfo.c_str()
......@@ -40,6 +42,7 @@ wstring GetSelfInfo() {
WeChatWinBase + 0x236607C,
WeChatWinBase + 0x2366548,
WeChatWinBase + 0x23660F4,
WeChatWinBase + 0x23661F8,
*(DWORD*)(WeChatWinBase + 0x236622C),
*(DWORD*)(WeChatWinBase + 0x23A111C),
*(DWORD*)(WeChatWinBase + 0x23663D4),
......@@ -53,6 +56,7 @@ wstring GetSelfInfo() {
L"\"wxId\"",
L"\"wxNumber\"",
L"\"wxNickName\"",
L"\"Sex\"",
L"\"wxSignature\"",
L"\"wxBigAvatar\"",
L"\"wxSmallAvatar\"",
......@@ -88,10 +92,29 @@ wstring GetSelfInfo() {
temp = (char*)SelfInfoAddr[i];
}
}
else if (!SelfInfoKey[i].compare(L"\"Sex\"")) {
int sex = *(int*)SelfInfoAddr[i];
switch (sex) {
case 1: {
selfinfo = selfinfo + L"男\",";
break;
}
case 2: {
selfinfo = selfinfo + L"女\",";
break;
}
default: {
selfinfo = selfinfo + L"未知\",";
break;
}
}
continue;
}
else {
temp = (char*)SelfInfoAddr[i];
if (temp == NULL || strlen(temp) == 0)
if (temp == NULL || strlen(temp) == 0) {
temp = (char*)"null";
}
}
wchar_t* wtemp = new wchar_t[strlen(temp) + 1];
ZeroMemory(wtemp, (strlen(temp) + 1) * 2);
......@@ -112,6 +135,11 @@ wstring GetSelfInfo() {
return selfinfo;
}
BOOL isWxLogin() {
DWORD CheckLoginAddr = GetWeChatWinBase() + CheckLoginOffset;
return *(BOOL*)CheckLoginAddr;
}
/*
* 删除个人信息缓存
* return:void
......
......@@ -6,4 +6,7 @@ wstring GetSelfInfo();
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) DWORD GetSelfInfoRemote();
extern "C" __declspec(dllexport) VOID DeleteSelfInfoCacheRemote();
extern "C" __declspec(dllexport) BOOL isWxLogin();
#else
BOOL isWxLogin();
#endif
\ No newline at end of file
......@@ -134,6 +134,18 @@ class WeChatRobot():
"""
status = self.robot.CStartRobotService()
return status
def IsWxLogin(self) -> int:
"""
获取微信登录状态
Returns
-------
bool
微信登录状态.
"""
return self.robot.CIsWxLogin()
def SendText(self,receiver:str,msg:str) -> int:
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册