MiDereferencePerSessionProtos

VOID __stdcall MiDereferencePerSessionProtos(_CONTROL_AREA *ControlArea, UINT64 SessionId){
  _ETHREAD *CurrentThread; 
  unsigned int v3; 
  _SEGMENT *Segment; 
  _EX_PUSH_LOCK *p_SegmentLock; 
  _SUBSECTION *i; 
  _SINGLE_LIST_ENTRY ProtosToProcess; 

  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  ProtosToProcess.Next = 0i64;
  v3 = SessionId;
  Segment = ControlArea->Segment;
  --CurrentThread->Tcb.SpecialApcDisable;
  p_SegmentLock = &Segment->SegmentLock;
  ExAcquirePushLockExclusiveEx(p_SegmentLock, 0i64);
  for( i = (_SUBSECTION *)&ControlArea[1]; i; i = i->NextSubsection )
    MiDereferenceSubsectionProtos(i, v3, (_MI_PER_SESSION_PROTOS **)&ProtosToProcess);
  if( (_InterlockedExchangeAdd64(&p_SegmentLock->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock(p_SegmentLock);
  KeAbPostRelease(p_SegmentLock);
  KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
  MiFreeSubsectionProtos(&ProtosToProcess);
}

Referenced by:

MiDeletePartialCloneVads
MiDeleteVad
MiFinishCreateSection
MiInsertInSystemSpace
MiMapSystemImage
MiMapViewOfImageSection
MiRemoveFromSystemSpace
MiSectionDelete
MiValidateSectionCreate