Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeLibraryHandle.cs / 1305376 / SafeLibraryHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeLibraryHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for a library handles ** ** Date: July 8, 2002 ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note that LoadLibraryEx returns 0 on failure internal SafeLibraryHandle() : base(true) {} [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] [ResourceExposure(ResourceScope.Machine)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] [ResourceExposure(ResourceScope.None)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool FreeLibrary(IntPtr hModule); override protected bool ReleaseHandle() { return FreeLibrary(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeLibraryHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for a library handles ** ** Date: July 8, 2002 ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note that LoadLibraryEx returns 0 on failure internal SafeLibraryHandle() : base(true) {} [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] [ResourceExposure(ResourceScope.Machine)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] [ResourceExposure(ResourceScope.None)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool FreeLibrary(IntPtr hModule); override protected bool ReleaseHandle() { return FreeLibrary(handle); } } } // 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
- VisualStyleInformation.cs
- Zone.cs
- DesignerSerializationVisibilityAttribute.cs
- DataGridGeneralPage.cs
- AppSecurityManager.cs
- _RequestCacheProtocol.cs
- NumericUpDown.cs
- ClientScriptManagerWrapper.cs
- PointAnimationBase.cs
- DesignTimeTemplateParser.cs
- TextEncodedRawTextWriter.cs
- BinaryHeap.cs
- ProcessRequestArgs.cs
- CodeRegionDirective.cs
- WorkflowPersistenceContext.cs
- AspCompat.cs
- PreProcessor.cs
- SplayTreeNode.cs
- OLEDB_Enum.cs
- ProviderConnectionPointCollection.cs
- QueryConverter.cs
- ConvertEvent.cs
- ApplicationContext.cs
- CompatibleIComparer.cs
- CharacterString.cs
- PaperSource.cs
- ElementNotAvailableException.cs
- VectorCollection.cs
- ApplicationHost.cs
- HtmlElement.cs
- HtmlMobileTextWriter.cs
- SqlTypeConverter.cs
- ObjectDisposedException.cs
- SymmetricAlgorithm.cs
- PropertyCollection.cs
- UserControlBuildProvider.cs
- FontStyleConverter.cs
- Transactions.cs
- BuildProviderUtils.cs
- ReadOnlyDataSource.cs
- QueryAccessibilityHelpEvent.cs
- RoutedEvent.cs
- XmlSchemaCompilationSettings.cs
- X509RawDataKeyIdentifierClause.cs
- GenericEnumerator.cs
- _LazyAsyncResult.cs
- MimeImporter.cs
- ToolStripItemGlyph.cs
- ScriptManagerProxy.cs
- ImageMap.cs
- SamlEvidence.cs
- CryptoKeySecurity.cs
- OdbcConnectionOpen.cs
- EndpointIdentityExtension.cs
- ReferentialConstraint.cs
- EdmComplexTypeAttribute.cs
- NavigationCommands.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- EntityViewContainer.cs
- ResXResourceSet.cs
- ToolStripSeparator.cs
- SpellCheck.cs
- TimeSpan.cs
- TdsParserStaticMethods.cs
- ZipIOCentralDirectoryBlock.cs
- NGCPageContentCollectionSerializerAsync.cs
- DataKeyCollection.cs
- FixedDSBuilder.cs
- TreeViewAutomationPeer.cs
- EntityClassGenerator.cs
- QuadraticBezierSegment.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- FilteredReadOnlyMetadataCollection.cs
- DockAndAnchorLayout.cs
- MbpInfo.cs
- CompositeControl.cs
- ObjectSet.cs
- XamlVector3DCollectionSerializer.cs
- WorkflowInstanceExtensionCollection.cs
- MailHeaderInfo.cs
- CodeFieldReferenceExpression.cs
- HopperCache.cs
- SendMessageContent.cs
- HWStack.cs
- ObjectAnimationBase.cs
- TraceLevelStore.cs
- HttpAsyncResult.cs
- RenderDataDrawingContext.cs
- XPathNodeInfoAtom.cs
- PropertyChangingEventArgs.cs
- XmlSerializationGeneratedCode.cs
- XmlNavigatorStack.cs
- GroupDescription.cs
- XmlTextReaderImplHelpers.cs
- SecurityContextKeyIdentifierClause.cs
- URLEditor.cs
- DataGridViewAutoSizeModeEventArgs.cs
- ReadWriteSpinLock.cs
- ObjectAssociationEndMapping.cs
- BitVec.cs