-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWeChatHook.cpp
74 lines (68 loc) · 1.57 KB
/
WeChatHook.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// WeChatHook.cpp : 定义应用程序的入口点。
//
#include "framework.h"
#include "WeChatHook.h"
#include <Windows.h>
#include "utils.h"
int PORT = 18888;
// 此代码模块中包含的函数的前向声明:
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DialogProc(_In_ HWND hDlg, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam);
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
BOOL result;
DWORD PID = ProcessNameFindPID(WeChatProcessName);
if (PID == 0)
{
return 0;
}
else
{
result = StartListen(PID, PORT);
if(result == 0)
{
return 0;
}
}
DialogBox(hInstance, MAKEINTRESOURCE(ID_MAIN), NULL, DialogProc);
return 0;
}
INT_PTR CALLBACK DialogProc(_In_ HWND hDlg, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam)
{
BOOL result;
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == INJECT)
{
DWORD PID = ProcessNameFindPID(WeChatProcessName);
StartListen(PID, PORT);
}
if (LOWORD(wParam) == UNJECT)
{
DWORD PID = ProcessNameFindPID(WeChatProcessName);
if (PID == 0)
{
MessageBox(NULL, "未找到进程", "错误", 0);
return 0;
}
result = StopListen(PID);
if (result == 0)
{
MessageBox(NULL, "未找到DLL", "错误", 0);
return 0;
}
}
break;
case WM_CLOSE:
EndDialog(hDlg, 0);
break;
}
return (INT_PTR)FALSE;
}