🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: problem with TerminateProcess and user rights

#11844
From: saso badovinac
Date: Tue, 13 Jan 2004 00:54
54 lines
2473 bytes
as i have expected i have to request first for the rights to open and then
terminate an process if i am an admin and the process i want to kill is from
some other user. i now have a visual basic code for this. now i have to do
it in c++. now i have a problem with

SetSecurityInfo(plist32.szExeFile,SE_KERNEL_OBJECT,OWNER_SECURITY_INFORMATIO
N,0,0,0,0);

i just dont know what to set for those 0 (NULL) at the end :\


the vb code:

Public Function KillProcess(ByVal hProcessID As Long, Optional ByVal
ExitCode As Long) As Boolean
    Dim hToken As Long
    Dim hProcess As Long
    Dim tp As TOKEN_PRIVILEGES

    If GetVersion() >= 0 Then

        If OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES Or
TOKEN_QUERY, hToken) = 0 Then
            GoTo CleanUp
        End If

        If LookupPrivilegeValue("", "SeDebugPrivilege", tp.LuidUDT) = 0 Then
            GoTo CleanUp
        End If

        tp.PrivilegeCount = 1
        tp.Attributes = SE_PRIVILEGE_ENABLED

        If AdjustTokenPrivileges(hToken, False, tp, 0, ByVal 0&, ByVal 0&) =
0 Then
            GoTo CleanUp
        End If
    End If

    hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, hProcessID)
    If hProcess Then

        KillProcess = (TerminateProcess(hProcess, ExitCode) <> 0)
        CloseHandle hProcess
    End If

    If GetVersion() >= 0 Then
        tp.Attributes = 0
        AdjustTokenPrivileges hToken, False, tp, 0, ByVal 0&, ByVal 0&

CleanUp:
        If hToken Then CloseHandle hToken
    End If
End Function
Technical Details
Message-ID: <400341ac@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4000a4a8@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,6dea0870157ee61c
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-12 17:09:57 PST
From: "saso badovinac" <none@none.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4000a4a8@newsgroups.borland.com>
Subject: Re: problem with TerminateProcess and user rights
Date: Tue, 13 Jan 2004 01:54:06 +0100
Lines: 58
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.179.129
Message-ID: <400341ac@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1073955244 193.77.179.129 (12 Jan 2004 16:54:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail