no message

master
zcy 2021-07-26 23:47:13 +08:00
parent b3f5cc3589
commit a58d20d811
1 changed files with 15 additions and 8 deletions

View File

@ -1,7 +1,7 @@
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-07-23 23:39:57 * @Date: 2021-07-23 23:39:57
* @LastEditTime: 2021-07-26 00:28:04 * @LastEditTime: 2021-07-26 23:44:58
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \generallib\general\src\function\daemon.c * @FilePath: \generallib\general\src\function\daemon.c
@ -109,7 +109,7 @@ static int RangeProcess()
{ {
EnumProcessModules(hProcess, hMod, sizeof(hMod), &Retn_bytes2); EnumProcessModules(hProcess, hMod, sizeof(hMod), &Retn_bytes2);
GetModuleFileNameEx(hProcess, hMod[0], szModName, sizeof(szModName)); GetModuleFileNameEx(hProcess, hMod[0], szModName, sizeof(szModName));
printf("PID=%d Path=%s\n", Proc_pid[i], szModName); // printf("PID=%d Path=%s\n", Proc_pid[i], szModName);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
@ -205,7 +205,7 @@ int DaemonizeMonitor::StartMonitor(){
{ {
EnumProcessModules(hProcess, hMod, sizeof(hMod), &Retn_bytes2); EnumProcessModules(hProcess, hMod, sizeof(hMod), &Retn_bytes2);
GetModuleFileNameEx(hProcess, hMod[0], szModName, sizeof(szModName)); GetModuleFileNameEx(hProcess, hMod[0], szModName, sizeof(szModName));
printf("PID=%d Path=%s\n", Proc_pid[i], szModName); // printf("PID=%d Path=%s\n", Proc_pid[i], szModName);
if(itr->second == Proc_pid[i]){ if(itr->second == Proc_pid[i]){
found = true; found = true;
break; break;
@ -216,18 +216,25 @@ int DaemonizeMonitor::StartMonitor(){
SetProcessPrivilege("SeDebugPrivilege", 0); SetProcessPrivilege("SeDebugPrivilege", 0);
if(!found){ if(!found){
// 没找到该应用实例就重启应用 // 没找到该应用实例就重启应用
for(int i = 0;i < m_path_process.size();i++){ auto it = m_path_process.begin();
if(itr->first == m_path_process.at(i)){ while (it != m_path_process.end())
{
if (*it == itr->first)
{
it = m_path_process.erase(it);
} }
else
it++;
}
for(auto it = m_path_process.begin();it != m_path_process.end();it++){
std::cout<<*it<<std::endl;
} }
this->AddNewProcess(itr->first); this->AddNewProcess(itr->first);
} }
} }
} }
} }
return 0; return 0;
} }