cwbe coordinatez:
101
792011
2663954
2663960
2722573

ABSOLUT
KYBERIA
permissions
you: r,
system: public
net: yes

neurons

stats|by_visit|by_K
source
tiamat
commanders
polls

total descendants::
total children::0
show[ 2 | 3] flat


sice vytvarat mutexy s NULL DACL je mierne nebezpecne, pouzil som v jednom VB projekte (uprave existujuceho, inak by som sa VB ani len nechytil) presne tento pristup... tu je zdrojak vytvarania (otvarania) takeho mutexu (pointa je, aby fungoval medzi roznymi usermi):


' WinAPI structures
Private Type ACL
AclRevision As Byte
Sbz1 As Byte
AclSize As Integer
AceCount As Integer
Sbz2 As Integer
End Type

Private Type SECURITY_DESCRIPTOR
Revision As Byte
Sbz1 As Byte
Control As Long
Owner As Long
Group As Long
Sacl As ACL
Dacl As ACL
End Type

Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

' WinAPI constants
Private Const MUTEX_ALL_ACCESS = 2031617
Private Const SECURITY_DESCRIPTOR_REVISION = (1)

' Mutex related WinAPI imports
Private Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (lpMutexAttributes As SECURITY_ATTRIBUTES, ByVal bInitialOwner As Long, ByVal lpName As String) As Long
Private Declare Function OpenMutex Lib "kernel32" Alias "OpenMutexA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Private Declare Function InitializeSecurityDescriptor Lib "advapi32.dll" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal dwRevision As Long) As Long
Private Declare Function SetSecurityDescriptorDacl Lib "advapi32.dll" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal bDaclPresent As Long, pDacl As Long, ByVal bDaclDefaulted As Long) As Long
...
Dim MutexHandle As Long
...
' Opening mutex with NULL DACL
MutexHandle = OpenMutex(MUTEX_ALL_ACCESS, 0, "VBMUTEX05")
If MutexHandle = 0 Then
Select Case Err.LastDllError
Case 2&
' Preparation of NULL SECURITY_DESCRIPTOR
Dim MutexAtts As SECURITY_ATTRIBUTES
MutexAtts.bInheritHandle = False
MutexAtts.nLength = Len(MutexAtts)
Dim SecDesc As SECURITY_DESCRIPTOR
Dim SecInitRes As Boolean
SecInitRes = InitializeSecurityDescriptor(SecDesc, _
SECURITY_DESCRIPTOR_REVISION)
If Not SecInitRes Then
' ERROR initializing SD
Exit Sub
End If
Dim SetSDRes As Boolean
SetSDRes = SetSecurityDescriptorDacl(SecDesc, _
True, ByVal 0&, False)
If Not SetSDRes Then
' ERROR creating DACL-SD
Exit Sub
End If
MutexAtts.lpSecurityDescriptor = VarPtr(SecDesc)

' Creating the mutex with NULL DACL
MutexHandle = CreateMutex(ByVal MutexAtts, 0, "VBMUTEX05")
Case Else
' ERROR: Unknown
Exit Sub
End Select
End If
' SUCCESS
...


zaujimave je na tom podla mna hlavne predavanie lp* parametrov WinAPI funkciam cez VarPtr(NazovPremennej).