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
- ScrollChrome.cs
- EditorBrowsableAttribute.cs
- DbQueryCommandTree.cs
- InstanceHandleConflictException.cs
- NativeWindow.cs
- SafeSecurityHelper.cs
- AutoScrollHelper.cs
- AbandonedMutexException.cs
- LessThan.cs
- StringKeyFrameCollection.cs
- ActivityInstanceReference.cs
- EditorOptionAttribute.cs
- ComboBox.cs
- NameTable.cs
- CollectionEditVerbManager.cs
- TextBoxRenderer.cs
- TextRange.cs
- ToolStripDropDownItem.cs
- FileChangesMonitor.cs
- ArrayMergeHelper.cs
- EventProviderWriter.cs
- RenderTargetBitmap.cs
- TrackBarRenderer.cs
- TdsParserHelperClasses.cs
- QueryCacheKey.cs
- HttpHandlerActionCollection.cs
- XmlSerializer.cs
- SafeFileMapViewHandle.cs
- _OverlappedAsyncResult.cs
- RowCache.cs
- ActivationServices.cs
- ProfileSettingsCollection.cs
- XhtmlBasicPanelAdapter.cs
- BezierSegment.cs
- DataStreamFromComStream.cs
- CustomErrorCollection.cs
- StorageAssociationSetMapping.cs
- MetadataArtifactLoaderCompositeResource.cs
- ServiceKnownTypeAttribute.cs
- ServiceThrottlingElement.cs
- Size.cs
- PrincipalPermission.cs
- SafeMILHandle.cs
- TypeBuilderInstantiation.cs
- Int64Storage.cs
- HostedImpersonationContext.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- ContainerAction.cs
- ExtentCqlBlock.cs
- WizardForm.cs
- Size3D.cs
- AppDomainResourcePerfCounters.cs
- ProxyDataContractResolver.cs
- DataServiceHostFactory.cs
- SapiInterop.cs
- FormViewRow.cs
- TypeDescriptor.cs
- TextRangeEditLists.cs
- ImageAttributes.cs
- SortedList.cs
- ObfuscationAttribute.cs
- HTMLTextWriter.cs
- XPathNavigatorKeyComparer.cs
- HitTestParameters3D.cs
- DesignTableCollection.cs
- RangeValueProviderWrapper.cs
- BitStream.cs
- PageThemeBuildProvider.cs
- ReadOnlyPropertyMetadata.cs
- Schema.cs
- BoolExpressionVisitors.cs
- PrivilegedConfigurationManager.cs
- SoapObjectInfo.cs
- XPathNavigator.cs
- TransformPattern.cs
- FixedSOMSemanticBox.cs
- WebReferenceOptions.cs
- DataGridPagerStyle.cs
- CodeDelegateInvokeExpression.cs
- StdRegProviderWrapper.cs
- QueryServiceConfigHandle.cs
- ManagedWndProcTracker.cs
- PackageDigitalSignatureManager.cs
- EqualityComparer.cs
- OnOperation.cs
- UndoManager.cs
- FilterException.cs
- ExceptionList.cs
- NameTable.cs
- AVElementHelper.cs
- SystemColors.cs
- StreamUpgradeInitiator.cs
- UserMapPath.cs
- UnsafeCollabNativeMethods.cs
- HttpApplication.cs
- ConfigurationFileMap.cs
- ImageKeyConverter.cs
- PropertyGeneratedEventArgs.cs
- MetadataArtifactLoaderResource.cs
- Model3D.cs