VB6 implements the privileges of enumeration processes

Source: Internet
Author: User

Original: http://blog.csdn.net/Modest/archive/2008/03/07/2156291.aspx

 

Of course, it is a special permission. For special permissions on processes, see msdn.
For methods to improve process permissions, refer to the author's article "two methods to improve process debug permissions in Win32 compilation", which can be easily modified to programs that provide other process permissions. This document lists all the special permissions in the enumeration process and returns the permission value in an array. What is the specific meaning of each permission value? The variable name can be further considered. For details, refer to msdn.

:::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::: <Br/> 'vb6 realize the privileges of enumeration process <br/> 'programmed by Wei sort <br/> 'website: http://www.chenoe.com <br/> 'blog: http://blog.csdn.net/Modest <br/> ':::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::: ::: <br/> Option explicit <br/> private const anysize_array as long = 100 <br/> private const tokenprivileges = 3 <br/> private const token_query = & H8 <br/> private type luid <br/> lowpart as long <br/> highpart as long <br/> end type <br/> private type luid_and_attributes <br/> pluid as luid <br/> attributes as long <br/> end type <br/> private type token_privileges <br/> privilegecount as long <br/> privileges (anysize_array) as luid_and_attributes <br/> end type <br/> private declare function getcurrentprocess () function getcurrentprocess lib "Kernel32" () as long <br/> private declare function openprocesstoken () function openprocesstoken lib "advapi32" (byval processhandle as long, byval desiredaccess as long, tokenhandle as long) As long <br/> private declare function gettokeninformation () function gettokeninformation lib "advapi32" (byval tokenhandle as long, tokeninformationclass as integer, tokeninformation as any, byval tokeninformationlength as long, returnlength as long) as long <br/> private declare function rtlmovememory () function rtlmovememory lib "Kernel32" (DEST as any, source as any, byval lsize as long) as long <br/> private declare function closehandle () function closehandle lib "Kernel32" (byval hobject as long) As long <br/> private function getprocressprivileges () function getprocressprivileges (byval hprocess as long) As long () <br/> dim htoken as long <br/> dim buffersize as long <br/> dim infobuffer () as long <br/> dim I as long, R () as long, X as long <br/> dim lresult as long <br/> dim tptokens as token_privileges <br/> call openprocesstoken (hprocess, token_query, htoken) <br/> If htoken then <br/> call gettokeninformation (htoken, byval tokenprivileges, 0, 0, buffersize) <br/> If buffersize then <br/> redim infobuffer (buffersize 4)-1) As long <br/> lresult = gettokeninformation (htoken, byval tokenprivileges, infobuffer (0), buffersize, buffersize) <br/> If lresult = 1 then <br/> call rtlmovememory (tptokens, infobuffer (0), lenb (tptokens )) <br/> for I = 0 to tptokens. privilegecount-1 <br/> If tptokens. privileges (I ). attributes <> 0 then <br/> redim preserve R (x) <br/> r (x) = tptokens. privileges (I ). pluid. lowpart <br/> X = x + 1 <br/> end if <br/> next <br/> end if <br/> call closehandle (htoken) <br/> end if <br/> getprocressprivileges = r <br/> end function <br/> 'sample Code <br/> private sub form_load () <br/> dim P () as long, I as long <br/> P = getprocressprivileges (getcurrentprocess) <br/> for I = 0 to ubound (P) <br/> debug. print P (I) <br/> next <br/> end sub

The permission value enumeration declaration is as follows for your reference only:

Private Enum se_privilegeenum se_privilege <br/> priority = 2 <br/> se_create_token_privilege = 2 <br/> priority = 3 <br/> priority = 4 <br/> priority = 5 <br/> se_machine_account_privilege = 6 <br/> se_tcb_privilege = 7 <br/> se_security_privilege = 8 <br/> priority = 9 <br/> priority = 10 <br/> priority = 11 <br/> se_systemtime_privilege = 12 <br/> hour = 13 <br/> hour = 14 <br/> se_create_pagefile_privilege = 15 <br/> se_create_permanent_privilege = 16 <br/se_backup_privilege = 17 <br/> se_restore_privilege = 18 <br/> se_shutdown_privilege = 19 <br/> priority = 20 <br/> priority = 21 <br/> priority = 22 <br /> se_change_policy_privillege = 23 <br/> hour = 24 <br/> se_undock_privilege = 25 <br/> hour = 26 <br/> hour = 27 <br/> se_manage_volume_privilege = 28 <br/> se_impersonate_privilege = 29 <br/> se_create_global_privilege = 30 <br/> se_max_well_known_privilege = se_create_global_privilege <br/> end Enum

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.