Home
About
Blog
Media Gallery

Clearing console without system call


Calls like this made defender delete my exe file and called it a trojan:
system("cls");

Use Win32 API instead (Windows.h):
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD startpos = {0,0};
DWORD written;
GetConsoleScreenBufferInfo(hOut, &csbi);
FillConsoleOutputCharacter(hOut, L' ', (csbi.dwSize.X * csbi.dwSize.Y), startpos, &written);


Original Post: Sep 7th, '22 13:54 CEST.
Updated: Sep 7th, '22 13:56 CEST.

Tags: C/C++