PiDrvDbQuerySyncNodesUpdated

INT64 __fastcall PiDrvDbQuerySyncNodesUpdated(CHAR a1, CHAR *a2){
  CHAR v3; 
  UINT64 v5; 
  int PersistedStateLocation; 
  VOID *PoolWithTag; 
  INT64 i; 
  const WCHAR *v10; 
  UINT64 v11; 
  ULONG v12; 
  int v13; 
  HANDLE Handle; 
  __int64 Source2; 
  __int64 Source1; 
  UINT64 v17; 
  int v18; 
  v3 = 0;
  Handle = 0i64;
  Source1 = 0i64;
  Source2 = 0i64;
  v5 = 520i64;
  v18 = 0;
  v12 = 0;
  v13 = 0;
  LODWORD(v17) = 0;
  while( 1 )
  {
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, v5, 0x62647050ui64);
    if( !PoolWithTag )
    {
      PersistedStateLocation = -1073741670;
      goto LABEL_7;
    }
    LODWORD(v11) = v5;
    PersistedStateLocation = RtlGetPersistedStateLocation(
                               (WCHAR *)&stru_1407D2340.Xmm10,
                               0i64,
                               &stru_1407D2340.P3Home,
                               0i64,
                               PoolWithTag,
                               v11,
                               &v17);
    if( PersistedStateLocation != -2147483643 )
      break;
    ExFreePoolWithTag(PoolWithTag, 0);
    PoolWithTag = 0i64;
    if( (unsigned int)v17 <= (unsigned int)v5 )
    {
      PersistedStateLocation = -1073741595;
      break;
    }
    v5 = (unsigned int)v17;
  }
  if( PersistedStateLocation >= 0 )
  {
    PersistedStateLocation = PnpCtxRegCreateTree(
                               0i64,
                               0i64,
                               (const wchar_t *)PoolWithTag,
                               0,
                               0x2001Fu,
                               0i64,
                               (__int64)&Handle,
                               0i64);
    if( PersistedStateLocation >= 0 )
    {
      for( i = PiDrvDbNodeList; (INT64 *)i != &PiDrvDbNodeList; i = *(_QWORD *)i )
      {
        if( (*(_DWORD *)(i + 64) & 4) == 0 || !PnpBootMode )
        {
          if( (int)PnpGetObjectProperty(
                      PiPnpRtlCtx,
                      *(_QWORD *)(i + 24),
                      7i64,
                      *(_QWORD *)(i + 72),
                      0i64,
                      (__int64)DEVPKEY_DriverDatabase_LastUpdateDate,
                      &v18,
                      (unsigned __int64)&Source1,
                      8,
                      &v12,
                      0) >= 0
            && v18 == 16
            && v12 == 8 )
          {
            v10 = *(const WCHAR **)(i + 24);
            LODWORD(v17) = 8;
            PersistedStateLocation = RegRtlQueryValue(Handle, v10, &v13, &Source2, (__int64)&v17);
            if( PersistedStateLocation < 0 || v13 != 3 || (_DWORD)v17 != 8 )
            {
              PersistedStateLocation = 0;
              Source2 = 0i64;
            }
            if( RtlCompareMemory(&Source1, &Source2, 8ui64) != 8 )
            {
              v3 = 1;
              if( !a1 )
                break;
              PersistedStateLocation = RegRtlSetValue(Handle, *(const WCHAR **)(i + 24), 3u, &Source1, 8u);
              if( PersistedStateLocation < 0 )
                goto LABEL_7;
            }
          }
          else
          {
            PersistedStateLocation = 0;
          }
        }
      }
      if( a2 )
        *a2 = v3;
    }
  }
LABEL_7:
  if( Handle )
    ZwClose(Handle);
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  return(unsigned int)PersistedStateLocation;
}

Referenced by:

PpDevCfgInit