Suspend process

1

I'm trying to suspend a process from windows to Delphi , but to no avail, I'm using the following code:

function SuspendProcess(pid:dword):boolean; // Suspende processo pelo PID 
var module,module1:thandle; 
    SusPendProcess:TNTdllApi; 
begin 
  result := false; 
  SetTokenPrivileges; 
  module := LoadLibrary('ntdll.dll'); 
  @SusPendProcess := Getprocaddress(module,'NtSuspendProcess'); 
  if @SusPendProcess <> nil then 
    begin 
      module1 := OpenProcess(PROCESS_ALL_ACCESS,FALSE,pid); 
      SusPendProcess(module1); 
    end; 
end; 

Where I report PID , but nothing happens, now using the tool PC Hunter , it suspends without any problem. Would it be possible to use PSSuspendProcess/ZwSuspendProcess ? Could you help me with an example? Thank you!

    
asked by anonymous 27.08.2016 / 22:24

1 answer

0

Would ending the process solve your problem? If you try:

PostMessage(FindWindow(<nome_da_tela_principal_do_processo>, nil), WM_CLOSE, 0,0);
    
08.09.2016 / 16:01