Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / CoTaskMemUnicodeSafeHandle.cs / 1305376 / CoTaskMemUnicodeSafeHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CoTaskMemUnicodeSafeHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native CoTaskMem allocated via SecureStringToCoTaskMemUnicode. ** ============================================================*/ 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 CoTaskMemUnicodeSafeHandle : SafeHandle { internal CoTaskMemUnicodeSafeHandle() : base(IntPtr.Zero, true) { } internal CoTaskMemUnicodeSafeHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } 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.ZeroFreeCoTaskMemUnicode(handle); handle = IntPtr.Zero; return true; } // DONT compare CoTaskMemUnicodeSafeHandle with CoTaskMemUnicodeSafeHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static CoTaskMemUnicodeSafeHandle Zero { get { return new CoTaskMemUnicodeSafeHandle(); } } } } // 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
- IISMapPath.cs
- CodeAttributeDeclaration.cs
- Int64Converter.cs
- ProviderException.cs
- PersonalizableTypeEntry.cs
- HttpResponse.cs
- Drawing.cs
- PrinterSettings.cs
- SemanticResultValue.cs
- PropertyValidationContext.cs
- securitycriticaldataformultiplegetandset.cs
- Math.cs
- HtmlHistory.cs
- TreeNodeCollection.cs
- MembershipAdapter.cs
- ActivityXRefConverter.cs
- ObjectAssociationEndMapping.cs
- BoundColumn.cs
- ArrayList.cs
- ZoneIdentityPermission.cs
- ArrayTypeMismatchException.cs
- ScalarConstant.cs
- ServiceBuildProvider.cs
- ParamArrayAttribute.cs
- OperationInfoBase.cs
- HyperLinkStyle.cs
- XAMLParseException.cs
- DateTimePicker.cs
- TextElementAutomationPeer.cs
- MsmqIntegrationSecurity.cs
- VirtualPath.cs
- XmlElementList.cs
- EntityDescriptor.cs
- ChannelBinding.cs
- TextRangeProviderWrapper.cs
- TextBreakpoint.cs
- PreservationFileReader.cs
- _LoggingObject.cs
- ProfileGroupSettings.cs
- Route.cs
- ControlPaint.cs
- WebPartHeaderCloseVerb.cs
- LogicalMethodInfo.cs
- Tokenizer.cs
- NativeRightsManagementAPIsStructures.cs
- IRCollection.cs
- XPathSingletonIterator.cs
- XmlSchemaGroupRef.cs
- RegisterResponseInfo.cs
- PipeStream.cs
- FrameDimension.cs
- ApplicationActivator.cs
- TraceSection.cs
- DesignBindingEditor.cs
- TypeBuilderInstantiation.cs
- ErrorFormatterPage.cs
- OutOfMemoryException.cs
- SqlExpander.cs
- TextSelectionHighlightLayer.cs
- ImageMap.cs
- TableLayoutPanelResizeGlyph.cs
- MissingManifestResourceException.cs
- WindowsPrincipal.cs
- TextUtf8RawTextWriter.cs
- DbProviderFactoriesConfigurationHandler.cs
- DataGridCellAutomationPeer.cs
- CalendarDay.cs
- AuthenticationModuleElementCollection.cs
- XmlFormatMapping.cs
- FlowDocumentReader.cs
- XomlCompilerParameters.cs
- xmlfixedPageInfo.cs
- DataGrid.cs
- InvalidOperationException.cs
- MdiWindowListItemConverter.cs
- SqlTransaction.cs
- TypeLibConverter.cs
- ThreadPool.cs
- RestrictedTransactionalPackage.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- ApplicationException.cs
- WebPartVerb.cs
- CryptoApi.cs
- TemplateXamlTreeBuilder.cs
- HttpModuleActionCollection.cs
- AdRotator.cs
- SQLBoolean.cs
- AlignmentYValidation.cs
- DataListItemEventArgs.cs
- ConfigurationManager.cs
- TakeQueryOptionExpression.cs
- TypeUsage.cs
- ReferenceEqualityComparer.cs
- XPathArrayIterator.cs
- RoutedEvent.cs
- TrackingParticipant.cs
- TerminatorSinks.cs
- PathTooLongException.cs
- Visual.cs
- Bits.cs