RtlpHpVaMgrCtxAllocatorReference

NTSTATUS __stdcall RtlpHpVaMgrCtxAllocatorReference(INT64 a1, INT64 a2, UINT64 a3){
  INT64 *v3; 
  int v5; 
  unsigned int v6; 
  unsigned __int64 v8; 
  __int64 v9; 
  INT64 v10; 
  __int16 v12; 
  INT64 v13; 

  v13 = 0i64;
  v3 = (INT64 *)(a1 + 2144);
  v5 = (unsigned int)a3 >> 20;
  v6 = a3;
  v8 = (unsigned __int8)ExAcquireSpinLockExclusive((INT64 *)(a1 + 2144));
  v9 = RtlpHpVaMgrCtxAllocatorFind(a1, a2, v5, &v13);
  v10 = v9;
  if( v9 )
  {
    v12 = *(_WORD *)(v9 + 42);
    if( v12 != -1 )
    {
      *(_WORD *)(v9 + 42) = v12 + 1;
      goto LABEL_5;
    }
  }
  else
  {
    if( !v13 )
      goto LABEL_5;
    v10 = v13;
    if( RtlpHpVaMgrStart(v13, a1, a2, v6, ((int)v13 - (int)a1 - 2160) / 48) >= 0 )
    {
      ++*(_DWORD *)(a1 + 2152);
      goto LABEL_5;
    }
  }
  v10 = 0i64;
LABEL_5:
  ExReleaseSpinLockExclusiveFromDpcLevel(v3);
  __writecr8(v8);
  if( v10 )
    return *(unsigned __int8 *)(v10 + 44);
  else
    return -1;
}

Referenced by:

RtlpHpRegisterEnvironment
RtlpHpVaMgrCtxStart