special_input_device 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/ext/special_input_device/_screen.c +25 -0
  3. data/ext/special_input_device/_screen.h +16 -0
  4. data/ext/special_input_device/_system_time.c +10 -0
  5. data/ext/special_input_device/_system_time.h +6 -0
  6. data/ext/special_input_device/_vendor__interception.c +331 -0
  7. data/ext/special_input_device/_vendor__interception.h +196 -0
  8. data/ext/special_input_device/color.c +25 -0
  9. data/ext/special_input_device/color.h +10 -0
  10. data/ext/special_input_device/extconf.rb +6 -0
  11. data/ext/special_input_device/interception_connector.c +75 -0
  12. data/ext/special_input_device/interception_connector.h +13 -0
  13. data/ext/special_input_device/keyboard.c +152 -0
  14. data/ext/special_input_device/mouse.c +1137 -0
  15. data/ext/special_input_device/point.c +17 -0
  16. data/ext/special_input_device/point.h +10 -0
  17. data/ext/special_input_device/rectangle.c +25 -0
  18. data/ext/special_input_device/rectangle.h +10 -0
  19. data/ext/special_input_device/ruby_macro.h +84 -0
  20. data/ext/special_input_device/screen.c +302 -0
  21. data/ext/special_input_device/special_input_device.c +40 -0
  22. data/ext/special_input_device/special_input_device.h +42 -0
  23. data/ext/special_input_device/win32error.c +69 -0
  24. data/ext/special_input_device/win32error.h +8 -0
  25. data/ext/special_input_device/window.c +1108 -0
  26. data/lib/special_input_device/attributes_equal_checker.rb +13 -0
  27. data/lib/special_input_device/color.rb +156 -0
  28. data/lib/special_input_device/image.rb +170 -0
  29. data/lib/special_input_device/image/bmp.rb +89 -0
  30. data/lib/special_input_device/image/error/damaged_image_error.rb +4 -0
  31. data/lib/special_input_device/image/error/image_error.rb +3 -0
  32. data/lib/special_input_device/image/error/unsupported_image_format_error.rb +4 -0
  33. data/lib/special_input_device/key_code.rb +268 -0
  34. data/lib/special_input_device/point.rb +48 -0
  35. data/lib/special_input_device/rectangle.rb +187 -0
  36. data/lib/special_input_device/special_input_device.rb +67 -0
  37. data/lib/special_input_device/table_2d.rb +157 -0
  38. data/stab/keyboard.rb +35 -0
  39. data/stab/mouse.rb +189 -0
  40. data/stab/screen.rb +56 -0
  41. data/stab/win32_error.rb +20 -0
  42. data/stab/window.rb +398 -0
  43. metadata +85 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef8f13accf6820c844dd6e53dcc893ef9ffd75a6
4
+ data.tar.gz: bfcb2590e5bacab820f881f9b7b208f177420319
5
+ SHA512:
6
+ metadata.gz: 9fb1a9fe52cd87db760c2ebcd55386fddc11cedf369590d7d2347926e91b37fd468f2a1d85cf57f3876cbf564a3f185d52968712d41e1eff9a6b2ec145a72162
7
+ data.tar.gz: 6be975f6a7d6d6436ece1215155586cc27d86184accaddf003def672008a3094f36ef32e08fe84081da818da1d7f2f7881081fadae71622eefac1cb75fa77db8
@@ -0,0 +1,25 @@
1
+ #include <windows.h>
2
+
3
+ INT getPrimaryScreenWidth() {
4
+ return GetSystemMetrics(SM_CXSCREEN);
5
+ }
6
+
7
+ INT getPrimaryScreenHeight() {
8
+ return GetSystemMetrics(SM_CYSCREEN);
9
+ }
10
+
11
+ INT getVirtualScreenX() {
12
+ return GetSystemMetrics(SM_XVIRTUALSCREEN);
13
+ }
14
+
15
+ INT getVirtualScreenY() {
16
+ return GetSystemMetrics(SM_YVIRTUALSCREEN);
17
+ }
18
+
19
+ INT getVirtualScreenWidth() {
20
+ return GetSystemMetrics(SM_CXVIRTUALSCREEN);
21
+ }
22
+
23
+ INT getVirtualScreenHeight() {
24
+ return GetSystemMetrics(SM_CYVIRTUALSCREEN);
25
+ }
@@ -0,0 +1,16 @@
1
+ #ifndef SPECIAL_INPUT_DEVICE_SCREEN_H
2
+ #define SPECIAL_INPUT_DEVICE_SCREEN_H
3
+
4
+ INT getPrimaryScreenWidth();
5
+
6
+ INT getPrimaryScreenHeight();
7
+
8
+ INT getVirtualScreenX();
9
+
10
+ INT getVirtualScreenY();
11
+
12
+ INT getVirtualScreenWidth();
13
+
14
+ INT getVirtualScreenHeight();
15
+
16
+ #endif //SPECIAL_INPUT_DEVICE_SCREEN_H
@@ -0,0 +1,10 @@
1
+ #include <windows.h>
2
+
3
+ ULONGLONG getSystemTimeIdentifier() {
4
+ FILETIME cFileTime;
5
+ ULARGE_INTEGER cInteger;
6
+ GetSystemTimeAsFileTime(&cFileTime);
7
+ cInteger.LowPart = cFileTime.dwLowDateTime;
8
+ cInteger.HighPart = cFileTime.dwHighDateTime;
9
+ return cInteger.QuadPart;
10
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef SPECIAL_INPUT_DEVICE_EXT_SYSTEM_TIME_H
2
+ #define SPECIAL_INPUT_DEVICE_EXT_SYSTEM_TIME_H
3
+
4
+ ULONGLONG getSystemTimeIdentifier();
5
+
6
+ #endif //SPECIAL_INPUT_DEVICE_EXT_SYSTEM_TIME_H
@@ -0,0 +1,331 @@
1
+ // Interception
2
+ // https://github.com/oblitum/Interception
3
+ // commit 16 Oct 2016 b76a4741fbad583c566d468a00e653fc4946eae2
4
+
5
+ #include <stdio.h>
6
+ #include <windows.h>
7
+
8
+ #include "_vendor__interception.h"
9
+
10
+ #define IOCTL_SET_PRECEDENCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
11
+ #define IOCTL_GET_PRECEDENCE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
12
+ #define IOCTL_SET_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
13
+ #define IOCTL_GET_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
14
+ #define IOCTL_SET_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
15
+ #define IOCTL_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x820, METHOD_BUFFERED, FILE_ANY_ACCESS)
16
+ #define IOCTL_READ CTL_CODE(FILE_DEVICE_UNKNOWN, 0x840, METHOD_BUFFERED, FILE_ANY_ACCESS)
17
+ #define IOCTL_GET_HARDWARE_ID CTL_CODE(FILE_DEVICE_UNKNOWN, 0x880, METHOD_BUFFERED, FILE_ANY_ACCESS)
18
+
19
+ typedef struct _KEYBOARD_INPUT_DATA {
20
+ USHORT UnitId;
21
+ USHORT MakeCode;
22
+ USHORT Flags;
23
+ USHORT Reserved;
24
+ ULONG ExtraInformation;
25
+ } KEYBOARD_INPUT_DATA, *PKEYBOARD_INPUT_DATA;
26
+
27
+ typedef struct _MOUSE_INPUT_DATA {
28
+ USHORT UnitId;
29
+ USHORT Flags;
30
+ USHORT ButtonFlags;
31
+ USHORT ButtonData;
32
+ ULONG RawButtons;
33
+ LONG LastX;
34
+ LONG LastY;
35
+ ULONG ExtraInformation;
36
+ } MOUSE_INPUT_DATA, *PMOUSE_INPUT_DATA;
37
+
38
+ typedef struct {
39
+ VOID *handle;
40
+ VOID *unempty;
41
+ } *InterceptionDeviceArray;
42
+
43
+ InterceptionContext interceptionCreateContext() {
44
+ InterceptionDeviceArray deviceArray;
45
+ CHAR deviceName[] = "\\\\.\\interception00";
46
+ DWORD bytesReturned;
47
+ InterceptionDevice t;
48
+
49
+ deviceArray = (InterceptionDeviceArray) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
50
+ INTERCEPTION_MAX_DEVICE *
51
+ sizeof(*((InterceptionDeviceArray) 0)));
52
+ if (!deviceArray)
53
+ return 0;
54
+
55
+ for (t = 0; t < INTERCEPTION_MAX_DEVICE; t++) {
56
+ HANDLE zero_padded_handle[2] = {0};
57
+
58
+ sprintf(&deviceName[sizeof(deviceName) - 3], "%02d", t);
59
+
60
+ deviceArray[t].handle = CreateFileA(deviceName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
61
+
62
+ if (deviceArray[t].handle == INVALID_HANDLE_VALUE)
63
+ continue;
64
+
65
+ deviceArray[t].unempty = CreateEvent(NULL, TRUE, FALSE, NULL);
66
+
67
+ if (!deviceArray[t].unempty) {
68
+ interceptionDestroyContext(deviceArray);
69
+ return 0;
70
+ }
71
+
72
+ zero_padded_handle[0] = deviceArray[t].unempty;
73
+
74
+ if (!DeviceIoControl(deviceArray[t].handle, IOCTL_SET_EVENT, zero_padded_handle, sizeof(zero_padded_handle),
75
+ NULL, 0, &bytesReturned, NULL)) {
76
+ interceptionDestroyContext(deviceArray);
77
+ return 0;
78
+ }
79
+ }
80
+
81
+ return deviceArray;
82
+ }
83
+
84
+ VOID interceptionDestroyContext(InterceptionContext context) {
85
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
86
+ UINT t;
87
+ if (!context)
88
+ return;
89
+
90
+ for (t = 0; t < INTERCEPTION_MAX_DEVICE; t++) {
91
+ if (deviceArray[t].handle != INVALID_HANDLE_VALUE)
92
+ CloseHandle(deviceArray[t].handle);
93
+
94
+ if (deviceArray[t].unempty)
95
+ CloseHandle(deviceArray[t].unempty);
96
+ }
97
+
98
+ HeapFree(GetProcessHeap(), 0, context);
99
+ }
100
+
101
+ InterceptionPrecedence interceptionGetPrecedence(InterceptionContext context, InterceptionDevice device) {
102
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
103
+ InterceptionPrecedence precedence = 0;
104
+ DWORD bytesReturned;
105
+
106
+ if (context && deviceArray[device - 1].handle)
107
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_GET_PRECEDENCE, NULL, 0, (LPVOID) &precedence,
108
+ sizeof(InterceptionPrecedence), &bytesReturned, NULL);
109
+
110
+ return precedence;
111
+ }
112
+
113
+ VOID
114
+ interceptionSetPrecedence(InterceptionContext context, InterceptionDevice device, InterceptionPrecedence precedence) {
115
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
116
+ DWORD bytesReturned;
117
+
118
+ if (context && deviceArray[device - 1].handle)
119
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_SET_PRECEDENCE, (LPVOID) &precedence,
120
+ sizeof(InterceptionPrecedence), NULL, 0, &bytesReturned, NULL);
121
+ }
122
+
123
+ InterceptionFilter interceptionGetFilter(InterceptionContext context, InterceptionDevice device) {
124
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
125
+ InterceptionFilter filter = 0;
126
+ DWORD bytesReturned;
127
+
128
+ if (context && deviceArray[device - 1].handle)
129
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_GET_FILTER, NULL, 0, (LPVOID) &filter,
130
+ sizeof(InterceptionFilter), &bytesReturned, NULL);
131
+
132
+ return filter;
133
+ }
134
+
135
+ VOID interceptionSetFilter(InterceptionContext context, InterceptionPredicate interception_predicate,
136
+ InterceptionFilter filter) {
137
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
138
+ DWORD bytesReturned;
139
+ InterceptionDevice t;
140
+
141
+ if (context) {
142
+ for (t = 0; t < INTERCEPTION_MAX_DEVICE; t++) {
143
+ if (deviceArray[t].handle && interception_predicate(t + 1))
144
+ DeviceIoControl(deviceArray[t].handle, IOCTL_SET_FILTER, (LPVOID) &filter, sizeof(InterceptionFilter),
145
+ NULL, 0, &bytesReturned, NULL);
146
+ }
147
+ }
148
+ }
149
+
150
+ InterceptionDevice interceptionWait(InterceptionContext context) {
151
+ return interceptionWaitWithTimeout(context, INFINITE);
152
+ }
153
+
154
+ InterceptionDevice interceptionWaitWithTimeout(InterceptionContext context, ULONG milliseconds) {
155
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
156
+ HANDLE waitHandles[INTERCEPTION_MAX_DEVICE];
157
+ DWORD index = 0;
158
+ DWORD waitResult;
159
+ DWORD t;
160
+
161
+ if (!context)
162
+ return 0;
163
+
164
+ for (t = 0; t < INTERCEPTION_MAX_DEVICE; t++) {
165
+ if (deviceArray[t].unempty)
166
+ waitHandles[index++] = deviceArray[t].unempty;
167
+ }
168
+
169
+ waitResult = WaitForMultipleObjects(index, waitHandles, FALSE, milliseconds);
170
+
171
+ if (waitResult == WAIT_FAILED || waitResult == WAIT_TIMEOUT)
172
+ return 0;
173
+
174
+ index = 0;
175
+ for (t = 0; t < INTERCEPTION_MAX_DEVICE; t++) {
176
+ if (deviceArray[t].unempty && waitResult == index++)
177
+ return (InterceptionDevice) t + 1;
178
+ }
179
+
180
+ return 0;
181
+ }
182
+
183
+ INT interceptionSend(InterceptionContext context, InterceptionDevice device, const InterceptionStroke *strokeValue,
184
+ UINT strokeCount) {
185
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
186
+ DWORD strokesWritten = 0;
187
+ UINT t;
188
+
189
+ if (!context || !strokeCount || interceptionIsInvalid(device) || !deviceArray[device - 1].handle)
190
+ return 0;
191
+
192
+ if (interceptionIsKeyboard(device)) {
193
+ PKEYBOARD_INPUT_DATA rawStrokes = (PKEYBOARD_INPUT_DATA) HeapAlloc(GetProcessHeap(), 0,
194
+ strokeCount * sizeof(KEYBOARD_INPUT_DATA));
195
+
196
+ if (!rawStrokes)
197
+ return 0;
198
+
199
+ for (t = 0; t < strokeCount; t++) {
200
+ InterceptionKeyStroke *key_stroke = (InterceptionKeyStroke *) strokeValue;
201
+
202
+ rawStrokes[t].UnitId = 0;
203
+ rawStrokes[t].MakeCode = key_stroke[t].code;
204
+ rawStrokes[t].Flags = key_stroke[t].state;
205
+ rawStrokes[t].Reserved = 0;
206
+ rawStrokes[t].ExtraInformation = key_stroke[t].information;
207
+ }
208
+
209
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_WRITE, rawStrokes,
210
+ (DWORD) strokeCount * sizeof(KEYBOARD_INPUT_DATA), NULL, 0, &strokesWritten, NULL);
211
+
212
+ HeapFree(GetProcessHeap(), 0, rawStrokes);
213
+
214
+ strokesWritten /= sizeof(KEYBOARD_INPUT_DATA);
215
+ } else {
216
+ PMOUSE_INPUT_DATA rawStrokes = (PMOUSE_INPUT_DATA) HeapAlloc(GetProcessHeap(), 0,
217
+ strokeCount * sizeof(MOUSE_INPUT_DATA));
218
+
219
+ if (!rawStrokes)
220
+ return 0;
221
+
222
+ for (t = 0; t < strokeCount; t++) {
223
+ InterceptionMouseStroke *mouse_stroke = (InterceptionMouseStroke *) strokeValue;
224
+
225
+ rawStrokes[t].UnitId = 0;
226
+ rawStrokes[t].Flags = mouse_stroke[t].flags;
227
+ rawStrokes[t].ButtonFlags = mouse_stroke[t].state;
228
+ rawStrokes[t].ButtonData = (USHORT) mouse_stroke[t].rolling;
229
+ rawStrokes[t].RawButtons = 0;
230
+ rawStrokes[t].LastX = mouse_stroke[t].x;
231
+ rawStrokes[t].LastY = mouse_stroke[t].y;
232
+ rawStrokes[t].ExtraInformation = mouse_stroke[t].information;
233
+ }
234
+
235
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_WRITE, rawStrokes,
236
+ (DWORD) strokeCount * sizeof(MOUSE_INPUT_DATA), NULL, 0, &strokesWritten, NULL);
237
+
238
+ HeapFree(GetProcessHeap(), 0, rawStrokes);
239
+
240
+ strokesWritten /= sizeof(MOUSE_INPUT_DATA);
241
+ }
242
+
243
+ return (INT) strokesWritten;
244
+ }
245
+
246
+ INT interceptionReceive(InterceptionContext context, InterceptionDevice device, InterceptionStroke *strokeValue,
247
+ UINT strokeCount) {
248
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
249
+ DWORD strokesRead = 0;
250
+
251
+ if (!context || !strokeCount || interceptionIsInvalid(device) || !deviceArray[device - 1].handle)
252
+ return 0;
253
+
254
+ if (interceptionIsKeyboard(device)) {
255
+ PKEYBOARD_INPUT_DATA rawStrokes = (PKEYBOARD_INPUT_DATA) HeapAlloc(GetProcessHeap(), 0,
256
+ strokeCount * sizeof(KEYBOARD_INPUT_DATA));
257
+ UINT t;
258
+
259
+ if (!rawStrokes)
260
+ return 0;
261
+
262
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_READ, NULL, 0, rawStrokes,
263
+ (DWORD) strokeCount * sizeof(KEYBOARD_INPUT_DATA), &strokesRead, NULL);
264
+
265
+ strokesRead /= sizeof(KEYBOARD_INPUT_DATA);
266
+
267
+ for (t = 0; t < (UINT) strokesRead; t++) {
268
+ InterceptionKeyStroke *key_stroke = (InterceptionKeyStroke *) strokeValue;
269
+
270
+ key_stroke[t].code = rawStrokes[t].MakeCode;
271
+ key_stroke[t].state = rawStrokes[t].Flags;
272
+ key_stroke[t].information = rawStrokes[t].ExtraInformation;
273
+ }
274
+
275
+ HeapFree(GetProcessHeap(), 0, rawStrokes);
276
+ } else {
277
+ PMOUSE_INPUT_DATA rawStrokes = (PMOUSE_INPUT_DATA) HeapAlloc(GetProcessHeap(), 0,
278
+ strokeCount * sizeof(MOUSE_INPUT_DATA));
279
+ UINT t;
280
+
281
+ if (!rawStrokes)
282
+ return 0;
283
+
284
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_READ, NULL, 0, rawStrokes,
285
+ (DWORD) strokeCount * sizeof(MOUSE_INPUT_DATA), &strokesRead, NULL);
286
+
287
+ strokesRead /= sizeof(MOUSE_INPUT_DATA);
288
+
289
+ for (t = 0; t < (UINT) strokesRead; t++) {
290
+ InterceptionMouseStroke *mouse_stroke = (InterceptionMouseStroke *) strokeValue;
291
+
292
+ mouse_stroke[t].flags = rawStrokes[t].Flags;
293
+ mouse_stroke[t].state = rawStrokes[t].ButtonFlags;
294
+ mouse_stroke[t].rolling = rawStrokes[t].ButtonData;
295
+ mouse_stroke[t].x = rawStrokes[t].LastX;
296
+ mouse_stroke[t].y = rawStrokes[t].LastY;
297
+ mouse_stroke[t].information = rawStrokes[t].ExtraInformation;
298
+ }
299
+
300
+ HeapFree(GetProcessHeap(), 0, rawStrokes);
301
+ }
302
+
303
+ return (INT) strokesRead;
304
+ }
305
+
306
+ UINT
307
+ interceptionGetHardwareIdentifier(InterceptionContext context, InterceptionDevice device,
308
+ VOID *hardwareIdentifierBuffer, UINT bufferSize) {
309
+ InterceptionDeviceArray deviceArray = (InterceptionDeviceArray) context;
310
+ DWORD outputSize = 0;
311
+
312
+ if (!context || interceptionIsInvalid(device) || !deviceArray[device - 1].handle)
313
+ return 0;
314
+
315
+ DeviceIoControl(deviceArray[device - 1].handle, IOCTL_GET_HARDWARE_ID, NULL, 0, hardwareIdentifierBuffer,
316
+ bufferSize, &outputSize, NULL);
317
+
318
+ return outputSize;
319
+ }
320
+
321
+ INT interceptionIsInvalid(InterceptionDevice device) {
322
+ return !interceptionIsKeyboard(device) && !interceptionIsMouse(device);
323
+ }
324
+
325
+ INT interceptionIsKeyboard(InterceptionDevice device) {
326
+ return device >= INTERCEPTION_KEYBOARD(0) && device <= INTERCEPTION_KEYBOARD(INTERCEPTION_MAX_KEYBOARD - 1);
327
+ }
328
+
329
+ INT interceptionIsMouse(InterceptionDevice device) {
330
+ return device >= INTERCEPTION_MOUSE(0) && device <= INTERCEPTION_MOUSE(INTERCEPTION_MAX_MOUSE - 1);
331
+ }
@@ -0,0 +1,196 @@
1
+ #ifndef _INTERCEPTION_H_
2
+ #define _INTERCEPTION_H_
3
+
4
+ #ifdef INTERCEPTION_STATIC
5
+ # define INTERCEPTION_API
6
+ #else
7
+ # if defined _WIN32 || defined __CYGWIN__
8
+ # ifdef INTERCEPTION_EXPORT
9
+ # ifdef __GNUC__
10
+ # define INTERCEPTION_API __attribute__((dllexport))
11
+ # else
12
+ # define INTERCEPTION_API __declspec(dllexport)
13
+ # endif
14
+ # else
15
+ # ifdef __GNUC__
16
+ # define INTERCEPTION_API __attribute__((dllimport))
17
+ # else
18
+ # define INTERCEPTION_API __declspec(dllimport)
19
+ # endif
20
+ # endif
21
+ # else
22
+ # if __GNUC__ >= 4
23
+ # define INTERCEPTION_API __attribute__ ((visibility("default")))
24
+ # else
25
+ # define INTERCEPTION_API
26
+ # endif
27
+ # endif
28
+ #endif
29
+
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+
34
+ #define INTERCEPTION_MAX_KEYBOARD 10
35
+
36
+ #define INTERCEPTION_MAX_MOUSE 10
37
+
38
+ #define INTERCEPTION_MAX_DEVICE ((INTERCEPTION_MAX_KEYBOARD) + (INTERCEPTION_MAX_MOUSE))
39
+
40
+ #define INTERCEPTION_KEYBOARD(index) ((index) + 1)
41
+
42
+ #define INTERCEPTION_MOUSE(index) ((INTERCEPTION_MAX_KEYBOARD) + (index) + 1)
43
+
44
+ typedef VOID *InterceptionContext;
45
+
46
+ typedef INT InterceptionDevice;
47
+
48
+ typedef INT InterceptionPrecedence;
49
+
50
+ typedef USHORT InterceptionFilter;
51
+
52
+ typedef INT (*InterceptionPredicate)(InterceptionDevice device);
53
+
54
+ enum InterceptionKeyState {
55
+ INTERCEPTION_KEY_DOWN = 0x00,
56
+ INTERCEPTION_KEY_UP = 0x01,
57
+ INTERCEPTION_KEY_E0 = 0x02,
58
+ INTERCEPTION_KEY_E1 = 0x04,
59
+ INTERCEPTION_KEY_TERMSRV_SET_LED = 0x08,
60
+ INTERCEPTION_KEY_TERMSRV_SHADOW = 0x10,
61
+ INTERCEPTION_KEY_TERMSRV_VKPACKET = 0x20
62
+ };
63
+
64
+ enum InterceptionFilterKeyState {
65
+ INTERCEPTION_FILTER_KEY_NONE = 0x0000,
66
+ INTERCEPTION_FILTER_KEY_ALL = 0xFFFF,
67
+ INTERCEPTION_FILTER_KEY_DOWN = INTERCEPTION_KEY_UP,
68
+ INTERCEPTION_FILTER_KEY_UP = INTERCEPTION_KEY_UP << 1,
69
+ INTERCEPTION_FILTER_KEY_E0 = INTERCEPTION_KEY_E0 << 1,
70
+ INTERCEPTION_FILTER_KEY_E1 = INTERCEPTION_KEY_E1 << 1,
71
+ INTERCEPTION_FILTER_KEY_TERMSRV_SET_LED = INTERCEPTION_KEY_TERMSRV_SET_LED << 1,
72
+ INTERCEPTION_FILTER_KEY_TERMSRV_SHADOW = INTERCEPTION_KEY_TERMSRV_SHADOW << 1,
73
+ INTERCEPTION_FILTER_KEY_TERMSRV_VKPACKET = INTERCEPTION_KEY_TERMSRV_VKPACKET << 1
74
+ };
75
+
76
+ enum InterceptionMouseState {
77
+ INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN = 0x001,
78
+ INTERCEPTION_MOUSE_LEFT_BUTTON_UP = 0x002,
79
+ INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN = 0x004,
80
+ INTERCEPTION_MOUSE_RIGHT_BUTTON_UP = 0x008,
81
+ INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN = 0x010,
82
+ INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP = 0x020,
83
+
84
+ INTERCEPTION_MOUSE_BUTTON_1_DOWN = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
85
+ INTERCEPTION_MOUSE_BUTTON_1_UP = INTERCEPTION_MOUSE_LEFT_BUTTON_UP,
86
+ INTERCEPTION_MOUSE_BUTTON_2_DOWN = INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
87
+ INTERCEPTION_MOUSE_BUTTON_2_UP = INTERCEPTION_MOUSE_RIGHT_BUTTON_UP,
88
+ INTERCEPTION_MOUSE_BUTTON_3_DOWN = INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN,
89
+ INTERCEPTION_MOUSE_BUTTON_3_UP = INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP,
90
+
91
+ INTERCEPTION_MOUSE_BUTTON_4_DOWN = 0x040,
92
+ INTERCEPTION_MOUSE_BUTTON_4_UP = 0x080,
93
+ INTERCEPTION_MOUSE_BUTTON_5_DOWN = 0x100,
94
+ INTERCEPTION_MOUSE_BUTTON_5_UP = 0x200,
95
+
96
+ INTERCEPTION_MOUSE_WHEEL = 0x400,
97
+ INTERCEPTION_MOUSE_HWHEEL = 0x800
98
+ };
99
+
100
+ enum InterceptionFilterMouseState {
101
+ INTERCEPTION_FILTER_MOUSE_NONE = 0x0000,
102
+ INTERCEPTION_FILTER_MOUSE_ALL = 0xFFFF,
103
+
104
+ INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_DOWN = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN,
105
+ INTERCEPTION_FILTER_MOUSE_LEFT_BUTTON_UP = INTERCEPTION_MOUSE_LEFT_BUTTON_UP,
106
+ INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_DOWN = INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN,
107
+ INTERCEPTION_FILTER_MOUSE_RIGHT_BUTTON_UP = INTERCEPTION_MOUSE_RIGHT_BUTTON_UP,
108
+ INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_DOWN = INTERCEPTION_MOUSE_MIDDLE_BUTTON_DOWN,
109
+ INTERCEPTION_FILTER_MOUSE_MIDDLE_BUTTON_UP = INTERCEPTION_MOUSE_MIDDLE_BUTTON_UP,
110
+
111
+ INTERCEPTION_FILTER_MOUSE_BUTTON_1_DOWN = INTERCEPTION_MOUSE_BUTTON_1_DOWN,
112
+ INTERCEPTION_FILTER_MOUSE_BUTTON_1_UP = INTERCEPTION_MOUSE_BUTTON_1_UP,
113
+ INTERCEPTION_FILTER_MOUSE_BUTTON_2_DOWN = INTERCEPTION_MOUSE_BUTTON_2_DOWN,
114
+ INTERCEPTION_FILTER_MOUSE_BUTTON_2_UP = INTERCEPTION_MOUSE_BUTTON_2_UP,
115
+ INTERCEPTION_FILTER_MOUSE_BUTTON_3_DOWN = INTERCEPTION_MOUSE_BUTTON_3_DOWN,
116
+ INTERCEPTION_FILTER_MOUSE_BUTTON_3_UP = INTERCEPTION_MOUSE_BUTTON_3_UP,
117
+
118
+ INTERCEPTION_FILTER_MOUSE_BUTTON_4_DOWN = INTERCEPTION_MOUSE_BUTTON_4_DOWN,
119
+ INTERCEPTION_FILTER_MOUSE_BUTTON_4_UP = INTERCEPTION_MOUSE_BUTTON_4_UP,
120
+ INTERCEPTION_FILTER_MOUSE_BUTTON_5_DOWN = INTERCEPTION_MOUSE_BUTTON_5_DOWN,
121
+ INTERCEPTION_FILTER_MOUSE_BUTTON_5_UP = INTERCEPTION_MOUSE_BUTTON_5_UP,
122
+
123
+ INTERCEPTION_FILTER_MOUSE_WHEEL = INTERCEPTION_MOUSE_WHEEL,
124
+ INTERCEPTION_FILTER_MOUSE_HWHEEL = INTERCEPTION_MOUSE_HWHEEL,
125
+
126
+ INTERCEPTION_FILTER_MOUSE_MOVE = 0x1000
127
+ };
128
+
129
+ enum InterceptionMouseFlag {
130
+ INTERCEPTION_MOUSE_MOVE_RELATIVE = 0x000,
131
+ INTERCEPTION_MOUSE_MOVE_ABSOLUTE = 0x001,
132
+ INTERCEPTION_MOUSE_VIRTUAL_DESKTOP = 0x002,
133
+ INTERCEPTION_MOUSE_ATTRIBUTES_CHANGED = 0x004,
134
+ INTERCEPTION_MOUSE_MOVE_NOCOALESCE = 0x008,
135
+ INTERCEPTION_MOUSE_TERMSRV_SRC_SHADOW = 0x100
136
+ };
137
+
138
+ typedef struct {
139
+ USHORT state;
140
+ USHORT flags;
141
+ SHORT rolling;
142
+ INT x;
143
+ INT y;
144
+ UINT information;
145
+ } InterceptionMouseStroke;
146
+
147
+ typedef struct {
148
+ USHORT code;
149
+ USHORT state;
150
+ UINT information;
151
+ } InterceptionKeyStroke;
152
+
153
+ typedef CHAR InterceptionStroke[sizeof(InterceptionMouseStroke)];
154
+
155
+ InterceptionContext INTERCEPTION_API interceptionCreateContext();
156
+
157
+ VOID INTERCEPTION_API interceptionDestroyContext(InterceptionContext context);
158
+
159
+ InterceptionPrecedence INTERCEPTION_API
160
+ interceptionGetPrecedence(InterceptionContext context, InterceptionDevice device);
161
+
162
+ VOID INTERCEPTION_API
163
+ interceptionSetPrecedence(InterceptionContext context, InterceptionDevice device, InterceptionPrecedence precedence);
164
+
165
+ InterceptionFilter INTERCEPTION_API interceptionGetFilter(InterceptionContext context, InterceptionDevice device);
166
+
167
+ VOID INTERCEPTION_API
168
+ interceptionSetFilter(InterceptionContext context, InterceptionPredicate predicate, InterceptionFilter filter);
169
+
170
+ InterceptionDevice INTERCEPTION_API interceptionWait(InterceptionContext context);
171
+
172
+ InterceptionDevice INTERCEPTION_API interceptionWaitWithTimeout(InterceptionContext context, ULONG milliseconds);
173
+
174
+ INT INTERCEPTION_API
175
+ interceptionSend(InterceptionContext context, InterceptionDevice device, const InterceptionStroke *strokeValue,
176
+ UINT strokeCount);
177
+
178
+ INT INTERCEPTION_API
179
+ interceptionReceive(InterceptionContext context, InterceptionDevice device, InterceptionStroke *strokeValue,
180
+ UINT strokeCount);
181
+
182
+ UINT INTERCEPTION_API
183
+ interceptionGetHardwareIdentifier(InterceptionContext context, InterceptionDevice device,
184
+ VOID *hardwareIdentifierBuffer, UINT bufferSize);
185
+
186
+ INT INTERCEPTION_API interceptionIsInvalid(InterceptionDevice device);
187
+
188
+ INT INTERCEPTION_API interceptionIsKeyboard(InterceptionDevice device);
189
+
190
+ INT INTERCEPTION_API interceptionIsMouse(InterceptionDevice device);
191
+
192
+ #ifdef __cplusplus
193
+ }
194
+ #endif
195
+
196
+ #endif