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
- HttpRuntimeSection.cs
- ControlCommandSet.cs
- EntitySetBase.cs
- AsymmetricSignatureFormatter.cs
- CurrentTimeZone.cs
- UnsafeNativeMethods.cs
- ExpressionNormalizer.cs
- RowToParametersTransformer.cs
- EdmComplexPropertyAttribute.cs
- RelatedPropertyManager.cs
- SatelliteContractVersionAttribute.cs
- BooleanAnimationBase.cs
- PartitionedStreamMerger.cs
- HijriCalendar.cs
- ResourceSet.cs
- MessageQueuePermissionEntryCollection.cs
- PrivilegeNotHeldException.cs
- DescendantOverDescendantQuery.cs
- ThemeDictionaryExtension.cs
- PathParser.cs
- DeferredTextReference.cs
- LinkedResource.cs
- CallTemplateAction.cs
- ExtensionSimplifierMarkupObject.cs
- DbRetry.cs
- ThreadStartException.cs
- Html32TextWriter.cs
- LambdaCompiler.ControlFlow.cs
- UnsafeNativeMethods.cs
- XXXInfos.cs
- XmlCollation.cs
- OleDbConnectionInternal.cs
- TdsParser.cs
- MouseDevice.cs
- XmlNodeChangedEventArgs.cs
- ISFTagAndGuidCache.cs
- DataServicePagingProviderWrapper.cs
- InputScopeManager.cs
- ParseNumbers.cs
- Point.cs
- PointCollectionValueSerializer.cs
- ReferenceAssemblyAttribute.cs
- Encoder.cs
- TargetParameterCountException.cs
- XmlSerializerNamespaces.cs
- TableCellCollection.cs
- QilUnary.cs
- MultiTrigger.cs
- NodeInfo.cs
- SQLMembershipProvider.cs
- AuthenticationModuleElementCollection.cs
- InstanceCreationEditor.cs
- DesignerVerb.cs
- CollectionChangeEventArgs.cs
- AttributeTableBuilder.cs
- ApplicationSecurityInfo.cs
- DocumentPage.cs
- XmlDocumentFragment.cs
- WindowsGrip.cs
- WrapPanel.cs
- EventProxy.cs
- CodeMemberMethod.cs
- XamlToRtfParser.cs
- WrappingXamlSchemaContext.cs
- DataKeyCollection.cs
- GenerateHelper.cs
- EventWaitHandle.cs
- CaseStatement.cs
- EventMappingSettingsCollection.cs
- Odbc32.cs
- MsmqInputChannelListener.cs
- CreateUserErrorEventArgs.cs
- JsonUriDataContract.cs
- DetailsViewUpdatedEventArgs.cs
- CompositeScriptReferenceEventArgs.cs
- Attributes.cs
- COM2FontConverter.cs
- ItemContainerPattern.cs
- SystemNetworkInterface.cs
- BaseParagraph.cs
- MembershipPasswordException.cs
- ObjectKeyFrameCollection.cs
- XPathExpr.cs
- SecurityPolicySection.cs
- MemoryPressure.cs
- LinearGradientBrush.cs
- InputReferenceExpression.cs
- ReadOnlyDataSourceView.cs
- GroupQuery.cs
- PageAsyncTask.cs
- ContentElementCollection.cs
- DynamicILGenerator.cs
- RouteTable.cs
- PeerObject.cs
- PageCodeDomTreeGenerator.cs
- BinaryKeyIdentifierClause.cs
- PassportAuthenticationModule.cs
- GuidelineSet.cs
- HttpFormatExtensions.cs
- WebPartConnectionsEventArgs.cs