What OS are you on Vista? If your on vista you probably need to set debug privileges and run as administrator.
Call the function loadPrivilege(SE_Debug_Name)
Module for setting debugPriv
Code:
Module SetDebugPrivileges
Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LUID) As Int32
Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Int32, ByVal DisableAllPrivileges As Int32, ByRef NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Int32, ByRef PreviousState As TOKEN_PRIVILEGES, ByRef ReturnLength As Int32) As Int32
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Int32, ByVal DesiredAccess As Int32, ByRef TokenHandle As Int32) As Int32
Private Declare Function GetCurrentProcess Lib "kernel32.dll" () As Int32
Private Const SE_DEBUG_NAME As String = "SeDebugPrivilege"
Private Const TOKEN_ADJUST_PRIVILEGES As Int32 = &H20
Private Const TOKEN_QUERY As Int32 = &H8
Private Const SE_PRIVILEGE_ENABLED As Int32 = &H2
Private Structure LUID
Dim LowPart As Int32
Dim HighPart As Int32
End Structure
Private Structure LUID_AND_ATTRIBUTES
Dim pLuid As LUID
Dim Attributes As Int32
End Structure
Private Structure TOKEN_PRIVILEGES
Dim PrivilegeCount As Int32
Dim TheLuid As LUID
Dim Attributes As Int32
End Structure
Public Function LoadPrivilege(ByVal Privilege As String) As Boolean
On Error GoTo ErrHandler
Dim ProcHandle As Int32
Dim htoken As Int32
Dim tokenPrivileges As TOKEN_PRIVILEGES
Dim SEDebugNameValue As LUID
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
ProcHandle = GetCurrentProcess()
OpenProcessToken(ProcHandle, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, htoken)
LookupPrivilegeValue("", Privilege, SEDebugNameValue)
With tokenPrivileges
.PrivilegeCount = 1
.TheLuid = SEDebugNameValue
.Attributes = SE_PRIVILEGE_ENABLED
End With
AdjustTokenPrivileges(htoken, False, tokenPrivileges, Len(tokenPrivileges), tkpNewButIgnored, Nothing)
Return True
Exit Function
ErrHandler:
Return False
End Function
End Module