internal static MemoryMappedView CreateView(SafeMemoryMappedFileHandle memMappedFileHandle, MemoryMappedFileAccess access, long offset, long size)
        {
            ulong num3;
            ulong num  = (ulong)(offset % ((long)MemoryMappedFile.GetSystemPageAllocationGranularity()));
            ulong num2 = ((ulong)offset) - num;

            if (size != 0L)
            {
                num3 = ((ulong)size) + num;
            }
            else
            {
                num3 = 0L;
            }
            if ((IntPtr.Size == 4) && (num3 > 0xffffffffL))
            {
                throw new ArgumentOutOfRangeException("size", System.SR.GetString("ArgumentOutOfRange_CapacityLargerThanLogicalAddressSpaceNotAllowed"));
            }
            Microsoft.Win32.UnsafeNativeMethods.MEMORYSTATUSEX lpBuffer = new Microsoft.Win32.UnsafeNativeMethods.MEMORYSTATUSEX();
            Microsoft.Win32.UnsafeNativeMethods.GlobalMemoryStatusEx(lpBuffer);
            ulong ullTotalVirtual = lpBuffer.ullTotalVirtual;

            if (num3 >= ullTotalVirtual)
            {
                throw new IOException(System.SR.GetString("IO_NotEnoughMemory"));
            }
            uint dwFileOffsetLow  = (uint)(num2 & 0xffffffffL);
            uint dwFileOffsetHigh = (uint)(num2 >> 0x20);
            SafeMemoryMappedViewHandle address = Microsoft.Win32.UnsafeNativeMethods.MapViewOfFile(memMappedFileHandle, MemoryMappedFile.GetFileMapAccess(access), dwFileOffsetHigh, dwFileOffsetLow, new UIntPtr(num3));

            if (address.IsInvalid)
            {
                System.IO.__Error.WinIOError(Marshal.GetLastWin32Error(), string.Empty);
            }
            Microsoft.Win32.UnsafeNativeMethods.MEMORY_BASIC_INFORMATION buffer = new Microsoft.Win32.UnsafeNativeMethods.MEMORY_BASIC_INFORMATION();
            Microsoft.Win32.UnsafeNativeMethods.VirtualQuery(address, ref buffer, (IntPtr)Marshal.SizeOf(buffer));
            ulong regionSize = (ulong)buffer.RegionSize;

            if ((buffer.State & 0x2000) != 0)
            {
                Microsoft.Win32.UnsafeNativeMethods.VirtualAlloc(address, (UIntPtr)regionSize, 0x1000, MemoryMappedFile.GetPageAccess(access));
                int errorCode = Marshal.GetLastWin32Error();
                if (address.IsInvalid)
                {
                    System.IO.__Error.WinIOError(errorCode, string.Empty);
                }
            }
            if (size == 0L)
            {
                size = (long)(regionSize - num);
            }
            address.Initialize(((ulong)size) + num);
            return(new MemoryMappedView(address, (long)num, size, access));
        }
 internal static MemoryMappedView CreateView(SafeMemoryMappedFileHandle memMappedFileHandle, MemoryMappedFileAccess access, long offset, long size)
 {
     ulong num3;
     ulong num = (ulong) (offset % ((long) MemoryMappedFile.GetSystemPageAllocationGranularity()));
     ulong num2 = ((ulong) offset) - num;
     if (size != 0L)
     {
         num3 = ((ulong) size) + num;
     }
     else
     {
         num3 = 0L;
     }
     if ((IntPtr.Size == 4) && (num3 > 0xffffffffL))
     {
         throw new ArgumentOutOfRangeException("size", System.SR.GetString("ArgumentOutOfRange_CapacityLargerThanLogicalAddressSpaceNotAllowed"));
     }
     Microsoft.Win32.UnsafeNativeMethods.MEMORYSTATUSEX lpBuffer = new Microsoft.Win32.UnsafeNativeMethods.MEMORYSTATUSEX();
     Microsoft.Win32.UnsafeNativeMethods.GlobalMemoryStatusEx(lpBuffer);
     ulong ullTotalVirtual = lpBuffer.ullTotalVirtual;
     if (num3 >= ullTotalVirtual)
     {
         throw new IOException(System.SR.GetString("IO_NotEnoughMemory"));
     }
     uint dwFileOffsetLow = (uint) (num2 & 0xffffffffL);
     uint dwFileOffsetHigh = (uint) (num2 >> 0x20);
     SafeMemoryMappedViewHandle address = Microsoft.Win32.UnsafeNativeMethods.MapViewOfFile(memMappedFileHandle, MemoryMappedFile.GetFileMapAccess(access), dwFileOffsetHigh, dwFileOffsetLow, new UIntPtr(num3));
     if (address.IsInvalid)
     {
         System.IO.__Error.WinIOError(Marshal.GetLastWin32Error(), string.Empty);
     }
     Microsoft.Win32.UnsafeNativeMethods.MEMORY_BASIC_INFORMATION buffer = new Microsoft.Win32.UnsafeNativeMethods.MEMORY_BASIC_INFORMATION();
     Microsoft.Win32.UnsafeNativeMethods.VirtualQuery(address, ref buffer, (IntPtr) Marshal.SizeOf(buffer));
     ulong regionSize = (ulong) buffer.RegionSize;
     if ((buffer.State & 0x2000) != 0)
     {
         Microsoft.Win32.UnsafeNativeMethods.VirtualAlloc(address, (UIntPtr) regionSize, 0x1000, MemoryMappedFile.GetPageAccess(access));
         int errorCode = Marshal.GetLastWin32Error();
         if (address.IsInvalid)
         {
             System.IO.__Error.WinIOError(errorCode, string.Empty);
         }
     }
     if (size == 0L)
     {
         size = (long) (regionSize - num);
     }
     address.Initialize(((ulong) size) + num);
     return new MemoryMappedView(address, (long) num, size, access);
 }