PnpCheckDeviceIdsChanged

__int64 __fastcall PnpCheckDeviceIdsChanged(__int64 a1, VOID *a2, wchar_t *a3, int a4, char a5, __int64 a6){
  _BYTE *v6; 
  bool v7; 
  VOID *v9; 
  int v10; 
  VOID **PropertyBuffer; 
  NTSTATUS DeviceRegProp; 
  wchar_t *v14; 
  WCHAR *v15; 
  __int64 v16; 
  unsigned int v17; 
  __int64 v18; 
  __int64 v19; 
  char *v21; 
  __int64 v22; 
  __int64 v23; 
  __int64 v24; 
  UINT64 *CmRegPropType; 
  UINT64 Flags; 
  UINT64 Flagsa; 
  UINT64 v28; 
  VOID *DeviceKey; 
  __int64 v30; 
  UINT64 NumberOfBytes; 
  int v32; 

  v32 = a4;
  v6 = (_BYTE *)a6;
  v7 = a5 != 0;
  a5 = -a5;
  v9 = a2;
  LODWORD(NumberOfBytes) = 0;
  v10 = -v7;
  LODWORD(v28) = 0;
  DeviceKey = 0i64;
  *(_BYTE *)a6 = 0;
  if( !a2 )
  {
    LODWORD(CmRegPropType) = 983103;
    DeviceRegProp = CmOpenDeviceRegKey(
                      *(&stru_140CF2E80 + 607),
                      *(WCHAR **)(a1 + 48),
                      CM_KEY_TYPE_DEVICE_INSTANCE,
                      0i64,
                      (UINT64)CmRegPropType,
                      0,
                      &DeviceKey,
                      0i64);
    if( DeviceRegProp < 0 )
      goto LABEL_21;
    v9 = DeviceKey;
  }
  LODWORD(NumberOfBytes) = 512;
  PropertyBuffer = ExAllocatePoolWithTag(1ui64, 0x200ui64, 1970499664i64);
  if( PropertyBuffer )
  {
    LODWORD(Flags) = 0;
    DeviceRegProp = CmGetDeviceRegProp(
                      *(&stru_140CF2E80 + 607),
                      *(const WCHAR **)(a1 + 48),
                      v9,
                      (unsigned int)(v10 + 3),
                      &v28,
                      (UINT8 *)PropertyBuffer,
                      &NumberOfBytes,
                      Flags);
    if( DeviceRegProp != -1073741789 )
      goto LABEL_4;
    ExFreePoolWithTag(PropertyBuffer, 0);
    PropertyBuffer = ExAllocatePoolWithTag(1ui64, (unsigned int)NumberOfBytes, 1970499664i64);
    if( PropertyBuffer )
    {
      LODWORD(Flagsa) = 0;
      DeviceRegProp = CmGetDeviceRegProp(
                        *(&stru_140CF2E80 + 607),
                        *(const WCHAR **)(a1 + 48),
                        v9,
                        (unsigned int)(v10 + 3),
                        &v28,
                        (UINT8 *)PropertyBuffer,
                        &NumberOfBytes,
                        Flagsa);
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( (_DWORD)v28 == 7 )
      {
        if( a3 && v32 == (_DWORD)NumberOfBytes )
        {
          v14 = a3;
          v15 = (WCHAR *)PropertyBuffer;
          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, v30 = v19, RtlCompareUnicodeStrings(v14, v17, v15, (unsigned int)v19, 1u)) )
              {
                *v6 = 1;
                break;
              }
              v14 += a6;
              v15 += v30;
              if( !*v14 )
                break;
            }
          }
          if( !*v6 )
          {
            if( !*v14 && !*v15 )
              goto LABEL_20;
            *v6 = 1;
          }
        }
        else
        {
          *v6 = 1;
        }
        v21 = (char *)PropertyBuffer;
        if( (_DWORD)NumberOfBytes )
        {
          do
          {
            if( !*(_WORD *)v21 )
              break;
            v22 = -1i64;
            do
              ++v22;
            while( *(_WORD *)&v21[2 * v22] );
            v21 += 2 * v22 + 2;
          }
          while( 2 * ((v21 - (char *)PropertyBuffer) >> 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(PropertyBuffer, 0);
      goto LABEL_21;
    }
  }
  DeviceRegProp = -1073741670;
LABEL_21:
  if( DeviceKey )
    ZwClose((_HANDLE)DeviceKey);
  return(unsigned int)DeviceRegProp;
}

Referenced by:

PiProcessNewDeviceNode
PipProcessStartPhase3