RegCreateKeyEx() function and SecAttr

This is a discussion on RegCreateKeyEx() function and SecAttr within the Windows Programming forums, part of the Platform Specific Boards category; RegCreateKeyEx(hKey, SubKey,0,KESPW,REG_OPTION_NON_VOLATILE,KEY_ALL_ACC ESS,SID,&hRegKey, &Result); I know that Win95/98 series will ignore the Security Attribute parameter, but what should I have ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    104

    RegCreateKeyEx() function and SecAttr

    RegCreateKeyEx(hKey, SubKey,0,KESPW,REG_OPTION_NON_VOLATILE,KEY_ALL_ACC ESS,SID,&hRegKey, &Result);

    I know that Win95/98 series will ignore the Security Attribute parameter, but what should I have for the security attribute if I want the funtion to work with the NT/2000/xp series?

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    This is what the documentation says:
    lpSecurityAttributes

    Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpSecurityAttributes is NULL, the handle cannot be inherited.
    Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new key. If lpSecurityAttributes is NULL, the key gets a default security descriptor.
    This is the documentation on SECURITY_ATTRIBUTES
    The SECURITY_ATTRIBUTES structure contains the security descriptor for an object and specifies whether the handle retrieved by specifying this structure is inheritable.

    typedef struct _SECURITY_ATTRIBUTES { // sa
    DWORD nLength;
    LPVOID lpSecurityDescriptor;
    BOOL bInheritHandle;
    } SECURITY_ATTRIBUTES;


    Members

    nLength

    Specifies the size, in bytes, of this structure. Set this value to the size of the SECURITY_ATTRIBUTES structure.

    Windows NT: Some functions that use the SECURITY_ATTRIBUTES structure do not verify the value of the nLength member. However, an application should still set it properly. That ensures current, future, and cross-platform compatibility.

    lpSecurityDescriptor

    Points to a security descriptor for the object that controls the sharing of it. If NULL is specified for this member, the object may be assigned the default security descriptor of the calling process.

    bInheritHandle

    Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle.

    Remarks

    A pointer to a SECURITY_ATTRIBUTES structure is used as a parameter in most kernel and window-management functions in the Win32 API that return a handle of an object.
    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    104
    Thanks,
    I guess what I really need to know is what are the default security settings (descriptors?) in the WinNT/2000/XP series. Is this something that would need to be read from the registry? What I would want is the default security descriptor (setting?) for the local machine in use.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    104
    Oh, never mind if the lpSecurityDescriptor only controls whether "it" can be used by a child process.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21