PiDmListEnumObjectsWithCallback

NTSTATUS __stdcall PiDmListEnumObjectsWithCallback(INT64 a1, _EX_PUSH_LOCK *a2, INT64 a3, INT64 a4){
  VOID **v4; 
  NTSTATUS v5; 
  __int64 v6; 
  ULONG_PTR v9; 
  __int64 v10; 
  _ETHREAD *CurrentThread; 
  char *v12; 
  unsigned int v13; 
  VOID **PoolWithTag; 
  char *i; 
  volatile signed __int32 *v16; 
  unsigned int v17; 
  VOID **v18; 
  _PI_DM_OBJECT **v19; 
  char v21; 

  v4 = 0i64;
  v21 = 0;
  v5 = 0;
  v6 = 0i64;
  v9 = (unsigned int)a2;
  v10 = 5i64 * (int)a1;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v12 = (char *)a2 + PiDmListDefs[5 * (int)a1 + 1];
  --CurrentThread->Tcb.KernelApcDisable;
  ExAcquirePushLockSharedEx(a2, 0i64);
  v13 = *((_DWORD *)v12 + 4);
  if( v13 )
  {
    PoolWithTag = ExAllocatePoolWithTag(1ui64, 8i64 * v13, 1517317712i64);
    v4 = PoolWithTag;
    if( PoolWithTag )
    {
      for( i = *(char **)v12; i != v12; v6 = (unsigned int)(v6 + 1) )
      {
        v16 = (volatile signed __int32 *)&i[-PiDmListDefs[v10 + 3]];
        PoolWithTag[v6] = (VOID *)v16;
        _InterlockedIncrement(v16 + 2);
        i = *(char **)i;
      }
    }
    else
    {
      v5 = -1073741670;
    }
  }
  ExReleasePushLockEx(v9, 0);
  KeLeaveCriticalRegionThread(KeGetCurrentThread());
  v17 = 0;
  if( (_DWORD)v6 )
  {
    v18 = v4;
    do
    {
      v5 = ((__int64(__fastcall *)(VOID *, INT64, char *))a3)(*v18, a4, &v21);
      if( v5 < 0 )
        break;
      if( v21 )
        break;
      ++v17;
      ++v18;
    }
    while( v17 < (unsigned int)v6 );
  }
  if( v4 )
  {
    if( (_DWORD)v6 )
    {
      v19 = (_PI_DM_OBJECT **)v4;
      do
      {
        PiDmObjectRelease(*v19++);
        --v6;
      }
      while( v6 );
    }
    ExFreePoolWithTag(v4, 0x5A706E50u);
  }
  return v5;
}

Referenced by:

PiDmGetObjectConstraintList
PiPnpRtlApplyMandatoryDeviceContainerFilters
PiPnpRtlCmActionCallback