Code:
/ 4.0 / 4.0 / 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. // ==++== // // 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
- SmiTypedGetterSetter.cs
- Compilation.cs
- BindingExpression.cs
- SecurityDocument.cs
- PropertyConverter.cs
- DesignParameter.cs
- ObjectIDGenerator.cs
- VisualTarget.cs
- MsmqActivation.cs
- TextEditorTyping.cs
- DataBinding.cs
- SqlCacheDependency.cs
- RegexMatch.cs
- ContentElementAutomationPeer.cs
- EnumerableRowCollection.cs
- PenThread.cs
- VisualStyleTypesAndProperties.cs
- Globals.cs
- SecurityDescriptor.cs
- OracleConnection.cs
- Pair.cs
- Timeline.cs
- SettingsPropertyValueCollection.cs
- DataPagerField.cs
- SemaphoreSecurity.cs
- Evidence.cs
- DoubleAnimation.cs
- ServiceOperation.cs
- Stylesheet.cs
- Events.cs
- TransformerConfigurationWizardBase.cs
- CodeTypeDeclaration.cs
- SecurityAccessDeniedException.cs
- CodeEventReferenceExpression.cs
- AmbientValueAttribute.cs
- StylusPlugInCollection.cs
- RefExpr.cs
- NavigationPropertyAccessor.cs
- RoutingBehavior.cs
- FunctionDetailsReader.cs
- ConstNode.cs
- TemplateField.cs
- PriorityRange.cs
- AttributeUsageAttribute.cs
- RbTree.cs
- SoapCodeExporter.cs
- IPAddress.cs
- Rotation3DAnimationBase.cs
- precedingsibling.cs
- MethodBuilderInstantiation.cs
- TextLineBreak.cs
- HighlightComponent.cs
- Memoizer.cs
- HiddenFieldPageStatePersister.cs
- PackWebRequestFactory.cs
- ValidationManager.cs
- TdsParserStaticMethods.cs
- TransactionScope.cs
- PreviewKeyDownEventArgs.cs
- MetadataArtifactLoader.cs
- ObjectSpanRewriter.cs
- GrammarBuilder.cs
- ContextMarshalException.cs
- SecurityCriticalDataForSet.cs
- StaticExtensionConverter.cs
- MobileCategoryAttribute.cs
- MSHTMLHost.cs
- XmlBaseWriter.cs
- SocketCache.cs
- GenericUriParser.cs
- SynchronizingStream.cs
- RoutedUICommand.cs
- HealthMonitoringSection.cs
- GZipStream.cs
- HttpApplicationFactory.cs
- MetabaseServerConfig.cs
- X509AudioLogo.cs
- Msec.cs
- ContainerParagraph.cs
- DeclarativeCatalogPartDesigner.cs
- PostBackTrigger.cs
- DataGridViewImageColumn.cs
- GeneralTransformGroup.cs
- TextTreeExtractElementUndoUnit.cs
- BackStopAuthenticationModule.cs
- DataViewListener.cs
- AccessibleObject.cs
- PolicyLevel.cs
- MarginCollapsingState.cs
- BooleanKeyFrameCollection.cs
- Wrapper.cs
- InfoCardBaseException.cs
- EmbossBitmapEffect.cs
- LongValidatorAttribute.cs
- BufferBuilder.cs
- DataServiceRequestException.cs
- XMLUtil.cs
- Win32SafeHandles.cs
- StructuralObject.cs
- ColumnResult.cs