CmDeleteInstallerClassMappedPropertyFromRegValue

__int64 __fastcall CmDeleteInstallerClassMappedPropertyFromRegValue(__int64 a1, const WCHAR *a2, char *a3, __int64 a4){
  int v4; 
  char *v5; 
  int v6; 
  DEVPROPKEY **v9; 
  __int64 v10; 
  DEVPROPKEY *v13; 
  DEVPROPKEY **v14; 
  __int64 v15; 
  WCHAR *v16; 
  __int64 v17; 
  int v18; 
  int inited; 
  __int64 v21; 
  HANDLE KeyHandle; 
  HANDLE Handle; 
  struct _UNICODE_STRING DestinationString; 
  v4 = *(_DWORD *)(a4 + 16);
  v5 = 0i64;
  KeyHandle = 0i64;
  v6 = 0;
  Handle = 0i64;
  v9 = &off_140985790;
  v10 = 0i64;
  do
  {
    v13 = *v9;
    v14 = v9;
    if( v4 == (*v9)->pid )
    {
      v15 = *(_QWORD *)a4 - *(_QWORD *)&v13->fmtid.Data1;
      if( *(_QWORD *)a4 == *(_QWORD *)&v13->fmtid.Data1 )
        v15 = *(_QWORD *)(a4 + 8) - *(_QWORD *)v13->fmtid.Data4;
      if( !v15 )
        break;
    }
    v14 = 0i64;
    v10 = (unsigned int)(v10 + 1);
    v9 += 4;
  }
  while( (unsigned int)v10 < 0xD );
  if( !v14 )
    return(unsigned int)-1073741802;
  if( a3 )
  {
LABEL_12:
    v16 = (WCHAR *)v14[2];
    if( *(_DWORD *)(a4 + 16) != 2 )
      goto LABEL_22;
    v17 = *(_QWORD *)a4 - *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1;
    if( *(_QWORD *)a4 == *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1 )
      v17 = *(_QWORD *)(a4 + 8) - *(_QWORD *)DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data4;
    if( v17 )
    {
LABEL_22:
      if( a3 )
        v5 = a3;
    }
    else
    {
      if( a3 )
        v5 = a3;
      v18 = PnpOpenPropertiesKey(a1, v5, 0i64, 2u, 0, v21, &KeyHandle);
      v6 = v18;
      if( v18 == -1073741772 )
      {
        v6 = 0;
        goto LABEL_32;
      }
      if( v18 < 0 )
        goto LABEL_32;
      v5 = (char *)KeyHandle;
    }
    DestinationString = 0i64;
    inited = RtlInitUnicodeStringEx(&DestinationString, v16);
    if( inited >= 0 )
      inited = ZwDeleteValueKey(v5, &DestinationString);
    if( inited != -1073741772 )
    {
      if( inited == -1073741444 )
        goto LABEL_32;
      if( inited < 0 )
      {
        v6 = inited;
        goto LABEL_32;
      }
    }
    DestinationString = 0i64;
    if( (int)RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)&word_1407CF120) >= 0 )
      ZwDeleteValueKey(v5, &DestinationString);
    goto LABEL_32;
  }
  v6 = CmOpenInstallerClassRegKey(a1, a2, v10, (__int64)v9, 2, 0, (__int64)&Handle, 0i64);
  if( v6 >= 0 )
  {
    v5 = (char *)Handle;
    goto LABEL_12;
  }
LABEL_32:
  if( KeyHandle )
    ZwClose(KeyHandle);
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)v6;
}

Referenced by:

CmSetInstallerClassMappedProperty