I'm working on a project to kill an application if it is running with a certain dll and if the time conditions permit. For example if someone opens a program with test.dll and the program is engaged I want to terminate it and if its not I want it to wait it out until the time is engaged and kill it. I am currently using the system(""); command with Taskkill /F /FI "MODULES eq test.dll" /FI "IMAGENAME ne calc.exe" however I am running into problems with double quotes and closing of the application, and it introduces an insecurity with the program (someone deletes taskkkill...) Is there a alternative? I would prefer to not use any system commands at all. The last thing I haven't a clue on how to include is to add new not equals exceptions without a recompile and without people being able to read the external file. the /FI "IMAGENAME ne calc.exe" makes it so that it wont kill calc.exe if it has test.dll. I need to be able to add new not equals exceptions without recompiling and so that people can't pry and find out they just need to rename exe's to run stuff. Here is a snippet of the code.. not sure it helps.
int main()
{
while(1)
{
char buffer [80];
int compare;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime (buffer,80,"%H%M",timeinfo);
compare = atoi(buffer);
std::cout << compare << std::endl;
if ((compare >= 915) && (compare <= 1530))
{
if ((compare >= 1220) && (compare <= 1305))
{
std::cout << "block disengage" << std::endl;
}else{
std::cout << "block engaged" << std::endl;
system("taskkill.exe /F /FI \"MODULES eq test.dll\" /FI \"IMAGENAME ne calc.exe"");
Sleep(60000);
}
}else{
std::cout << "block disengaged" << std::endl;
Sleep(5000);
}
}
}
The main thing Im looking to do is get rid of external calls with system the external exception adding is just a plus. I know im asking alot but thanks in advance