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
- InternalBufferOverflowException.cs
- ScriptResourceAttribute.cs
- ContainerAction.cs
- VirtualizedItemProviderWrapper.cs
- GenericEnumConverter.cs
- MaterialGroup.cs
- NavigationFailedEventArgs.cs
- DetailsViewPagerRow.cs
- CqlErrorHelper.cs
- PageThemeCodeDomTreeGenerator.cs
- ThumbButtonInfo.cs
- ObjectParameter.cs
- AttributeQuery.cs
- PropertyGrid.cs
- UnsafeNativeMethodsTablet.cs
- NumberAction.cs
- SqlDelegatedTransaction.cs
- CodeEventReferenceExpression.cs
- TemplateNameScope.cs
- DataServiceQueryOfT.cs
- CustomSignedXml.cs
- XmlCharType.cs
- CodeCastExpression.cs
- MenuItemAutomationPeer.cs
- CodeTypeConstructor.cs
- CellCreator.cs
- DataSourceHelper.cs
- GridViewActionList.cs
- MarkupCompilePass1.cs
- UDPClient.cs
- SortedList.cs
- XmlSerializationGeneratedCode.cs
- EntityExpressionVisitor.cs
- FontEmbeddingManager.cs
- BufferBuilder.cs
- CurrencyWrapper.cs
- SchemaCollectionCompiler.cs
- OleDbDataReader.cs
- PerfCounterSection.cs
- GetIndexBinder.cs
- RepeatBehaviorConverter.cs
- CodeDOMUtility.cs
- FlowDocumentScrollViewer.cs
- TypefaceMetricsCache.cs
- InternalException.cs
- XamlFigureLengthSerializer.cs
- SystemIPv6InterfaceProperties.cs
- BitmapEffectGeneralTransform.cs
- DateTimeFormatInfoScanner.cs
- AdRotator.cs
- ListenerUnsafeNativeMethods.cs
- GridSplitterAutomationPeer.cs
- ForAllOperator.cs
- XmlSchemaAnnotation.cs
- ProgressBarAutomationPeer.cs
- WindowsFormsLinkLabel.cs
- Italic.cs
- DataGridViewButtonColumn.cs
- FileDialog.cs
- Canvas.cs
- LabelTarget.cs
- ContractUtils.cs
- Crypto.cs
- ObfuscationAttribute.cs
- ToolStripManager.cs
- UTF32Encoding.cs
- CompositeActivityTypeDescriptor.cs
- NestedContainer.cs
- mansign.cs
- RepeatBehaviorConverter.cs
- EntityReference.cs
- unsafenativemethodstextservices.cs
- WhitespaceRuleReader.cs
- AutoSizeToolBoxItem.cs
- LayoutManager.cs
- MediaPlayer.cs
- RedirectionProxy.cs
- EncodingTable.cs
- ConfigurationSectionGroup.cs
- SafeEventLogWriteHandle.cs
- DataGridViewCellValidatingEventArgs.cs
- DrawingContextWalker.cs
- ImplicitInputBrush.cs
- ToolStripCodeDomSerializer.cs
- DataSourceBooleanViewSchemaConverter.cs
- EncodingDataItem.cs
- ToolStripRendererSwitcher.cs
- RuntimeUtils.cs
- Camera.cs
- ConfigurationManagerInternalFactory.cs
- DataGridHeaderBorder.cs
- XmlCountingReader.cs
- ArcSegment.cs
- CodePrimitiveExpression.cs
- ResourcePool.cs
- StorageFunctionMapping.cs
- ButtonBaseAdapter.cs
- SimpleRecyclingCache.cs
- PngBitmapEncoder.cs
- DurableInstancingOptions.cs