Impl Hook/UnHook
This commit is contained in:
parent
abf980ecac
commit
65f9ab7650
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "exec_sql.h"
|
#include "exec_sql.h"
|
||||||
#include "get_contacts.h"
|
#include "get_contacts.h"
|
||||||
|
#include "receive_msg.h"
|
||||||
#include "rpc_h.h"
|
#include "rpc_h.h"
|
||||||
#include "rpc_server.h"
|
#include "rpc_server.h"
|
||||||
#include "sdk.h"
|
#include "sdk.h"
|
||||||
@ -13,21 +14,24 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern HANDLE g_hEvent;
|
extern int IsLogin(void); // Defined in spy.cpp
|
||||||
extern MsgQueue_t g_MsgQueue;
|
extern HANDLE g_hEvent; // New message signal
|
||||||
extern const MsgTypesMap_t g_WxMsgTypes;
|
extern BOOL g_rpcKeepAlive; // Keep RPC server thread running
|
||||||
extern int IsLogin(void);
|
extern MsgQueue_t g_MsgQueue; // Queue for message
|
||||||
|
extern const MsgTypesMap_t g_WxMsgTypes; // Map of WeChat Message types
|
||||||
|
|
||||||
|
static BOOL listenMsgFlag = false;
|
||||||
|
|
||||||
int server_IsLogin() { return IsLogin(); }
|
int server_IsLogin() { return IsLogin(); }
|
||||||
|
|
||||||
void server_EnableReceiveMsg()
|
void server_EnableReceiveMsg()
|
||||||
{
|
{
|
||||||
unsigned long ulCode = 0;
|
unsigned long ulCode = 0;
|
||||||
|
ListenMessage();
|
||||||
RpcTryExcept
|
RpcTryExcept
|
||||||
{
|
{
|
||||||
// 调用客户端的回调函数
|
// 调用客户端的回调函数
|
||||||
while (true) {
|
while (listenMsgFlag) {
|
||||||
// 中断式,兼顾及时性和CPU使用率
|
// 中断式,兼顾及时性和CPU使用率
|
||||||
WaitForSingleObject(g_hEvent, INFINITE); // 等待消息
|
WaitForSingleObject(g_hEvent, INFINITE); // 等待消息
|
||||||
while (!g_MsgQueue.empty()) {
|
while (!g_MsgQueue.empty()) {
|
||||||
@ -153,9 +157,9 @@ int server_GetDbTables(const wchar_t *db, int *pNum, PPRpcTables *tbls)
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (auto it = tables.begin(); it != tables.end(); it++) {
|
for (auto it = tables.begin(); it != tables.end(); it++) {
|
||||||
PRpcTables p = (PRpcTables)midl_user_allocate(sizeof(RpcTables_t));
|
PRpcTables p = (PRpcTables)midl_user_allocate(sizeof(RpcTables_t));
|
||||||
p->table = it->table;
|
p->table = it->table;
|
||||||
p->sql = it->sql;
|
p->sql = it->sql;
|
||||||
pp[index++] = p;
|
pp[index++] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
*tbls = pp;
|
*tbls = pp;
|
||||||
@ -192,8 +196,9 @@ int RpcStartServer(HMODULE hModule)
|
|||||||
(unsigned)-1, // Infinite max size of incoming data blocks.
|
(unsigned)-1, // Infinite max size of incoming data blocks.
|
||||||
SecurityCallback); // Naive security callback.
|
SecurityCallback); // Naive security callback.
|
||||||
|
|
||||||
while (1) {
|
listenMsgFlag = true;
|
||||||
Sleep(10000); // 休眠,释放CPU
|
while (g_rpcKeepAlive) {
|
||||||
|
Sleep(1000); // 休眠,释放CPU
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -202,7 +207,11 @@ int RpcStartServer(HMODULE hModule)
|
|||||||
int RpcStopServer(void)
|
int RpcStopServer(void)
|
||||||
{
|
{
|
||||||
RPC_STATUS status;
|
RPC_STATUS status;
|
||||||
status = RpcMgmtStopServerListening(NULL);
|
|
||||||
|
UnListenMessage();
|
||||||
|
|
||||||
|
listenMsgFlag = false;
|
||||||
|
status = RpcMgmtStopServerListening(NULL);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
23
Spy/spy.cpp
23
Spy/spy.cpp
@ -1,20 +1,13 @@
|
|||||||
#include "load_calls.h"
|
#include "load_calls.h"
|
||||||
#include "receive_msg.h"
|
|
||||||
#include "rpc_server.h"
|
#include "rpc_server.h"
|
||||||
#include "spy.h"
|
#include "spy.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
HANDLE g_hEvent = NULL;
|
HANDLE g_hEvent = NULL;
|
||||||
|
BOOL g_rpcKeepAlive = false;
|
||||||
WxCalls_t g_WxCalls = { 0 };
|
WxCalls_t g_WxCalls = { 0 };
|
||||||
DWORD g_WeChatWinDllAddr = 0;
|
DWORD g_WeChatWinDllAddr = 0;
|
||||||
|
|
||||||
DWORD WINAPI Monitor(HMODULE hModule)
|
|
||||||
{
|
|
||||||
ListenMessage();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitSpy(HMODULE hModule)
|
void InitSpy(HMODULE hModule)
|
||||||
{
|
{
|
||||||
wchar_t version[16] = { 0 };
|
wchar_t version[16] = { 0 };
|
||||||
@ -40,20 +33,8 @@ void InitSpy(HMODULE hModule)
|
|||||||
if (rpcThread != 0) {
|
if (rpcThread != 0) {
|
||||||
CloseHandle(rpcThread);
|
CloseHandle(rpcThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE mThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Monitor, hModule, NULL, 0);
|
|
||||||
if (mThread != 0) {
|
|
||||||
CloseHandle(mThread);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroySpy() { RpcStopServer(); }
|
void DestroySpy() { RpcStopServer(); }
|
||||||
|
|
||||||
int IsLogin(void)
|
int IsLogin(void) { return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login); }
|
||||||
{
|
|
||||||
if (g_WeChatWinDllAddr == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user