PnpGetDeviceLocationStrings

__int64 __fastcall PnpGetDeviceLocationStrings(__int64 a1, __int64 *a2, _DWORD *a3){
  __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  unsigned int v6; 
  __int64 v7; 
  VOID **PoolWithTag; 
  PVOID *v9; 
  __int64 v10; 
  int v11; 
  VOID **v12; 
  VOID **v13; 
  unsigned int v14; 
  int v15; 
  int v16; 
  int v17; 
  unsigned int v18; 
  _WORD *i; 
  __int64 v20; 
  __int64 v21; 
  __int64 v22; 
  size_t v23; 
  VOID **v24; 
  _WORD *v25; 
  unsigned int v26; 
  int v27; 
  char v28; 
  char v29; 
  __int64 v30; 
  __int64 v31; 
  PVOID *v32; 
  size_t v34; 
  VOID **v35; 
  unsigned int v36; 
  char *v37; 
  unsigned int v38; 
  unsigned int v39; 
  unsigned int v40; 
  unsigned int v41; 
  char *v42; 
  char v43; 
  char v44; 
  char v45; 
  unsigned int v46; 
  _WORD *v47; 
  char v48; 
  char v49; 
  __int64 v50; 
  __int64 v51; 
  char *v52; 
  __int64 v53; 
  __int64 v54; 
  __int64 v55; 
  int v56; 
  int v57; 
  unsigned int v58; 
  unsigned int v59; 
  VOID *Src; 
  PVOID P; 
  int v62; 
  unsigned int v63; 
  unsigned int v64; 
  unsigned int v65; 
  unsigned int v66; 
  VOID **v67; 
  VOID **v68; 
  int v69; 
  __int64 v70; 
  __int128 v71; 
  __int128 v72; 
  __int64(__fastcall *v73)(_QWORD, VOID **); 
  __int64 v74; 
  char v75; 
  int v78; 

  v74 = a1;
  v73 = 0i64;
  Src = 0i64;
  LOBYTE(v62) = 0;
  v3 = a1;
  v63 = -1;
  v4 = 0i64;
  v58 = -1;
  v67 = 0i64;
  v71 = 0i64;
  v72 = 0i64;
  if( !a1 || !a2 || !a3 )
    return 3221225485i64;
  v5 = *(&PnpReplaceEvent + 831);
  *a2 = 0i64;
  *a3 = 0;
  if( v3 == v5 )
    return 3221225486i64;
  v6 = 0;
  v7 = v3;
  do
  {
    v7 = *(_QWORD *)(v7 + 16);
    ++v6;
  }
  while( v7 != v5 );
  v66 = v6;
  v70 = v6;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 8i64 * v6, 1970499664i64);
  P = PoolWithTag;
  v9 = PoolWithTag;
  if( PoolWithTag )
  {
    memset(PoolWithTag, 0i64, 8 * v6);
    v10 = 4i64 * v6;
    v11 = 1;
    v12 = ExAllocatePoolWithTag(1ui64, v10, 1970499664i64);
    v68 = v12;
    v13 = v12;
    if( v12 )
    {
      memset(v12, 0i64, v10);
      v78 = 1;
      v14 = 0;
      if( v3 != *(&PnpReplaceEvent + 831) )
      {
        while( 1 )
        {
          v15 = PnpQueryInterface(
                  *(PDEVICE_OBJECT *)(v3 + 32),
                  (_IO_SECURITY_CONTEXT *)&GUID_PNP_LOCATION_INTERFACE,
                  1,
                  0x28u,
                  0i64,
                  &v71);
          if( v15 < 0 )
          {
            v4 = 0i64;
            goto LABEL_53;
          }
          if( v73 )
          {
            Src = 0i64;
            v15 = v73(*((_QWORD *)&v71 + 1), &Src);
            if( v15 < 0 )
              goto LABEL_112;
            if( !Src )
              v15 = -1073741637;
            if( v15 < 0 )
            {
LABEL_112:
              if( Src )
              {
                ExFreePoolWithTag(Src, 0);
                Src = 0i64;
              }
            }
            else
            {
              v16 = 0;
              v17 = 0;
              v18 = 0;
              *((_DWORD *)v13 + v14) = 0;
              for( i = Src; *i; i += v22 + 1 )
              {
                ++v16;
                v20 = -1i64;
                *((_DWORD *)v13 + v14) = v16;
                do
                  ++v20;
                while( i[v20] );
                v17 += v20 + 1;
                v21 = -1i64;
                do
                  ++v21;
                while( i[v21] );
                if( (unsigned int)v21 <= v18 )
                  LODWORD(v21) = v18;
                v18 = v21;
                v22 = -1i64;
                do
                  ++v22;
                while( i[v22] );
              }
              LODWORD(v4) = v18 + v4;
              v23 = 2 * (v17 + 1);
              v78 *= v16;
              v24 = ExAllocatePoolWithTag(1ui64, 2i64 * (unsigned int)(v17 + 1), 1970499664i64);
              *((_QWORD *)P + v14) = v24;
              if( v24 )
              {
                memmove(v24, Src, v23);
                v25 = (_WORD *)*((_QWORD *)P + v14);
                if( *v25 )
                {
                  v26 = v63;
                  LOBYTE(v27) = v62;
                  while( 1 )
                  {
                    v28 = 0;
                    v29 = 0;
                    while( 1 )
                    {
                      if( *v25 == 33 )
                      {
                        v28 = 1;
                        goto LABEL_51;
                      }
                      if( *v25 != 64 )
                        break;
                      v29 = 1;
LABEL_51:
                      ++v25;
                    }
                    v27 = (unsigned __int8)v27;
                    if( v29 )
                      v27 = 1;
                    if( v28 && v26 == -1 )
                      v26 = v14;
                    v30 = -1i64;
                    do
                      ++v30;
                    while( v25[v30] );
                    v25 += v30 + 1;
                    if( !*v25 )
                    {
                      v62 = v27;
                      v3 = v74;
                      v63 = v26;
                      v13 = v68;
                      break;
                    }
                  }
                }
                ++v14;
              }
              else
              {
                v15 = -1073741670;
              }
              ExFreePoolWithTag(Src, 0);
              v6 = v66;
              Src = 0i64;
            }
          }
          else
          {
            v15 = -1073741823;
          }
          if( *((_QWORD *)&v72 + 1) )
            (*((void(__fastcall **)(_QWORD))&v72 + 1))(*((_QWORD *)&v71 + 1));
          if( v15 < 0 )
          {
            v4 = (__int64)v67;
            goto LABEL_53;
          }
          if( v15 == 288 || v14 == v6 )
          {
            LODWORD(v4) = v4 + 1;
LABEL_66:
            v11 = v78;
            break;
          }
          v3 = *(_QWORD *)(v3 + 16);
          LODWORD(v4) = v4 + 1;
          v74 = v3;
          if( v3 == *(&PnpReplaceEvent + 831) )
            goto LABEL_66;
        }
      }
      v15 = 0;
      v69 = 0;
      v34 = 2 * (v11 * v4 + 1);
      v35 = ExAllocatePoolWithTag(1ui64, 2i64 * (unsigned int)(v11 * v4 + 1), 1970499664i64);
      v67 = v35;
      v4 = (__int64)v35;
      if( v35 )
      {
        memset(v35, 0i64, v34);
        v36 = v14 - 1;
        v59 = v14 - 1;
        v37 = (char *)v4;
        v64 = 0;
        v38 = 0;
        if( !v11 )
        {
LABEL_102:
          *(_WORD *)v37 = 0;
          *a2 = v4;
          *a3 = (__int64)&v37[-v4 + 2] >> 1;
          goto LABEL_53;
        }
        v39 = v78;
LABEL_70:
        v40 = v36;
        v65 = v39;
        v41 = v39;
        v75 = 0;
        v42 = v37;
        v43 = 0;
        v44 = 0;
        v45 = 0;
LABEL_71:
        v46 = v38 / (v41 / *((_DWORD *)v68 + v40)) % *((_DWORD *)v68 + v40);
        v47 = (_WORD *)*((_QWORD *)P + v40);
        if( v46 )
        {
          v54 = v46;
          do
          {
            v55 = -1i64;
            do
              ++v55;
            while( v47[v55] );
            v47 += v55 + 1;
            --v54;
          }
          while( v54 );
          v39 = v78;
        }
        v48 = 0;
        v49 = 0;
        while( 1 )
        {
          if( *v47 == 33 )
          {
            v48 = 1;
          }
          else
          {
            if( *v47 != 64 )
            {
              if( v40 == v36 )
              {
                v56 = -1;
                v75 = v48;
                v43 = v48;
                v44 = v48;
                v45 = v48;
                if( v48 )
                  v56 = v40;
                v58 = v56;
              }
              if( v48 )
              {
                if( !(_BYTE)v62 && !v45 )
                  goto LABEL_100;
                v58 = v40;
                v43 = 1;
                v45 = v44 != 0 ? v45 : 0;
              }
              else
              {
                v75 = 0;
              }
              if( v49 )
              {
                v57 = -1;
                v75 = v48;
                v42 = v37;
                v43 = v48;
                v45 = v48;
                if( v48 )
                  v57 = v40;
                v58 = v57;
              }
              v50 = -1i64;
              do
                ++v50;
              while( v47[v50] );
              memmove(v42, v47, 2 * v50);
              v51 = -1i64;
              do
                ++v51;
              while( v47[v51] );
              v52 = &v42[2 * v51];
              if( v40 )
              {
                v53 = (__int64)v68;
                v44 = v75;
                v38 = v64;
                v36 = v59;
                *(_WORD *)v52 = 35;
                v42 = v52 + 2;
                v41 = v65 / *(_DWORD *)(v53 + 4i64 * v40--);
                v65 = v41;
                goto LABEL_71;
              }
              if( !v43 || v45 && v58 <= v63 )
              {
                *(_WORD *)v52 = 0;
                v37 = v52 + 2;
              }
              v36 = v59;
LABEL_100:
              v38 = v64 + 1;
              v64 = v38;
              if( v38 >= v39 )
              {
                v15 = v69;
                v4 = (__int64)v67;
                v13 = v68;
                goto LABEL_102;
              }
              goto LABEL_70;
            }
            v49 = 1;
          }
          ++v47;
        }
      }
      v15 = -1073741670;
LABEL_53:
      v9 = (PVOID *)P;
    }
    else
    {
      v15 = -1073741670;
    }
    if( v66 )
    {
      v31 = v70;
      v32 = v9;
      do
      {
        if( *v32 )
          ExFreePoolWithTag(*v32, 0);
        ++v32;
        --v31;
      }
      while( v31 );
    }
    ExFreePoolWithTag(v9, 0);
    if( v13 )
      ExFreePoolWithTag(v13, 0);
    if( v15 < 0 )
    {
      if( v4 )
        ExFreePoolWithTag((PVOID)v4, 0);
    }
  }
  else
  {
    return(unsigned int)-1073741670;
  }
  return(unsigned int)v15;
}

Referenced by:

PiProcessNewDeviceNode
PiQueryRemovableDeviceOverride