PspImplicitAssignProcessToJob

__int64 __fastcall PspImplicitAssignProcessToJob(__int64 a1, unsigned __int64 a2, __int16 a3){
  _ETHREAD *CurrentThread; 
  INT64 EffectiveServerSilo; 
  int v8; 
  int v10; 
  INT64 v11; 
  INT64 v12; 
  volatile signed __int32 *v13; 
  __int64 v14; 
  int v15; 
  int v16; 
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  PspLockJobChain(a1, (__int64)CurrentThread, 0);
  if( (a3 & 0x400) != 0 )
  {
    EffectiveServerSilo = (INT64)PsGetEffectiveServerSilo((_EJOB *)a1);
  }
  else
  {
    for( EffectiveServerSilo = a1; EffectiveServerSilo; EffectiveServerSilo = *(_QWORD *)(EffectiveServerSilo + 1072) )
    {
      v10 = *(_DWORD *)(EffectiveServerSilo + 256);
      if( (v10 & 0x1000) == 0 )
      {
        if( (a3 & 1) == 0 )
          goto LABEL_3;
        if( (v10 & 0x800) == 0 )
          break;
      }
    }
    if( (a3 & 1) != 0 && EffectiveServerSilo == a1 && (*(_DWORD *)(EffectiveServerSilo + 1320) & 0x40000000) == 0 )
    {
      v8 = -1073741790;
      goto LABEL_5;
    }
  }
LABEL_3:
  if( !EffectiveServerSilo )
  {
    v8 = 0;
LABEL_5:
    PspUnlockJobChain(a1, (__int64)CurrentThread, 0);
    return(unsigned int)v8;
  }
  if( !PspValidateJobAssignmentMemoryPartition(EffectiveServerSilo, 0i64, a2, 1i64) )
  {
    v8 = -1073741637;
    goto LABEL_5;
  }
  v8 = PspValidateJobChainLimits(EffectiveServerSilo, v11, v12, a3);
  if( v8 < 0 )
    goto LABEL_5;
  v8 = PspEstablishJobHierarchy((CHAR *)EffectiveServerSilo, a2, 0i64, 1i64);
  if( v8 < 0 )
    goto LABEL_5;
  PspIncrementJobChainProcessCounts(EffectiveServerSilo, 0i64, a2, a3);
  PspApplyJobChainLimitsToProcess(EffectiveServerSilo, 0i64, a2);
  if( (*(_DWORD *)(EffectiveServerSilo + 1320) & 0x1000) != 0 )
  {
    v13 = (volatile signed __int32 *)(a2 + 2472);
    v14 = 7i64;
    do
    {
      _interlockedbittestandset(v13++, 0x1Fu);
      --v14;
    }
    while( v14 );
    _interlockedbittestandset((volatile signed __int32 *)(a2 + 2508), 0x1Fu);
  }
  PspUnlockJobChain(a1, (__int64)CurrentThread, 0);
  v15 = PspApplyWorkingSetLimitsToProcess(a2);
  if( v15 >= 0 )
  {
    MmAssignProcessToJob((_EPROCESS *)a2, 0i64);
    if( !v16 )
      return(unsigned int)-1073741756;
  }
  return(unsigned int)v15;
}

Referenced by:

No references.