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
- QueryCursorEventArgs.cs
- HasCopySemanticsAttribute.cs
- InheritedPropertyChangedEventArgs.cs
- TextFormatterImp.cs
- WebResponse.cs
- DataServiceConfiguration.cs
- GetIndexBinder.cs
- CompletionProxy.cs
- RandomNumberGenerator.cs
- DES.cs
- SendMailErrorEventArgs.cs
- Pair.cs
- XmlObjectSerializerReadContext.cs
- remotingproxy.cs
- WSSecurityOneDotZeroReceiveSecurityHeader.cs
- OrCondition.cs
- SortedDictionary.cs
- XNodeValidator.cs
- InvokeFunc.cs
- securitycriticaldata.cs
- InputLanguageProfileNotifySink.cs
- CorePropertiesFilter.cs
- SQLInt64Storage.cs
- BooleanSwitch.cs
- IdentityManager.cs
- EntryIndex.cs
- PrintDialog.cs
- RuntimeHelpers.cs
- WorkflowDataContext.cs
- XPathException.cs
- Context.cs
- SystemInfo.cs
- ImmutableCommunicationTimeouts.cs
- ToolStripPanelSelectionBehavior.cs
- ClientTargetSection.cs
- SmtpNtlmAuthenticationModule.cs
- DoubleCollectionValueSerializer.cs
- WebPartZoneCollection.cs
- CalendarButtonAutomationPeer.cs
- PermissionAttributes.cs
- MonthChangedEventArgs.cs
- ScriptResourceHandler.cs
- _TransmitFileOverlappedAsyncResult.cs
- OperationResponse.cs
- WebPartAddingEventArgs.cs
- GenericEnumConverter.cs
- XmlDataSourceDesigner.cs
- ServiceManager.cs
- ResourceBinder.cs
- BaseCodePageEncoding.cs
- AttachmentCollection.cs
- StaticResourceExtension.cs
- PageAsyncTaskManager.cs
- TraceHandlerErrorFormatter.cs
- X509ThumbprintKeyIdentifierClause.cs
- Walker.cs
- FixedSOMSemanticBox.cs
- OfTypeExpression.cs
- WebConfigurationHostFileChange.cs
- NotificationContext.cs
- MessageHeaderException.cs
- WorkflowValidationFailedException.cs
- VerticalAlignConverter.cs
- SQLBytes.cs
- Content.cs
- Root.cs
- DrawingImage.cs
- XhtmlTextWriter.cs
- DictationGrammar.cs
- XmlElementAttribute.cs
- EntityDataSourceWizardForm.cs
- SerializationObjectManager.cs
- PipelineModuleStepContainer.cs
- DoubleCollectionConverter.cs
- CompilerGlobalScopeAttribute.cs
- KeyValueConfigurationElement.cs
- x509utils.cs
- unsafenativemethodstextservices.cs
- DataConnectionHelper.cs
- WorkflowTerminatedException.cs
- TcpAppDomainProtocolHandler.cs
- PanelStyle.cs
- SoapInteropTypes.cs
- EventMappingSettingsCollection.cs
- SafeArrayTypeMismatchException.cs
- SecurityRequiresReviewAttribute.cs
- CustomAttributeFormatException.cs
- IntSecurity.cs
- XamlWriter.cs
- ConnectionStringSettings.cs
- PasswordRecovery.cs
- UdpSocket.cs
- ToolStripArrowRenderEventArgs.cs
- CharacterMetrics.cs
- HashCodeCombiner.cs
- ServiceOperation.cs
- DataControlImageButton.cs
- FontDriver.cs
- EmitterCache.cs
- PointHitTestParameters.cs