PspSetJobMemoryPartition

NTSTATUS __stdcall PspSetJobMemoryPartition(_EJOB *Job, INT8 a2, VOID *a3){
  char v4; 
  int v5; 
  INT64 v6; 
  INT32 *v7; 
  _EJOB *v8; 
  char v9; 
  volatile signed __int32 *v10; 
  INT64 v11; 
  PVOID Object; 

  Object = 0i64;
  v4 = 0;
  v5 = PsReferencePartitionByHandle(a3, 1ui64, a2, 0x624A7350u, &Object);
  if( v5 < 0 )
    goto LABEL_13;
  if( _interlockedbittestandset((volatile signed __int32 *)Object + 30, 0) )
  {
    v5 = -1073741637;
LABEL_13:
    v10 = (volatile signed __int32 *)Object;
    goto LABEL_14;
  }
  v4 = 1;
  ExAcquireResourceExclusiveLite((UINT64)Job + 56, 1, v6);
  PsIsServerSilo((INT64)Job, v7);
  if( v9 || *((_QWORD *)Job + 195) || *((_EJOB **)Job + 132) != (_EJOB *)((char *)Job + 1056) || *((_DWORD *)Job + 54) )
  {
    v5 = -1073741637;
    goto LABEL_12;
  }
  v5 = PspConvertJobToMixed(v8);
  if( v5 < 0 )
  {
LABEL_12:
    ExReleaseResourceLite((PERESOURCE)((char *)Job + 56));
    goto LABEL_13;
  }
  *((_QWORD *)Job + 195) = -1i64;
  ExReleaseResourceLite((PERESOURCE)((char *)Job + 56));
  v10 = (volatile signed __int32 *)Object;
  v5 = PsAssignProcessToJobObject(Job, *((_EPROCESS **)Object + 13));
  if( v5 >= 0 )
  {
    ObfReferenceObjectWithTag((VOID *)v10, 0x624A7350ui64);
    ExAcquireResourceExclusiveLite((UINT64)Job + 56, 1, v11);
    *((_QWORD *)Job + 195) = v10;
    *((_QWORD *)Job + 196) = Job;
    ExReleaseResourceLite((PERESOURCE)((char *)Job + 56));
    v4 = 0;
    v5 = 0;
  }
LABEL_14:
  if( v10 )
  {
    if( *((_QWORD *)Job + 195) == -1i64 )
      *((_QWORD *)Job + 195) = 0i64;
    if( v4 )
    {
      _interlockedbittestandreset(v10 + 30, 0);
      v10 = (volatile signed __int32 *)Object;
    }
    PsDereferencePartition((INT64)v10);
  }
  return v5;
}

Referenced by:

NtSetInformationJobObject