MiJoinSession
NTSTATUS __stdcall MiJoinSession(_MM_SESSION_SPACE **SessionGlobalJoined){
_ETHREAD *CurrentThread;
_EPROCESS *Process;
_MM_SESSION_SPACE *Session;
signed __int32 v4;
signed __int32 v5;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
*SessionGlobalJoined = 0i64;
Process = CurrentThread->Tcb.ApcState.Process;
if( (Process->Flags3 & 0x1000) != 0 )
return 1;
Session = Process->Session;
if( !Session )
return 1;
v4 = *(_DWORD *)Session;
while( v4 )
{
v5 = v4;
v4 = _InterlockedCompareExchange((volatile signed __int32 *)Session, v4 + 1, v4);
if( v5 == v4 )
{
_InterlockedIncrement((volatile signed __int32 *)Session + 3);
*SessionGlobalJoined = Session;
return 1;
}
}
return 0;
}Referenced by:
MmCreateProcessAddressSpace