BiOpenKey

INT64 __stdcall BiOpenKey(PVOID ParentHandle, WCHAR *KeyName, UINT64 Access, PVOID *Handle){
  unsigned int v5; 
  unsigned int i; 
  void *KeySecurityDescriptor; 
  void *v10; 
  UINT64 v11; 
  NTSTATUS v12; 
  UINT64 v14; 
  PVOID KeyHandle; 
  PVOID v16; 
  struct _UNICODE_STRING DestinationString; 
  OBJECT_ATTRIBUTES ObjectAttributes; 
  void *v19; 
  v5 = Access;
  v16 = 0i64;
  DestinationString = 0i64;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  for( i = 0; ; ++i )
  {
    KeyHandle = 0i64;
    KeySecurityDescriptor = 0i64;
    RtlInitUnicodeString(&DestinationString, KeyName, Access);
    LODWORD(v10) = BiSanitizeHandle(ParentHandle);
    v19 = v10;
    v5 |= 0x40000u;
    v11 = v5;
    if( (v5 & 0x60019) != v5 )
      v11 = 0x40000i64;
    ObjectAttributes.Length = 48;
    ObjectAttributes.RootDirectory = v10;
    ObjectAttributes.Attributes = 576;
    ObjectAttributes.ObjectName = &DestinationString;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    v12 = BiZwOpenKey(&KeyHandle, v11, &ObjectAttributes);
    if( v12 >= 0 )
    {
      if( (v5 & 0x60019) == v5 )
        goto LABEL_6;
      KeySecurityDescriptor = BiCreateKeySecurityDescriptor(0xF003Fui64);
      v12 = BiZwSetSecurityObject(KeyHandle, v14, KeySecurityDescriptor);
      if( v12 >= 0 )
      {
        v12 = BiZwOpenKey(&v16, v5, &ObjectAttributes);
        if( v12 >= 0 )
        {
          CmSiCloseSection(KeyHandle);
          KeyHandle = v16;
LABEL_6:
          *Handle = KeyHandle;
        }
      }
    }
    if( v12 < 0 && KeyHandle )
      CmSiCloseSection(KeyHandle);
    if( KeySecurityDescriptor )
      ExFreePoolWithTag(KeySecurityDescriptor, 0x4B444342u);
    if( v12 == -1073741443 )
    {
      __debugbreak();
      ParentHandle = v19;
      if( i < 5 )
        continue;
    }
    break;
  }
  return(unsigned int)v12;
}

Referenced by:

BcdEnumerateObjects
BcdGetElementDataWithFlags
BcdOpenObject
BcdSetElementDataWithFlags
BiAddStoreFromFile
BiBuildIdentifierList
BiCleanupLoadedStores
BiCreateObject
BiDeleteElement
BiDeleteKey
BiDeleteRegistryValue
BiGetObjectDescription
BiGetRegistryValue
BiIsPortableWorkspaceBoot
BiOpenStoreKeyFromObject
BiOpenSystemStore
BiSetRegistryValue