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
- CodeDomConfigurationHandler.cs
- FeatureSupport.cs
- MaskedTextBox.cs
- Oci.cs
- ConvertEvent.cs
- Popup.cs
- OpenTypeCommon.cs
- XmlSecureResolver.cs
- NamespaceDecl.cs
- __Filters.cs
- AuthenticationSection.cs
- PropertyPathConverter.cs
- sqlser.cs
- SqlDelegatedTransaction.cs
- KeyedCollection.cs
- DataGridRelationshipRow.cs
- WindowManager.cs
- HttpException.cs
- SqlDataSourceSelectingEventArgs.cs
- DateTimeConstantAttribute.cs
- AnnotationComponentChooser.cs
- MouseActionValueSerializer.cs
- ProgressBar.cs
- KeyValuePairs.cs
- XhtmlTextWriter.cs
- ProxyWebPartManager.cs
- OperatingSystem.cs
- CalendarTable.cs
- CustomTypeDescriptor.cs
- RawKeyboardInputReport.cs
- MessageFilter.cs
- DateTimeValueSerializer.cs
- AnimationStorage.cs
- newinstructionaction.cs
- OdbcRowUpdatingEvent.cs
- WebMessageEncoderFactory.cs
- PropertyItemInternal.cs
- PathSegmentCollection.cs
- DetailsViewInsertedEventArgs.cs
- GenericWebPart.cs
- SqlDelegatedTransaction.cs
- ConfigurationSchemaErrors.cs
- TextElementCollection.cs
- PingReply.cs
- ContextMenuStrip.cs
- Resources.Designer.cs
- CharUnicodeInfo.cs
- ColumnClickEvent.cs
- XmlWriterTraceListener.cs
- AnimationException.cs
- HttpConfigurationSystem.cs
- DataGridLinkButton.cs
- SqlDataSourceCustomCommandEditor.cs
- XmlSchemaImporter.cs
- ContentDefinition.cs
- CalendarDesigner.cs
- AssociationSetEnd.cs
- BindingOperations.cs
- AutoResetEvent.cs
- recordstate.cs
- EventsTab.cs
- _ProxyRegBlob.cs
- WsatTransactionHeader.cs
- DataTableReaderListener.cs
- DataContractSet.cs
- RequiredFieldValidator.cs
- SharedRuntimeState.cs
- ControlParameter.cs
- GridViewPageEventArgs.cs
- ArrayList.cs
- XmlSchemaValidationException.cs
- ListViewUpdateEventArgs.cs
- FileUpload.cs
- DataTable.cs
- HostingMessageProperty.cs
- GroupedContextMenuStrip.cs
- StorageEntityContainerMapping.cs
- Utility.cs
- XmlCDATASection.cs
- Internal.cs
- TriggerBase.cs
- XmlDataSourceView.cs
- PathParser.cs
- LayoutInformation.cs
- DrawingAttributesDefaultValueFactory.cs
- WSSecurityPolicy12.cs
- AuthenticationSection.cs
- FormatVersion.cs
- ListBindingConverter.cs
- SlipBehavior.cs
- OletxTransactionManager.cs
- FieldNameLookup.cs
- BitmapCodecInfo.cs
- XdrBuilder.cs
- XmlILCommand.cs
- DetailsViewRowCollection.cs
- DataTrigger.cs
- SystemResourceKey.cs
- BoundingRectTracker.cs
- SolidColorBrush.cs