Re: how to set PROCESS_TERMINATE privilege?

From: Ndi (Ndi_at_Ndi_dot_ro)
Date: 10/23/03


Date: Thu, 23 Oct 2003 08:48:01 +0300


> >Note that you need admin rights to open a process with
> >PROCESS_TERMINATE access.

  I'll allow tar and feathers if I'm wrong, but you don't?

  Anybody can aquire PROCESS_TERMINATE for the processes running as his own
user (under NT) and to any process (Wintendo - 9x/ME).

  You can kill any process you started, either by hand or with any other
tool that states by the Explorer or whatever (they inherit). That is unless
the process is a service or started on purpose by another user and left
there, you can kill it.

> how can i set this privilege settings for the current user and
> then reset it to the default value for that user?

  You only need privileges if you want to kill a process that does not
belong to you. In that case, I think you need SE_DEBUG privilege (actually,
I KNOW you need it. There might, however, be another way).

  What you DO need to do with PROCESS_TERMINATE is to set the flag when
calling OpenProcess. It should be

  hProcess := OpenProcess( PROCESS_TERMINATE, false, PID);
  if hProcess <> 0 then
    TerminateProcess( hProcess, 0)
  else
    Showmessage('I wuz un''able tuh open the blasted process. You do not
have no permissions here. Shoo.'); // change this in production code

  This is from memory and against Peter's recomandation to not type code in
the newsreader. :)

--
Andrei "Ndi" Dobrin
Brainbench MVP
www.Brainbench.com


Relevant Pages

  • Privileges and killing a process
    ... then the application will kill them (by terminating the process by PID). ... Dim hProcess As Long ... GoTo CleanUp ...
    (microsoft.public.vb.general.discussion)
  • Re: Privileges and killing a process
    ... then the application will kill them (by terminating the process by PID). ... >Dim hProcess As Long ... >GoTo CleanUp ...
    (microsoft.public.vb.general.discussion)
  • Re: Privileges and killing a process
    ... "Lee Peedin" wrote: ... sure seems like a lot of code when you can run a simple script ... then the application will kill them. ... >>Dim hProcess As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Kill remote Process(service)
    ... if (schSCManager == NULL) ... if (!QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, ... hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, ... I think the reason of that error is that im trying to kill the process ...
    (microsoft.public.win32.programmer.networks)
  • Re: F-Prot being killed?
    ... Can a process kill its self? ... since that's part of 'adequate privileges'. ... The problem with the world is stupidity. ...
    (alt.os.linux)