private static Microsoft.Win32.SafeHandles.SafeMemoryMappedFileHandle CreateCore(SafeFileHandle fileHandle, string mapName, HandleInheritability inheritability, MemoryMappedFileSecurity memoryMappedFileSecurity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, long capacity)
{
Microsoft.Win32.SafeHandles.SafeMemoryMappedFileHandle handle = null;
object obj2;
Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES lpAttributes = GetSecAttrs(inheritability, memoryMappedFileSecurity, out obj2);
int dwMaximumSizeLow = (int)(((ulong)capacity) & 0xffffffffL);
int dwMaximumSizeHigh = (int)(capacity >> 0x20);
try
{
handle = Microsoft.Win32.UnsafeNativeMethods.CreateFileMapping(fileHandle, lpAttributes, GetPageAccess(access) | options, dwMaximumSizeHigh, dwMaximumSizeLow, mapName);
int errorCode = Marshal.GetLastWin32Error();
if (!handle.IsInvalid && (errorCode == 0xb7))
{
handle.Dispose();
System.IO.__Error.WinIOError(errorCode, string.Empty);
return(handle);
}
if (handle.IsInvalid)
{
System.IO.__Error.WinIOError(errorCode, string.Empty);
}
}
finally
{
if (obj2 != null)
{
((GCHandle)obj2).Free();
}
}
return(handle);
}