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
- XmlnsPrefixAttribute.cs
- Identifier.cs
- ChameleonKey.cs
- Timer.cs
- XmlExtensionFunction.cs
- FontDriver.cs
- CacheEntry.cs
- SecurityTimestamp.cs
- CqlParserHelpers.cs
- AssemblyBuilderData.cs
- ImportCatalogPart.cs
- SelectionItemPattern.cs
- SingleSelectRootGridEntry.cs
- MethodSignatureGenerator.cs
- XmlAttributeCollection.cs
- XpsException.cs
- DataKey.cs
- HttpDictionary.cs
- DataGridTableCollection.cs
- behaviorssection.cs
- DataGridItemCollection.cs
- BitmapDownload.cs
- _CacheStreams.cs
- CustomValidator.cs
- WebPartTransformer.cs
- CodeMemberEvent.cs
- DataBindingExpressionBuilder.cs
- SecurityHeaderLayout.cs
- SafeRightsManagementQueryHandle.cs
- ReadOnlyMetadataCollection.cs
- DataConnectionHelper.cs
- SelectionRange.cs
- NativeMethods.cs
- NamedPipeHostedTransportConfiguration.cs
- DataServiceHostFactory.cs
- Int64Storage.cs
- SynchronizedRandom.cs
- Pair.cs
- JsonFormatReaderGenerator.cs
- AttributeConverter.cs
- InheritanceRules.cs
- ProxyAttribute.cs
- Pkcs9Attribute.cs
- SuppressMessageAttribute.cs
- SoapIncludeAttribute.cs
- RequestCachingSection.cs
- ButtonBase.cs
- ExpressionsCollectionConverter.cs
- GridSplitter.cs
- OleDbPropertySetGuid.cs
- dbdatarecord.cs
- QueryBranchOp.cs
- UpdateRecord.cs
- CodeTypeReferenceCollection.cs
- CommandPlan.cs
- HttpCookieCollection.cs
- PropertyValue.cs
- SHA256Managed.cs
- Selection.cs
- TextReader.cs
- WebBodyFormatMessageProperty.cs
- PerformanceCounterPermissionEntry.cs
- BoolExpression.cs
- CatalogPart.cs
- CaseExpr.cs
- ExtensionWindowHeader.cs
- SimpleApplicationHost.cs
- MimeWriter.cs
- DispatcherFrame.cs
- NumericPagerField.cs
- Deserializer.cs
- SpeechDetectedEventArgs.cs
- CookielessData.cs
- BamlLocalizationDictionary.cs
- XmlElementAttribute.cs
- CodePrimitiveExpression.cs
- WebRequest.cs
- FixedPageProcessor.cs
- GridViewItemAutomationPeer.cs
- SystemFonts.cs
- XmlSerializationGeneratedCode.cs
- SchemaCollectionCompiler.cs
- Crc32.cs
- CustomTypeDescriptor.cs
- HandleCollector.cs
- ModuleElement.cs
- XmlSchemaSimpleContentRestriction.cs
- PathSegmentCollection.cs
- XmlAnyElementAttributes.cs
- CodeDirectoryCompiler.cs
- Relationship.cs
- ScriptReference.cs
- SqlCacheDependencyDatabase.cs
- BaseUriHelper.cs
- WindowsStreamSecurityUpgradeProvider.cs
- ResetableIterator.cs
- DesignerSerializationVisibilityAttribute.cs
- SimpleColumnProvider.cs
- RelatedEnd.cs
- ObjectStateManagerMetadata.cs