- Код: Выделить всё
Option Explicit
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32.dll" () As Long
Private Declare Function GetTokenInformation Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal TokenInformationClass As Long, TokenInformation As Any, ByVal TokenInformationLength As Long, ReturnLength As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function VirtualAlloc Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFree Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
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
Privilege() As LUID_AND_ATTRIBUTES
End Type
Private Cost PAGE_READWRITE = &H4
Private Cost MEM_COMMIT = &H1000
Private Cost MEM_DECOMMIT = &H8000
Private Sub Form_Load()
Dim hProcess As Long
Dim Priv As Long
Dim Priv_Normal As TOKEN_PRIVILEGES
Dim Temp As Long
Dim Ret As Long
Call OpenProcessToken(GetCurrentProcess, &H8, hProcess)
Call GetTokenInformation(hProcess, 3, ByVal 0, 0, Ret)
Priv = VirtualAlloc(0, Ret, MEM_COMMIT, PAGE_READWRITE)
Call GetTokenInformation(hProcess, 3, Priv, Ret, Ret)
Call CopyMemory(Temp, Priv, 4)
MsgBox Temp
Call VirtualFree(Priv, Ret, MEM_DECOMMIT)
CloseHandle hProcess
End Sub
Данным кодом я планирую показывать (Включеные\Выключеные) привилегии у процесса.
Проблема в том, что VB "киляется" при выполнении строки "Call GetTokenInformation(hProcess, 3, Priv, Ret, Ret)", при чем код я менял по всякому, вобщем пробовал все, но VB "летит" по всякому...
Подскажите, пожалуйста, что я не учел.
Заранее благодарен.