Code:
/ 4.0 / 4.0 / 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. // ==++== // // 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
- SmiContext.cs
- AllowedAudienceUriElementCollection.cs
- XmlCollation.cs
- SafeReadContext.cs
- XmlBufferReader.cs
- TextProviderWrapper.cs
- XhtmlBasicCalendarAdapter.cs
- LinearGradientBrush.cs
- HtmlTable.cs
- ExitEventArgs.cs
- PnrpPermission.cs
- Pens.cs
- TrustLevelCollection.cs
- SimpleBitVector32.cs
- NotFiniteNumberException.cs
- MulticastDelegate.cs
- HGlobalSafeHandle.cs
- UnrecognizedAssertionsBindingElement.cs
- DataGridViewColumnConverter.cs
- WindowsButton.cs
- OperationInvokerBehavior.cs
- SqlMetaData.cs
- EdmEntityTypeAttribute.cs
- WebHeaderCollection.cs
- ConnectionStringSettings.cs
- WebBrowser.cs
- AddingNewEventArgs.cs
- AggregateException.cs
- DataSourceHelper.cs
- DbDataSourceEnumerator.cs
- BulletedList.cs
- LockedActivityGlyph.cs
- Tokenizer.cs
- ExpressionBuilderContext.cs
- FilterException.cs
- BindingContext.cs
- SemaphoreFullException.cs
- LayoutInformation.cs
- DbDataReader.cs
- TextOutput.cs
- XPathExpr.cs
- XslCompiledTransform.cs
- cache.cs
- CustomCategoryAttribute.cs
- TextEffect.cs
- XmlSchemas.cs
- Int32Animation.cs
- ExpressionDumper.cs
- NonParentingControl.cs
- LocalFileSettingsProvider.cs
- View.cs
- AndCondition.cs
- FrameworkContextData.cs
- InstanceDataCollection.cs
- UrlMappingCollection.cs
- QilVisitor.cs
- CollectionContainer.cs
- QueryModel.cs
- PostBackTrigger.cs
- DbQueryCommandTree.cs
- Model3DGroup.cs
- ApplicationId.cs
- BrowserCapabilitiesFactory.cs
- StyleBamlRecordReader.cs
- XPathBinder.cs
- AsmxEndpointPickerExtension.cs
- HyperlinkAutomationPeer.cs
- PrimitiveCodeDomSerializer.cs
- ImageButton.cs
- CaseInsensitiveHashCodeProvider.cs
- AsyncWaitHandle.cs
- HttpInputStream.cs
- RegistryKey.cs
- DetailsViewRow.cs
- SimpleRecyclingCache.cs
- DesignerUtility.cs
- ColorContextHelper.cs
- ValidationErrorCollection.cs
- BufferedStream.cs
- OrderedEnumerableRowCollection.cs
- TreeNodeCollection.cs
- XPathScanner.cs
- ColumnHeader.cs
- PaperSource.cs
- DbConnectionInternal.cs
- ToolStripPanelSelectionBehavior.cs
- XamlTemplateSerializer.cs
- DataGridTablesFactory.cs
- xml.cs
- ColumnCollection.cs
- FtpRequestCacheValidator.cs
- Variant.cs
- SliderAutomationPeer.cs
- FormView.cs
- Color.cs
- ProxyWebPartManager.cs
- COM2ComponentEditor.cs
- AssemblyBuilder.cs
- KerberosRequestorSecurityToken.cs
- ZipPackage.cs