Skip to content

Commit

Permalink
Fixed up the defend command. No issues detected.
Browse files Browse the repository at this point in the history
  • Loading branch information
TBye101 committed Jul 25, 2017
1 parent a0fcf6c commit 387b3d5
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions CommandEverything/CommandEverythingCPP/CommandDefend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,32 @@ void CommandDefend::Defend()
string converted(ws.begin(), ws.end());
//https://stackoverflow.com/questions/45288937/avoid-killing-a-specific-process-c?noredirect=1#comment77540465_45288937

//Kill process.
if (TerminateProcess(hProcess, 1))
char drive[4];
char directory[MAX_PATH];
char filename[MAX_PATH];
char extension[MAX_PATH];
_splitpath(converted.c_str(), drive, directory, filename, extension);

if (filename[0] != 'c' || filename[1] != 'o' || filename[2] != 'n' || filename[3] != 'h'
|| filename[4] != 'o' || filename[5] != 's' || filename[6] != 't'
|| extension[0] != '.' || extension[1] != 'e' || extension[2] != 'x'
|| extension[3] != 'e')
{
string msg = "Killed a process: ";
msg.append(converted);
Console->WriteLine(&msg);
}
else
{
this->FailedHitList.push_back(aProcesses[i]);
string msg = "Failed to kill a process: ";
msg.append(converted);
Console->WriteLine(&msg);
Console->WriteLine(&to_string(GetLastError()));
//Kill process.
if (TerminateProcess(hProcess, 1))
{
string msg = "Killed a process: ";
msg.append(converted);
Console->WriteLine(&msg);
}
else
{
this->FailedHitList.push_back(aProcesses[i]);
string msg = "Failed to kill a process: ";
msg.append(converted);
Console->WriteLine(&msg);
Console->WriteLine(&to_string(GetLastError()));
}
}
}
}
Expand Down

0 comments on commit 387b3d5

Please sign in to comment.