forked from gaojunxin/TSPlug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DXBind.h
217 lines (166 loc) · 5.67 KB
/
DXBind.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#pragma once
#include "TSMessage.h"
#include "TSFindPicture.h"
typedef bool (__stdcall * MySetWindowHook)(BOOL,DWORD);
//TSMOUSE_MODE 鼠标模式
#define MOUSE_NORMAL 0x00000001L
#define MOUSE_WINDOW 0x00000002L
#define MOUSE_API 0x00000004L
//TSKEYBOARD_MODE 窗口模式
#define KEY_NORMAL 0x00000001L
#define KEY_WINDOW 0x00000002L
#define KEY_API 0x00000004L
#define KEY_STATEAPI 0x00000008L
#define KEY_LOCKAPI 0x00000010L
//TSDISPLAY_MODE 显示模式
#define DISPLAY_GDI 0x00000001L
#define DISPLAY_DX_2D 0x00000002L
#define DISPLAY_DX_3D 0x00000004L
#define DISPLAY_NORMAL 0x00000008L
#define DISPLAY_DX2 0x00000010L
#define DISPLAY_GDI2 0x00000020L
//定义创建内存映射的名字宏
#define TS_MAPVIEW_NAME "TSMAPVIEW:REMOTECTRL"
//定义创建绑定窗口标识名字宏
//定义创建绑定窗口标识名字宏
#define TS_BINDWINDOW_GDIWINDOW "TSBINDWINDOWNAME_GDIWINDOW:"
#define TS_BINDWINDOW_SETWINDOWHOOK "TSBINDWINDOWNAME_SETWINDOWHOOK:"
#define TS_BINDWINDOW_IME "TSBINDWINDOWNAME_IME:"
#define TS_BINDWINDOW_IME101 "TSBINDWINDOWNAME_IME101:"
#define TS_BINDWINDOW_103 "TSBINDWINDOWNAME_103:"
#define TS_EVENT_IMEHOOK "TSEVENT:IMEHOOK:"
#define TS_EVENT_WRITEMEM L"TSEVENT:WRITEMEM:"
//定义一个事件内核对象名,用于处理图色处理API
#define TS_EVENT_NAME L"TSEVENT:DISPLAY"
#define TS_EVENT_FINDPIC L"TSEVENT:FINDPIC"
#define TS_EVENT_FINDSTR L"TSEVENT:FINDSTR"
#define TS_EVENT_FINDCOLOR L"TSEVENT:FINDCOLOR"
#define TS_EVENT_KEYHOOKNAME L"TSEVENT:KEYHOOK"
#define TS_IMEUNHOOKAPI_NAME L"TSEVENT:IMEUNHOOKAPI"
#define TS_BIND201_NAME L"TSEVENT:BIND201"
//定义内存映射最大值
#define TS_MAFVIEW_MAXSIZE 1024*5
//绑定模式
enum BIND_MODE
{
BIND_WINHOOK,
BIND_IME,
BIND_IME101 = 101,
BIND_103 =103,
BIND_201 =201,
BIND_203 =203,
BIND_MAX,
};
////绑定的显示模式
//enum DISPLAY_MODE
//{
// DISPLAY_GDI,
// DISPLAY_DX,
// DISPLAY_MAX,
//};
class DXBind
{
public:
//////////////////////////////////这里是本地使用的API接口////////////////////////////////////
//MyFindPictureClass fpic;
//绑定操作
bool bind(HWND wnd,DWORD keyMod,DWORD mouseMod,DWORD disMod,BIND_MODE bindMode);
bool UnBind();
//发送消息
LRESULT SendMsg(UINT Msg, WPARAM wParam=0, LPARAM lParam=0) {
return ::SendMessage(m_mousekeyhwnd, Msg, wParam, lParam);
}
bool SetWindowHookExInject(HWND wnd);
//输入法注入
bool IMEInject(HWND wnd);
//201注入
bool Inject201();
//
int findPic(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_name, wchar_t *color, DOUBLE sim, LONG dir, LONG &intX, LONG &intY,wchar_t *retstring=NULL,int type=0);
//
int findColor(LONG x1, LONG y1, LONG x2, LONG y2, int color, DOUBLE sim, LONG dir, LONG &intX, LONG &intY,wchar_t *colorstr=NULL,wchar_t *retstring=NULL,wchar_t *MultiColor=NULL);
int GetColor(LONG x,LONG y,BSTR sColor);
bool CmpColor(LONG x,LONG y,BSTR sColor,DOUBLE sim);
bool TSSetpath(wchar_t *path);
//
void setIsBind(bool isbind);
int Capture(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_path,int pictype);
int CaptureGif(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_path,int delay,int time);
bool TSSetDict(int index,wchar_t *filepath);
bool TSUseDict(int index);
int Ocr(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t *color, DOUBLE sim,int type=0);
//Findstrtype=0,Findstr=Findstr;Findstrtype=1,Findstr=FindstrFast;
int Findstr(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* findstring, wchar_t *color, DOUBLE sim, LONG &intX, LONG &intY,BYTE Findstrtype,wchar_t *retstring=NULL,int type=0);
//判断是否卡屏
int IsDisplayDead(LONG x1, LONG y1, LONG x2, LONG y2,int times);
bool TSGetScreenData(LONG x1, LONG y1, LONG x2, LONG y2);
//
bool isBind();
//////////////////////////////////这里是注入游戏远程使用的API接口///////////////////////////////
//拦截API,会起一个循环检测的线程
bool hookApi();
bool DownCpu(DWORD sleeptime);
bool TSMatchPicName(wchar_t *pic_name,wchar_t*ret_name);
bool TSGetMachineCode(wchar_t* retcode);
void mysleep(DWORD delaytime);
void InitGdiNormal();
bool TSEnableRealMouse(LONG X,LONG Y);
DWORD TSRealKeyMousSleepTime(DWORD type);
void TSMoveToEx(ULONG x,ULONG y,ULONG w,ULONG h,wchar_t *retstring);
public:
DWORD ColorDataInfo[2000][2000];
COLORREF** pWndBmpBuffer;
short **pWndBmpStrxy;
BYTE * pBuffer;
DWORD winver;
DWORD nPid;
DWORD KeyDownsleep;//键盘单击延时
DWORD NormalKeysleep;
DWORD MouseClicksleep;//鼠标单击延时
DWORD WindowsKeyMouseClicksleep;// Windows模式键盘\鼠标单击延时
DWORD NormalClicksleep;
HWND m_hwnd; //被绑定的窗口的句柄
HWND m_mousekeyhwnd; //鼠标键盘后台窗口绑定
HWND m_parenthwnd; //父窗口句柄
HANDLE m_eventMsg;
int BindMode;
MySetWindowHook mSetHook;
wchar_t m_SetPath[MAX_PATH];
wchar_t m_Retstr[MAX_PATH*100];
short LastMouseMoveX;
short LastMouseMoveY;
bool m_isBind;
DWORD m_displayMode;
DWORD m_keyMode;
DWORD m_mouseMode;
DWORD m_dwExStyle;
bool g_IsSYSKEY;
bool IsNpProtect;
CMessageData *pData;
bool Isdxkmprotect; //dx键鼠不被恶意检测盾
bool Isdxantiapi;//开启dx.public.anti.api保护
pMyDictInfo MyDictCount[20]; //存储当前所有字库,默认最大字库个数为20个
int nMaxStrHight[20]; //记录每个字库中,最高的字高.
int nMyDictCountsize[20]; //记录每个字库的数量
int NowUsingDictIndex;//记录当前正在使用字库的下标
bool Isgraphicprotect;//防止图色检测盾
bool isdxpic;
BYTE CallCode[0x50];//201注入的代码
bool IsTSEnableRealMouse;
bool IsTSEnableRealKeypad;
LONG mousedelay;
LONG mousestep;
DWORD GDI_dwExStyle;
private:
int CallCodelen;
LPVOID Alloaddr;//201注入的申请到的内存地址
HKL MSetUpIME;
HKL SysIME;
int Colors[MAX_PATH];//颜色
BYTE m_colorOffR[MAX_PATH]; // R的偏移量
BYTE m_colorOffG[MAX_PATH]; // G的偏移量
BYTE m_colorOffB[MAX_PATH]; // B的偏移量
public:
DXBind(void);
~DXBind(void);
};