PspSetCreateThreadNotifyRoutine

__int64 __fastcall PspSetCreateThreadNotifyRoutine(KSPIN_LOCK a1, unsigned int a2){
  char v2; 
  struct EX_RUNDOWN_REF *v3; 
  __int64 v4; 
  v2 = a2;
  v3 = ExAllocateCallBack(a1, a2);
  if( !v3 )
    return 3221225626i64;
  v4 = 0i64;
  while( !ExCompareExchangeCallBack(&PspCreateThreadNotifyRoutine + v4, v3, 0i64) )
  {
    v4 = (unsigned int)(v4 + 1);
    if( (unsigned int)v4 >= 0x40 )
    {
      ExFreePoolWithTag(v3, 0);
      return 3221225626i64;
    }
  }
  if( (v2 & 1) != 0 )
  {
    _InterlockedIncrement(&PspCreateThreadNotifyRoutineNonSystemCount);
    if( (PspNotifyEnableMask & 0x10) == 0 )
      _interlockedbittestandset(&PspNotifyEnableMask, 4u);
  }
  else
  {
    _InterlockedIncrement(&PspCreateThreadNotifyRoutineCount);
    if( (PspNotifyEnableMask & 8) == 0 )
      _interlockedbittestandset(&PspNotifyEnableMask, 3u);
  }
  return 0i64;
}

Referenced by:

PsSetCreateThreadNotifyRoutine
PsSetCreateThreadNotifyRoutineEx