MmIsSessionInCurrentServerSilo

VOID __stdcall MmIsSessionInCurrentServerSilo(UINT64 SessionId, INT16 DX){
  unsigned int v2; 
  NTSTATUS v3; 
  NTSTATUS v4; 
  int v5; 
  _RTL_BALANCED_NODE *Root; 
  unsigned int Right; 
  _KLOCK_QUEUE_HANDLE LockHandle; 

  memset(&LockHandle, 0, sizeof(LockHandle));
  v2 = SessionId;
  v3 = MmGetSessionIdEx(KeGetCurrentThread()->ApcState.Process);
  v4 = 0;
  if( v3 != -1 )
    v4 = v3;
  if( v4 != v2 )
  {
    LOBYTE(v5) = KeIsExecutingInArbitraryThreadContext();
    if( !v5 )
      PsGetThreadServerSilo((INT64)KeGetCurrentThread());
    KeAcquireInStackQueuedSpinLock((PKSPIN_LOCK)&stru_140C4DB30 + 522, &LockHandle);
    Root = Tree.Root;
    while( Root )
    {
      Right = (unsigned int)Root[-6].Right;
      if( v2 > Right )
      {
        Root = Root->Children[1];
      }
      else
      {
        if( v2 >= Right )
          break;
        Root = Root->Children[0];
      }
    }
    KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
    __writecr8(LockHandle.OldIrql);
  }
}

Referenced by:

PopGetSettingNotificationName