Compartir a través de


3.1.5.3 OpenLocalMachine (Opnum 2)

The OpenLocalMachine method is called by the client. In response, the server opens a handle to the HKEY_LOCAL_MACHINE predefined key.

 error_status_t OpenLocalMachine(
   [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_LOCAL_MACHINE, 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.

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.

If the server is a 64-bit registry server and supports both the 32-bit and 64-bit key namespaces, as defined in section 3.1.1.4, the server MUST first check if both the KEY_WOW64_64KEY and KEY_WOW64_32KEY bits are set in the samDesired parameter. If both the KEY_WOW64_64KEY and KEY_WOW64_32KEY are set, the server SHOULD<14> fail the method and return ERROR_INVALID_PARAMETER.

The server attempts to open the root key, HKEY_LOCAL_MACHINE, 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 if 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_LOCAL_MACHINE key. The server MUST place the handle value (see 3.1.1.9) in the phKey parameter.

If the caller does not have access, the server MUST return ERROR_ACCESS_DENIED. The server SHOULD return without modification any other error code encountered in servicing the client request in accordance with [MS-ERREF] section 2.2.

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.

The server MUST disregard the samDesired parameter if the samDesired parameter set by the client has bit 0x2 set, indicating permission to create a subkey. The server MUST not allow subkey creation in certain locations of the registry hierarchy. These restrictions are detailed within the Server Operations section of the BaseRegCreateKey method.