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
- PersonalizationProviderHelper.cs
- SettingsBase.cs
- Configuration.cs
- StaticContext.cs
- InheritanceRules.cs
- PolicyManager.cs
- ValidatorCompatibilityHelper.cs
- SingleTagSectionHandler.cs
- DataBoundControl.cs
- WinEventQueueItem.cs
- PopupRootAutomationPeer.cs
- SoapInteropTypes.cs
- SqlConnectionFactory.cs
- EditingMode.cs
- FontInfo.cs
- Nullable.cs
- StringFreezingAttribute.cs
- DynamicValueConverter.cs
- HtmlControl.cs
- BasicKeyConstraint.cs
- EntityWithKeyStrategy.cs
- ListItemConverter.cs
- LineInfo.cs
- FlowDecision.cs
- ComboBox.cs
- mediapermission.cs
- FixedTextContainer.cs
- SQLGuid.cs
- TextTreeTextElementNode.cs
- SystemWebSectionGroup.cs
- RegistryConfigurationProvider.cs
- DbException.cs
- WindowsTab.cs
- WindowsListViewItemCheckBox.cs
- RightNameExpirationInfoPair.cs
- ModelItemCollectionImpl.cs
- SpeakInfo.cs
- AdornerPresentationContext.cs
- DefaultSection.cs
- CodeActivityContext.cs
- SequentialOutput.cs
- XmlIncludeAttribute.cs
- ExtensibleClassFactory.cs
- SerializableAttribute.cs
- TagMapCollection.cs
- DataGridSortCommandEventArgs.cs
- HtmlInputSubmit.cs
- TextViewSelectionProcessor.cs
- VirtualizingPanel.cs
- HierarchicalDataSourceConverter.cs
- DirectoryObjectSecurity.cs
- BindableAttribute.cs
- DataShape.cs
- ResetableIterator.cs
- XmlImplementation.cs
- MsmqSecureHashAlgorithm.cs
- SizeFConverter.cs
- Zone.cs
- NumberFunctions.cs
- ResourceManager.cs
- AdapterDictionary.cs
- KeyFrames.cs
- SqlTrackingWorkflowInstance.cs
- InfoCardSchemas.cs
- PriorityRange.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- RoamingStoreFile.cs
- SemanticResultKey.cs
- RoleGroupCollection.cs
- SqlDataSourceEnumerator.cs
- MissingMemberException.cs
- SQLInt32.cs
- AstTree.cs
- ImmutablePropertyDescriptorGridEntry.cs
- RegularExpressionValidator.cs
- ObjectDataSourceDisposingEventArgs.cs
- VideoDrawing.cs
- MarginCollapsingState.cs
- CanonicalFontFamilyReference.cs
- TripleDES.cs
- RectAnimation.cs
- SqlProviderServices.cs
- LambdaCompiler.Logical.cs
- RootCodeDomSerializer.cs
- UriTemplateClientFormatter.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- SchemaImporterExtensionElement.cs
- FixedSOMContainer.cs
- XmlIncludeAttribute.cs
- WindowsFormsHostAutomationPeer.cs
- ParameterCollection.cs
- OdbcErrorCollection.cs
- RsaSecurityTokenAuthenticator.cs
- ProviderConnectionPoint.cs
- SerializationException.cs
- DataGridViewCellLinkedList.cs
- ExpressionServices.cs
- WindowsProgressbar.cs
- FontStretches.cs
- ConstructorNeedsTagAttribute.cs