Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / CoTaskMemSafeHandle.cs / 1305376 / CoTaskMemSafeHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CoTaskMemSafeHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native CoTaskMem allocated via StringToCoTaskMemAuto. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // #pragma warning disable 618 // Have not migrated to v4 transparency yet [System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)] #pragma warning restore 618 internal sealed class CoTaskMemSafeHandle : SafeHandle { internal CoTaskMemSafeHandle() : base(IntPtr.Zero, true) { } internal void SetMemory(IntPtr handle) { SetHandle(handle); } internal IntPtr GetMemory() { return handle; } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { Marshal.FreeCoTaskMem(handle); handle = IntPtr.Zero; return true; } // // DONT compare CoTaskMemSafeHandle with CoTaskMemSafeHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed // public static CoTaskMemSafeHandle Zero { get { return new CoTaskMemSafeHandle(); } } } } // 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
- Label.cs
- TemplateLookupAction.cs
- HtmlInputControl.cs
- GeometryDrawing.cs
- MarkupExtensionParser.cs
- PropertyPathConverter.cs
- TextPenaltyModule.cs
- HuffModule.cs
- ResourceDisplayNameAttribute.cs
- Setter.cs
- SessionStateItemCollection.cs
- ExecutedRoutedEventArgs.cs
- ClientSideProviderDescription.cs
- ErrorWebPart.cs
- TableLayoutStyleCollection.cs
- NamedPipeHostedTransportConfiguration.cs
- Component.cs
- CombinedTcpChannel.cs
- KeyEvent.cs
- sqlpipe.cs
- ExceptionHandlerDesigner.cs
- GraphicsState.cs
- Sorting.cs
- DocComment.cs
- DBConnection.cs
- Deflater.cs
- Ipv6Element.cs
- HandlerMappingMemo.cs
- ScrollBarRenderer.cs
- AppModelKnownContentFactory.cs
- NetTcpSecurityElement.cs
- Icon.cs
- ReadWriteSpinLock.cs
- InternalBufferOverflowException.cs
- ResourceAssociationType.cs
- WebPartsSection.cs
- AsymmetricSecurityBindingElement.cs
- TextPenaltyModule.cs
- InvokePattern.cs
- ListViewItemSelectionChangedEvent.cs
- PropertyInformation.cs
- CommandSet.cs
- ColumnClickEvent.cs
- DeadCharTextComposition.cs
- WebRequest.cs
- TreeNode.cs
- ProvidersHelper.cs
- EventlogProvider.cs
- XComponentModel.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- Decimal.cs
- ValuePattern.cs
- ISAPIWorkerRequest.cs
- Constants.cs
- OleDbCommand.cs
- AnimationClockResource.cs
- InputProcessorProfilesLoader.cs
- StringSource.cs
- IdentityModelStringsVersion1.cs
- ExcCanonicalXml.cs
- SqlDataSourceQueryConverter.cs
- DbConnectionInternal.cs
- DecimalAnimationUsingKeyFrames.cs
- Exceptions.cs
- TextFormatterContext.cs
- HorizontalAlignConverter.cs
- _CommandStream.cs
- SafeNativeMemoryHandle.cs
- InternalPermissions.cs
- IntSecurity.cs
- DoubleLinkList.cs
- WeakRefEnumerator.cs
- DecoratedNameAttribute.cs
- FixedFlowMap.cs
- ManageRequest.cs
- UrlMappingsModule.cs
- Crc32Helper.cs
- ReadOnlyNameValueCollection.cs
- Exceptions.cs
- SoapSchemaExporter.cs
- SerialStream.cs
- SafeEventLogWriteHandle.cs
- RegexParser.cs
- SmiMetaDataProperty.cs
- RichTextBox.cs
- JoinSymbol.cs
- DoubleAverageAggregationOperator.cs
- TemplatePagerField.cs
- _AuthenticationState.cs
- SrgsRuleRef.cs
- Attachment.cs
- ParenthesizePropertyNameAttribute.cs
- BamlLocalizer.cs
- CapabilitiesUse.cs
- AnnotationAdorner.cs
- CharKeyFrameCollection.cs
- JoinCqlBlock.cs
- EncodingDataItem.cs
- webproxy.cs
- MsmqAppDomainProtocolHandler.cs