CreateView() private method

private CreateView ( SafeMemoryMappedFileHandle memMappedFileHandle, MemoryMappedFileAccess access, long offset, long size ) : MemoryMappedView
memMappedFileHandle Microsoft.Win32.SafeHandles.SafeMemoryMappedFileHandle
access MemoryMappedFileAccess
offset long
size long
return MemoryMappedView
Example #1
0
        public MemoryMappedViewAccessor CreateViewAccessor(long offset, long size, MemoryMappedFileAccess access)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
            }

            if (size < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), SR.ArgumentOutOfRange_PositiveOrDefaultSizeRequired);
            }

            if (access < MemoryMappedFileAccess.ReadWrite || access > MemoryMappedFileAccess.ReadWriteExecute)
            {
                throw new ArgumentOutOfRangeException(nameof(access));
            }

            if (IntPtr.Size == 4 && size > uint.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(size), SR.ArgumentOutOfRange_CapacityLargerThanLogicalAddressSpaceNotAllowed);
            }

            MemoryMappedView view = MemoryMappedView.CreateView(_handle, access, offset, size);

            return(new MemoryMappedViewAccessor(view));
        }
Example #2
0
        public MemoryMappedViewStream CreateViewStream(Int64 offset, Int64 size, MemoryMappedFileAccess access)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", SR.GetString(SR.ArgumentOutOfRange_NeedNonNegNum));
            }

            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size", SR.GetString(SR.ArgumentOutOfRange_PositiveOrDefaultSizeRequired));
            }

            if (access < MemoryMappedFileAccess.ReadWrite || access > MemoryMappedFileAccess.ReadWriteExecute)
            {
                throw new ArgumentOutOfRangeException("access");
            }

            if (IntPtr.Size == 4 && size > UInt32.MaxValue)
            {
                throw new ArgumentOutOfRangeException("size", SR.GetString(SR.ArgumentOutOfRange_CapacityLargerThanLogicalAddressSpaceNotAllowed));
            }

            MemoryMappedView view = MemoryMappedView.CreateView(_handle, access, offset, size);

            return(new MemoryMappedViewStream(view));
        }
        public MemoryMappedViewAccessor CreateViewAccessor(long offset, long size, MemoryMappedFileAccess access = MemoryMappedFileAccess.ReadWrite)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "Value must be non-negative");
            }
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size", "Value must be positive or zero for default size");
            }
            if (IntPtr.Size == 4 && size > ((1024 * 1024 * 1024) * (long)4))
            {
                throw new ArgumentOutOfRangeException("size", "The capacity cannot be greater than the size of the system's logical address space.");
            }
            MemoryMappedView memoryMappedView = MemoryMappedView.CreateView(this._handle, access, offset, size);

            return(new MemoryMappedViewAccessor(memoryMappedView));
        }
Example #4
0
 public MemoryMappedViewStream CreateViewStream(long offset, long size, MemoryMappedFileAccess access)
 {
     if (offset < 0L)
     {
         throw new ArgumentOutOfRangeException("offset", System.SR.GetString("ArgumentOutOfRange_NeedNonNegNum"));
     }
     if (size < 0L)
     {
         throw new ArgumentOutOfRangeException("size", System.SR.GetString("ArgumentOutOfRange_PositiveOrDefaultSizeRequired"));
     }
     if ((access < MemoryMappedFileAccess.ReadWrite) || (access > MemoryMappedFileAccess.ReadWriteExecute))
     {
         throw new ArgumentOutOfRangeException("access");
     }
     if ((IntPtr.Size == 4) && (size > 0xffffffffL))
     {
         throw new ArgumentOutOfRangeException("size", System.SR.GetString("ArgumentOutOfRange_CapacityLargerThanLogicalAddressSpaceNotAllowed"));
     }
     return(new MemoryMappedViewStream(MemoryMappedView.CreateView(this._handle, access, offset, size)));
 }