[Reprint] Code for upgrading the process to the debug level

Source: Internet
Author: User

Const standard_rights_required = & hf0000
Const token_assign_primary = & H1
Const token_duplicate = (& H2)
Const token_impersonate = (& h4)
Const token_query = (& H8)
Const token_query_source = (& H10)
Const token_adjust_privileges = (& H20)
Const token_adjust_groups = (& h40)
Const token_adjust_default = (& h80)
Const token_all_access = (standard_rights_required or token_assign_primary or _
Token_duplicate or token_impersonate or token_query or token_query_source or _
Token_adjust_privileges or token_adjust_groups or token_adjust_default)
Const se_privilege_enabled = & H2
Const anysize_array = 1
Private type luid
Lowpart as long
Highpart as long
End type
Private type luid_and_attributes
Pluid as luid
Attributes as long
End type
Private type token_privileges
Privilegecount as long
Privileges (anysize_array) as luid_and_attributes
End type
Private declare function getcurrentprocess lib "Kernel32" () as long
Private declare function lookupprivilegevalue lib "advapi32.dll" alias "lookupprivilegevaluea" (byval lpsystemname as string, byval lpname as string, lpluid as luid) as long
Private declare function using lib "values" (byval tokenhandle as long, byval disableallprivileges as long, newstate as token_privileges, byval bufferlength as long, previusstate as values, returnlength as long) as long
Private declare function openprocesstoken lib "advapi32.dll" (byval processhandle as long, byval desiredaccess as long, tokenhandle as long) as long

Sub adjusttokenprivileges2000 ()
Dim hdlprocesshandle as long
Dim hdltokenhandle as long
Dim tmpluid as luid
Dim tkp as token_privileges
Dim tkpnewbutignored as token_privileges
Dim lbufferneeded as long
Dim LP as long
Hdlprocesshandle = getcurrentprocess ()
Lp = openprocesstoken (hdlprocesshandle, token_all_access, hdltokenhandle)
Lp = lookupprivilegevalue ("", "sedebugprivilege", tmpluid)
Tkp. privilegecount = 1
Tkp. Privileges (0). pluid = tmpluid
Tkp. Privileges (0). Attributes = se_privilege_enabled
Lp = adjusttokenprivileges (hdltokenhandle, false, tkp, Len (tkpnewbutignored), tkpnewbutignored, lbufferneeded)
End sub

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.