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