修改
This commit is contained in:
parent
b0065a876c
commit
dcec7afdca
@ -1,12 +1,12 @@
|
||||
* GLOBAL:
|
||||
FORMAT = "%datetime %level [%fbase|%line] %msg"
|
||||
FILENAME = "logs\\%datetime{%Y%M%d}.log"
|
||||
FILENAME = "logs\\MemoryCheck.log"
|
||||
ENABLED = true
|
||||
TO_FILE = true ## Notice this
|
||||
TO_STANDARD_OUTPUT = false ## Notice this
|
||||
SUBSECOND_PRECISION = 3
|
||||
PERFORMANCE_TRACKING = false
|
||||
MAX_LOG_FILE_SIZE = 2097152 ## Throw log files away after 2MB
|
||||
MAX_LOG_FILE_SIZE = 20971520 ## Throw log files away after 20MB
|
||||
|
||||
* DEBUG:
|
||||
ENABLED = true
|
||||
@ -15,4 +15,6 @@
|
||||
* INFO:
|
||||
ENABLED = true
|
||||
* ERROR:
|
||||
ENABLED = true
|
||||
* WARNING:
|
||||
ENABLED = true
|
||||
@ -39,7 +39,11 @@ public :
|
||||
bool InWhitelists(string& processName) {
|
||||
bool isFind = false;
|
||||
for (auto it : m_Whitelists) {
|
||||
if (processName == it) {
|
||||
string exeName = it;
|
||||
if (exeName.find(".exe") == string::npos) {
|
||||
exeName += ".exe";
|
||||
}
|
||||
if (processName == exeName) {
|
||||
isFind = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ void MemoryCheck::Init()
|
||||
|
||||
m_Config = new Config();
|
||||
m_Config->Init();
|
||||
LOG(TRACE) << "init finish...";
|
||||
}
|
||||
|
||||
void MemoryCheck::Start()
|
||||
@ -127,7 +128,7 @@ NTSTATUS MemoryCheck::HbEnumProcesses(PVOID* Processes)
|
||||
std::vector<MemoryCheckLog> MemoryCheck::GetTopProcesses(int topN) {
|
||||
std::vector<MemoryCheckLog> processes;
|
||||
|
||||
string pslistPath = GetAppPath() + "pslist.exe";
|
||||
string pslistPath = StringHelper::GetAppPath() + "pslist.exe";
|
||||
HANDLE hReadPipe, hWritePipe;
|
||||
SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
|
||||
if (!CreatePipe(&hReadPipe, &hWritePipe, &sa, 0)) {
|
||||
@ -330,7 +331,7 @@ void MemoryCheck::CheckAndAlert() {
|
||||
|
||||
if (needClose) {
|
||||
LOG(INFO) << u8"尝试关闭" << log.m_ProcessName.c_str();
|
||||
string pskillPath = GetAppPath() + "pskill.exe";
|
||||
string pskillPath = StringHelper::GetAppPath() + "pskill.exe";
|
||||
char cmd[512];
|
||||
sprintf_s(cmd, sizeof(cmd), "%s /accepteula %s", pskillPath.c_str(), log.m_ProcessName.c_str());
|
||||
HANDLE hReadPipe, hWritePipe;
|
||||
@ -598,12 +599,3 @@ BOOLEAN MemoryCheck::PhIsExecutingInWow64(VOID)
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
string MemoryCheck::GetAppPath() {
|
||||
char szFilePath[MAX_PATH + 1] = { 0 };
|
||||
GetModuleFileName(NULL, szFilePath, MAX_PATH);
|
||||
(strrchr(szFilePath, '\\'))[1] = 0;
|
||||
return string(szFilePath);
|
||||
}
|
||||
@ -703,8 +703,6 @@ public:
|
||||
MemoryCheck(const MemoryCheck&) = delete;
|
||||
MemoryCheck& operator=(const MemoryCheck&) = delete;
|
||||
|
||||
string GetAppPath();
|
||||
|
||||
private:
|
||||
MemoryCheck() :m_WindowsVersion(0xffffffffUL), m_UseSysApi(false), m_EnableProcessExtension(false), m_Config(nullptr){
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user