Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- StylusPointProperties.cs
- ConnectivityStatus.cs
- SqlCommandSet.cs
- AsyncPostBackTrigger.cs
- StorageBasedPackageProperties.cs
- CollectionView.cs
- BaseCodeDomTreeGenerator.cs
- ReadOnlyDataSourceView.cs
- ReceiveSecurityHeaderElementManager.cs
- SqlDataSourceCache.cs
- TextTreeInsertElementUndoUnit.cs
- FrameworkTextComposition.cs
- DeviceSpecificChoiceCollection.cs
- AuthenticationService.cs
- SectionVisual.cs
- DependencyObject.cs
- CounterCreationDataCollection.cs
- MultilineStringConverter.cs
- NegotiateStream.cs
- TextRenderingModeValidation.cs
- TokenBasedSetEnumerator.cs
- WindowsListViewScroll.cs
- TrustManagerMoreInformation.cs
- DoubleLinkList.cs
- EnvelopedSignatureTransform.cs
- ZipPackagePart.cs
- FocusChangedEventArgs.cs
- ErrorWrapper.cs
- TrackingParameters.cs
- MembershipAdapter.cs
- DataRelation.cs
- MULTI_QI.cs
- TimeManager.cs
- WebPartMenu.cs
- BooleanProjectedSlot.cs
- DatePickerAutomationPeer.cs
- DynamicObject.cs
- ContextMenuStripActionList.cs
- SettingsProperty.cs
- TypeConverterAttribute.cs
- Glyph.cs
- Mapping.cs
- Converter.cs
- ImageSource.cs
- FormsAuthenticationCredentials.cs
- SoapSchemaExporter.cs
- UriSection.cs
- XmlWriterSettings.cs
- CodeSnippetTypeMember.cs
- SqlDataRecord.cs
- Converter.cs
- SapiRecognizer.cs
- AssemblyResourceLoader.cs
- NullableBoolConverter.cs
- XPathNodeHelper.cs
- FormatStringEditor.cs
- DataBindingValueUIHandler.cs
- DataGridViewCellParsingEventArgs.cs
- SqlGatherConsumedAliases.cs
- OdbcHandle.cs
- Identity.cs
- WebPartConnectionsCancelEventArgs.cs
- SymDocumentType.cs
- ReferentialConstraintRoleElement.cs
- InvalidOleVariantTypeException.cs
- RenameRuleObjectDialog.Designer.cs
- EncodingConverter.cs
- HtmlInputImage.cs
- SqlServices.cs
- OletxTransactionManager.cs
- ConfigurationStrings.cs
- EditingMode.cs
- CompareValidator.cs
- CompositeCollection.cs
- ConfigurationManagerHelper.cs
- Stack.cs
- FastPropertyAccessor.cs
- SHA1CryptoServiceProvider.cs
- ChtmlTextWriter.cs
- TextTreeFixupNode.cs
- MatrixKeyFrameCollection.cs
- DataGridViewRowsAddedEventArgs.cs
- StreamGeometry.cs
- OutputCacheSettingsSection.cs
- TimeSpanParse.cs
- FunctionImportMapping.cs
- Crc32Helper.cs
- SchemaExporter.cs
- Roles.cs
- XmlAttribute.cs
- SqlConnectionStringBuilder.cs
- WindowsStatic.cs
- assemblycache.cs
- CodeConstructor.cs
- AlignmentYValidation.cs
- ValidationRuleCollection.cs
- CodeSnippetTypeMember.cs
- ResolveRequestResponseAsyncResult.cs
- BinaryObjectInfo.cs
- SymbolUsageManager.cs