feat(message): impl wechat log

This commit is contained in:
Changhua 2025-02-17 00:42:41 +08:00
parent 2297afa25d
commit 3658796a00
3 changed files with 19 additions and 7 deletions

View File

@ -6,10 +6,11 @@
#include "framework.h"
#include "account_manager.h"
#include "log.hpp"
#include "offsets.h"
#include "pb_util.h"
#include "rpc_helper.h"
#include "account_manager.h"
#include "util.h"
extern QWORD g_WeChatWinDllAddr;
@ -37,6 +38,8 @@ extern QWORD g_WeChatWinDllAddr;
namespace message
{
namespace OsMsg = Offsets::Message;
QWORD Handler::DispatchMsg(QWORD arg1, QWORD arg2)
{
auto &handler = getInstance();
@ -190,13 +193,15 @@ int Handler::EnableLog()
{
if (isLogging) return 1;
funcWxLog = reinterpret_cast<funcWxLog_t>(g_WeChatWinDllAddr + OS_WXLOG);
funcWxLog = reinterpret_cast<funcWxLog_t>(g_WeChatWinDllAddr + OsMsg::LOG);
pLogLevel = reinterpret_cast<uint32_t *>(g_WeChatWinDllAddr + OsMsg::LOG_LEVEL);
if (InitializeHook() != MH_OK) return -1;
if (MH_CreateHook(funcWxLog, &PrintWxLog, reinterpret_cast<LPVOID *>(&realWxLog)) != MH_OK) return -1;
if (MH_EnableHook(funcWxLog) != MH_OK) return -1;
if (MH_CreateHook(funcWxLog, &PrintWxLog, reinterpret_cast<LPVOID *>(&realWxLog)) != MH_OK) return -2;
if (MH_EnableHook(funcWxLog) != MH_OK) return -3;
isLogging = true;
*pLogLevel = 0;
isLogging = true;
return 0;
}
@ -204,8 +209,9 @@ int Handler::DisableLog()
{
if (!isLogging) return 1;
if (MH_DisableHook(funcWxLog) != MH_OK) return -1;
if (UninitializeHook() != MH_OK) return -1;
isLogging = false;
if (UninitializeHook() != MH_OK) return -2;
*pLogLevel = 6;
isLogging = false;
return 0;
}

View File

@ -55,6 +55,7 @@ private:
using funcWxLog_t = QWORD (*)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD);
using funcRecvPyq_t = QWORD (*)(QWORD, QWORD, QWORD);
uint32_t *pLogLevel;
funcWxLog_t funcWxLog, realWxLog;
funcRecvMsg_t funcRecvMsg, realRecvMsg;
funcRecvPyq_t funcRecvPyq, realRecvPyq;

View File

@ -16,6 +16,11 @@ namespace Account
constexpr uint64_t LOGIN = 0x7F8; // 登录状态
}
namespace Message
{
constexpr uint64_t LOG = 0x261B890; // 日志函数
constexpr uint64_t LOG_LEVEL = 0x56E4244; // 日志级别
}
}
#endif // OFFSETS_H