Closed YounesN closed 6 years ago
- OUTPUT_FILE = fopen(file, "a+");
+ fopen_s(&OUTPUT_FILE, file, "a+");
- time_t t = time(NULL);
- struct tm *tm = localtime(&t);
- char s[64];
- strftime(s, sizeof(s), "%c", tm);
+ time_t t = time(NULL);
+ struct tm tm;
+ localtime_s(&tm, &t);
+ char s[64];
+ strftime(s, sizeof(s), "%c", &tm);
- strcpy(lastwindow, window_title);
+ strcpy_s(lastwindow, window_title);
The issue with specifying a buffer size is that a user may miss some keystrokes if that is done.
Nothing will be harmful to your computer, however you can always edit your personal code if you would like. 😄
I tried to compile the code on:
I get the following errors: `Error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. DataProtection c:\Users\yneja\Desktop\Keylogger\windows\klog_main.cpp 79
Error C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. DataProtection c:\Users\yneja\Desktop\Keylogger\windows\klog_main.cpp 69
Error C4996 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. DataProtection c:\Users\yneja\Desktop\Keylogger\windows\klog_main.cpp 83`
I got around it by _CRT_SECURE_NO_WARNINGS, but maybe they should be switched to safer versions.