Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeFileMappingHandle.cs / 1 / SafeFileMappingHandle.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeFileMappingHandle
**
** Author: David Gutierrez ([....])
**
** A wrapper for handle to file mappings, returned by
** CreateFileMapping and OpenFileMapping. Used for shared
** memory.
**
** Date: July 8, 2002
**
===========================================================*/
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
[HostProtectionAttribute(MayLeakOnAbort = true)]
[SuppressUnmanagedCodeSecurityAttribute]
internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Note that CreateFileMapping returns 0 on failure.
// Note that you can pass in -1 for the hFile parameter.
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
internal SafeFileMappingHandle() : base(true) {}
[DllImport(ExternDll.Kernel32, ExactSpelling=true, SetLastError=true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool CloseHandle(IntPtr handle);
override protected bool ReleaseHandle()
{
return CloseHandle(handle);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeFileMappingHandle
**
** Author: David Gutierrez ([....])
**
** A wrapper for handle to file mappings, returned by
** CreateFileMapping and OpenFileMapping. Used for shared
** memory.
**
** Date: July 8, 2002
**
===========================================================*/
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
[HostProtectionAttribute(MayLeakOnAbort = true)]
[SuppressUnmanagedCodeSecurityAttribute]
internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Note that CreateFileMapping returns 0 on failure.
// Note that you can pass in -1 for the hFile parameter.
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
internal SafeFileMappingHandle() : base(true) {}
[DllImport(ExternDll.Kernel32, ExactSpelling=true, SetLastError=true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool CloseHandle(IntPtr handle);
override protected bool ReleaseHandle()
{
return CloseHandle(handle);
}
}
}
// 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
- FileCodeGroup.cs
- COM2PropertyDescriptor.cs
- CellTreeNode.cs
- PageCatalogPart.cs
- HelloMessageApril2005.cs
- DataGridRow.cs
- VirtualizingStackPanel.cs
- TextParagraphView.cs
- CompilerWrapper.cs
- AmbientProperties.cs
- OdbcConnectionOpen.cs
- ImageBrush.cs
- UserControlCodeDomTreeGenerator.cs
- Scheduling.cs
- PropertyChangedEventArgs.cs
- CombinedGeometry.cs
- UserInitiatedRoutedEventPermission.cs
- DiagnosticTraceSource.cs
- EncryptedReference.cs
- BrowserTree.cs
- UnsafeNativeMethods.cs
- PartitionedStreamMerger.cs
- SettingsProviderCollection.cs
- ImageCodecInfo.cs
- CachingHintValidation.cs
- XmlAutoDetectWriter.cs
- MatrixTransform.cs
- _ListenerResponseStream.cs
- CodeGroup.cs
- EntityAdapter.cs
- ChannelBinding.cs
- BindingOperations.cs
- DataContractSet.cs
- WindowsProgressbar.cs
- Preprocessor.cs
- UndoEngine.cs
- WebPartManagerInternals.cs
- DesignerTransaction.cs
- TextElementEnumerator.cs
- XmlSchemaInfo.cs
- QueryCacheEntry.cs
- TextDecorations.cs
- NetworkInformationPermission.cs
- StickyNoteAnnotations.cs
- SemanticResolver.cs
- Scalars.cs
- SecuritySessionSecurityTokenAuthenticator.cs
- HealthMonitoringSection.cs
- errorpatternmatcher.cs
- Transform3D.cs
- ExpandCollapseProviderWrapper.cs
- CompositeTypefaceMetrics.cs
- EmptyElement.cs
- SchemaRegistration.cs
- Propagator.cs
- RequestCachingSection.cs
- RouteUrlExpressionBuilder.cs
- ApplicationManager.cs
- unsafenativemethodstextservices.cs
- GeneralTransform3D.cs
- FormsAuthenticationEventArgs.cs
- SafeCryptContextHandle.cs
- ConstantSlot.cs
- PolyBezierSegment.cs
- HttpProtocolImporter.cs
- X509Certificate2.cs
- SoapElementAttribute.cs
- StylusPointPropertyId.cs
- CodeArrayCreateExpression.cs
- HtmlInputControl.cs
- ConfigXmlWhitespace.cs
- AsymmetricSignatureDeformatter.cs
- SplineKeyFrames.cs
- SapiInterop.cs
- LogSwitch.cs
- MessageQueuePermissionEntry.cs
- LogicalMethodInfo.cs
- PropertyNames.cs
- QueryPageSettingsEventArgs.cs
- RotationValidation.cs
- VirtualPath.cs
- RowSpanVector.cs
- MeasurementDCInfo.cs
- SerializationEventsCache.cs
- XPathSelfQuery.cs
- VisualStyleRenderer.cs
- IMembershipProvider.cs
- SoapCodeExporter.cs
- OutputCacheSettingsSection.cs
- MouseEvent.cs
- StringArrayConverter.cs
- Message.cs
- ObjectStateFormatter.cs
- NumberFunctions.cs
- ValueChangedEventManager.cs
- PropertyGeneratedEventArgs.cs
- AdornerLayer.cs
- AmbientProperties.cs
- ThreadInterruptedException.cs
- Substitution.cs