Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Win32 / SafeHandles / SafeMemoryMappedViewHandle.cs / 1305376 / SafeMemoryMappedViewHandle.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeMemoryMappedViewHandle
**
** Purpose: Safe handle wrapping a MMF view pointer
**
** Date: February 7, 2007
**
===========================================================*/
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
namespace Microsoft.Win32.SafeHandles {
// Reliability notes:
// ReleaseHandle has reliability guarantee of Cer.Success, as defined by SafeHandle.
// It gets prepared as a CER at instance construction time. This safe handle doesn't
// need to override IsInvalid because the one it inherits from
// SafeHandleZeroOrMinusOneIsInvalid is correct.
//
//
//
#pragma warning disable 618 // Have not migrated to v4 transparency yet
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
#pragma warning restore 618
public sealed class SafeMemoryMappedViewHandle : SafeBuffer {
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeMemoryMappedViewHandle() : base(true) { }
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeMemoryMappedViewHandle(IntPtr handle, bool ownsHandle) : base(ownsHandle) {
base.SetHandle(handle);
}
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
override protected bool ReleaseHandle() {
if (UnsafeNativeMethods.UnmapViewOfFile(handle)) {
handle = IntPtr.Zero;
return true;
}
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeMemoryMappedViewHandle
**
** Purpose: Safe handle wrapping a MMF view pointer
**
** Date: February 7, 2007
**
===========================================================*/
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
namespace Microsoft.Win32.SafeHandles {
// Reliability notes:
// ReleaseHandle has reliability guarantee of Cer.Success, as defined by SafeHandle.
// It gets prepared as a CER at instance construction time. This safe handle doesn't
// need to override IsInvalid because the one it inherits from
// SafeHandleZeroOrMinusOneIsInvalid is correct.
//
//
//
#pragma warning disable 618 // Have not migrated to v4 transparency yet
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
#pragma warning restore 618
public sealed class SafeMemoryMappedViewHandle : SafeBuffer {
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeMemoryMappedViewHandle() : base(true) { }
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeMemoryMappedViewHandle(IntPtr handle, bool ownsHandle) : base(ownsHandle) {
base.SetHandle(handle);
}
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
override protected bool ReleaseHandle() {
if (UnsafeNativeMethods.UnmapViewOfFile(handle)) {
handle = IntPtr.Zero;
return true;
}
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ExpressionWriter.cs
- DataGridTableCollection.cs
- IList.cs
- SoapEnumAttribute.cs
- MobileControl.cs
- CookieParameter.cs
- PageParser.cs
- PolicyVersion.cs
- WindowsStatusBar.cs
- ProfilePropertySettingsCollection.cs
- DBConnectionString.cs
- QilName.cs
- TrayIconDesigner.cs
- GPPOINTF.cs
- HttpCacheVary.cs
- MaterialGroup.cs
- RotateTransform.cs
- LinqMaximalSubtreeNominator.cs
- SmtpException.cs
- ServiceObjectContainer.cs
- HttpRequest.cs
- ValidatedControlConverter.cs
- AsymmetricAlgorithm.cs
- CertificateElement.cs
- ContextMarshalException.cs
- CultureInfoConverter.cs
- EditCommandColumn.cs
- ListViewEditEventArgs.cs
- SamlAttribute.cs
- Rule.cs
- PackagingUtilities.cs
- Domain.cs
- SafeRightsManagementHandle.cs
- MenuItem.cs
- HtmlControl.cs
- SerializationException.cs
- WebPartCloseVerb.cs
- IListConverters.cs
- Rectangle.cs
- AndMessageFilter.cs
- BitmapEffectState.cs
- NotConverter.cs
- CommonProperties.cs
- future.cs
- ListViewUpdatedEventArgs.cs
- PasswordDeriveBytes.cs
- StyleBamlTreeBuilder.cs
- PenCursorManager.cs
- connectionpool.cs
- InputBinding.cs
- ThaiBuddhistCalendar.cs
- SqlReorderer.cs
- Application.cs
- ToolStripOverflow.cs
- UIElementCollection.cs
- ToggleButton.cs
- MasterPageCodeDomTreeGenerator.cs
- NamespaceDisplay.xaml.cs
- DbFunctionCommandTree.cs
- DesignerWithHeader.cs
- DateTimeUtil.cs
- ProxyFragment.cs
- XPathDocument.cs
- ConfigErrorGlyph.cs
- BooleanSwitch.cs
- XmlComplianceUtil.cs
- Matrix.cs
- StickyNoteContentControl.cs
- ValidatorUtils.cs
- TargetControlTypeAttribute.cs
- Filter.cs
- TypeReference.cs
- Main.cs
- HMACMD5.cs
- XmlDataContract.cs
- PrintingPermission.cs
- SchemaTableColumn.cs
- MetaForeignKeyColumn.cs
- HMACRIPEMD160.cs
- ConfigXmlText.cs
- PartialTrustVisibleAssemblyCollection.cs
- SetMemberBinder.cs
- DesignConnectionCollection.cs
- SecurityResources.cs
- MasterPage.cs
- SecurityTokenProvider.cs
- XmlSchemaAnyAttribute.cs
- Security.cs
- MimeFormatExtensions.cs
- BuildResult.cs
- WindowsToolbar.cs
- DetailsViewCommandEventArgs.cs
- SqlException.cs
- PropertyFilterAttribute.cs
- MessageFilterException.cs
- ToolStripGrip.cs
- WorkflowRuntime.cs
- WindowsListView.cs
- BitmapEffect.cs
- SqlServer2KCompatibilityAnnotation.cs