Does anyone have any idea to detect if the EXE files is still running or not?
I try to make a little anti-virus removal. The program can scan and detect the virus then try to terminate the process & delete it...
Can anybody give me any idea...
Printable View
Does anyone have any idea to detect if the EXE files is still running or not?
I try to make a little anti-virus removal. The program can scan and detect the virus then try to terminate the process & delete it...
Can anybody give me any idea...
Here's a function I wrote for a tiny debugger I made a while back that gives some rudimentary info on processes (the whole script can be found here):
Code:void process_snap(void) {
FILE *hFile;
HANDLE hSnapshot;
PROCESSENTRY32 ppe32E = { sizeof(PROCESSENTRY32) };
int proccount = 0;
if(NULL == (hFile = fopen("proc_snap.log","a"))) {
printf("+--Could not open log file--+\n");
goto end;
}
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(NULL == hSnapshot) {
fprintf(hFile,"+--Could not create process snapshot: %d--+\n",GetLastError());
goto end;
}
if(FALSE == Process32First(hSnapshot,&ppe32E)) {
fprintf(hFile,"+--Could not get first process: %d--+\n",GetLastError());
goto end;
}
fprintf(hFile,"+---PROCESS SNAP RESULTS:-----+\n");
do {
fprintf(hFile,"Process %d:\n",++proccount);
fprintf(hFile,"--Path: %s\n",ppe32E.szExeFile);
fprintf(hFile,"--ProcID: 0x%x\n",ppe32E.th32ProcessID);
} while(FALSE != Process32Next(hSnapshot,&ppe32E));
fprintf(hFile,"+-----------------------------+\n");
fprintf(hFile,"\n\n\n");
printf("+--Everything snapped, logs in proc_snap.log--+\n");
end:
fclose(hFile);
}
You can of course do it other ways, namely using things like the native API, but I feel that's beyond the basic scope of what you're asking (at least right now.)
Thanks alot man... The code giving me some idea how to retrieve an information from the running process...
I currently trying to make a function that can force to terminate & delete an EXE files that currently running...
Lets say,
ABC.EXE is currently running...
Then I want to force delete this files...
Did anybody have an idea? Or Pseudo Code...
thanks again for Mad_guy... Just what i need... :D