PnpCheckDeviceIdsChanged

__int64 __fastcall PnpCheckDeviceIdsChanged(__int64 a1, void *a2, const WCHAR *a3, int a4, char a5, __int64 a6){
  _BYTE *v6; 
  bool v7; 
  void *v9; 
  int v10; 
  void *PoolWithTag; 
  int DeviceRegProp; 
  const WCHAR *v14; 
  _WORD *v15; 
  __int64 v16; 
  unsigned int v17; 
  __int64 v18; 
  __int64 v19; 
  char *v21; 
  __int64 v22; 
  __int64 v23; 
  __int64 v24; 
  int v25; 
  HANDLE Handle; 
  __int64 v27; 
  SIZE_T NumberOfBytes; 
  int v29; 
  v29 = a4;
  v6 = (_BYTE *)a6;
  v7 = a5 != 0;
  a5 = -a5;
  v9 = a2;
  LODWORD(NumberOfBytes) = 0;
  v10 = -v7;
  v25 = 0;
  Handle = 0i64;
  *(_BYTE *)a6 = 0;
  if( !a2 )
  {
    DeviceRegProp = CmOpenDeviceRegKey(
                      PiPnpRtlCtx,
                      *(const wchar_t **)(a1 + 48),
                      16,
                      0,
                      983103,
                      0,
                      (__int64)&Handle,
                      0i64);
    if( DeviceRegProp < 0 )
      goto LABEL_21;
    v9 = Handle;
  }
  LODWORD(NumberOfBytes) = 512;
  PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x200ui64, 0x75737050ui64);
  if( PoolWithTag )
  {
    DeviceRegProp = CmGetDeviceRegProp(
                      PiPnpRtlCtx,
                      *(const wchar_t **)(a1 + 48),
                      (__int64)v9,
                      v10 + 3,
                      (__int64)&v25,
                      (__int64)PoolWithTag,
                      (__int64)&NumberOfBytes,
                      0);
    if( DeviceRegProp != -1073741789 )
      goto LABEL_4;
    ExFreePoolWithTag(PoolWithTag, 0);
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x75737050ui64);
    if( PoolWithTag )
    {
      DeviceRegProp = CmGetDeviceRegProp(
                        PiPnpRtlCtx,
                        *(const wchar_t **)(a1 + 48),
                        (__int64)v9,
                        v10 + 3,
                        (__int64)&v25,
                        (__int64)PoolWithTag,
                        (__int64)&NumberOfBytes,
                        0);
LABEL_4:
      if( DeviceRegProp < 0 )
      {
        if( DeviceRegProp == -1073741275 )
        {
          DeviceRegProp = 0;
          if( a3 )
          {
            for( *v6 = 1; *a3; a3 += v24 + 1 )
            {
              v24 = -1i64;
              do
                ++v24;
              while( a3[v24] );
            }
          }
        }
        goto LABEL_20;
      }
      if( v25 == 7 )
      {
        if( a3 && v29 == (_DWORD)NumberOfBytes )
        {
          v14 = a3;
          v15 = PoolWithTag;
          if( *a3 )
          {
            while( *v15 )
            {
              v16 = -1i64;
              do
                ++v16;
              while( v14[v16] );
              v17 = v16 + 1;
              v18 = -1i64;
              do
                ++v18;
              while( v15[v18] );
              v19 = (unsigned int)(v18 + 1);
              if( v17 != (_DWORD)v19 || (a6 = v17, v27 = v19, RtlCompareUnicodeStrings((SIZE_T)v14, v17, (BOOL)v15)) )
              {
                *v6 = 1;
                break;
              }
              v14 += a6;
              v15 += v27;
              if( !*v14 )
                break;
            }
          }
          if( !*v6 )
          {
            if( !*v14 && !*v15 )
              goto LABEL_20;
            *v6 = 1;
          }
        }
        else
        {
          *v6 = 1;
        }
        v21 = (char *)PoolWithTag;
        if( (_DWORD)NumberOfBytes )
        {
          do
          {
            if( !*(_WORD *)v21 )
              break;
            v22 = -1i64;
            do
              ++v22;
            while( *(_WORD *)&v21[2 * v22] );
            v21 += 2 * v22 + 2;
          }
          while( 2 * ((v21 - (_BYTE *)PoolWithTag) >> 1) < (unsigned __int64)(unsigned int)NumberOfBytes );
        }
        if( a3 )
        {
          while( *a3 )
          {
            v23 = -1i64;
            do
              ++v23;
            while( a3[v23] );
            a3 += v23 + 1;
          }
        }
        goto LABEL_20;
      }
      DeviceRegProp = -1073741823;
LABEL_20:
      ExFreePoolWithTag(PoolWithTag, 0);
      goto LABEL_21;
    }
  }
  DeviceRegProp = -1073741670;
LABEL_21:
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)DeviceRegProp;
}

Referenced by:

PiProcessNewDeviceNode
PipProcessStartPhase3