vendredi 22 mars 2019

Trying to delete .exe file using Path from windows registries and DeleteFile() method

So I need to scan windows registries, display them all on the console and then check which of those values has the same name as set in the code

When the program finds the value with the targeted name I need to terminate it process and delete it from hardware using DeleteFile().

So I have done everything got the path to the .exe file destination but when I'm using DeleteFile(); it doesn't delete the file

void EndProcess(HANDLE snap, HANDLE &process, PROCESSENTRY32 pe32, TCHAR 
virusName[], TCHAR valuePath[], wofstream &file)
{
    process = OpenProcess(PROCESS_TERMINATE, FALSE, pe32.th32ProcessID);
    if (TerminateProcess(process, 1))
    {
        cout << "Virus process is found and successfully terminated!" << 
    endl;
        file << "Virus process is found and successfully terminated!" << 
    endl;
        CloseHandle(process);
        DeleteFile(valuePath);
    }
    else
    {
        cout << "Failed to terminate Virus process!" << endl;
        file << "Failed to terminate Virus process!" << endl;
    }
}

Aucun commentaire:

Enregistrer un commentaire