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
- MessageDirection.cs
- PackWebRequestFactory.cs
- StrongNameUtility.cs
- WebServiceTypeData.cs
- RootBrowserWindow.cs
- Tuple.cs
- AvtEvent.cs
- InputBuffer.cs
- ImageMetadata.cs
- GridView.cs
- OutputCacheModule.cs
- WebException.cs
- RichTextBoxContextMenu.cs
- Win32Native.cs
- IndexingContentUnit.cs
- ThreadExceptionDialog.cs
- EmptyQuery.cs
- GridViewAutomationPeer.cs
- RouteData.cs
- TrackingMemoryStreamFactory.cs
- UnsafeNativeMethods.cs
- Table.cs
- DBCSCodePageEncoding.cs
- DataTablePropertyDescriptor.cs
- XmlWellformedWriter.cs
- RepeatButton.cs
- Interlocked.cs
- UInt16.cs
- TableCellsCollectionEditor.cs
- DefaultTextStoreTextComposition.cs
- ConstrainedDataObject.cs
- CellLabel.cs
- ImageKeyConverter.cs
- DataGridColumnHeader.cs
- BaseTemplateParser.cs
- XhtmlBasicSelectionListAdapter.cs
- IList.cs
- CatalogZone.cs
- XslTransform.cs
- SimpleBitVector32.cs
- PresentationSource.cs
- RangeValuePatternIdentifiers.cs
- TypeLibConverter.cs
- EventSinkHelperWriter.cs
- DataBinding.cs
- OciHandle.cs
- GridLengthConverter.cs
- MultiSelectRootGridEntry.cs
- ResXResourceWriter.cs
- AppDomainAttributes.cs
- StrokeCollectionDefaultValueFactory.cs
- SystemBrushes.cs
- TreeWalkHelper.cs
- MultilineStringEditor.cs
- SelectionWordBreaker.cs
- Visitors.cs
- XPSSignatureDefinition.cs
- ProxyElement.cs
- InfoCardKeyedHashAlgorithm.cs
- MetadataCache.cs
- HyperLinkField.cs
- Token.cs
- XmlArrayAttribute.cs
- TextServicesHost.cs
- XmlSchemaSimpleTypeList.cs
- HttpBrowserCapabilitiesWrapper.cs
- HttpPostLocalhostServerProtocol.cs
- ArrayElementGridEntry.cs
- ObjectStateEntryDbDataRecord.cs
- GrammarBuilder.cs
- SerializerWriterEventHandlers.cs
- Stylesheet.cs
- PrimitiveType.cs
- DataTemplate.cs
- ConfigXmlSignificantWhitespace.cs
- InlineCategoriesDocument.cs
- ConfigXmlComment.cs
- WindowsComboBox.cs
- WarningException.cs
- ScriptModule.cs
- MatrixCamera.cs
- KerberosSecurityTokenProvider.cs
- DataGridTableCollection.cs
- ThreadStartException.cs
- ObjectToken.cs
- ReachDocumentPageSerializer.cs
- ServiceBuildProvider.cs
- UIElement3DAutomationPeer.cs
- Error.cs
- SafeFileMappingHandle.cs
- ClosableStream.cs
- MULTI_QI.cs
- FunctionNode.cs
- XmlDataContract.cs
- ClaimComparer.cs
- Panel.cs
- IListConverters.cs
- embossbitmapeffect.cs
- InternalConfigSettingsFactory.cs
- UIAgentMonitorHandle.cs