PspEvaluateAndNotifyEmptyJob

VOID __stdcall PspEvaluateAndNotifyEmptyJob(_EJOB *Job, UINT8 RemoveProcess, UINT8 SendZeroProcessCountMessage){
  _ETHREAD *CurrentThread; 
  unsigned int ShadowActiveProcessCount; 
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  PspLockJobExclusive((__int64)Job, (__int64)CurrentThread);
  ShadowActiveProcessCount = Job->ShadowActiveProcessCount;
  if( RemoveProcess )
    Job->ShadowActiveProcessCount = --ShadowActiveProcessCount;
  if( !ShadowActiveProcessCount )
  {
    if( _interlockedbittestandreset((volatile signed __int32 *)&Job->1320, 7u) )
      KeSetEvent(&Job->Event, 0);
    if( !_interlockedbittestandset((volatile signed __int32 *)&Job->1320, 0x15u) )
    {
      if( SendZeroProcessCountMessage && Job->CompletionPort && (Job->CompletionFilter & 0x10) != 0 )
        PspSendReliableJobNotification(Job, 4ui64);
      if( (Job->LimitFlags & 0x400000) != 0
        && !_interlockedbittestandset((volatile signed __int32 *)&Job->1320, 0x1Du)
        && (Job->JobFlags & 0x40000000) != 0 )
      {
        PspHardDereferenceSiloWorker(Job);
      }
    }
  }
  PspUnlockJob((__int64)Job, (__int64)CurrentThread);
}

Referenced by:

PspNotifyEmptyJobsInJobChain
PspTerminateAllProcessesInJobHierarchy