PnpOpenFirstMatchingSubKey

INT64 __stdcall PnpOpenFirstMatchingSubKey(WCHAR *MultiSzKeyNames, PVOID RootHandle, PVOID *MatchingKeyHandle){
  WCHAR *v4; 
  INT64 result; 
  __int64 v6; 
  struct _UNICODE_STRING DestinationString; 
  struct _OBJECT_ATTRIBUTES ObjectAttributes; 
  PHANDLE KeyHandle; 
  v4 = MultiSzKeyNames;
  DestinationString = 0i64;
  if( !MultiSzKeyNames || !RootHandle || !KeyHandle )
    return 3221225485i64;
  *KeyHandle = 0i64;
  result = 3221225524i64;
  if( *MultiSzKeyNames )
  {
    do
    {
      RtlInitUnicodeString(&DestinationString, v4, (WCHAR)MatchingKeyHandle);
      *(_QWORD *)&ObjectAttributes.Length = 48i64;
      ObjectAttributes.ObjectName = &DestinationString;
      *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
      *KeyHandle = 0i64;
      ObjectAttributes.RootDirectory = RootHandle;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      LODWORD(result) = ZwOpenKey(KeyHandle, 0x20019u, &ObjectAttributes);
      if( (int)result >= 0 )
        break;
      *KeyHandle = 0i64;
      v6 = -1i64;
      do
        ++v6;
      while( v4[v6] );
      v4 += v6 + 1;
    }
    while( *v4 );
  }
  return result;
}

Referenced by:

PiDevCfgConfigureDeviceLocation
PiQueryRemovableDeviceOverride