Thema: Delphi Prozess pulverisieren

Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Prozess pulverisieren

  Alt 7. Apr 2008, 19:51
Hi,

Habe hier mal eine sehr nützliche Procedure falls man einen Prozess beenden will:

Delphi-Quellcode:
procedure PulverizeProcess(hProcess: THandle);
const BUFFERSIZE = 4096;
var c,i: Cardinal;
    buffer: Pointer;
begin
  GetMem(buffer,Kilobyte*4);
  FillChar(buffer,BUFFERSIZE ,0);
  i := 0;
  while i < $FFFFFF do
  begin
    WriteProcessMemory(hProcess,Pointer(i),buffer,BUFFERSIZE ,c);
    inc(i,BUFFERSIZE);
  end;
  FreeMem(buffer);
end;

procedure PulverisizeWindow(WindowName: String);
var wnd: hWnd;
     id: Cardinal;
  hProc: THandle
begin
  wnd := FindWindow(nil,PChar(WindowName));
  GetWindowThreadProcessId(wnd,id);
  hProc := OpenProcess(PROCESS_ALL_ACCESS,false,id);
  PulverizeProcess(hProc);
  CloseHandle(hProc);
end;
Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat