3.1.5.2 OpenCurrentUser (Opnum 1)
The OpenCurrentUser method is called by the client. In response, the server opens a handle to the HKEY_CURRENT_USER key. The server MUST determine which subkey of HKEY_USERS is the correct key to map to HKEY_CURRENT_USER, as explained in section 3.1.1.8.
-
error_status_t OpenCurrentUser( [in, unique] PREGISTRY_SERVER_NAME ServerName, [in] REGSAM samDesired, [out] PRPC_HKEY phKey );
ServerName: SHOULD be sent as NULL, and MUST be ignored on receipt because the binding to the server is already complete at this stage.
samDesired: A bit field that describes the wanted security access for the key. It MUST be constructed from one or more of the values that are specified in section 2.2.3.
phKey: A pointer to an RPC context handle for the root key, HKEY_CURRENT_USER, as specified in section 3.1.1.7. The handle is found in the handle table (HANDLETABLE).
Return Values: The method returns 0 (ERROR_SUCCESS) to indicate success; otherwise, it returns a nonzero error code as specified in [MS-ERREF] section 2.2. The most common error codes are listed in the following table.
-
Return value/code
Description
0x00000005
ERROR_ACCESS_DENIED
Access is denied.
0x00000013
ERROR_WRITE_PROTECT
A read or write operation was attempted to a volume after it was dismounted. The server can no longer service registry requests because server shutdown has been initiated (SHUTDOWNINPROGRESS is set to TRUE).
Server Operations
If the registry server can no longer service registry requests because server shutdown has been initiated (SHUTDOWNINPROGRESS is set to TRUE), the server MUST return ERROR_WRITE_PROTECT.
The server MUST determine which subkey of the HKEY_USERS predefined key is mapped as the HKEY_CURRENT_USER key, as defined in section 3.1.1.8.
The server attempts to open the root key, HKEY_CURRENT_USER, and return a handle to that key in the phKey parameter.
The server MUST evaluate the security descriptor that is associated with the key against the requested access that is expressed in the samDesired parameter to determine whether the caller can open this key.
If the caller is permitted to open the key, the server MUST return 0 to indicate success, and create a new valid context handle. The server MUST store the context handle value in the handle table (HANDLETABLE) along with a mapping to the HKEY_CURRENT_USER key. The server MUST place the context handle in the phKey parameter. If the caller does not have access, the server MUST return ERROR_ACCESS_DENIED.
The server MUST validate the value of the samDesired parameter set by the client. If the value of samDesired includes flags set which are not listed in section 2.2.3, the server MUST return ERROR_INVALID_PARAMETER.