提交 0b527e72 编写于 作者: L ljc545w

添加Debug模式输出微信运行日志

上级 f6f8bd05
......@@ -157,6 +157,7 @@
<ClInclude Include="CheckFriendStatus.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="FriendList.h" />
<ClInclude Include="LogMsgInfo.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="SelfInfo.h" />
<ClInclude Include="SendArticle.h" />
......@@ -183,6 +184,7 @@
<ClCompile Include="SendImage.cpp" />
<ClCompile Include="SendText.cpp" />
<ClCompile Include="UserInfo.cpp" />
<ClCompile Include="LogMsgInfo.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
......@@ -49,6 +49,9 @@
<Filter Include="好友相关\好友状态">
<UniqueIdentifier>{5a6d7d8b-a126-4da1-b540-09c79886ffef}</UniqueIdentifier>
</Filter>
<Filter Include="微信日志">
<UniqueIdentifier>{54c9691e-786d-4279-874d-b1e35673a666}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -84,6 +87,9 @@
<ClInclude Include="CheckFriendStatus.h">
<Filter>好友相关\好友状态</Filter>
</ClInclude>
<ClInclude Include="LogMsgInfo.h">
<Filter>微信日志</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
......@@ -119,5 +125,8 @@
<ClCompile Include="CheckFriendStatus.cpp">
<Filter>好友相关\好友状态</Filter>
</ClCompile>
<ClCompile Include="LogMsgInfo.cpp">
<Filter>微信日志</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
#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
#pragma once
#include<windows.h>
VOID HookLogMsgInfo();
VOID UnHookLogMsgInfo();
\ No newline at end of file
// 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;
}
}
......
......@@ -63,5 +63,6 @@ void UnHookAnyAddress(DWORD dwHookAddr, char* originalRecieveCode)
}
void UnHookAll() {
UnHookLogMsgInfo();
return;
}
\ No newline at end of file
......@@ -20,6 +20,7 @@
#include "SelfInfo.h"
#include "SendCard.h"
#include "CheckFriendStatus.h"
#include "LogMsgInfo.h"
#endif //PCH_H
using namespace std;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册