Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / safemediahandle.cs / 1305600 / safemediahandle.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All Rights Reserved. // // File: SafeMediaHandle.cs // //----------------------------------------------------------------------------- using System; using System.IO; using System.Security; using System.Security.Permissions; using System.Collections; using System.Reflection; using MS.Internal; using MS.Win32; using System.Diagnostics; using System.Windows.Media; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; using UnsafeNativeMethods=MS.Win32.PresentationCore.UnsafeNativeMethods; namespace System.Windows.Media { internal class SafeMediaHandle : SafeMILHandle { ////// internal SafeMediaHandle() { } ////// ////// Critical: calls SafeHandle.SetHandle which LinkDemands /// also takes arbitrary IntPtr as a handle /// [SecurityCritical] internal SafeMediaHandle(IntPtr handle) { SetHandle(handle); } ////// Critical - calls unmanaged code, not treat as safe because you must /// validate that handle is a valid COM object. /// [SecurityCritical] protected override bool ReleaseHandle() { HRESULT.Check(MILMedia.Shutdown(handle)); UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle); return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All Rights Reserved. // // File: SafeMediaHandle.cs // //----------------------------------------------------------------------------- using System; using System.IO; using System.Security; using System.Security.Permissions; using System.Collections; using System.Reflection; using MS.Internal; using MS.Win32; using System.Diagnostics; using System.Windows.Media; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; using UnsafeNativeMethods=MS.Win32.PresentationCore.UnsafeNativeMethods; namespace System.Windows.Media { internal class SafeMediaHandle : SafeMILHandle { ////// internal SafeMediaHandle() { } ////// ////// Critical: calls SafeHandle.SetHandle which LinkDemands /// also takes arbitrary IntPtr as a handle /// [SecurityCritical] internal SafeMediaHandle(IntPtr handle) { SetHandle(handle); } ////// Critical - calls unmanaged code, not treat as safe because you must /// validate that handle is a valid COM object. /// [SecurityCritical] protected override bool ReleaseHandle() { HRESULT.Check(MILMedia.Shutdown(handle)); UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle); return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StatusBarDesigner.cs
- Win32.cs
- mediaeventargs.cs
- AnnotationResourceChangedEventArgs.cs
- DesignSurface.cs
- ResourceExpressionBuilder.cs
- TableLayoutColumnStyleCollection.cs
- MulticastOption.cs
- Rect3DConverter.cs
- TrackingProfileCache.cs
- BindingList.cs
- HttpProfileBase.cs
- Accessible.cs
- BamlReader.cs
- AuthenticateEventArgs.cs
- PathSegment.cs
- ReadOnlyObservableCollection.cs
- AsymmetricSignatureFormatter.cs
- TypedDataSetSchemaImporterExtension.cs
- TextLineBreak.cs
- CollectionContainer.cs
- KnownTypeAttribute.cs
- FrameworkElement.cs
- XmlUtil.cs
- EntityClassGenerator.cs
- KeyInfo.cs
- HwndHostAutomationPeer.cs
- Base64Encoder.cs
- DSASignatureDeformatter.cs
- FixedSOMTextRun.cs
- OledbConnectionStringbuilder.cs
- CapabilitiesUse.cs
- ControlBuilderAttribute.cs
- PresentationAppDomainManager.cs
- SpecialFolderEnumConverter.cs
- ImageSource.cs
- TranslateTransform.cs
- DesignerDataColumn.cs
- X509AsymmetricSecurityKey.cs
- HandlerMappingMemo.cs
- Comparer.cs
- VideoDrawing.cs
- IntSecurity.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- CellTreeNode.cs
- SafeLibraryHandle.cs
- _Events.cs
- Logging.cs
- _HTTPDateParse.cs
- SqlClientPermission.cs
- ProxyGenerator.cs
- Int16Animation.cs
- LeaseManager.cs
- ArrangedElementCollection.cs
- AggregationMinMaxHelpers.cs
- CodeDomSerializationProvider.cs
- Int16KeyFrameCollection.cs
- KeyValueConfigurationElement.cs
- ScriptingAuthenticationServiceSection.cs
- WebPartTransformerAttribute.cs
- MenuBase.cs
- WebPartAuthorizationEventArgs.cs
- SchemaImporterExtensionsSection.cs
- RegularExpressionValidator.cs
- ConfigXmlDocument.cs
- MenuItemStyle.cs
- DataSourceSelectArguments.cs
- DynamicScriptObject.cs
- EmptyImpersonationContext.cs
- TextTreeTextNode.cs
- ObjectTokenCategory.cs
- ExpandCollapsePattern.cs
- Control.cs
- ToolStripLabel.cs
- SerializationSectionGroup.cs
- SimpleMailWebEventProvider.cs
- TextEndOfParagraph.cs
- FontCacheUtil.cs
- InfoCardRSACryptoProvider.cs
- MessageLoggingFilterTraceRecord.cs
- AsymmetricSignatureFormatter.cs
- LocatorGroup.cs
- ScriptingSectionGroup.cs
- BatchWriter.cs
- WorkflowMarkupSerializer.cs
- TimersDescriptionAttribute.cs
- PrintingPermissionAttribute.cs
- QuaternionKeyFrameCollection.cs
- SelectionChangedEventArgs.cs
- DatePicker.cs
- PointConverter.cs
- TextMetrics.cs
- NamedPermissionSet.cs
- PlatformCulture.cs
- PageAction.cs
- IndexOutOfRangeException.cs
- DataRecord.cs
- PathNode.cs
- FormatterServices.cs
- XmlBinaryReader.cs