CmUpdateDevicePanel

NTSTATUS __stdcall CmUpdateDevicePanel(
        INT64 a1,
        const WCHAR *a2,
        INT64 a3,
        INT64 a4,
        INT64 a5,
        INT64 _188,
        INT64 _190,
        INT64 _198,
        INT64 a9,
        INT64 a10,
        INT64 a11,
        INT64 a12,
        INT64 a13,
        INT64 a14,
        INT64 a15){
  HPNPCTX *v15; 
  _DWORD *v16; 
  VOID **v17; 
  INT64 v18; 
  NTSTATUS DevicePanelPldProperty; 
  NTSTATUS ParentDeviceContainerId; 
  VOID **v23; 
  NTSTATUS ObjectProperty; 
  PVOID v25; 
  unsigned __int16 *v26; 
  _DWORD *v27; 
  NTSTATUS v28; 
  __int64 v30; 
  int v31; 
  VOID **PoolWithTag; 
  int v33; 
  unsigned int v34; 
  UINT64 i; 
  VOID **v36; 
  PVOID v37; 
  const __int64 *v38; 
  int v39; 
  __int64 v40; 
  NTSTATUS v41; 
  __int64 v42; 
  INT64 v43; 
  INT64 v44; 
  unsigned int v45; 
  INT64 v46; 
  int v47; 
  NTSTATUS v48; 
  unsigned int v49; 
  int v50; 
  unsigned int v51; 
  int v52; 
  __int64 v53; 
  WCHAR *v54; 
  INT64 v55; 
  int v56; 
  __int64 v57; 
  int v58; 
  __int64 v59; 
  unsigned int v60; 
  unsigned int v61; 
  unsigned int v62; 
  unsigned int v63; 
  char v64; 
  __int16 v65; 
  PVOID v66; 
  _DWORD v67[4]; 
  PVOID P; 
  INT64 v69; 
  INT64 a8; 
  unsigned int v71; 
  __int64 v72; 
  unsigned int v73; 
  INT64 a7; 
  PVOID v75; 
  PVOID v76; 
  INT64 v77; 
  INT64 a6; 
  UINT8 PropertyBuffer[16]; 
  _DEVPROPKEY PropertyKey; 
  INT64 v81[2]; 
  int v82; 

  v15 = (HPNPCTX *)*(&stru_140CF2E80 + 607);
  a6 = 0i64;
  a8 = 0i64;
  a7 = 0i64;
  v76 = 0i64;
  v16 = 0i64;
  v71 = 0;
  v17 = 0i64;
  v66 = 0i64;
  v18 = 0i64;
  *(_OWORD *)PropertyBuffer = 0i64;
  v69 = 0i64;
  P = 0i64;
  v75 = 0i64;
  v65 = 0;
  memset(&PropertyKey, 0, sizeof(PropertyKey));
  *(_OWORD *)v81 = 0i64;
  v82 = 0;
  v77 = 0i64;
  v64 = 0;
  v63 = 0;
  v72 = 0i64;
  LOBYTE(v67[0]) = 0;
  v67[1] = 0;
  v67[2] = 1;
  if( CmIsRootDevice((WCHAR *)a2) )
    return -1073741637;
  DevicePanelPldProperty = CmQueryDevicePanelPldProperty(
                             v15,
                             (WCHAR *)a2,
                             1,
                             (VOID *)a3,
                             (_DEVPROPKEY *)&DEVPKEY_Device_PhysicalDeviceLocation,
                             (INT64)&a6,
                             (INT64)&a7 + 4,
                             (INT64)&a8,
                             (INT64)&a7);
  ParentDeviceContainerId = DevicePanelPldProperty;
  if( DevicePanelPldProperty == -1073741275 )
  {
    a8 = 0i64;
    goto LABEL_4;
  }
  if( DevicePanelPldProperty >= 0 )
  {
    v16 = (_DWORD *)a8;
    if( !a8 )
      goto LABEL_4;
    ParentDeviceContainerId = CmGetParentDeviceContainerId(v15, (WCHAR *)a2, PropertyBuffer);
    if( ParentDeviceContainerId >= 0 )
    {
      HIBYTE(v65) = 1;
      LODWORD(v69) = CmGetDevicePanelGroup((INT64)v16);
      v31 = 0;
      if( ((v16[2] >> 3) & 7) != 7 )
        v31 = dword_14001F7D0[(v16[2] >> 3) & 7];
      HIDWORD(v69) = v31;
      PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x72ui64, 1380994640i64);
      v17 = PoolWithTag;
      if( PoolWithTag )
      {
        CmBuildDevicePanelId((INT64 *)PropertyBuffer, (unsigned int)v69, HIDWORD(v69), (WCHAR *)PoolWithTag);
        ParentDeviceContainerId = v33;
        if( v33 < 0 )
          goto LABEL_26;
        v34 = 16;
        for( i = 16i64; ; i = v67[1] )
        {
          v73 = v34;
          v36 = ExAllocatePoolWithTag(1ui64, i, 1380994640i64);
          v66 = v36;
          if( !v36 )
            goto LABEL_98;
          ParentDeviceContainerId = PnpGetObjectProperty(
                                      (ULONG)v15,
                                      (INT64)a2,
                                      1i64,
                                      a3,
                                      0i64,
                                      (INT64)&DEVPKEY_Device_PhysicalDeviceLocationSpatial,
                                      (INT64)&v67[2],
                                      (INT64)v36);
          if( ParentDeviceContainerId != -1073741789 )
            goto LABEL_63;
          if( v67[1] <= v73 )
            break;
          ExFreePoolWithTag(v66, 0);
          v34 = v67[1];
        }
        ParentDeviceContainerId = -1073741823;
LABEL_63:
        if( ParentDeviceContainerId == -1073741275 )
        {
          v37 = v66;
        }
        else
        {
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v37 = v66;
        }
        ExFreePoolWithTag(v37, 0);
        v66 = 0i64;
LABEL_4:
        v23 = ExAllocatePoolWithTag(1ui64, 0x72ui64, 1380994640i64);
        P = v23;
        if( !v23 )
        {
LABEL_98:
          ParentDeviceContainerId = -1073741801;
          goto LABEL_26;
        }
        ObjectProperty = PnpGetObjectProperty(
                           (ULONG)v15,
                           (INT64)a2,
                           1i64,
                           a3,
                           0i64,
                           (INT64)&DEVPKEY_Device_PanelId,
                           (INT64)&v67[2],
                           (INT64)v23);
        ParentDeviceContainerId = ObjectProperty;
        if( ObjectProperty != -1073741275 && ObjectProperty < 0 )
          goto LABEL_26;
        ExFreePoolWithTag(P, 0);
        v25 = 0i64;
        P = 0i64;
        if( !v17 )
          goto LABEL_7;
        LOBYTE(v65) = 1;
        v30 = -1i64;
        do
          ++v30;
        while( *((_WORD *)v17 + v30) );
        ParentDeviceContainerId = PnpSetObjectProperty(
                                    (INT64)v15,
                                    (INT64)a2,
                                    1u,
                                    a3,
                                    0i64,
                                    (__int64)&DEVPKEY_Device_PanelId,
                                    18,
                                    (__int64)v17,
                                    2 * (int)v30 + 2,
                                    0);
        if( ParentDeviceContainerId < 0 )
          goto LABEL_26;
        ParentDeviceContainerId = PnpSetObjectProperty(
                                    (INT64)v15,
                                    (INT64)a2,
                                    1u,
                                    a3,
                                    0i64,
                                    (__int64)&DEVPKEY_Device_PanelGroup,
                                    7,
                                    (__int64)&v69,
                                    4,
                                    0);
        if( ParentDeviceContainerId < 0 )
          goto LABEL_26;
        ParentDeviceContainerId = PnpSetObjectProperty(
                                    (INT64)v15,
                                    (INT64)a2,
                                    1u,
                                    a3,
                                    0i64,
                                    (__int64)&DEVPKEY_Device_PanelSide,
                                    7,
                                    (__int64)&v69 + 4,
                                    4,
                                    0);
        if( ParentDeviceContainerId < 0 )
          goto LABEL_26;
        v25 = P;
        if( v16 )
        {
          v63 = (unsigned __int16)v16[1];
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelWidth,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v63 = *((unsigned __int16 *)v16 + 3);
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelHeight,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v25 = P;
          if( P )
            PnpSetObjectProperty(
              (INT64)v15,
              (INT64)a2,
              1u,
              a3,
              0i64,
              (__int64)&DEVPKEY_Device_PanelLength,
              0,
              0i64,
              0,
              0);
        }
        else if( P )
        {
          PnpSetObjectProperty((INT64)v15, (INT64)a2, 1u, a3, 0i64, (__int64)&DEVPKEY_Device_PanelWidth, 0, 0i64, 0, 0);
          PnpSetObjectProperty((INT64)v15, (INT64)a2, 1u, a3, 0i64, (__int64)&DEVPKEY_Device_PanelHeight, 0, 0i64, 0, 0);
          PnpSetObjectProperty((INT64)v15, (INT64)a2, 1u, a3, 0i64, (__int64)&DEVPKEY_Device_PanelLength, 0, 0i64, 0, 0);
        }
        if( !v16 || *((_WORD *)v16 + 9) == 0xFFFF || (unsigned __int16)v16[4] == 0xFFFF )
        {
LABEL_7:
          v26 = (unsigned __int16 *)v66;
          if( !v66 )
          {
            if( !v25 )
            {
LABEL_9:
              if( v17 && v16 )
              {
                if( v26 )
                {
                  v63 = ((*(_DWORD *)v26 >> 5) & 0x1FFu) % 0x168;
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)a2,
                                              1u,
                                              a3,
                                              0i64,
                                              (__int64)&DEVPKEY_Device_PanelRotationX,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_26;
                  v63 = ((*(_DWORD *)v66 >> 14) & 0x1FFu) % 0x168;
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)a2,
                                              1u,
                                              a3,
                                              0i64,
                                              (__int64)&DEVPKEY_Device_PanelRotationY,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_26;
                  v63 = (*(_DWORD *)v66 >> 23) % 0x168u;
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)a2,
                                              1u,
                                              a3,
                                              0i64,
                                              (__int64)&DEVPKEY_Device_PanelRotationZ,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_26;
                  v25 = P;
                  goto LABEL_11;
                }
                v63 = 45 * ((v16[3] >> 19) & 0xFu) % 0x168;
                ParentDeviceContainerId = PnpSetObjectProperty(
                                            (INT64)v15,
                                            (INT64)a2,
                                            1u,
                                            a3,
                                            0i64,
                                            (__int64)&DEVPKEY_Device_PanelRotationZ,
                                            7,
                                            (__int64)&v63,
                                            4,
                                            0);
                if( ParentDeviceContainerId < 0 )
                  goto LABEL_26;
                v25 = P;
                if( !P )
                  goto LABEL_11;
                PnpSetObjectProperty(
                  (INT64)v15,
                  (INT64)a2,
                  1u,
                  a3,
                  0i64,
                  (__int64)&DEVPKEY_Device_PanelRotationX,
                  0,
                  0i64,
                  0,
                  0);
                v38 = &DEVPKEY_Device_PanelRotationY;
              }
              else
              {
                if( !v25 )
                  goto LABEL_11;
                PnpSetObjectProperty(
                  (INT64)v15,
                  (INT64)a2,
                  1u,
                  a3,
                  0i64,
                  (__int64)&DEVPKEY_Device_PanelRotationX,
                  0,
                  0i64,
                  0,
                  0);
                PnpSetObjectProperty(
                  (INT64)v15,
                  (INT64)a2,
                  1u,
                  a3,
                  0i64,
                  (__int64)&DEVPKEY_Device_PanelRotationY,
                  0,
                  0i64,
                  0,
                  0);
                v38 = &DEVPKEY_Device_PanelRotationZ;
              }
              PnpSetObjectProperty((INT64)v15, (INT64)a2, 1u, a3, 0i64, (__int64)v38, 0, 0i64, 0, 0);
LABEL_11:
              if( !v17 || !v16 || (*v16 & 0x80u) != 0 )
              {
                if( v25 )
                  PnpSetObjectProperty(
                    (INT64)v15,
                    (INT64)a2,
                    1u,
                    a3,
                    0i64,
                    (__int64)&DEVPKEY_Device_PanelColor,
                    0,
                    0i64,
                    0,
                    0);
LABEL_14:
                if( v17 && v16 )
                {
                  v39 = 0;
                  v40 = (v16[2] >> 10) & 0xF;
                  if( (unsigned int)v40 < 9 )
                    v39 = dword_14001F7F0[v40];
                  v63 = v39;
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)a2,
                                              1u,
                                              a3,
                                              0i64,
                                              (__int64)&DEVPKEY_Device_PanelShape,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_26;
                  v25 = P;
                }
                else if( v25 )
                {
                  PnpSetObjectProperty(
                    (INT64)v15,
                    (INT64)a2,
                    1u,
                    a3,
                    0i64,
                    (__int64)&DEVPKEY_Device_PanelShape,
                    0,
                    0i64,
                    0,
                    0);
                }
                if( v17 && v16 )
                {
                  LOBYTE(v67[0]) = -((v16[2] & 1) != 0);
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)a2,
                                              1u,
                                              a3,
                                              0i64,
                                              (__int64)&DEVPKEY_Device_PanelVisible,
                                              17,
                                              (__int64)v67,
                                              1,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_26;
                }
                else if( v25 )
                {
                  PnpSetObjectProperty(
                    (INT64)v15,
                    (INT64)a2,
                    1u,
                    a3,
                    0i64,
                    (__int64)&DEVPKEY_Device_PanelVisible,
                    0,
                    0i64,
                    0,
                    0);
                }
                if( v17 )
                {
                  if( (_BYTE)v65 )
                  {
                    v41 = CmAddPanelDevice(v15, v17, (INT64)a2);
                    ParentDeviceContainerId = v41;
                    if( v41 < 0 )
                      goto LABEL_26;
                  }
                }
                v27 = 0i64;
                PropertyKey.pid = 2;
                PropertyKey.fmtid = (_GUID)DEVPKEY_Device_PhysicalDeviceLocationPanel;
                v82 = 2;
                *(_OWORD *)v81 = DEVPKEY_Device_PhysicalDeviceLocationJoint;
                while( 2 )
                {
                  v28 = CmQueryDevicePanelPldProperty(
                          v15,
                          (WCHAR *)a2,
                          1,
                          (VOID *)a3,
                          &PropertyKey,
                          (INT64)&a6,
                          (INT64)&a7 + 4,
                          (INT64)&a8,
                          (INT64)&a7);
                  ParentDeviceContainerId = v28;
                  if( v28 == -1073741275 )
                  {
                    ParentDeviceContainerId = 0;
                    goto LABEL_24;
                  }
                  if( v28 < 0 )
                    goto LABEL_24;
                  if( !HIBYTE(v65) )
                  {
                    ParentDeviceContainerId = CmGetParentDeviceContainerId(v15, (WCHAR *)a2, PropertyBuffer);
                    if( ParentDeviceContainerId < 0 )
                      goto LABEL_24;
                    HIBYTE(v65) = 1;
                  }
                  LODWORD(v69) = CmGetDevicePanelGroup(a8);
                  v43 = (unsigned int)v69;
                  v44 = 0i64;
                  v45 = (*(_DWORD *)(v42 + 8) >> 3) & 7;
                  if( v45 < 7 )
                    v44 = (unsigned int)dword_14001F7D0[v45];
                  HIDWORD(v69) = v44;
                  if( !v17 )
                  {
                    v17 = ExAllocatePoolWithTag(1ui64, 0x72ui64, 1380994640i64);
                    if( !v17 )
                      break;
                    v43 = (unsigned int)v69;
                    v44 = HIDWORD(v69);
                  }
                  CmBuildDevicePanelId((INT64 *)PropertyBuffer, v43, v44, (WCHAR *)v17);
                  ParentDeviceContainerId = v47;
                  if( v47 < 0 )
                    goto LABEL_24;
                  v48 = CmCreateDevicePanel(v15, (WCHAR *)v17, v46, (VOID **)&v77, &v64);
                  v18 = v77;
                  ParentDeviceContainerId = v48;
                  if( v48 < 0 )
                    goto LABEL_24;
                  v63 = (unsigned __int16)*(_DWORD *)(a8 + 4);
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)v17,
                                              6u,
                                              v77,
                                              0i64,
                                              (__int64)&DEVPKEY_DevicePanel_Width,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_24;
                  v63 = *(unsigned __int16 *)(a8 + 6);
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)v17,
                                              6u,
                                              v18,
                                              0i64,
                                              (__int64)&DEVPKEY_DevicePanel_Height,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_24;
                  if( (*(_DWORD *)a8 & 0x80u) != 0 )
                  {
                    if( !v64 )
                      PnpSetObjectProperty(
                        (INT64)v15,
                        (INT64)v17,
                        6u,
                        v18,
                        0i64,
                        (__int64)&DEVPKEY_DevicePanel_Color,
                        0,
                        0i64,
                        0,
                        0);
                  }
                  else
                  {
                    v63 = (unsigned __int8)BYTE1(*(_DWORD *)a8) | (((*(unsigned __int8 *)(a8 + 3) << 8) | (unsigned __int8)BYTE2(*(_DWORD *)a8)) << 8) | 0xFF000000;
                    ParentDeviceContainerId = PnpSetObjectProperty(
                                                (INT64)v15,
                                                (INT64)v17,
                                                6u,
                                                v18,
                                                0i64,
                                                (__int64)&DEVPKEY_DevicePanel_Color,
                                                7,
                                                (__int64)&v63,
                                                4,
                                                0);
                    if( ParentDeviceContainerId < 0 )
                      goto LABEL_24;
                  }
                  v49 = v71;
                  if( !v27 )
                    v49 = 16;
                  while( 1 )
                  {
                    v71 = v49;
                    if( !v27 )
                    {
                      v76 = ExAllocatePoolWithTag(1ui64, v49, 1380994640i64);
                      v27 = v76;
                      if( !v76 )
                        goto LABEL_203;
                    }
                    ParentDeviceContainerId = PnpGetObjectProperty(
                                                (ULONG)v15,
                                                (INT64)a2,
                                                1i64,
                                                a3,
                                                0i64,
                                                (INT64)v81,
                                                (INT64)&v67[2],
                                                (INT64)v27);
                    if( ParentDeviceContainerId != -1073741789 )
                      goto LABEL_146;
                    if( v67[1] <= v71 )
                      break;
                    ExFreePoolWithTag(v27, 0);
                    v49 = v67[1];
                    v27 = 0i64;
                    v76 = 0i64;
                  }
                  ParentDeviceContainerId = -1073741823;
LABEL_146:
                  if( ParentDeviceContainerId == -1073741275 )
                  {
                    *v27 &= 0xFFFFFFE0;
                  }
                  else
                  {
                    if( ParentDeviceContainerId < 0 )
                      goto LABEL_24;
                    if( v67[2] != 4099 || v67[1] < 0x10u )
                      *v27 &= 0xFFFFFFE0;
                  }
                  if( (*v27 & 0x1F) == 0 )
                  {
                    if( v64 )
                      goto LABEL_202;
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointType,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointSourcePanelEdge,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetPanelId,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetPanelEdge,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointSourcePositionX,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointSourcePositionY,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointSourcePositionZ,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetPositionX,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetPositionY,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetPositionZ,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetRotationX,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetRotationY,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointTargetRotationZ,
                      0,
                      0i64,
                      0,
                      0);
                    PnpSetObjectProperty(
                      (INT64)v15,
                      (INT64)v17,
                      6u,
                      v18,
                      0i64,
                      (__int64)&DEVPKEY_DevicePanel_JointMovementOrientation,
                      0,
                      0i64,
                      0,
                      0);
                    goto LABEL_201;
                  }
                  v50 = 0;
                  v51 = (*v27 >> 5) & 0xF;
                  if( v51 < 5 )
                    v50 = dword_1400401E0[v51];
                  v63 = v50;
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)v17,
                                              6u,
                                              v18,
                                              0i64,
                                              (__int64)&DEVPKEY_DevicePanel_JointType,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_24;
                  v52 = 0;
                  v53 = (*v27 >> 9) & 7;
                  if( (unsigned int)v53 < 5 )
                    v52 = dword_1400401F8[v53];
                  v63 = v52;
                  ParentDeviceContainerId = PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)v17,
                                              6u,
                                              v18,
                                              0i64,
                                              (__int64)&DEVPKEY_DevicePanel_JointSourcePanelEdge,
                                              7,
                                              (__int64)&v63,
                                              4,
                                              0);
                  if( ParentDeviceContainerId < 0 )
                    goto LABEL_24;
                  v54 = (WCHAR *)v75;
                  if( v75
                    || (v75 = ExAllocatePoolWithTag(1ui64, 0x72ui64, 1380994640i64), (v54 = (WCHAR *)v75) != 0i64) )
                  {
                    v55 = 0i64;
                    if( ((*v27 >> 20) & 7) != 7 )
                      v55 = (unsigned int)dword_14001F7D0[(*v27 >> 20) & 7];
                    v63 = v55;
                    CmBuildDevicePanelId((INT64 *)PropertyBuffer, (unsigned __int8)(*v27 >> 12), v55, v54);
                    ParentDeviceContainerId = v56;
                    if( v56 < 0 )
                      goto LABEL_24;
                    v57 = -1i64;
                    do
                      ++v57;
                    while( *((_WORD *)v75 + v57) );
                    ParentDeviceContainerId = PnpSetObjectProperty(
                                                (INT64)v15,
                                                (INT64)v17,
                                                6u,
                                                v18,
                                                0i64,
                                                (__int64)&DEVPKEY_DevicePanel_JointTargetPanelId,
                                                18,
                                                (__int64)v75,
                                                2 * (int)v57 + 2,
                                                0);
                    if( ParentDeviceContainerId < 0 )
                      goto LABEL_24;
                    v58 = 0;
                    v59 = (*v27 >> 23) & 7;
                    if( (unsigned int)v59 < 5 )
                      v58 = dword_1400401F8[v59];
                    v63 = v58;
                    ParentDeviceContainerId = PnpSetObjectProperty(
                                                (INT64)v15,
                                                (INT64)v17,
                                                6u,
                                                v18,
                                                0i64,
                                                (__int64)&DEVPKEY_DevicePanel_JointTargetPanelEdge,
                                                7,
                                                (__int64)&v63,
                                                4,
                                                0);
                    if( ParentDeviceContainerId < 0 )
                      goto LABEL_24;
                    if( *(_WORD *)(a8 + 18) == 0xFFFF || (unsigned __int16)*(_DWORD *)(a8 + 16) == 0xFFFF )
                    {
                      if( !v64 )
                      {
                        PnpSetObjectProperty(
                          (INT64)v15,
                          (INT64)v17,
                          6u,
                          v18,
                          0i64,
                          (__int64)&DEVPKEY_DevicePanel_JointSourcePositionX,
                          0,
                          0i64,
                          0,
                          0);
                        PnpSetObjectProperty(
                          (INT64)v15,
                          (INT64)v17,
                          6u,
                          v18,
                          0i64,
                          (__int64)&DEVPKEY_DevicePanel_JointSourcePositionY,
                          0,
                          0i64,
                          0,
                          0);
                        PnpSetObjectProperty(
                          (INT64)v15,
                          (INT64)v17,
                          6u,
                          v18,
                          0i64,
                          (__int64)&DEVPKEY_DevicePanel_JointSourcePositionZ,
                          0,
                          0i64,
                          0,
                          0);
                      }
                    }
                    else
                    {
                      v63 = *(unsigned __int16 *)(a8 + 18);
                      ParentDeviceContainerId = PnpSetObjectProperty(
                                                  (INT64)v15,
                                                  (INT64)v17,
                                                  6u,
                                                  v18,
                                                  0i64,
                                                  (__int64)&DEVPKEY_DevicePanel_JointSourcePositionX,
                                                  7,
                                                  (__int64)&v63,
                                                  4,
                                                  0);
                      if( ParentDeviceContainerId < 0 )
                        goto LABEL_24;
                      v63 = (unsigned __int16)*(_DWORD *)(a8 + 16);
                      ParentDeviceContainerId = PnpSetObjectProperty(
                                                  (INT64)v15,
                                                  (INT64)v17,
                                                  6u,
                                                  v18,
                                                  0i64,
                                                  (__int64)&DEVPKEY_DevicePanel_JointSourcePositionY,
                                                  7,
                                                  (__int64)&v63,
                                                  4,
                                                  0);
                      if( ParentDeviceContainerId < 0 )
                        goto LABEL_24;
                      if( !v64 )
                        PnpSetObjectProperty(
                          (INT64)v15,
                          (INT64)v17,
                          6u,
                          v18,
                          0i64,
                          (__int64)&DEVPKEY_DevicePanel_JointSourcePositionZ,
                          0,
                          0i64,
                          0,
                          0);
                    }
                    v63 = (unsigned __int16)v27[2];
                    ParentDeviceContainerId = PnpSetObjectProperty(
                                                (INT64)v15,
                                                (INT64)v17,
                                                6u,
                                                v18,
                                                0i64,
                                                (__int64)&DEVPKEY_DevicePanel_JointTargetPositionX,
                                                7,
                                                (__int64)&v63,
                                                4,
                                                0);
                    if( ParentDeviceContainerId >= 0 )
                    {
                      v63 = *((unsigned __int16 *)v27 + 5);
                      ParentDeviceContainerId = PnpSetObjectProperty(
                                                  (INT64)v15,
                                                  (INT64)v17,
                                                  6u,
                                                  v18,
                                                  0i64,
                                                  (__int64)&DEVPKEY_DevicePanel_JointTargetPositionY,
                                                  7,
                                                  (__int64)&v63,
                                                  4,
                                                  0);
                      if( ParentDeviceContainerId >= 0 )
                      {
                        v63 = (unsigned __int16)v27[3];
                        ParentDeviceContainerId = PnpSetObjectProperty(
                                                    (INT64)v15,
                                                    (INT64)v17,
                                                    6u,
                                                    v18,
                                                    0i64,
                                                    (__int64)&DEVPKEY_DevicePanel_JointTargetPositionZ,
                                                    7,
                                                    (__int64)&v63,
                                                    4,
                                                    0);
                        if( ParentDeviceContainerId >= 0 )
                        {
                          v63 = (*((_WORD *)v27 + 7) & 0x1FFu) % 0x168;
                          ParentDeviceContainerId = PnpSetObjectProperty(
                                                      (INT64)v15,
                                                      (INT64)v17,
                                                      6u,
                                                      v18,
                                                      0i64,
                                                      (__int64)&DEVPKEY_DevicePanel_JointTargetRotationZ,
                                                      7,
                                                      (__int64)&v63,
                                                      4,
                                                      0);
                          if( ParentDeviceContainerId >= 0 )
                          {
                            v63 = dword_140040210[(unsigned __int64)(unsigned int)*v27 >> 31];
                            ParentDeviceContainerId = PnpSetObjectProperty(
                                                        (INT64)v15,
                                                        (INT64)v17,
                                                        6u,
                                                        v18,
                                                        0i64,
                                                        (__int64)&DEVPKEY_DevicePanel_JointMovementOrientation,
                                                        7,
                                                        (__int64)&v63,
                                                        4,
                                                        0);
                            if( ParentDeviceContainerId >= 0 )
                            {
                              if( (*v27 & 0x1E0) != 0 && (*v27 & 0x1E0u) <= 0x80 )
                              {
                                v63 = 0;
                                if( (int)PnpSetObjectProperty(
                                            (INT64)v15,
                                            (INT64)v17,
                                            6u,
                                            v18,
                                            0i64,
                                            (__int64)&DEVPKEY_DevicePanel_JointMovementPositionMin,
                                            7,
                                            (__int64)&v63,
                                            4,
                                            0) >= 0 )
                                {
                                  v60 = *((unsigned __int16 *)v27 + 3);
                                  v61 = (unsigned __int16)v27[1];
                                  if( (*v27 & 0x1E0) != 32 )
                                  {
                                    v60 %= 0x168u;
                                    v61 %= 0x168u;
                                  }
                                  LODWORD(v72) = v61 + v60;
                                  if( (int)PnpSetObjectProperty(
                                              (INT64)v15,
                                              (INT64)v17,
                                              6u,
                                              v18,
                                              0i64,
                                              (__int64)&DEVPKEY_DevicePanel_JointMovementPositionMax,
                                              7,
                                              (__int64)&v72,
                                              4,
                                              0) >= 0 )
                                  {
                                    v62 = *((unsigned __int16 *)v27 + 3);
                                    if( (*v27 & 0x1E0) != 32 )
                                      v62 %= 0x168u;
                                    HIDWORD(v72) = v62;
                                    if( (int)PnpSetObjectProperty(
                                                (INT64)v15,
                                                (INT64)v17,
                                                6u,
                                                v18,
                                                0i64,
                                                (__int64)&DEVPKEY_DevicePanel_JointMovementPositionStart,
                                                7,
                                                (__int64)&v72 + 4,
                                                4,
                                                0) >= 0
                                      && (PnpGetObjectProperty(
                                            (ULONG)v15,
                                            (INT64)v17,
                                            6i64,
                                            v18,
                                            0i64,
                                            (INT64)&DEVPKEY_DevicePanel_JointMovementPosition,
                                            (INT64)&v67[2],
                                            (INT64)&v63) < 0
                                       || v67[2] != 7
                                       || v67[1] != 4
                                       || v63 > (unsigned int)v72) )
                                    {
                                      PnpSetObjectProperty(
                                        (INT64)v15,
                                        (INT64)v17,
                                        6u,
                                        v18,
                                        0i64,
                                        (__int64)&DEVPKEY_DevicePanel_JointMovementPosition,
                                        7,
                                        (__int64)&v72 + 4,
                                        4,
                                        0);
                                    }
                                  }
                                }
                                goto LABEL_202;
                              }
                              if( v64 )
                              {
LABEL_202:
                                ++PropertyKey.pid;
                                ++v82;
                                continue;
                              }
LABEL_201:
                              PnpSetObjectProperty(
                                (INT64)v15,
                                (INT64)v17,
                                6u,
                                v18,
                                0i64,
                                (__int64)&DEVPKEY_DevicePanel_JointMovementPositionMin,
                                0,
                                0i64,
                                0,
                                0);
                              PnpSetObjectProperty(
                                (INT64)v15,
                                (INT64)v17,
                                6u,
                                v18,
                                0i64,
                                (__int64)&DEVPKEY_DevicePanel_JointMovementPositionMax,
                                0,
                                0i64,
                                0,
                                0);
                              PnpSetObjectProperty(
                                (INT64)v15,
                                (INT64)v17,
                                6u,
                                v18,
                                0i64,
                                (__int64)&DEVPKEY_DevicePanel_JointMovementPositionStart,
                                0,
                                0i64,
                                0,
                                0);
                              PnpSetObjectProperty(
                                (INT64)v15,
                                (INT64)v17,
                                6u,
                                v18,
                                0i64,
                                (__int64)&DEVPKEY_DevicePanel_JointMovementPosition,
                                0,
                                0i64,
                                0,
                                0);
                              goto LABEL_202;
                            }
                          }
                        }
                      }
                    }
LABEL_24:
                    if( v18 )
                      ZwClose(v18);
                    goto LABEL_26;
                  }
                  break;
                }
LABEL_203:
                ParentDeviceContainerId = -1073741801;
                goto LABEL_24;
              }
              v63 = (unsigned __int8)BYTE1(*v16) | (((*((unsigned __int8 *)v16 + 3) << 8) | (unsigned __int8)BYTE2(*v16)) << 8) | 0xFF000000;
              ParentDeviceContainerId = PnpSetObjectProperty(
                                          (INT64)v15,
                                          (INT64)a2,
                                          1u,
                                          a3,
                                          0i64,
                                          (__int64)&DEVPKEY_Device_PanelColor,
                                          7,
                                          (__int64)&v63,
                                          4,
                                          0);
              if( ParentDeviceContainerId >= 0 )
              {
                v25 = P;
                goto LABEL_14;
              }
LABEL_26:
              if( v17 )
                ExFreePoolWithTag(v17, 0);
              if( P )
                ExFreePoolWithTag(P, 0);
              if( v75 )
                ExFreePoolWithTag(v75, 0);
              v16 = v66;
              goto LABEL_33;
            }
            PnpSetObjectProperty(
              (INT64)v15,
              (INT64)a2,
              1u,
              a3,
              0i64,
              (__int64)&DEVPKEY_Device_PanelPositionX,
              0,
              0i64,
              0,
              0);
            PnpSetObjectProperty(
              (INT64)v15,
              (INT64)a2,
              1u,
              a3,
              0i64,
              (__int64)&DEVPKEY_Device_PanelPositionY,
              0,
              0i64,
              0,
              0);
            PnpSetObjectProperty(
              (INT64)v15,
              (INT64)a2,
              1u,
              a3,
              0i64,
              (__int64)&DEVPKEY_Device_PanelPositionZ,
              0,
              0i64,
              0,
              0);
LABEL_69:
            v26 = (unsigned __int16 *)v66;
            goto LABEL_9;
          }
        }
        else
        {
          v26 = (unsigned __int16 *)v66;
        }
        if( v26 )
        {
          v63 = v26[5];
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelPositionX,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v63 = (unsigned __int16)*((_DWORD *)v66 + 3);
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelPositionY,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v63 = *((unsigned __int16 *)v66 + 7);
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelPositionZ,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v25 = P;
        }
        else
        {
          v63 = *((unsigned __int16 *)v16 + 9);
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelPositionX,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v63 = (unsigned __int16)v16[4];
          ParentDeviceContainerId = PnpSetObjectProperty(
                                      (INT64)v15,
                                      (INT64)a2,
                                      1u,
                                      a3,
                                      0i64,
                                      (__int64)&DEVPKEY_Device_PanelPositionY,
                                      7,
                                      (__int64)&v63,
                                      4,
                                      0);
          if( ParentDeviceContainerId < 0 )
            goto LABEL_26;
          v25 = P;
          if( P )
            PnpSetObjectProperty(
              (INT64)v15,
              (INT64)a2,
              1u,
              a3,
              0i64,
              (__int64)&DEVPKEY_Device_PanelPositionZ,
              0,
              0i64,
              0,
              0);
        }
        goto LABEL_69;
      }
      ParentDeviceContainerId = -1073741801;
    }
    v16 = 0i64;
  }
LABEL_33:
  if( a6 )
    ExFreePoolWithTag((PVOID)a6, 0);
  if( v16 )
    ExFreePoolWithTag(v16, 0);
  if( v76 )
    ExFreePoolWithTag(v76, 0);
  return ParentDeviceContainerId;
}

Referenced by:

No references.