CmGetDeviceMappedPropertyKeys

NTSTATUS __stdcall CmGetDeviceMappedPropertyKeys(
        HPNPCTX *hPnpCtx,
        WCHAR *DeviceInstanceId,
        VOID *ObjectBaseKey,
        UINT8 SkipPresenceCheck,
        _DEVPROPKEY *PropertyKeys,
        UINT64 BufferLength,
        UINT64 *PropertyCount){
  _GUID **v7; 
  NTSTATUS result; 
  unsigned int v10; 
  _GUID *v11; 
  char v12; 
  __int64 v13; 
  __int64 v14; 
  unsigned int v15; 
  int v16; 
  unsigned int v17; 
  unsigned int v18; 
  const _DEVPROPKEY **v19; 
  const _DEVPROPKEY *v20; 
  char v21; 
  __int64 v22; 
  __int64 v23; 
  unsigned int v24; 
  int v25; 
  unsigned int v26; 
  unsigned int v27; 
  const _DEVPROPKEY **v28; 
  const _DEVPROPKEY *v29; 
  char v30; 
  __int64 v31; 
  __int64 v32; 
  unsigned int v33; 
  int v34; 
  unsigned int v35; 
  UINT64 BufferSize; 
  UINT64 PropertyType[9]; 
  HPNPCTX *hPnpCtxa; 
  WCHAR *DeviceInstanceIda; 
  _REPARSE_DATA_BUFFER *ReparseBuffer; 

  ReparseBuffer = (_REPARSE_DATA_BUFFER *)ObjectBaseKey;
  DeviceInstanceIda = DeviceInstanceId;
  hPnpCtxa = hPnpCtx;
  v7 = (_GUID **)&CmDeviceRegPropMap;
  result = 0;
  HIDWORD(PropertyType[0]) = 0;
  *(_DWORD *)PropertyCount = 0;
  v10 = 0;
  LODWORD(PropertyType[0]) = 0;
  while( 1 )
  {
    v11 = *v7;
    v12 = 0;
    if( !*v7 )
      goto LABEL_11;
    if( SkipPresenceCheck )
      goto LABEL_63;
    CmGetDeviceMappedPropertyFromRegProp(
      (_IRP *)hPnpCtx,
      (_FILE_OBJECT *)DeviceInstanceId,
      (_REPARSE_DATA_BUFFER *)ObjectBaseKey);
    if( result == -1073741789 || !result )
    {
      v12 = 1;
    }
    else if( result == -1073741632 )
    {
LABEL_41:
      *(_DWORD *)PropertyCount = 0;
      return result;
    }
    result = 0;
    if( v12 )
    {
LABEL_63:
      if( PropertyKeys )
      {
        v13 = *(unsigned int *)PropertyCount;
        if( (unsigned int)v13 < (unsigned int)BufferLength )
        {
          v14 = v13;
          PropertyKeys[v14].fmtid = *v11;
          PropertyKeys[v14].pid = v11[1].Data1;
        }
      }
      v15 = *(_DWORD *)PropertyCount;
      v16 = -1;
      v17 = *(_DWORD *)PropertyCount + 1;
      if( v17 >= *(_DWORD *)PropertyCount )
        v16 = *(_DWORD *)PropertyCount + 1;
      *(_DWORD *)PropertyCount = v16;
      result = v17 < v15 ? 0xC0000095 : 0;
      if( v17 < v15 )
        break;
    }
    hPnpCtx = hPnpCtxa;
    DeviceInstanceId = DeviceInstanceIda;
LABEL_11:
    ++v10;
    v7 += 3;
    if( v10 >= 0x21 )
      goto LABEL_13;
    ObjectBaseKey = ReparseBuffer;
  }
  *(_DWORD *)PropertyCount = 0;
LABEL_13:
  if( result >= 0 )
  {
    v18 = 0;
    v19 = (const _DEVPROPKEY **)&off_140983E70;
    while( 1 )
    {
      v20 = *v19;
      v21 = 0;
      if( *v19 )
      {
        if( SkipPresenceCheck )
          goto LABEL_64;
        LODWORD(BufferSize) = 0;
        result = CmGetDeviceMappedPropertyFromInstanceKeyRegValue(
                   hPnpCtxa,
                   DeviceInstanceIda,
                   ReparseBuffer,
                   v20,
                   (UINT64 *)((char *)PropertyType + 4),
                   0i64,
                   BufferSize,
                   PropertyType);
        if( result == -1073741789 || !result )
        {
          v21 = 1;
        }
        else if( result == -1073741632 )
        {
          goto LABEL_41;
        }
        result = 0;
        if( v21 )
        {
LABEL_64:
          if( PropertyKeys )
          {
            v22 = *(unsigned int *)PropertyCount;
            if( (unsigned int)v22 < (unsigned int)BufferLength )
            {
              v23 = v22;
              PropertyKeys[v23].fmtid = v20->fmtid;
              PropertyKeys[v23].pid = v20->pid;
            }
          }
          v24 = *(_DWORD *)PropertyCount;
          v25 = -1;
          v26 = *(_DWORD *)PropertyCount + 1;
          if( v26 >= *(_DWORD *)PropertyCount )
            v25 = *(_DWORD *)PropertyCount + 1;
          *(_DWORD *)PropertyCount = v25;
          result = v26 < v24 ? 0xC0000095 : 0;
          if( v26 < v24 )
            break;
        }
      }
      ++v18;
      v19 += 4;
      if( v18 >= 2 )
        goto LABEL_24;
    }
    *(_DWORD *)PropertyCount = 0;
LABEL_24:
    if( result >= 0 )
    {
      v27 = 0;
      v28 = (const _DEVPROPKEY **)&off_140985E60;
      while( 1 )
      {
        v29 = *v28;
        v30 = 0;
        if( SkipPresenceCheck )
          goto LABEL_65;
        LODWORD(BufferSize) = 0;
        result = CmGetDeviceMappedPropertyFromComposite(
                   hPnpCtxa,
                   DeviceInstanceIda,
                   ReparseBuffer,
                   v29,
                   (UINT64 *)((char *)PropertyType + 4),
                   0i64,
                   BufferSize,
                   PropertyType);
        if( result == -1073741789 || !result )
        {
          v30 = 1;
        }
        else if( result == -1073741632 )
        {
          goto LABEL_41;
        }
        result = 0;
        if( v30 )
        {
LABEL_65:
          if( PropertyKeys )
          {
            v31 = *(unsigned int *)PropertyCount;
            if( (unsigned int)v31 < (unsigned int)BufferLength )
            {
              v32 = v31;
              PropertyKeys[v32].fmtid = v29->fmtid;
              PropertyKeys[v32].pid = v29->pid;
            }
          }
          v33 = *(_DWORD *)PropertyCount;
          v34 = -1;
          v35 = *(_DWORD *)PropertyCount + 1;
          if( v35 >= *(_DWORD *)PropertyCount )
            v34 = *(_DWORD *)PropertyCount + 1;
          *(_DWORD *)PropertyCount = v34;
          result = v35 < v33 ? 0xC0000095 : 0;
          if( v35 < v33 )
            break;
        }
        ++v27;
        v28 += 2;
        if( v27 >= 0x1B )
          goto LABEL_34;
      }
      *(_DWORD *)PropertyCount = 0;
LABEL_34:
      if( result >= 0 )
        return(unsigned int)BufferLength < *(_DWORD *)PropertyCount ? 0xC0000023 : 0;
    }
  }
  return result;
}

Referenced by:

CmDeleteDeviceWorker
PnpDispatchDevice