From 0b527e72d00e3bb51c994247e83667e7d3d38b88 Mon Sep 17 00:00:00 2001 From: ljc545w Date: Mon, 28 Mar 2022 00:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Debug=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=BE=AE=E4=BF=A1=E8=BF=90=E8=A1=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DWeChatRobot/DWeChatRobot.vcxproj | 380 +++++++++++----------- DWeChatRobot/DWeChatRobot.vcxproj.filters | 253 +++++++------- DWeChatRobot/LogMsgInfo.cpp | 48 +++ DWeChatRobot/LogMsgInfo.h | 4 + DWeChatRobot/dllmain.cpp | 14 +- DWeChatRobot/pch.cpp | 1 + DWeChatRobot/pch.h | 1 + 7 files changed, 377 insertions(+), 324 deletions(-) create mode 100644 DWeChatRobot/LogMsgInfo.cpp create mode 100644 DWeChatRobot/LogMsgInfo.h diff --git a/DWeChatRobot/DWeChatRobot.vcxproj b/DWeChatRobot/DWeChatRobot.vcxproj index 452b060..968993b 100644 --- a/DWeChatRobot/DWeChatRobot.vcxproj +++ b/DWeChatRobot/DWeChatRobot.vcxproj @@ -1,190 +1,192 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {C0FC8DAB-0590-46AC-9270-6FEA45D52390} - MyWeChatRobot - 10.0 - DWeChatRobot - - - - DynamicLibrary - true - v142 - Unicode - - - DynamicLibrary - false - v142 - true - Unicode - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(ProjectName) - - - false - $(ProjectName) - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - true - true - false - - - - - Level3 - true - _DEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - NDEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - true - true - false - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {C0FC8DAB-0590-46AC-9270-6FEA45D52390} + MyWeChatRobot + 10.0 + DWeChatRobot + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(ProjectName) + + + false + $(ProjectName) + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + + + + + Level3 + true + true + true + WIN32;NDEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + + + + + Level3 + true + _DEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + + + + + Level3 + true + true + true + NDEBUG;MYWECHATROBOT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + \ No newline at end of file diff --git a/DWeChatRobot/DWeChatRobot.vcxproj.filters b/DWeChatRobot/DWeChatRobot.vcxproj.filters index 0c7daea..d706531 100644 --- a/DWeChatRobot/DWeChatRobot.vcxproj.filters +++ b/DWeChatRobot/DWeChatRobot.vcxproj.filters @@ -1,123 +1,132 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {b1463ca2-6055-4c67-8c42-6319a6171dd2} - - - {b22823ee-f629-4e0a-8358-da017f0e5c3a} - - - {912e6334-b078-4ba6-813c-66d0de3ee123} - - - {069b8c09-e473-4bba-a49e-571f35f2efef} - - - {25f77de8-b12c-4f2b-a3ac-0260b6a16897} - - - {8ad1ff87-550b-4942-8ebd-afbe1cfaddc9} - - - {24dc11dd-cb6a-4c63-bf21-35823cd389ab} - - - {564cc9ef-a939-4bfd-a420-a08b3072d198} - - - {722c02ee-dda5-4a6a-9443-f1ed3c112709} - - - {edd6e39f-235b-4db5-aea1-ec2c8d0072c5} - - - {fc747a68-6314-4f23-92de-a1e55275a01e} - - - {5a6d7d8b-a126-4da1-b540-09c79886ffef} - - - - - 通用标头 - - - 通用标头 - - - 发送消息\发送图片 - - - 发送消息\发送文本 - - - 发送消息\发送文件 - - - 好友相关\好友列表 - - - 好友相关\好友信息 - - - 个人信息 - - - 发送消息\发送文章 - - - 发送消息\发送名片 - - - 好友相关\好友状态 - - - - - 通用函数 - - - 通用函数 - - - 发送消息\发送图片 - - - 发送消息\发送文本 - - - 发送消息\发送文件 - - - 好友相关\好友列表 - - - 好友相关\好友信息 - - - 个人信息 - - - 发送消息\发送文章 - - - 发送消息\发送名片 - - - 好友相关\好友状态 - - + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {b1463ca2-6055-4c67-8c42-6319a6171dd2} + + + {b22823ee-f629-4e0a-8358-da017f0e5c3a} + + + {912e6334-b078-4ba6-813c-66d0de3ee123} + + + {069b8c09-e473-4bba-a49e-571f35f2efef} + + + {25f77de8-b12c-4f2b-a3ac-0260b6a16897} + + + {8ad1ff87-550b-4942-8ebd-afbe1cfaddc9} + + + {24dc11dd-cb6a-4c63-bf21-35823cd389ab} + + + {564cc9ef-a939-4bfd-a420-a08b3072d198} + + + {722c02ee-dda5-4a6a-9443-f1ed3c112709} + + + {edd6e39f-235b-4db5-aea1-ec2c8d0072c5} + + + {fc747a68-6314-4f23-92de-a1e55275a01e} + + + {5a6d7d8b-a126-4da1-b540-09c79886ffef} + + + {54c9691e-786d-4279-874d-b1e35673a666} + + + + + 通用标头 + + + 通用标头 + + + 发送消息\发送图片 + + + 发送消息\发送文本 + + + 发送消息\发送文件 + + + 好友相关\好友列表 + + + 好友相关\好友信息 + + + 个人信息 + + + 发送消息\发送文章 + + + 发送消息\发送名片 + + + 好友相关\好友状态 + + + 微信日志 + + + + + 通用函数 + + + 通用函数 + + + 发送消息\发送图片 + + + 发送消息\发送文本 + + + 发送消息\发送文件 + + + 好友相关\好友列表 + + + 好友相关\好友信息 + + + 个人信息 + + + 发送消息\发送文章 + + + 发送消息\发送名片 + + + 好友相关\好友状态 + + + 微信日志 + + \ No newline at end of file diff --git a/DWeChatRobot/LogMsgInfo.cpp b/DWeChatRobot/LogMsgInfo.cpp new file mode 100644 index 0000000..0391983 --- /dev/null +++ b/DWeChatRobot/LogMsgInfo.cpp @@ -0,0 +1,48 @@ +#include "pch.h" + +#define HookLogMsgInfoAddrOffset 0x103408A4 - 0x0FC40000 +#define HookLogMsgInfoNextCallOffset 0x11586DFC - 0x0FC40000 +#define HookLogMsgJmpBackOffset 0x103408A9 - 0x0FC40000 + +DWORD HookLogMsgInfoAddr = GetWeChatWinBase() + HookLogMsgInfoAddrOffset; +DWORD NextCallAddr = GetWeChatWinBase() + HookLogMsgInfoNextCallOffset; +DWORD JmpBackAddr = GetWeChatWinBase() + HookLogMsgJmpBackOffset; + +BOOL LogMsgHooked = false; +char LogOldAsmCode[5] = { 0 }; + +VOID PrintMsg(DWORD msg) { + if (!msg) + return; + string message = (char*)msg; + cout << message; + return; +} + +__declspec(naked) void doprintmsg(){ + __asm { + pushad; + pushfd; + push eax; + call PrintMsg; + add esp, 0x4; + popfd; + popad; + call NextCallAddr; + jmp JmpBackAddr; + } +} + +VOID HookLogMsgInfo() { + if (LogMsgHooked) + return; + HookAnyAddress(HookLogMsgInfoAddr,(LPVOID)doprintmsg, LogOldAsmCode); + LogMsgHooked = true; +} + +VOID UnHookLogMsgInfo() { + if (!LogMsgHooked) + return; + UnHookAnyAddress(HookLogMsgInfoAddr, LogOldAsmCode); + LogMsgHooked = false; +} \ No newline at end of file diff --git a/DWeChatRobot/LogMsgInfo.h b/DWeChatRobot/LogMsgInfo.h new file mode 100644 index 0000000..eac73b8 --- /dev/null +++ b/DWeChatRobot/LogMsgInfo.h @@ -0,0 +1,4 @@ +#pragma once +#include +VOID HookLogMsgInfo(); +VOID UnHookLogMsgInfo(); \ No newline at end of file diff --git a/DWeChatRobot/dllmain.cpp b/DWeChatRobot/dllmain.cpp index bb59639..58eeec6 100644 --- a/DWeChatRobot/dllmain.cpp +++ b/DWeChatRobot/dllmain.cpp @@ -1,10 +1,6 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" -#ifdef _DEBUG - int detach_count = 0; -#endif - BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -16,8 +12,6 @@ BOOL APIENTRY DllMain( HMODULE hModule, { #ifdef _DEBUG CreateConsole(); - DWORD base = (DWORD)GetModuleHandleA("DWeChatRobot.dll"); - printf("SendImage 0x%08X\n", (DWORD)SendImage); printf("SendText 0x%08X\n", (DWORD)SendText); printf("SendFile 0x%08X\n", (DWORD)SendFile); @@ -26,19 +20,13 @@ BOOL APIENTRY DllMain( HMODULE hModule, printf("SendArticle 0x%08X\n", (DWORD)SendArticle); printf("SendCard 0x%08X\n", (DWORD)SendCard); printf("CheckFriendStatus 0x%08X\n", (DWORD)CheckFriendStatus); + HookLogMsgInfo(); #endif break; } case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: { -#ifdef _DEBUG - detach_count++; - if (detach_count != 1) { - FreeConsole(); - // UnHookAll(); - } -#endif break; } } diff --git a/DWeChatRobot/pch.cpp b/DWeChatRobot/pch.cpp index 7ccf902..b7a8382 100644 --- a/DWeChatRobot/pch.cpp +++ b/DWeChatRobot/pch.cpp @@ -63,5 +63,6 @@ void UnHookAnyAddress(DWORD dwHookAddr, char* originalRecieveCode) } void UnHookAll() { + UnHookLogMsgInfo(); return; } \ No newline at end of file diff --git a/DWeChatRobot/pch.h b/DWeChatRobot/pch.h index 102887c..213d7e7 100644 --- a/DWeChatRobot/pch.h +++ b/DWeChatRobot/pch.h @@ -20,6 +20,7 @@ #include "SelfInfo.h" #include "SendCard.h" #include "CheckFriendStatus.h" +#include "LogMsgInfo.h" #endif //PCH_H using namespace std; -- GitLab