🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11912

problem with TerminateProcess and user rights

#11912
From: saso badovinac
Date: Sun, 11 Jan 2004 01:19
38 lines
2318 bytes
hi

i have made a small program that terminates a process with the
TerminateProcess function. now the program works fine, but only if i
terminate a process that has the same user. now what my problem is
that if i run my program as an administrator i am not able to terminate
processes from other users (as an admin i should be able to).

with other words, i am only able to terminate the process if the user is the
same, i should be able to terminate it if the user is the same AND if the
user has admin rights.

any comments and suggestions are welcome :)

HANDLE FSnapshotHandle=CreateToolhelp32Snapshot(0x00000002, 0);
 PROCESSENTRY32 plist32;
 plist32.dwSize = sizeof(plist32);
 ContinueLoop = Process32First(FSnapshotHandle, &plist32);
 while (ContinueLoop) {

//----------- i am using this for windows 9x
  char nov[255] ="";
  for (int i = strlen(plist32.szExeFile)-strlen(p); i <=
strlen(plist32.szExeFile); i++) nov[i-strlen(plist32.szExeFile)+strlen(p)] =
plist32.szExeFile[i];
//------------------------------------------

  if (!lstrcmpi(nov,p)) {

// i belive that at this point i am missing sommething to be able to get the
terminate process rights

   TerminateProcess(OpenProcess((0x0001),0,plist32.th32ProcessID), 0);
  }

  ContinueLoop = Process32Next(FSnapshotHandle, &plist32);
 }
 CloseHandle(FSnapshotHandle);
Technical Details
Message-ID: <4000a4a8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.eunet.no!fi.sn.net!newsfeed2.fi.sn.net!news2.euro.net!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,6dea0870157ee61c,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-10 17:36:44 PST
From: "saso badovinac" <none@none.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: problem with TerminateProcess and user rights
Date: Sun, 11 Jan 2004 02:19:41 +0100
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 193.77.234.35
Message-ID: <4000a4a8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1073783976 193.77.234.35 (10 Jan 2004 17:19:36 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.eunet.no!fi.sn.net!newsfeed2.fi.sn.net!news2.euro.net!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail