Impl DisableReceiveMsg
This commit is contained in:
+24
-7
@@ -33,8 +33,6 @@ RPC_STATUS RpcDisconnectServer()
|
||||
RPC_STATUS status;
|
||||
// Free the memory allocated by a string
|
||||
status = RpcStringFree(&pszStringBinding);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
// Releases binding handle resources and disconnects from the server
|
||||
status = RpcBindingFree(&hSpyBinding);
|
||||
@@ -42,7 +40,7 @@ RPC_STATUS RpcDisconnectServer()
|
||||
return status;
|
||||
}
|
||||
|
||||
unsigned int __stdcall RpcSetTextMsgCb(void *p)
|
||||
int RpcEnableReceiveMsg()
|
||||
{
|
||||
unsigned long ulCode = 0;
|
||||
RpcTryExcept
|
||||
@@ -53,7 +51,25 @@ unsigned int __stdcall RpcSetTextMsgCb(void *p)
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("rpcWxSetTextMsgCb exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
printf("RpcEnableReceiveMsg exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RpcDisableReceiveMsg()
|
||||
{
|
||||
unsigned long ulCode = 0;
|
||||
RpcTryExcept
|
||||
{
|
||||
// UnHook Message receiving
|
||||
client_DisableReceiveMsg();
|
||||
}
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("RpcDisableReceiveMsg exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
@@ -72,7 +88,8 @@ int RpcIsLogin()
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("rpcIsLogin exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
printf("RpcIsLogin exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
return -1;
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
@@ -88,7 +105,7 @@ int RpcSendTextMsg(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t *m
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("rpcWxSendTextMsg exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
printf("RpcSendTextMsg exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
@@ -104,7 +121,7 @@ int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("rpcWxSendImageMsg exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
printf("RpcSendImageMsg exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@
|
||||
RPC_STATUS RpcConnectServer();
|
||||
RPC_STATUS RpcDisconnectServer();
|
||||
|
||||
unsigned int __stdcall RpcSetTextMsgCb(void *p);
|
||||
int RpcEnableReceiveMsg();
|
||||
int RpcDisableReceiveMsg();
|
||||
int RpcIsLogin();
|
||||
int RpcSendTextMsg(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t *msg);
|
||||
int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path);
|
||||
|
||||
+29
-9
@@ -19,7 +19,7 @@ static WCHAR SpyDllPath[MAX_PATH] = { 0 };
|
||||
|
||||
int WxInitSDK()
|
||||
{
|
||||
DWORD status = 0;
|
||||
int status = 0;
|
||||
unsigned long ulCode = 0;
|
||||
|
||||
GetModuleFileName(GetModuleHandle(WECHATSDKDLL), SpyDllPath, MAX_PATH);
|
||||
@@ -34,35 +34,49 @@ int WxInitSDK()
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
Sleep(2000); // 等待微信打开
|
||||
if (InjectDll(WeChatPID, SpyDllPath)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
RpcConnectServer();
|
||||
|
||||
while (!RpcIsLogin()) {
|
||||
Sleep(1000);
|
||||
Sleep(1000); // 等待SPY就绪
|
||||
status = RpcConnectServer();
|
||||
if (status != 0) {
|
||||
printf("RpcConnectServer: %d\n", status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
do {
|
||||
status = RpcIsLogin();
|
||||
if (status == -1) {
|
||||
return status;
|
||||
}
|
||||
else if (status == 1) {
|
||||
break;
|
||||
}
|
||||
Sleep(1000);
|
||||
} while (1);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int WxDestroySDK()
|
||||
{
|
||||
WxDisableRecvMsg();
|
||||
RpcDisconnectServer();
|
||||
EjectDll(WeChatPID, SpyDllPath);
|
||||
// 关闭 RPC,但不卸载 DLL,方便下次使用。
|
||||
//EjectDll(WeChatPID, SpyDllPath);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int WxSetTextMsgCb(const std::function<int(WxMessage_t)> &onMsg)
|
||||
int WxEnableRecvMsg(const std::function<int(WxMessage_t)> &onMsg)
|
||||
{
|
||||
if (onMsg) {
|
||||
HANDLE msgThread;
|
||||
g_cbReceiveTextMsg = onMsg;
|
||||
|
||||
msgThread = (HANDLE)_beginthreadex(NULL, 0, RpcSetTextMsgCb, NULL, 0, NULL);
|
||||
msgThread = (HANDLE)CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RpcEnableReceiveMsg, NULL, 0, NULL);
|
||||
if (msgThread == NULL) {
|
||||
printf("Failed to create innerWxRecvTextMsg.\n");
|
||||
return -2;
|
||||
@@ -76,6 +90,12 @@ int WxSetTextMsgCb(const std::function<int(WxMessage_t)> &onMsg)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WxDisableRecvMsg()
|
||||
{
|
||||
RpcDisableReceiveMsg();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WxSendTextMsg(wstring wxid, wstring at_wxid, wstring msg)
|
||||
{
|
||||
return RpcSendTextMsg(wxid.c_str(), at_wxid.c_str(), msg.c_str());
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
EXPORTS
|
||||
WxInitSDK
|
||||
WxDestroySDK
|
||||
WxSetTextMsgCb
|
||||
WxEnableRecvMsg
|
||||
WxDisableRecvMsg
|
||||
WxSendTextMsg
|
||||
WxGetMsgTypes
|
||||
WxSendImageMsg
|
||||
|
||||
@@ -39,7 +39,8 @@ typedef vector<WxDbTable_t> DbTableVector_t;
|
||||
|
||||
int WxInitSDK();
|
||||
int WxDestroySDK();
|
||||
int WxSetTextMsgCb(const std::function<int(WxMessage_t)> &onMsg);
|
||||
int WxEnableRecvMsg(const std::function<int(WxMessage_t)> &onMsg);
|
||||
int WxDisableRecvMsg();
|
||||
int WxSendTextMsg(wstring wxid, wstring at_wxid, wstring msg);
|
||||
int WxSendImageMsg(wstring wxid, wstring path);
|
||||
ContactMap_t WxGetContacts();
|
||||
|
||||
Reference in New Issue
Block a user