CmSetInstallerClassRegPropWorker

__int64 __fastcall CmSetInstallerClassRegPropWorker(
        __int64 a1,
        __int64 a2,
        void *a3,
        int a4,
        int a5,
        __int64 a6,
        ULONG SecurityDescriptorLength,
        __int16 a8){
  int inited; 
  void *v12; 
  int v13; 
  const WCHAR *v14; 
  __int64 v15; 
  __int64 v16; 
  __int64 v17; 
  int v18; 
  char *v19; 
  void *v20; 
  wchar_t *v21; 
  NTSTATUS v22; 
  HANDLE v23; 
  __int64 v25; 
  HANDLE Handle; 
  HANDLE KeyHandle; 
  struct _UNICODE_STRING DestinationString; 
  inited = 0;
  Handle = 0i64;
  KeyHandle = 0i64;
  if( a8 )
    return(unsigned int)-1073741811;
  if( SecurityDescriptorLength )
  {
    v12 = (void *)a6;
    if( !a6 )
      return(unsigned int)-1073741811;
  }
  else
  {
    v12 = 0i64;
  }
  if( (unsigned int)(a4 - 1) > 0x24 || !CmClassPropertyRead(a4) )
    goto LABEL_57;
  if( !CmClassPropertyWrite(v13) )
    return(unsigned int)-1073741790;
  if( a4 == 8 || a4 == 13 )
  {
    v18 = 1;
  }
  else
  {
    if( a4 <= 17 )
      return(unsigned int)-1073741264;
    if( a4 <= 19 )
    {
      v18 = 7;
    }
    else
    {
      if( a4 != 24 )
      {
        if( (unsigned int)(v17 - 26) <= 2 )
        {
          v18 = 4;
          goto LABEL_21;
        }
        return(unsigned int)-1073741264;
      }
      v18 = 3;
    }
  }
LABEL_21:
  if( a5 != v18 )
    return(unsigned int)-1073741811;
  if( a4 == 8 )
  {
    if( SecurityDescriptorLength <= 0x40 )
      goto LABEL_31;
    return(unsigned int)-1073741811;
  }
  if( a4 != 24 || !SecurityDescriptorLength )
  {
LABEL_31:
    if( !a3 )
    {
      inited = CmOpenInstallerClassRegKey(a1, v14, v16, v17, 33554438, 0, (__int64)&Handle, 0i64);
      if( inited < 0 )
        goto LABEL_58;
    }
    if( a4 == 8 || a4 == 13 || a4 <= 19 )
    {
      v20 = a3;
      if( !a3 )
        v20 = Handle;
    }
    else
    {
      v19 = (char *)Handle;
      if( a3 )
        v19 = (char *)a3;
      inited = PnpOpenPropertiesKey(a1, v19, 0i64, 2u, 1, v25, &KeyHandle);
      if( inited < 0 )
        goto LABEL_58;
      v20 = KeyHandle;
    }
    v21 = (wchar_t *)MapCmClassPropertyToRegValue(v15, a4);
    if( v21 )
    {
      if( SecurityDescriptorLength )
      {
        v22 = RegRtlSetValue(v20, v21, a5, v12, SecurityDescriptorLength);
        if( v22 == -1073741444 )
        {
          inited = -1073741772;
          goto LABEL_58;
        }
        if( v22 < 0 )
          inited = v22;
      }
      else
      {
        DestinationString = 0i64;
        inited = RtlInitUnicodeStringEx(&DestinationString, v21);
        if( inited >= 0 )
          inited = ZwDeleteValueKey(v20, &DestinationString);
        if( inited == -1073741772 || inited == -1073741444 )
          inited = -1073741275;
      }
      if( inited >= 0 )
      {
        v23 = Handle;
        if( a3 )
          v23 = a3;
        CmRaisePropertyChangeEvent(a1, a2, 2u, (__int64)v23, a4);
      }
      goto LABEL_58;
    }
LABEL_57:
    inited = -1073741264;
    goto LABEL_58;
  }
  if( RtlValidRelativeSecurityDescriptor(v12, SecurityDescriptorLength, 0i64)
    && (unsigned int)RtlLengthSecurityDescriptor(v12) == SecurityDescriptorLength )
  {
    v14 = (const WCHAR *)a2;
    goto LABEL_31;
  }
  inited = -1073741811;
LABEL_58:
  if( KeyHandle )
    ZwClose(KeyHandle);
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)inited;
}

Referenced by:

CmSetInstallerClassRegProp