IopCreateRegistryKeyEx

NTSTATUS __stdcall IopCreateRegistryKeyEx(
        PVOID *Handle,
        PVOID BaseHandle,
        _UNICODE_STRING *KeyName,
        UINT64 DesiredAccess,
        UINT64 CreateOptions,
        UINT64 *Disposition){
  PVOID *v6; 
  __int64 v7; 
  __int64 v8; 
  int v11; 
  wchar_t *Buffer; 
  unsigned int v14; 
  __int64 Length; 
  wchar_t *v16; 
  wchar_t *v17; 
  char v18; 
  UINT64 v19; 
  UINT64 v20; 
  VOID *Handlea[2]; 
  __int128 v22; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  char v25; 
  UINT64 v26; 
  UINT64 DesiredAccessa; 

  LODWORD(DesiredAccessa) = DesiredAccess;
  *(&ObjectAttributes.Length + 1) = 0;
  v6 = Handle;
  *(&ObjectAttributes.Attributes + 1) = 0;
  v7 = 0i64;
  *Handle = 0i64;
  LODWORD(v26) = 0;
  LODWORD(v8) = 1;
  LODWORD(v19) = CreateOptions;
  ObjectAttributes.RootDirectory = BaseHandle;
  ObjectAttributes.ObjectName = KeyName;
  ObjectAttributes.Length = 48;
  ObjectAttributes.Attributes = 576;
  *(_OWORD *)Handlea = 0i64;
  v22 = 0i64;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v11 = ZwCreateKey(&Handlea[1], (unsigned int)DesiredAccess, &ObjectAttributes, 0i64, 0i64, v19, &v26);
  if( v11 != -1073741772 )
    goto LABEL_2;
  if( BaseHandle )
  {
    Buffer = KeyName->Buffer;
    v14 = 0;
    Length = KeyName->Length;
    Handlea[0] = 0i64;
    v16 = (wchar_t *)((char *)Buffer + Length);
    Handlea[1] = BaseHandle;
    v25 = 1;
    while( 1 )
    {
      if( v14 > 1 )
        ZwClose((_HANDLE)Handlea[v7]);
      v7 = (unsigned int)v8;
      v17 = Buffer;
      v8 = ((_BYTE)v8 - 1) & 1;
      for( Handlea[v8] = 0i64; v17 < v16; ++v17 )
      {
        if( *v17 == 92 )
          break;
      }
      if( (_DWORD)v17 == (_DWORD)Buffer )
        break;
      WORD1(v22) = (_WORD)v17 - (_WORD)Buffer;
      LOWORD(v22) = (_WORD)v17 - (_WORD)Buffer;
      ObjectAttributes.RootDirectory = Handlea[v7];
      ObjectAttributes.ObjectName = (_UNICODE_STRING *)&v22;
      LODWORD(v20) = CreateOptions;
      *((_QWORD *)&v22 + 1) = Buffer;
      ObjectAttributes.Length = 48;
      ObjectAttributes.Attributes = 576;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      v11 = ZwCreateKey(&Handlea[v8], (unsigned int)DesiredAccessa, &ObjectAttributes, 0i64, 0i64, v20, &v26);
      if( v11 < 0 )
        goto LABEL_21;
      ++v14;
      if( v17 == v16 )
        goto LABEL_19;
      Buffer = v17 + 1;
      if( v17 + 1 == v16 )
        goto LABEL_19;
      v18 = v25;
LABEL_20:
      if( !v18 )
      {
LABEL_21:
        if( v14 > 1 )
          ZwClose((_HANDLE)Handlea[v7]);
        v6 = Handle;
LABEL_2:
        if( v11 >= 0 )
        {
          *v6 = Handlea[(unsigned int)v8];
          if( Disposition )
            *(_DWORD *)Disposition = v26;
        }
        return v11;
      }
    }
    v11 = -1073741811;
LABEL_19:
    v18 = 0;
    v25 = 0;
    goto LABEL_20;
  }
  return v11;
}

Referenced by:

IoReportHalResourceUsage
IoSetSystemPartition
IopCreateSecureDeviceClassSettings
IopInitializePlugPlayServices
IopInitializeResourceMap
IopStoreSystemPartitionInformation
IopUpdateSecureDeviceClassState
IopWriteResourceList
NtDisableLastKnownGood
PiDevCfgConfigureSoftwareDevices
PiInitFirmwareResources
PipHardwareConfigInit
PipHardwareConfigTriggerRespecialize
PipInitComputerIds
PipOpenServiceEnumKeys
PnpBuildCmResourceList
PnpOpenCCSPnpRegKey