Thread: RegCreateKeyEx() function and SecAttr

  1. #1
    Registered User
    Join Date
    Dec 2001

    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
    This is what the documentation says:

    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;



    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.


    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.


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


    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
    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
    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
Website Security Test