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
- LinkArea.cs
- UnknownWrapper.cs
- EmptyCollection.cs
- CompilerGeneratedAttribute.cs
- XmlWriterTraceListener.cs
- XmlHierarchicalDataSourceView.cs
- XmlExtensionFunction.cs
- FontUnit.cs
- PreloadedPackages.cs
- Permission.cs
- BindingSource.cs
- PasswordRecovery.cs
- ProfileService.cs
- ReturnValue.cs
- TagMapInfo.cs
- ReferenceConverter.cs
- SQLBytes.cs
- CustomErrorsSection.cs
- TdsEnums.cs
- ScriptModule.cs
- NetworkCredential.cs
- TextureBrush.cs
- CollectionViewGroupRoot.cs
- EdmConstants.cs
- SchemaNames.cs
- WebUtil.cs
- DispatchChannelSink.cs
- GeneralTransformGroup.cs
- GridViewCellAutomationPeer.cs
- PackWebRequestFactory.cs
- XmlBinaryReaderSession.cs
- DocumentPageTextView.cs
- WebServiceFault.cs
- Span.cs
- SqlCacheDependency.cs
- TraceContextRecord.cs
- RangeValidator.cs
- LazyTextWriterCreator.cs
- Material.cs
- SourceItem.cs
- ParameterBinding.cs
- RepeaterCommandEventArgs.cs
- HierarchicalDataTemplate.cs
- XmlUrlResolver.cs
- DirectoryRootQuery.cs
- EventTask.cs
- StrokeNodeOperations.cs
- AxisAngleRotation3D.cs
- BindingManagerDataErrorEventArgs.cs
- RtfToXamlReader.cs
- DataGridViewHitTestInfo.cs
- EdmRelationshipRoleAttribute.cs
- AttachmentService.cs
- SqlSupersetValidator.cs
- XmlSerializerFactory.cs
- Size3D.cs
- WorkflowApplication.cs
- TreeNodeSelectionProcessor.cs
- XmlnsDictionary.cs
- XmlResolver.cs
- LocationSectionRecord.cs
- ProfileServiceManager.cs
- DataError.cs
- XmlSchemaObject.cs
- ProfileManager.cs
- NavigationWindow.cs
- IDataContractSurrogate.cs
- RawStylusSystemGestureInputReport.cs
- MediaContext.cs
- JsonFormatGeneratorStatics.cs
- BitConverter.cs
- UInt64Converter.cs
- BamlLocalizableResourceKey.cs
- Preprocessor.cs
- CompiledQueryCacheEntry.cs
- SelectorAutomationPeer.cs
- OleDbErrorCollection.cs
- PageAsyncTask.cs
- ADRoleFactoryConfiguration.cs
- TrackingDataItem.cs
- TraceHandlerErrorFormatter.cs
- StylusButtonCollection.cs
- LineGeometry.cs
- ConfigsHelper.cs
- RadioButtonAutomationPeer.cs
- TTSEvent.cs
- DbProviderFactory.cs
- WinInetCache.cs
- NetTcpSectionData.cs
- TextEffectResolver.cs
- ActionFrame.cs
- MetaModel.cs
- SqlClientMetaDataCollectionNames.cs
- MsdtcClusterUtils.cs
- OdbcParameterCollection.cs
- TreeNode.cs
- BitmapCache.cs
- CodeDirectionExpression.cs
- BoundPropertyEntry.cs
- PeerNameRecord.cs