PipOpenServiceEnumKeys

NTSTATUS __stdcall PipOpenServiceEnumKeys(
        UNICODE_STRING *ServiceKeyName,
        UINT64 DesiredAccess,
        PVOID *ServiceHandle,
        PVOID *ServiceEnumHandle,
        UINT8 CreateEnum){
  ACCESS_MASK v6; 
  NTSTATUS result; 
  NTSTATUS v10; 
  NTSTATUS v11; 
  __int64 *v12; 
  UINT64 CreateOptions; 
  void *KeyHandle; 
  void *v15; 
  HANDLE Handle; 
  UNICODE_STRING KeyName; 
  struct _OBJECT_ATTRIBUTES ObjectAttributes; 
  Handle = 0i64;
  v15 = 0i64;
  v6 = DesiredAccess;
  KeyName = 0i64;
  result = PnpCtxGetCachedContextBaseKey(PiPnpRtlCtx, 6, (__int64 *)&v15);
  if( result >= 0 )
  {
    *(&ObjectAttributes.Length + 1) = 0;
    memset(&ObjectAttributes.Attributes + 1, 0, 20);
    KeyHandle = 0i64;
    ObjectAttributes.RootDirectory = v15;
    ObjectAttributes.Length = 48;
    ObjectAttributes.Attributes = 576;
    ObjectAttributes.ObjectName = ServiceKeyName;
    result = ZwOpenKey(&KeyHandle, v6, &ObjectAttributes);
    if( result == -1073741772 )
    {
      v12 = 0i64;
      while( 1 )
      {
        if( !v12 )
          v12 = (__int64 *)(PiPnpRtlCtx + 8);
        v12 = (__int64 *)*v12;
        if( v12 == (__int64 *)(PiPnpRtlCtx + 8) || !v12 )
          break;
        result = PnpCtxGetCachedNodeBaseKey(PiPnpRtlCtx, v12, 6ui64, (__int64 *)&v15);
        if( result < 0 )
        {
          if( result != -2147483622 )
            goto LABEL_3;
          break;
        }
        *(&ObjectAttributes.Length + 1) = 0;
        memset(&ObjectAttributes.Attributes + 1, 0, 20);
        KeyHandle = 0i64;
        ObjectAttributes.RootDirectory = v15;
        ObjectAttributes.Length = 48;
        ObjectAttributes.Attributes = 576;
        ObjectAttributes.ObjectName = ServiceKeyName;
        result = ZwOpenKey(&KeyHandle, v6, &ObjectAttributes);
        if( result != -1073741772 )
          goto LABEL_3;
      }
      result = -1073741772;
    }
LABEL_3:
    if( result >= 0 )
    {
      if( ServiceEnumHandle || CreateEnum )
      {
        *(_DWORD *)&KeyName.Length = 655368;
        KeyName.Buffer = (wchar_t *)&stru_1407D01E0.Xmm7;
        if( CreateEnum )
        {
          LODWORD(CreateOptions) = 1;
          v10 = IopCreateRegistryKeyEx(&Handle, KeyHandle, &KeyName, v6, CreateOptions, 0i64);
        }
        else
        {
          *(&ObjectAttributes.Length + 1) = 0;
          memset(&ObjectAttributes.Attributes + 1, 0, 20);
          ObjectAttributes.RootDirectory = KeyHandle;
          ObjectAttributes.ObjectName = &KeyName;
          ObjectAttributes.Length = 48;
          ObjectAttributes.Attributes = 576;
          v10 = ZwOpenKey(&Handle, v6, &ObjectAttributes);
        }
        v11 = v10;
        if( v10 < 0 )
        {
          ZwClose(KeyHandle);
          return v11;
        }
        if( ServiceEnumHandle )
          *ServiceEnumHandle = Handle;
        else
          ZwClose(Handle);
      }
      if( ServiceHandle )
        *ServiceHandle = KeyHandle;
      else
        ZwClose(KeyHandle);
      return 0;
    }
  }
  return result;
}

Referenced by:

IoOpenDriverRegistryKey
PiDevCfgMakeServiceBootStart
PiDevCfgVerifyService
PiProcessDriverInstance
PipApplyFunctionToServiceInstances
PipCallDriverAddDeviceQueryRoutine
PipDmgGetDriverDmarCompatLevel
PipGetDriverKsrGuid
PipHardwareConfigActivateService
PipServiceInstanceToDeviceInstance
PnpDriverLoadingFailed
PpDevCfgInit