forked from emilytouchingcomputers/CTFium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.c
53 lines (43 loc) · 957 Bytes
/
example.c
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
int main()
{
struct input_event ie;
int fd, fd2, ret;
char test[10] = {0, };
fd = open("/dev/input/event2", O_RDONLY);
if(fd < 0) {
perror("event2");
return -1;
}
fd2 = open("/dev/input_test_driver", O_RDWR);
if(fd < 0) {
perror("input_test_driver");
return -1;
}
test[0] = 1;
test[1] = 2;
test[2] = 3;
test[3] = 4;
test[4] = 5;
write(fd2, test, 5);
ioctl(fd2, 0x1337, 0);
while(1) {
ret = read(fd, &ie, sizeof(struct input_event));
if(ret < 0) {
perror("error");
break;
}
printf("type: %hu, code: %hu, value: %d \n", ie.type, ie.code, ie.value);
}
close(fd);
close(fd2);
return 0;
}