mirror of
https://github.com/ttttupup/wxhelper.git
synced 2024-11-05 18:09:24 +08:00
feat: doAddMsg hook
This commit is contained in:
parent
74ac1c944e
commit
9836771ef7
@ -65,7 +65,7 @@ int BaseHook::Hook() {
|
|||||||
}
|
}
|
||||||
DetourTransactionBegin();
|
DetourTransactionBegin();
|
||||||
DetourUpdateThread(GetCurrentThread());
|
DetourUpdateThread(GetCurrentThread());
|
||||||
DetourAttach((PVOID *)origin_, (PVOID *)detour_);
|
DetourAttach((PVOID *)origin_, detour_);
|
||||||
LONG ret = DetourTransactionCommit();
|
LONG ret = DetourTransactionCommit();
|
||||||
if (ret == NO_ERROR) {
|
if (ret == NO_ERROR) {
|
||||||
hook_flag_ = true;
|
hook_flag_ = true;
|
||||||
@ -81,7 +81,7 @@ int BaseHook::Unhook() {
|
|||||||
UINT64 base = wxhelper::wxutils::GetWeChatWinBase();
|
UINT64 base = wxhelper::wxutils::GetWeChatWinBase();
|
||||||
DetourTransactionBegin();
|
DetourTransactionBegin();
|
||||||
DetourUpdateThread(GetCurrentThread());
|
DetourUpdateThread(GetCurrentThread());
|
||||||
DetourDetach((PVOID *)origin_, (PVOID *)detour_);
|
DetourDetach((PVOID *)origin_, detour_);
|
||||||
LONG ret = DetourTransactionCommit();
|
LONG ret = DetourTransactionCommit();
|
||||||
if (ret == NO_ERROR) {
|
if (ret == NO_ERROR) {
|
||||||
hook_flag_ = false;
|
hook_flag_ = false;
|
||||||
|
@ -7,40 +7,35 @@
|
|||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
#include "thread_pool.h"
|
#include "thread_pool.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "wechat_interface.h"
|
|
||||||
#include "wxutils.h"
|
#include "wxutils.h"
|
||||||
|
|
||||||
namespace wxhelper {
|
namespace wxhelper {
|
||||||
|
|
||||||
void SyncMsgHook::Init() {
|
void SyncMsgHook::Init() {
|
||||||
int64_t addr = wxutils::GetWeChatWinBase() + wechat::offset::kDoAddMsg;
|
int64_t addr = wxutils::GetWeChatWinBase() + wechat::offset::kDoAddMsg;
|
||||||
wechat::function::__DoAddMsg addMsg = (wechat::function::__DoAddMsg)addr;
|
kDoAddMsg = (wechat::function::__DoAddMsg)addr;
|
||||||
origin_ = addMsg;
|
origin_ = &kDoAddMsg;
|
||||||
detour_ = &HandleSyncMsg;
|
detour_ = &HandleSyncMsg;
|
||||||
|
hook_flag_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncMsgHook::HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3) {
|
void SyncMsgHook::HandleSyncMsg(int64_t param1, int64_t param2, int64_t param3) {
|
||||||
nlohmann::json msg;
|
nlohmann::json msg;
|
||||||
|
|
||||||
msg["pid"] = GetCurrentProcessId();
|
msg["pid"] = GetCurrentProcessId();
|
||||||
msg["fromUser"] =
|
msg["fromUser"] = wxutils::ReadSKBuiltinString(*(int64_t *)(param2 + 0x18));
|
||||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x18));
|
msg["toUser"] = wxutils::ReadSKBuiltinString(*(int64_t *)(param2 + 0x28));
|
||||||
msg["toUser"] =
|
msg["content"] = wxutils::ReadSKBuiltinString(*(int64_t *)(param2 + 0x30));
|
||||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x28));
|
msg["signature"] = wxutils::ReadWeChatStr(*(int64_t *)(param2 + 0x48));
|
||||||
msg["content"] =
|
msg["msgId"] = *(int64_t *)(param2 + 0x60);
|
||||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x30));
|
|
||||||
msg["signature"] =
|
|
||||||
wxhelper::wxutils::ReadWeChatStr(*(INT64 *)(param2 + 0x48));
|
|
||||||
msg["msgId"] = *(INT64 *)(param2 + 0x60);
|
|
||||||
msg["msgSequence"] = *(DWORD *)(param2 + 0x5C);
|
msg["msgSequence"] = *(DWORD *)(param2 + 0x5C);
|
||||||
msg["createTime"] = *(DWORD *)(param2 + 0x58);
|
msg["createTime"] = *(DWORD *)(param2 + 0x58);
|
||||||
msg["displayFullContent"] =
|
msg["displayFullContent"] = wxutils::ReadWeChatStr(*(int64_t *)(param2 + 0x50));
|
||||||
wxhelper::wxutils::ReadWeChatStr(*(INT64 *)(param2 + 0x50));
|
|
||||||
DWORD type = *(DWORD *)(param2 + 0x24);
|
DWORD type = *(DWORD *)(param2 + 0x24);
|
||||||
msg["type"] = type;
|
msg["type"] = type;
|
||||||
if (type == 3) {
|
if (type == 3) {
|
||||||
std::string img =
|
std::string img = wxutils::ReadSKBuiltinBuffer(*(int64_t *)(param2 + 0x40));
|
||||||
wxhelper::wxutils::ReadSKBuiltinBuffer(*(INT64 *)(param2 + 0x40));
|
|
||||||
SPDLOG_INFO("encode size:{}", img.size());
|
SPDLOG_INFO("encode size:{}", img.size());
|
||||||
msg["base64Img"] = base64_encode(img);
|
msg["base64Img"] = base64_encode(img);
|
||||||
}
|
}
|
||||||
@ -49,7 +44,7 @@ void SyncMsgHook::HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3) {
|
|||||||
inner_msg->buffer = new char[jstr.size() + 1];
|
inner_msg->buffer = new char[jstr.size() + 1];
|
||||||
memcpy(inner_msg->buffer, jstr.c_str(), jstr.size() + 1);
|
memcpy(inner_msg->buffer, jstr.c_str(), jstr.size() + 1);
|
||||||
inner_msg->length = jstr.size();
|
inner_msg->length = jstr.size();
|
||||||
std::string mode = wxhelper::Config::GetInstance().GetRecvMessageMode();
|
std::string mode = Config::GetInstance().GetRecvMessageMode();
|
||||||
if (mode == "http") {
|
if (mode == "http") {
|
||||||
bool add = base::ThreadPool::GetInstance().AddWork(
|
bool add = base::ThreadPool::GetInstance().AddWork(
|
||||||
hook::SendHttpMsgCallback, inner_msg);
|
hook::SendHttpMsgCallback, inner_msg);
|
||||||
@ -59,9 +54,10 @@ void SyncMsgHook::HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3) {
|
|||||||
inner_msg);
|
inner_msg);
|
||||||
SPDLOG_INFO("add tcp msg work:{}", add);
|
SPDLOG_INFO("add tcp msg work:{}", add);
|
||||||
}
|
}
|
||||||
int64_t addr =
|
if (kDoAddMsg == nullptr){
|
||||||
wxhelper::wxutils::GetWeChatWinBase() + wechat::offset::kDoAddMsg;
|
int64_t addr = wxutils::GetWeChatWinBase() + wechat::offset::kDoAddMsg;
|
||||||
wechat::function::__DoAddMsg addMsg = (wechat::function::__DoAddMsg)addr;
|
kDoAddMsg = (wechat::function::__DoAddMsg)addr;
|
||||||
addMsg(param1, param2, param3);
|
}
|
||||||
|
kDoAddMsg(param1, param2, param3);
|
||||||
}
|
}
|
||||||
} // namespace wxhelper
|
} // namespace wxhelper
|
@ -2,12 +2,14 @@
|
|||||||
#define WXHELPER_SYNC_MSG_HOOK_H_
|
#define WXHELPER_SYNC_MSG_HOOK_H_
|
||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
#include "singleton.h"
|
#include "singleton.h"
|
||||||
|
#include "wechat_interface.h"
|
||||||
namespace wxhelper{
|
namespace wxhelper{
|
||||||
|
static wechat::function::__DoAddMsg kDoAddMsg= nullptr;
|
||||||
class SyncMsgHook : public hook::BaseHook,public base::Singleton<SyncMsgHook> {
|
class SyncMsgHook : public hook::BaseHook,public base::Singleton<SyncMsgHook> {
|
||||||
public:
|
public:
|
||||||
void Init();
|
void Init();
|
||||||
private:
|
private:
|
||||||
static void HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3);
|
static void HandleSyncMsg(int64_t param1, int64_t param2, int64_t param3);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user