Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / CoTaskMemSafeHandle.cs / 1305376 / CoTaskMemSafeHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CoTaskMemSafeHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native CoTaskMem allocated via StringToCoTaskMemAuto. ** ============================================================*/ 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 CoTaskMemSafeHandle : SafeHandle { internal CoTaskMemSafeHandle() : base(IntPtr.Zero, true) { } 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.FreeCoTaskMem(handle); handle = IntPtr.Zero; return true; } // // DONT compare CoTaskMemSafeHandle with CoTaskMemSafeHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed // public static CoTaskMemSafeHandle Zero { get { return new CoTaskMemSafeHandle(); } } } } // 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
- Variant.cs
- DesignerDataSourceView.cs
- WindowsListViewItem.cs
- SelectionHighlightInfo.cs
- DateTime.cs
- BuildResultCache.cs
- ValidationResult.cs
- ClientApiGenerator.cs
- FormViewAutoFormat.cs
- HttpHandlerAction.cs
- NamedPipeHostedTransportConfiguration.cs
- AsyncDataRequest.cs
- WindowsPrincipal.cs
- RegistryConfigurationProvider.cs
- CSharpCodeProvider.cs
- Header.cs
- LostFocusEventManager.cs
- DataServiceResponse.cs
- ChildTable.cs
- ValueQuery.cs
- Formatter.cs
- DataBoundControl.cs
- RowBinding.cs
- PlacementWorkspace.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- FormatConvertedBitmap.cs
- FeatureSupport.cs
- PhysicalAddress.cs
- ImageButton.cs
- ListViewInsertionMark.cs
- ControlCachePolicy.cs
- GridView.cs
- ForeignConstraint.cs
- WmlSelectionListAdapter.cs
- Bold.cs
- MouseGestureConverter.cs
- StrongNameUtility.cs
- codemethodreferenceexpression.cs
- ReferenceEqualityComparer.cs
- BasePattern.cs
- Int64KeyFrameCollection.cs
- Constants.cs
- DBCommandBuilder.cs
- InternalBufferOverflowException.cs
- RepeatInfo.cs
- ObjectQueryExecutionPlan.cs
- ScriptIgnoreAttribute.cs
- Membership.cs
- LicenseContext.cs
- DbCommandDefinition.cs
- EditingMode.cs
- ImpersonateTokenRef.cs
- FixedPageAutomationPeer.cs
- SeparatorAutomationPeer.cs
- RenderDataDrawingContext.cs
- Int16Converter.cs
- VisualStateGroup.cs
- SetIterators.cs
- DataGridViewRowHeaderCell.cs
- HttpConfigurationSystem.cs
- EntityCommandCompilationException.cs
- baseshape.cs
- ListItemCollection.cs
- CharacterMetrics.cs
- ExpandableObjectConverter.cs
- Compilation.cs
- BasicExpressionVisitor.cs
- OleDbDataReader.cs
- RotateTransform.cs
- ControlHelper.cs
- FileDialog_Vista_Interop.cs
- Viewport3DAutomationPeer.cs
- Vars.cs
- Attributes.cs
- DataSetViewSchema.cs
- SnapshotChangeTrackingStrategy.cs
- DictionaryManager.cs
- MouseGesture.cs
- TreeViewImageIndexConverter.cs
- SystemTcpStatistics.cs
- MethodBuilder.cs
- __FastResourceComparer.cs
- ClientOptions.cs
- LinkButton.cs
- StorageMappingFragment.cs
- SpanIndex.cs
- AssemblyCache.cs
- DrawingContextWalker.cs
- XmlHierarchicalDataSourceView.cs
- DockAndAnchorLayout.cs
- Literal.cs
- TypeExtensions.cs
- XmlNamedNodeMap.cs
- WhitespaceRuleReader.cs
- _FtpControlStream.cs
- TimeStampChecker.cs
- CustomErrorCollection.cs
- PatternMatcher.cs
- SQLByte.cs
- ConfigXmlComment.cs