CmGetDeviceMappedPropertyFromComposite

NTSTATUS __stdcall CmGetDeviceMappedPropertyFromComposite(
        HPNPCTX *hPnpCtx,
        const WCHAR *DeviceInstanceId,
        VOID *ObjectBaseKey,
        const _DEVPROPKEY *PropertyKey,
        UINT64 *PropertyType,
        UINT8 *PropertyBuffer,
        UINT64 BufferSize,
        UINT64 *PropertySize){
  UINT64 *v8; 
  WCHAR *v9; 
  int v11; 
  HPNPCTX *v12; 
  int inited; 
  unsigned int v14; 
  unsigned int pid; 
  unsigned int v16; 
  __int64 v17; 
  WCHAR *v18; 
  __int64 v20; 
  __int64 v21; 
  unsigned int v22; 
  int v23; 
  __int64 v24; 
  int v25; 
  _DWORD *v26; 
  unsigned int v27; 
  __int64 v28; 
  __int64 v29; 
  _DWORD *v30; 
  __int64 v31; 
  __int64 v32; 
  __int64 v33; 
  int v34; 
  NTSTATUS v35; 
  __int64 v36; 
  __int64 v37; 
  _DWORD *v38; 
  __int64 v39; 
  __int64 v40; 
  int v41; 
  __int64 v42; 
  NTSTATUS ObjectProperty; 
  NTSTATUS v44; 
  __int64 v45; 
  __int64 v46; 
  VOID *v47; 
  ULONG v48; 
  __int64 v49; 
  int v50; 
  __int64 v51; 
  __int64 v52; 
  __int64 v53; 
  int DeviceProperty; 
  __int64 v55; 
  __int64 v56; 
  int v57; 
  __int64 v58; 
  int v59; 
  NTSTATUS v60; 
  NTSTATUS DeviceParent; 
  _DWORD *v62; 
  __int64 v63; 
  VOID *v64; 
  VOID *v65; 
  ULONG v66; 
  NTSTATUS v67; 
  INT64 v68; 
  NTSTATUS v69; 
  __int64 v70; 
  int v71; 
  __int64 v72; 
  __int64 v73; 
  __int64 v74; 
  NTSTATUS DeviceSiblings; 
  _DWORD *v76; 
  int v77; 
  __int64 v78; 
  __int64 v79; 
  NTSTATUS DeviceRelationsList; 
  unsigned int v81; 
  UINT64 v82; 
  __int64 v83; 
  _DWORD *v84; 
  __int64 v85; 
  __int64 v86; 
  bool v87; 
  UINT64 *DeviceProblem; 
  UINT64 dwFlags; 
  INT64 v90; 
  INT64 v91; 
  INT64 v92; 
  INT64 v93; 
  _NTSTRSAFE_PCWSTR pszSrc[2]; 
  INT64 v95; 
  UINT64 ParentDeviceInstanceIdLength; 
  UINT64 DeviceStatus; 
  INT64 ProblemStatus; 
  unsigned int v99; 
  VOID *ObjectBaseKeya; 
  _UNICODE_STRING DestinationString; 
  INT64 v102; 
  INT64 v103; 
  UINT64 CmRegPropType; 
  _SIZE_T pcchLength[2]; 
  VOID *DeviceKey; 
  INT64 buf2[2]; 
  __int128 buf1; 
  UINT8 v109[80]; 
  WCHAR ContainerId[40]; 
  UINT64 Flags; 

  v8 = PropertySize;
  v9 = (WCHAR *)PropertyBuffer;
  *(_QWORD *)pszSrc = DeviceInstanceId;
  ObjectBaseKeya = ObjectBaseKey;
  v11 = Flags;
  v12 = hPnpCtx;
  v95 = (INT64)hPnpCtx;
  inited = 0;
  v102 = (INT64)PropertyType;
  ProblemStatus = 0i64;
  v103 = 0i64;
  ParentDeviceInstanceIdLength = 0i64;
  DeviceStatus = 0i64;
  *(_QWORD *)pcchLength = 0i64;
  DeviceKey = 0i64;
  LODWORD(CmRegPropType) = 0;
  LOBYTE(v93) = 0;
  DestinationString = 0i64;
  *(_OWORD *)buf2 = 0i64;
  buf1 = 0i64;
  if( (_WORD)Flags )
    return -1073741811;
  *(_DWORD *)PropertyType = 0;
  *(_DWORD *)v8 = 0;
  v99 = v11 & 0xFFFF0000;
  if( PropertyBuffer )
  {
    v14 = BufferSize;
    v9 = (WCHAR *)(-(__int64)((_DWORD)BufferSize != 0) & (unsigned __int64)PropertyBuffer);
  }
  else
  {
    v14 = 0;
    LODWORD(BufferSize) = 0;
  }
  pid = PropertyKey->pid;
  if( pid < 2 )
    return -1073741264;
  switch( pid )
  {
    case 0xAu:
      v42 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_NAME.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_NAME.fmtid.Data1 )
        v42 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_NAME.fmtid.Data4;
      if( !v42 )
      {
        ObjectProperty = PnpGetObjectProperty(
                           (ULONG)hPnpCtx,
                           (INT64)DeviceInstanceId,
                           1i64,
                           (INT64)ObjectBaseKeya,
                           0i64,
                           (INT64)&DEVPKEY_Device_FriendlyName,
                           (INT64)PropertyType,
                           (INT64)v9);
        inited = ObjectProperty;
        if( !ObjectProperty || ObjectProperty == -1073741789 )
        {
          *(_DWORD *)v8 = ParentDeviceInstanceIdLength;
        }
        else if( ObjectProperty == -1073741275 )
        {
          v18 = *(WCHAR **)pszSrc;
          v44 = PnpGetObjectProperty(
                  (ULONG)v12,
                  *(INT64 *)pszSrc,
                  1i64,
                  (INT64)ObjectBaseKeya,
                  0i64,
                  (INT64)&DEVPKEY_Device_DeviceDesc,
                  v102,
                  (INT64)v9);
          inited = v44;
          if( !v44 || v44 == -1073741789 )
          {
            *(_DWORD *)v8 = ParentDeviceInstanceIdLength;
          }
          else if( v44 == -1073741275 )
          {
            return inited;
          }
          goto LABEL_31;
        }
        goto LABEL_30;
      }
      v74 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_Siblings.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_Siblings.fmtid.Data1 )
        v74 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_Siblings.fmtid.Data4;
      if( v74 )
        return inited;
      HIDWORD(ParentDeviceInstanceIdLength) = v14 >> 1;
      DeviceSiblings = CmGetDeviceSiblings(
                         hPnpCtx,
                         (WCHAR *)DeviceInstanceId,
                         v9,
                         (UINT64 *)((char *)&ParentDeviceInstanceIdLength + 4));
      goto LABEL_244;
    case 0x100u:
      v29 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_InstanceId.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_InstanceId.fmtid.Data1 )
        v29 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_InstanceId.fmtid.Data4;
      if( v29 )
        return inited;
      inited = RtlUnalignedStringCchLengthW(DeviceInstanceId, 200, pcchLength);
      if( inited < 0 )
        goto LABEL_30;
      *(_DWORD *)v8 = 2 * pcchLength[0] + 2;
      *v30 = 18;
      if( v14 < *(_DWORD *)v8 )
        return -1073741789;
      v18 = *(WCHAR **)pszSrc;
      LODWORD(dwFlags) = 2304;
      inited = RtlStringCbCopyExW(v9, *(unsigned int *)v8, *(WCHAR **)pszSrc, 0i64, 0i64, dwFlags);
      if( inited >= 0 )
        goto LABEL_31;
      v76 = (_DWORD *)v102;
      goto LABEL_219;
    case 2u:
      v21 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_DevNodeStatus.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_DevNodeStatus.fmtid.Data1 )
        v21 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_DevNodeStatus.fmtid.Data4;
      if( !v21 )
        goto LABEL_40;
      break;
  }
  if( pid == 3 )
  {
    v51 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ProblemCode.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ProblemCode.fmtid.Data1 )
      v51 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ProblemCode.fmtid.Data4;
    if( !v51 )
    {
LABEL_40:
      inited = CmGetDeviceStatus(
                 v12,
                 DeviceInstanceId,
                 ObjectBaseKeya,
                 &DeviceStatus,
                 (UINT64 *)((char *)&ProblemStatus + 4),
                 &ProblemStatus,
                 v90);
      if( inited < 0 )
        goto LABEL_30;
      v22 = PropertyKey->pid;
      v23 = DeviceStatus;
      if( v22 == 2 )
      {
        v24 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_DevNodeStatus.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_DevNodeStatus.fmtid.Data1 )
          v24 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_DevNodeStatus.fmtid.Data4;
        if( !v24 )
          goto LABEL_45;
      }
      if( v22 != 3 )
        goto LABEL_151;
      v55 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ProblemCode.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ProblemCode.fmtid.Data1 )
        v55 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ProblemCode.fmtid.Data4;
      if( !v55 )
      {
LABEL_45:
        v25 = 7;
      }
      else
      {
LABEL_151:
        if( (DeviceStatus & 0x400) == 0 )
          return -1073741275;
        v25 = 24;
      }
      v26 = (_DWORD *)v102;
      *(_DWORD *)v8 = 4;
      *v26 = v25;
      if( (unsigned int)BufferSize < *(_DWORD *)v8 )
        return -1073741789;
      if( PropertyKey->pid == 12 )
      {
        v73 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ProblemStatus.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ProblemStatus.fmtid.Data1 )
          v73 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ProblemStatus.fmtid.Data4;
        if( !v73 )
        {
          if( PnpGetObjectProperty(
                 v95,
                 *(INT64 *)pszSrc,
                 1i64,
                 (INT64)ObjectBaseKeya,
                 0i64,
                 (INT64)&DEVPKEY_Device_ProblemStatusOverride,
                 (INT64)&DeviceStatus + 4,
                 (INT64)&v103) >= 0
            && HIDWORD(DeviceStatus) == 24 )
          {
            v77 = ProblemStatus;
            if( (_DWORD)ParentDeviceInstanceIdLength == 4 )
              v77 = v103;
            LODWORD(ProblemStatus) = v77;
          }
          v23 = DeviceStatus;
        }
      }
      v27 = PropertyKey->pid;
      if( v27 == 2 )
      {
        v28 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_DevNodeStatus.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_DevNodeStatus.fmtid.Data1 )
          v28 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_DevNodeStatus.fmtid.Data4;
        if( !v28 )
        {
          *(_DWORD *)v9 = v23;
          goto LABEL_53;
        }
      }
      else if( v27 == 3 )
      {
        v56 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ProblemCode.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ProblemCode.fmtid.Data1 )
          v56 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ProblemCode.fmtid.Data4;
        if( !v56 )
        {
          v57 = (v23 & 0x400) != 0 ? HIDWORD(ProblemStatus) : 0;
LABEL_158:
          *(_DWORD *)v9 = v57;
          goto LABEL_53;
        }
      }
      v57 = ProblemStatus;
      goto LABEL_158;
    }
  }
  if( pid == 12 )
  {
    v72 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ProblemStatus.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ProblemStatus.fmtid.Data1 )
      v72 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ProblemStatus.fmtid.Data4;
    if( v72 )
      return inited;
    goto LABEL_40;
  }
  v16 = 4;
  switch( pid )
  {
    case 4u:
      v45 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_EjectionRelations.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_EjectionRelations.fmtid.Data1 )
        v45 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_EjectionRelations.fmtid.Data4;
      if( v45 )
      {
        v46 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_InLocalMachineContainer.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_InLocalMachineContainer.fmtid.Data1 )
          v46 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_InLocalMachineContainer.fmtid.Data4;
        if( v46 )
          return inited;
        v12 = (HPNPCTX *)v95;
        v47 = ObjectBaseKeya;
        v48 = v95;
        *(_DWORD *)PropertyType = 17;
        *(_DWORD *)v8 = 1;
        inited = PnpGetObjectProperty(
                   v48,
                   (INT64)DeviceInstanceId,
                   1i64,
                   (INT64)v47,
                   0i64,
                   (INT64)&DEVPKEY_Device_ContainerId,
                   (INT64)&DeviceStatus + 4,
                   (INT64)buf2);
        if( inited < 0 )
          goto LABEL_30;
        inited = PnpGetObjectProperty(
                   (ULONG)v12,
                   (INT64)L"HTREE\\ROOT\\0",
                   1i64,
                   0i64,
                   0i64,
                   (INT64)&DEVPKEY_Device_BaseContainerId,
                   (INT64)&DeviceStatus + 4,
                   (INT64)&buf1);
        if( inited < 0 )
          goto LABEL_30;
        if( (unsigned int)BufferSize >= *(_DWORD *)v8 )
        {
          *(_BYTE *)v9 = (memcmp(&buf1, buf2, 0x10ui64) != 0) - 1;
          goto LABEL_30;
        }
        return -1073741789;
      }
      goto LABEL_234;
    case 5u:
      v39 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_RemovalRelations.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_RemovalRelations.fmtid.Data1 )
        v39 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_RemovalRelations.fmtid.Data4;
      if( v39 )
      {
        v40 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_IsPresent.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_IsPresent.fmtid.Data1 )
          v40 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_IsPresent.fmtid.Data4;
        if( v40 )
          return inited;
        *(_DWORD *)v8 = 1;
        *(_DWORD *)PropertyType = 17;
        if( v14 < *(_DWORD *)v8 )
          return -1073741789;
        v12 = (HPNPCTX *)v95;
        inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
        if( inited < 0 )
          goto LABEL_30;
        *(_BYTE *)v9 = 0;
        v41 = NtPlugPlayGetDeviceStatus(
                (__int64)v12,
                (__int64)&DestinationString,
                (__int64)&DeviceStatus,
                (__int64)&ProblemStatus + 4,
                (__int64)&ProblemStatus);
        inited = v41;
        if( v41 != -1073741810 )
        {
          v18 = *(WCHAR **)pszSrc;
          if( v41 < 0 )
            goto LABEL_31;
LABEL_101:
          *(_BYTE *)v9 = -1;
          goto LABEL_31;
        }
        return 0;
      }
      v16 = 8;
      goto LABEL_234;
    case 6u:
      v31 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_PowerRelations.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_PowerRelations.fmtid.Data1 )
        v31 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_PowerRelations.fmtid.Data4;
      if( !v31 )
      {
        v16 = 16;
LABEL_234:
        LODWORD(DeviceProblem) = 0;
        DeviceRelationsList = CmGetDeviceRelationsList(
                                (HPNPCTX *)v95,
                                DeviceInstanceId,
                                v16,
                                0i64,
                                (UINT64)DeviceProblem,
                                (UINT64 *)((char *)&ParentDeviceInstanceIdLength + 4),
                                v90);
        inited = DeviceRelationsList;
        if( DeviceRelationsList == -1073741772 || !DeviceRelationsList )
          return -1073741275;
        if( DeviceRelationsList != -1073741789 )
        {
          v12 = (HPNPCTX *)v95;
          goto LABEL_30;
        }
        v76 = (_DWORD *)v102;
        *(_DWORD *)v8 = 2 * HIDWORD(ParentDeviceInstanceIdLength);
        v81 = BufferSize;
        *v76 = 8210;
        if( v81 < *(_DWORD *)v8 )
          return -1073741789;
        v18 = *(WCHAR **)pszSrc;
        v82 = v16;
        v12 = (HPNPCTX *)v95;
        LODWORD(DeviceProblem) = v81 >> 1;
        inited = CmGetDeviceRelationsList(
                   (HPNPCTX *)v95,
                   *(const WCHAR **)pszSrc,
                   v82,
                   v9,
                   (UINT64)DeviceProblem,
                   (UINT64 *)((char *)&ParentDeviceInstanceIdLength + 4),
                   v91);
        if( !inited )
        {
          *(_DWORD *)v8 = 2 * PnpMultiSzGetLen(v9);
          return inited;
        }
LABEL_219:
        *(_DWORD *)v8 = 0;
        *v76 = 0;
        goto LABEL_31;
      }
      v32 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_HasProblem.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_HasProblem.fmtid.Data1 )
        v32 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_HasProblem.fmtid.Data4;
      if( v32 )
        return inited;
      *(_DWORD *)PropertyType = 17;
      *(_DWORD *)v8 = 1;
      if( !v14 )
        return -1073741789;
      inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
      if( inited >= 0 )
      {
        v33 = v95;
        *(_BYTE *)v9 = 0;
        v34 = NtPlugPlayGetDeviceStatus(
                v33,
                (__int64)&DestinationString,
                (__int64)&DeviceStatus,
                (__int64)&ProblemStatus + 4,
                (__int64)&ProblemStatus);
        inited = v34;
        if( v34 == -1073741810 )
          return 0;
        if( v34 >= 0 )
        {
          if( (DeviceStatus & 0x8000) == 0 )
          {
            if( (DeviceStatus & 0x400) == 0
              || HIDWORD(ProblemStatus) <= 0x1D && (v71 = 591396864, _bittest(&v71, HIDWORD(ProblemStatus))) )
            {
              v18 = *(WCHAR **)pszSrc;
              if( (DeviceStatus & 8) == 0 )
              {
                v12 = (HPNPCTX *)v95;
                v35 = PnpGetObjectProperty(
                        v95,
                        *(INT64 *)pszSrc,
                        1i64,
                        (INT64)ObjectBaseKeya,
                        0i64,
                        (INT64)&DEVPKEY_Device_Capabilities,
                        (INT64)&DeviceStatus + 4,
                        (INT64)&v103 + 4);
                inited = v35;
                if( v35 == -1073741275 )
                  return 0;
                if( v35 < 0 )
                  goto LABEL_31;
                if( (v103 & 0x4000000000i64) != 0 )
                  *(_BYTE *)v9 = -1;
              }
LABEL_54:
              v12 = (HPNPCTX *)v95;
              goto LABEL_31;
            }
          }
          *(_BYTE *)v9 = -1;
        }
      }
LABEL_53:
      v18 = *(WCHAR **)pszSrc;
      goto LABEL_54;
    case 7u:
      v78 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_BusRelations.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_BusRelations.fmtid.Data1 )
        v78 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_BusRelations.fmtid.Data4;
      if( v78 )
        return inited;
      v16 = 32;
      goto LABEL_234;
    case 0xBu:
      v79 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_TransportRelations.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_TransportRelations.fmtid.Data1 )
        v79 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_TransportRelations.fmtid.Data4;
      if( v79 )
        return inited;
      v16 = 64;
      goto LABEL_234;
    case 8u:
      v52 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_Parent.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_Parent.fmtid.Data1 )
        v52 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_Parent.fmtid.Data4;
      if( v52 )
      {
        v53 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ReportedDeviceIdsHash.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ReportedDeviceIdsHash.fmtid.Data1 )
          v53 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ReportedDeviceIdsHash.fmtid.Data4;
        if( v53 )
          return inited;
        *(_DWORD *)PropertyType = 7;
        *(_DWORD *)v8 = 4;
        v12 = (HPNPCTX *)v95;
        inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
        if( inited < 0 )
          goto LABEL_30;
        DeviceProperty = NtPlugPlayGetDeviceProperty(
                           v95,
                           (__int64)&DestinationString,
                           0xDu,
                           (__int64)v9,
                           v14,
                           (__int64)&BufferSize);
LABEL_145:
        inited = DeviceProperty;
        if( DeviceProperty == -1073741772 )
          return -1073741275;
        goto LABEL_30;
      }
      v12 = (HPNPCTX *)v95;
      HIDWORD(ParentDeviceInstanceIdLength) = v14 >> 1;
      DeviceParent = CmGetDeviceParent(
                       (HPNPCTX *)v95,
                       (WCHAR *)DeviceInstanceId,
                       v9,
                       (UINT64 *)((char *)&ParentDeviceInstanceIdLength + 4));
      inited = DeviceParent;
      if( DeviceParent && DeviceParent != -1073741789 )
        goto LABEL_30;
      v62 = (_DWORD *)v102;
      *(_DWORD *)v8 = 2 * HIDWORD(ParentDeviceInstanceIdLength);
      *v62 = 18;
      goto LABEL_178;
    case 9u:
      v83 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_Children.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_Children.fmtid.Data1 )
        v83 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_Children.fmtid.Data4;
      if( v83 )
        return inited;
      v12 = (HPNPCTX *)v95;
      HIDWORD(ParentDeviceInstanceIdLength) = v14 >> 1;
      DeviceSiblings = CmGetDeviceChildren(
                         (HPNPCTX *)v95,
                         (WCHAR *)DeviceInstanceId,
                         v9,
                         (UINT64 *)((char *)&ParentDeviceInstanceIdLength + 4));
LABEL_244:
      inited = DeviceSiblings;
      if( DeviceSiblings != -1073741789 && DeviceSiblings )
        goto LABEL_30;
      v84 = (_DWORD *)v102;
      *(_DWORD *)v8 = 2 * HIDWORD(ParentDeviceInstanceIdLength);
      *v84 = 8210;
LABEL_178:
      if( (unsigned int)BufferSize >= *(_DWORD *)v8 )
        goto LABEL_30;
      return -1073741789;
    case 2u:
      v36 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_SafeRemovalRequired.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_SafeRemovalRequired.fmtid.Data1 )
        v36 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_SafeRemovalRequired.fmtid.Data4;
      if( !v36 )
      {
        *(_DWORD *)v8 = 1;
        *(_DWORD *)PropertyType = 17;
        if( v14 >= *(_DWORD *)v8 )
        {
          *(_BYTE *)v9 = -(CmIsDeviceSafeRemovalRequired((HPNPCTX *)v95, (WCHAR *)DeviceInstanceId, ObjectBaseKeya) != 0);
          return inited;
        }
        return -1073741789;
      }
      v37 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_ContainerId.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_ContainerId.fmtid.Data1 )
        v37 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_ContainerId.fmtid.Data4;
      if( v37 )
        return inited;
      v12 = (HPNPCTX *)v95;
      LODWORD(v92) = v11;
      LODWORD(ParentDeviceInstanceIdLength) = 78;
      inited = CmGetDeviceRegProp(
                 (HPNPCTX *)v95,
                 DeviceInstanceId,
                 ObjectBaseKeya,
                 37i64,
                 &CmRegPropType,
                 v109,
                 &ParentDeviceInstanceIdLength,
                 v92);
      if( inited < 0 )
        goto LABEL_30;
      if( wcscmp((PWCHAR)L"{00000000-0000-0000-0000-000000000000}", (PWCHAR)v109) )
      {
        v38 = (_DWORD *)v102;
        *(_DWORD *)v8 = 16;
        *v38 = 13;
        if( (unsigned int)BufferSize >= *(_DWORD *)v8 )
        {
          v18 = *(WCHAR **)pszSrc;
          inited = CmGetDeviceContainerIdFromBase(
                     v12,
                     *(const WCHAR **)pszSrc,
                     (const WCHAR *)v109,
                     ContainerId,
                     (UINT64)DeviceProblem);
          if( inited >= 0 )
          {
            inited = RtlInitUnicodeStringEx(&DestinationString, ContainerId);
            if( inited >= 0 )
              inited = RtlGUIDFromString(&DestinationString, (_GUID *)v9);
          }
          goto LABEL_31;
        }
        return -1073741789;
      }
      return -1073741275;
    case 0xFu:
      v58 = *(_QWORD *)&PropertyKey->fmtid.Data1 - DEVPKEY_Device_IsConnected;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == DEVPKEY_Device_IsConnected )
        v58 = *(_QWORD *)PropertyKey->fmtid.Data4 - 0x293B573F92A15394i64;
      if( v58 )
        return inited;
      *(_DWORD *)PropertyType = 17;
      *(_DWORD *)v8 = 1;
      if( !v14 )
        return -1073741789;
      v12 = (HPNPCTX *)v95;
      inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
      if( inited < 0 )
        goto LABEL_30;
      *(_BYTE *)v9 = 0;
      v59 = NtPlugPlayGetDeviceStatus(
              (__int64)v12,
              (__int64)&DestinationString,
              (__int64)&DeviceStatus,
              (__int64)&ProblemStatus + 4,
              (__int64)&ProblemStatus);
      inited = v59;
      if( v59 != -1073741810 )
      {
        if( v59 >= 0 )
        {
          v18 = *(WCHAR **)pszSrc;
          if( (DeviceStatus & 0x2000000) != 0 )
            goto LABEL_31;
          v60 = PnpGetObjectProperty(
                  (ULONG)v12,
                  *(INT64 *)pszSrc,
                  1i64,
                  0i64,
                  0i64,
                  (INT64)&DEVPKEY_Device_PresenceNotForDevice,
                  (INT64)&DeviceStatus + 4,
                  (INT64)&v93);
          inited = v60;
          if( v60 >= 0 )
          {
            if( HIDWORD(DeviceStatus) == 17 && (_BYTE)v93 == 0xFF )
              goto LABEL_31;
          }
          else
          {
            if( v60 != -1073741275 && v60 != -1073741789 )
              goto LABEL_31;
            inited = 0;
          }
          goto LABEL_101;
        }
        goto LABEL_30;
      }
      return 0;
    case 0x10u:
      v49 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_IsRebootRequired.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_IsRebootRequired.fmtid.Data1 )
        v49 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_IsRebootRequired.fmtid.Data4;
      if( v49 )
        return inited;
      *(_DWORD *)PropertyType = 17;
      *(_DWORD *)v8 = 1;
      if( !v14 )
        return -1073741789;
      v12 = (HPNPCTX *)v95;
      inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
      if( inited < 0 )
        goto LABEL_30;
      *(_BYTE *)v9 = 0;
      v50 = NtPlugPlayGetDeviceStatus(
              (__int64)v12,
              (__int64)&DestinationString,
              (__int64)&DeviceStatus,
              (__int64)&ProblemStatus + 4,
              (__int64)&ProblemStatus);
      inited = v50;
      if( v50 != -1073741810 )
      {
        if( v50 >= 0 && ((DeviceStatus & 0x100) != 0 || (DeviceStatus & 0x400) != 0 && HIDWORD(ProblemStatus) == 14) )
          *(_BYTE *)v9 = -1;
        goto LABEL_30;
      }
      return 0;
    case 0xEu:
      v70 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_Stack.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_Stack.fmtid.Data1 )
        v70 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_Stack.fmtid.Data4;
      if( v70 )
        return inited;
      *(_DWORD *)PropertyType = 8210;
      v12 = (HPNPCTX *)v95;
      inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
      if( inited < 0 )
        goto LABEL_30;
      DeviceProperty = NtPlugPlayGetDeviceProperty(
                         v95,
                         (__int64)&DestinationString,
                         0xEu,
                         (__int64)v9,
                         v14,
                         (__int64)v8);
      goto LABEL_145;
    case 0x14u:
      v85 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_DependencyProviders.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_DependencyProviders.fmtid.Data1 )
        v85 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_DependencyProviders.fmtid.Data4;
      if( v85 )
        return inited;
      *(_DWORD *)PropertyType = 8210;
      v12 = (HPNPCTX *)v95;
      inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
      if( inited < 0 )
        goto LABEL_30;
      DeviceProperty = NtPlugPlayGetDeviceProperty(
                         v95,
                         (__int64)&DestinationString,
                         0xFu,
                         (__int64)v9,
                         v14,
                         (__int64)v8);
      goto LABEL_145;
    case 0x15u:
      v86 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_DependencyDependents.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_DependencyDependents.fmtid.Data1 )
        v86 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_DependencyDependents.fmtid.Data4;
      if( v86 )
        return inited;
      *(_DWORD *)PropertyType = 8210;
      v12 = (HPNPCTX *)v95;
      inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)DeviceInstanceId);
      if( inited < 0 )
        goto LABEL_30;
      DeviceProperty = NtPlugPlayGetDeviceProperty(
                         v95,
                         (__int64)&DestinationString,
                         0x10u,
                         (__int64)v9,
                         v14,
                         (__int64)v8);
      goto LABEL_145;
  }
  if( pid != 26 )
  {
    if( pid != 22 )
      goto LABEL_28;
    v20 = *(_QWORD *)&PropertyKey->fmtid.Data1 - DEVPKEY_Device_CompoundUpperFilters;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == DEVPKEY_Device_CompoundUpperFilters )
      v20 = *(_QWORD *)PropertyKey->fmtid.Data4 - 0x293B573F92A15394i64;
    if( v20 )
    {
LABEL_28:
      if( pid != 23 )
        return inited;
      v17 = *(_QWORD *)&PropertyKey->fmtid.Data1 - DEVPKEY_Device_CompoundLowerFilters;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == DEVPKEY_Device_CompoundLowerFilters )
        v17 = *(_QWORD *)PropertyKey->fmtid.Data4 - 0x293B573F92A15394i64;
      if( v17 )
        return inited;
    }
    v12 = (HPNPCTX *)v95;
    LODWORD(v90) = v14;
    inited = CmGetDeviceCompoundFilters(
               v95,
               (WCHAR *)DeviceInstanceId,
               ObjectBaseKeya,
               (INT64)PropertyKey,
               PropertyType,
               v9,
               v90,
               v8);
    goto LABEL_30;
  }
  v63 = *(_QWORD *)&PropertyKey->fmtid.Data1 - DEVPKEY_Device_OmitFromSystemSpec;
  if( *(_QWORD *)&PropertyKey->fmtid.Data1 == DEVPKEY_Device_OmitFromSystemSpec )
    v63 = *(_QWORD *)PropertyKey->fmtid.Data4 + 0x298AF3586C1A6853i64;
  if( v63 )
    return inited;
  *(_DWORD *)PropertyType = 17;
  *(_DWORD *)v8 = 1;
  if( !v14 )
    return -1073741789;
  v64 = ObjectBaseKeya;
  v12 = (HPNPCTX *)v95;
  v65 = ObjectBaseKeya;
  v66 = v95;
  *(_BYTE *)v9 = 0;
  v67 = PnpGetObjectProperty(
          v66,
          (INT64)DeviceInstanceId,
          1i64,
          (INT64)v65,
          0i64,
          (INT64)&DEVPKEY_Device_UpdateWithUngroupedDrivers,
          (INT64)&DeviceStatus + 4,
          (INT64)&v93);
  inited = v67;
  if( v67 < 0 )
  {
    if( v67 == -1073741275 || v67 == -1073741789 )
      goto LABEL_186;
LABEL_30:
    v18 = *(WCHAR **)pszSrc;
    goto LABEL_31;
  }
  if( HIDWORD(DeviceStatus) == 17 && (_DWORD)ParentDeviceInstanceIdLength == 1 )
  {
    v18 = *(WCHAR **)pszSrc;
    v87 = (_BYTE)v93 == 0;
    goto LABEL_265;
  }
LABEL_186:
  v68 = (INT64)v64;
  v18 = *(WCHAR **)pszSrc;
  v69 = PnpGetObjectProperty(
          (ULONG)v12,
          *(INT64 *)pszSrc,
          1i64,
          v68,
          0i64,
          (INT64)&DEVPKEY_Device_DriverInGroup,
          (INT64)&DeviceStatus + 4,
          (INT64)&v93);
  inited = v69;
  if( v69 < 0 )
  {
    if( v69 == -1073741275 || v69 == -1073741789 )
      inited = 0;
    goto LABEL_31;
  }
  if( HIDWORD(DeviceStatus) == 17 && (_DWORD)ParentDeviceInstanceIdLength == 1 )
  {
    v87 = (_BYTE)v93 == 0xFF;
LABEL_265:
    if( !v87 )
      goto LABEL_31;
    goto LABEL_101;
  }
LABEL_31:
  if( inited != -1073741810 )
    return inited;
  LODWORD(DeviceProblem) = 1;
  inited = CmOpenDeviceRegKey(v12, v18, CM_KEY_TYPE_DEVICE_INSTANCE, 0i64, (UINT64)DeviceProblem, 0, &DeviceKey, 0i64);
  if( !inited )
  {
    ZwClose((_HANDLE)DeviceKey);
    return -1073741275;
  }
  if( inited != -1073741810 && inited != -1073741632 )
    return -1073741823;
  return inited;
}

Referenced by:

CmGetDeviceMappedProperty
CmGetDeviceMappedPropertyKeys