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
- HtmlTernaryTree.cs
- InfiniteTimeSpanConverter.cs
- MemberHolder.cs
- IImplicitResourceProvider.cs
- CaseInsensitiveComparer.cs
- DesignTimeParseData.cs
- TCPClient.cs
- TreeViewImageIndexConverter.cs
- ProfileInfo.cs
- ProtocolsConfigurationHandler.cs
- TextBreakpoint.cs
- ZoneButton.cs
- TableCell.cs
- FileSystemInfo.cs
- MultiView.cs
- CopyCodeAction.cs
- Vector.cs
- BulletChrome.cs
- RegularExpressionValidator.cs
- AssemblyBuilderData.cs
- ReaderWriterLock.cs
- SqlFormatter.cs
- Parameter.cs
- EventWaitHandle.cs
- PresentationUIStyleResources.cs
- ColumnResult.cs
- ContextMenu.cs
- CompoundFileStreamReference.cs
- HtmlEmptyTagControlBuilder.cs
- MarkupProperty.cs
- PackageRelationshipSelector.cs
- ClientBuildManagerCallback.cs
- Win32.cs
- LinearGradientBrush.cs
- HighlightVisual.cs
- IPHostEntry.cs
- FilterException.cs
- GZipStream.cs
- ContractNamespaceAttribute.cs
- Memoizer.cs
- TypeElement.cs
- Base64Encoder.cs
- TablePatternIdentifiers.cs
- CopyOnWriteList.cs
- PropertySourceInfo.cs
- NativeObjectSecurity.cs
- SmiEventSink_DeferedProcessing.cs
- XmlSchemaType.cs
- ExecutionEngineException.cs
- DataMisalignedException.cs
- TextSelectionHighlightLayer.cs
- DataTrigger.cs
- OutputCacheSettings.cs
- PersonalizationProvider.cs
- CustomAttributeFormatException.cs
- ProcessModuleCollection.cs
- HtmlWindowCollection.cs
- Pkcs7Recipient.cs
- DataBindEngine.cs
- UrlMappingsModule.cs
- TraceAsyncResult.cs
- ConfigurationProperty.cs
- Message.cs
- DocumentScope.cs
- AttributeEmitter.cs
- ToolStripHighContrastRenderer.cs
- ContextStaticAttribute.cs
- _SslState.cs
- UserValidatedEventArgs.cs
- WSHttpBindingBase.cs
- LaxModeSecurityHeaderElementInferenceEngine.cs
- IndicCharClassifier.cs
- SegmentInfo.cs
- SoundPlayer.cs
- NeutralResourcesLanguageAttribute.cs
- Oid.cs
- OperationAbortedException.cs
- RegexBoyerMoore.cs
- DataConnectionHelper.cs
- OleAutBinder.cs
- RequiredArgumentAttribute.cs
- PenThread.cs
- SeverityFilter.cs
- TextFormatter.cs
- TextDecorationCollection.cs
- Pts.cs
- TemplateInstanceAttribute.cs
- TypedDatasetGenerator.cs
- BaseDataBoundControl.cs
- Trace.cs
- ProcessManager.cs
- ConnectionOrientedTransportBindingElement.cs
- PaperSource.cs
- WindowsListView.cs
- XmlRawWriter.cs
- AutomationPatternInfo.cs
- LOSFormatter.cs
- CodeNamespaceCollection.cs
- ProtectedProviderSettings.cs
- ReferenceTypeElement.cs