GiacomoLaw / Keylogger

A simple keylogger for Windows, Linux and Mac
https://simple-keylogger.github.io/
MIT License
2.09k stars 616 forks source link

"Invisible" Window feature not working (FindWindowA returns null?) #95

Closed SimonKaluza closed 9 months ago

SimonKaluza commented 4 years ago

Describe the bug Setting the "invisible" macro does not correctly hide the console window. i.e. the ShowWindow(FindWindowA("ConsoleWindowClass", NULL), 0) call on line 161 of klog_main.cpp doesn't seem to have any effect.

To Reproduce Steps to reproduce the behavior:

  1. Create a new VS 2019 command-line CPP project
  2. Paste the entire code of klog_main.cpp
  3. Change #define visible to #define invisible
  4. Command-line window showing Keylogger still remains open after compiling/running successfully.

Expected behavior We expect the command-line window to be hidden, but it seems the call to FindWindowA("ConsoleWindowClass", NULL) returns null, which means the subsequent call to ShowWindow has no effect.

mfrank37 commented 12 months ago

There exist HWND WINAPI GetConsoleWindow(void); to get the console window of the keylogger, it works, although, windows defender might flag the build as a Trojan/Keylogger.

mydarkthawts commented 9 months ago

I added the FreeConsole(); call after ShowWindow(FindWindowA("ConsoleWindowClass", NULL), 0); // invisible window which resolves this concern. I submitted a pull request with the change. Hopefully it is accepted as a solution.

GiacomoLaw commented 9 months ago

Fixed in e931864230ae37b49b036634cb4843f0a1f4fa3e