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
- AttributeData.cs
- TdsParser.cs
- AssemblyBuilder.cs
- PropertyMapper.cs
- ReferenceSchema.cs
- TypeToken.cs
- InfoCardProofToken.cs
- RefType.cs
- GlyphRun.cs
- Globals.cs
- UserThread.cs
- LineGeometry.cs
- AuthenticationConfig.cs
- StdValidatorsAndConverters.cs
- PeerResolverElement.cs
- NameTable.cs
- DBConnection.cs
- ListViewGroup.cs
- XmlAutoDetectWriter.cs
- NamedPipeAppDomainProtocolHandler.cs
- XmlSchemaObjectTable.cs
- IdentifierService.cs
- DistributedTransactionPermission.cs
- DataGridTextBox.cs
- XamlUtilities.cs
- ComponentGlyph.cs
- ListViewUpdatedEventArgs.cs
- Variant.cs
- EncoderBestFitFallback.cs
- Command.cs
- InputScope.cs
- SessionParameter.cs
- BasicBrowserDialog.designer.cs
- PrivateFontCollection.cs
- AnyAllSearchOperator.cs
- ArrayElementGridEntry.cs
- EdmItemCollection.cs
- AtlasWeb.Designer.cs
- SurrogateChar.cs
- DataGridItemAttachedStorage.cs
- TextPenaltyModule.cs
- SHA384Managed.cs
- DesigntimeLicenseContext.cs
- DesignerValidationSummaryAdapter.cs
- HttpHandlersSection.cs
- BamlLocalizableResourceKey.cs
- KeyEvent.cs
- UriParserTemplates.cs
- PrintController.cs
- WebEventTraceProvider.cs
- DataGridViewCellStyleChangedEventArgs.cs
- CheckBoxList.cs
- ManagementInstaller.cs
- EventLog.cs
- TdsParserHelperClasses.cs
- Span.cs
- ParallelTimeline.cs
- CustomBinding.cs
- WorkflowRuntimeSection.cs
- RegionInfo.cs
- PackageDigitalSignature.cs
- ExplicitDiscriminatorMap.cs
- SortQueryOperator.cs
- BookmarkList.cs
- SurrogateSelector.cs
- __Filters.cs
- IISMapPath.cs
- TextEditorDragDrop.cs
- MDIWindowDialog.cs
- TcpAppDomainProtocolHandler.cs
- ToolStripLabel.cs
- LeafCellTreeNode.cs
- Directory.cs
- SystemException.cs
- LinqDataSourceContextData.cs
- AxisAngleRotation3D.cs
- DecoderBestFitFallback.cs
- WindowsAuthenticationEventArgs.cs
- HtmlControl.cs
- DNS.cs
- HttpApplicationFactory.cs
- WindowsSidIdentity.cs
- WebSysDefaultValueAttribute.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- ContainerUIElement3D.cs
- SupportedAddressingMode.cs
- AccessViolationException.cs
- CodeMethodReturnStatement.cs
- XmlSchemaType.cs
- PersonalizableTypeEntry.cs
- XmlSchemaImporter.cs
- ReadOnlyDataSourceView.cs
- PatternMatchRules.cs
- unsafenativemethodsother.cs
- PrePrepareMethodAttribute.cs
- Pkcs7Recipient.cs
- DataGridViewEditingControlShowingEventArgs.cs
- XmlAttributeProperties.cs
- DataGridViewHeaderCell.cs
- indexingfiltermarshaler.cs