Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Get API returned structure into userdef. type (VBA O97)

    Hallo,

    I want to retrieve the inheritance properties of a security descriptor (SD) for a registry key. To retrieve the SD i use GetNamedSecurityInfo() which puts a pointer to the SD structure into a passed variable.

    Question #1: How can I transfer the contents of this structure from somewhere in outer(memory)space <img src=/S/confused.gif border=0 alt=confused width=15 height=20> into my variable of user defined type:

    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

    I need to either directly check the SECURITY_DESCRIPTOR.Control value or use GetSecurityDescriptorControl() which seems to need a direct reference to the SD structure.

    Question #2: The WIN32API.TXT file contains the following declaration where it defines "pControl As Integer", but shouldn't that be a Long considering the SECURITY_DESCRIPTOR.Control definition? MSDN Platform SDK says "typedef WORD SECURITY_DESCRIPTOR_CONTROL;".

    Private Declare Function GetSecurityDescriptorControl Lib "advapi32.dll" _
    (pSecurityDescriptor As SECURITY_DESCRIPTOR, _
    pControl As Integer, lpdwRevision As Long) As Long


    Question #3: Where can I get the WINNT.H file for declarations not found in WIN32API.TXT?

    I appreciate any hints. Regards,
    Martin

    ----- And this is how I declare GetNamedSecurityInfo() -----

    Private Declare Function GetNamedSecurityInfo Lib "advapi32.dll" Alias _
    "GetNamedSecurityInfoA" _
    (ByVal ObjName As String, _
    ByVal SE_OBJECT_TYPE As Long, _
    ByVal SecInfo As Long, _
    ByVal pSid As Long, _
    ByVal pSidGroup As Long, _
    pDacl As Long, _
    ByVal pSacl As Long, _
    pSecurityDescriptor As Long) As Long

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Get API returned structure into userdef. type (VBA O97)

    Let me state first that I don't know anything about these API functions; the following is just based on general ideas.

    1. pSecurityDescriptor is (by default) a ByRef argument of GetSecurityDescriptorControl. Its elements will be modified when you call GetSecurityDescriptorControl.

    Sub TestAPI
    Dim MySecurityDescriptor As SECURITY_DESCRIPTOR
    Dim intControl As Integer
    Dim lngRevision As Long
    Dim lngRetVal As Long

    ' Set elements of MySecurityDescriptor as needed to initialize
    With MySecurityDescriptor
    .Control = ...
    ...
    End With

    lngRetVal = GetSecurityDescriptorControl(MySecurityDescriptor, intControl, lngRevision)

    ' Read modified elements of MySecurityDescriptor
    With MySecurityDescriptor
    MsgBox .Control
    ...
    End With
    End Sub

    2. WORD = Integer, DWORD = Long.

    3. No idea. Have you tried Google?

  3. #3
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Get API returned structure into userdef. type (VBA O97)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    Thanks for your answer, Hans.

    Finally I did find WINNT.H at Microsoft, at least I hope so while downloading their 342MB Platform SDK which is located at http://www.microsoft.com/msdownload/platfo...ate/default.htm

    Concerning Q1, I STILL DON'T KNOW how to get the complete SecurityDescriptor data into my variable.

    Martin

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Get API returned structure into userdef. type (VBA O97)

    As I mentioned in my first reply, I don't have any experience with these API functions. Does the following example help?

    NTFS Permissions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •