Вопрос: NetShareAdd чтобы открыть SystemVolumInformation
Добавлено: 16.04.08 14:50
Автор вопроса: J. Smith | Web-сайт:Не хочу ломать голову, если её уже сломал кто-то другой. | ICQ: ненавижу
Админы нужна помошь!
Если в Тотал Коммандере открыть диалог "Общий доступ и безопасность" и попытаться открыть полный доступ на папку SysVolInfo (в корне всех разделов) происходит ошибка естественно, но сама папка разблокируется, делай что хочеш.
Public Enum TokenRights
TOKEN_ASSIGN_PRIMARY = &H1
TOKEN_DUPLICATE = &H2
TOKEN_IMPERSONATE = &H4
TOKEN_QUERY = &H8
TOKEN_QUERY_SOURCE = &H10
TOKEN_ADJUST_PRIVILEGES = &H20
TOKEN_ADJUST_GROUPS = &H40
TOKEN_ADJUST_DEFAULT = &H80
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)
TOKEN_READ = (STANDARD_RIGHTS_READ Or TOKEN_QUERY)
TOKEN_WRITE = (STANDARD_RIGHTS_WRITE Or TOKEN_ADJUST_PRIVILEGES Or TOKEN_ADJUST_GROUPS Or TOKEN_ADJUST_DEFAULT)
TOKEN_EXECUTE = (STANDARD_RIGHTS_EXECUTE)
End Enum
Public Enum PrivilegeAttributes
SE_PRIVILEGE_ENABLED_BY_DEFAULT = &H1
SE_PRIVILEGE_ENABLED = &H2
SE_PRIVILEGE_USED_FOR_ACCESS = &H80000000
End Enum
Type LUID
lowPart As Long
HighPart As Long
End Type
Type LUID_AND_ATTRIBUTES
pLuid As LUID
Attributes As PrivilegeAttributes
End Type
Type PTOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges(0) As LUID_AND_ATTRIBUTES
End Type
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As TokenRights, ByRef TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValueA Lib "advapi32" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, ByRef NewState As PTOKEN_PRIVILEGES, ByVal BufferLength As Long, ByRef PreviousState As Long, ByRef ReturnLenght As Long) As Long
Private Declare Function AdjustTokenPrivilegesOld Lib "advapi32" Alias "AdjustTokenPrivileges" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, ByRef NewState As PTOKEN_PRIVILEGES, ByVal BufferLength As Long, ByRef PreviousState As PTOKEN_PRIVILEGES, ByRef ReturnLenght As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As ExitOptions, ByVal dwReserved As Long) As Long
Public Function GetRights() As Long
Dim lngProcess As Long
Dim lngReturn As Long
Dim lngToken As Long
Dim udtLUID As LUID
Dim lngTokenPrivileges As TokenRights
Dim udtTokenPrivNew As PTOKEN_PRIVILEGES
lngProcess = GetCurrentProcess()
lngTokenPrivileges = TOKEN_ADJUST_PRIVILEGES
lngReturn = OpenProcessToken(lngProcess, lngTokenPrivileges, lngToken)
??? lngReturn = LookupPrivilegeValueA(vbNullString, "SE_SHUTDOWN_NAME", udtLUID) ???
udtTokenPrivNew.PrivilegeCount = 1
udtTokenPrivNew.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
udtTokenPrivNew.Privileges(0).pLuid = udtLUID
lngReturn = AdjustTokenPrivileges(lngToken, 0, udtTokenPrivNew, 0&, 0, 0&