CmDeleteInstallerClassMappedPropertyFromRegValue

NTSTATUS __stdcall CmDeleteInstallerClassMappedPropertyFromRegValue(
        HPNPCTX *hPnpCtx,
        WCHAR *ClassGuid,
        VOID *ObjectBaseKey,
        _DEVPROPKEY *PropertyKey){
  unsigned int pid; 
  VOID *v5; 
  int v6; 
  const UINT8 *v9; 
  UINT64 v10; 
  _QWORD *v13; 
  const UINT8 *v14; 
  __int64 v15; 
  WCHAR *v16; 
  __int64 v17; 
  int v18; 
  NTSTATUS inited; 
  _OBJECT_TYPE *v20; 
  _OBJECT_TYPE *v21; 
  VOID **ClassKey; 
  UINT64 *Disposition; 
  VOID *KeyHandle; 
  VOID *Handle; 
  _UNICODE_STRING DestinationString; 

  pid = PropertyKey->pid;
  v5 = 0i64;
  KeyHandle = 0i64;
  v6 = 0;
  Handle = 0i64;
  v9 = &Create;
  v10 = 0i64;
  do
  {
    v13 = *(_QWORD **)v9;
    v14 = v9;
    if( pid == *(_DWORD *)(*(_QWORD *)v9 + 16i64) )
    {
      v15 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *v13;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *v13 )
        v15 = *(_QWORD *)PropertyKey->fmtid.Data4 - v13[1];
      if( !v15 )
        break;
    }
    v14 = 0i64;
    v10 = (unsigned int)(v10 + 1);
    v9 += 32;
  }
  while( (unsigned int)v10 < 0xD );
  if( !v14 )
    return -1073741802;
  if( ObjectBaseKey )
  {
LABEL_12:
    v16 = (WCHAR *)*((_QWORD *)v14 + 2);
    if( PropertyKey->pid != 2 )
      goto LABEL_22;
    v17 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1 )
      v17 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data4;
    if( v17 )
    {
LABEL_22:
      if( ObjectBaseKey )
        v5 = ObjectBaseKey;
    }
    else
    {
      if( ObjectBaseKey )
        v5 = ObjectBaseKey;
      v18 = PnpOpenPropertiesKey((__int64)hPnpCtx, v5, 0i64, 2u, 0, (int)Disposition, (INT64)&KeyHandle);
      v6 = v18;
      if( v18 == -1073741772 )
      {
        v6 = 0;
        goto LABEL_32;
      }
      if( v18 < 0 )
        goto LABEL_32;
      v5 = KeyHandle;
    }
    DestinationString = 0i64;
    inited = RtlInitUnicodeStringEx(&DestinationString, v16);
    if( inited >= 0 )
      inited = ZwDeleteValueKey(v5, &DestinationString, v20);
    if( inited != -1073741772 )
    {
      if( inited == -1073741444 )
        goto LABEL_32;
      if( inited < 0 )
      {
        v6 = inited;
        goto LABEL_32;
      }
    }
    DestinationString = 0i64;
    if( RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)&dword_1407CF120) >= 0 )
      ZwDeleteValueKey(v5, &DestinationString, v21);
    goto LABEL_32;
  }
  LOBYTE(Disposition) = 0;
  LODWORD(ClassKey) = 2;
  v6 = CmOpenInstallerClassRegKey(hPnpCtx, ClassGuid, v10, (UINT8)v9, ClassKey, Disposition);
  if( v6 >= 0 )
  {
    v5 = Handle;
    goto LABEL_12;
  }
LABEL_32:
  if( KeyHandle )
    ZwClose((_HANDLE)KeyHandle);
  if( Handle )
    ZwClose((_HANDLE)Handle);
  return v6;
}

Referenced by:

CmSetInstallerClassMappedProperty