ViQueryObjectContext

_VF_CONTEXT_HEADER *__stdcall ViQueryObjectContext(VOID *Object, _VF_OBJECT_TYPE ObjectType, UINT64 ContextId){
  __int64 v3; 
  _VF_CONTEXT_HEADER *v4; 
  _VF_CONTEXT_HEADER *result; 
  volatile signed __int64 *v6; 
  __int64 v7; 

  v3 = (unsigned int)ContextId;
  v4 = 0i64;
  result = ViGetContextPointer(Object, ObjectType);
  v6 = (volatile signed __int64 *)result;
  if( result )
  {
    if( ViLockContextPointer(result) )
    {
      v7 = *(_QWORD *)(*v6 + 8 * v3 + 8);
      if( v7 )
      {
        v4 = *(_VF_CONTEXT_HEADER **)(*v6 + 8 * v3 + 8);
        _InterlockedAdd((volatile signed __int32 *)(v7 + 4), 1u);
      }
      _InterlockedExchangeAdd64(v6, 1ui64);
    }
    return v4;
  }
  return result;
}

Referenced by:

VfQueryDeviceContext
VfQueryDriverContext
VfQueryIrpContext
VfQueryThreadContext