Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / clr / src / BCL / System / Security / SafeSecurityHandles.cs / 2 / SafeSecurityHandles.cs
// Copyright (c) Microsoft Corporation. All rights reserved. namespace Microsoft.Win32.SafeHandles { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Security; internal sealed class SafeLocalAllocHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLocalAllocHandle () : base(true) {} // 0 is an Invalid Handle internal SafeLocalAllocHandle (IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLocalAllocHandle InvalidHandle { get { return new SafeLocalAllocHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { return Win32Native.LocalFree(handle) == IntPtr.Zero; } } internal sealed class SafeLsaLogonProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaLogonProcessHandle() : base (true) {} // 0 is an Invalid Handle internal SafeLsaLogonProcessHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaLogonProcessHandle InvalidHandle { get { return new SafeLsaLogonProcessHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { // LsaDeregisterLogonProcess returns an NTSTATUS return Win32Native.LsaDeregisterLogonProcess(handle) >= 0; } } internal sealed class SafeLsaMemoryHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaMemoryHandle() : base(true) {} // 0 is an Invalid Handle internal SafeLsaMemoryHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaMemoryHandle InvalidHandle { get { return new SafeLsaMemoryHandle( IntPtr.Zero ); } } override protected bool ReleaseHandle() { return Win32Native.LsaFreeMemory(handle) == 0; } } internal sealed class SafeLsaPolicyHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaPolicyHandle() : base(true) {} // 0 is an Invalid Handle internal SafeLsaPolicyHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaPolicyHandle InvalidHandle { get { return new SafeLsaPolicyHandle( IntPtr.Zero ); } } override protected bool ReleaseHandle() { return Win32Native.LsaClose(handle) == 0; } } internal sealed class SafeLsaReturnBufferHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaReturnBufferHandle() : base (true) {} // 0 is an Invalid Handle internal SafeLsaReturnBufferHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaReturnBufferHandle InvalidHandle { get { return new SafeLsaReturnBufferHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { // LsaFreeReturnBuffer returns an NTSTATUS return Win32Native.LsaFreeReturnBuffer(handle) >= 0; } } internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeProcessHandle() : base (true) {} // 0 is an Invalid Handle internal SafeProcessHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeProcessHandle InvalidHandle { get { return new SafeProcessHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); } } internal sealed class SafeThreadHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeThreadHandle() : base (true) {} // 0 is an Invalid Handle internal SafeThreadHandle(IntPtr handle) : base (true) { SetHandle(handle); } override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); } } internal sealed class SafeTokenHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeTokenHandle() : base (true) {} // 0 is an Invalid Handle internal SafeTokenHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeTokenHandle InvalidHandle { get { return new SafeTokenHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { return Win32Native.CloseHandle(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
- FormsAuthenticationModule.cs
- PointAnimation.cs
- ThreadStateException.cs
- MsmqActivation.cs
- TableLayoutCellPaintEventArgs.cs
- ProcessModelSection.cs
- ProcessStartInfo.cs
- _ContextAwareResult.cs
- HighContrastHelper.cs
- ProcessHostServerConfig.cs
- _StreamFramer.cs
- SelectedDatesCollection.cs
- HttpModuleCollection.cs
- HttpHandlerActionCollection.cs
- AbsoluteQuery.cs
- KeyedHashAlgorithm.cs
- QilCloneVisitor.cs
- ContractValidationHelper.cs
- HMAC.cs
- EntityModelBuildProvider.cs
- IPEndPoint.cs
- SqlFactory.cs
- EntityCommand.cs
- OutOfMemoryException.cs
- TextMarkerSource.cs
- documentation.cs
- IMembershipProvider.cs
- HandlerFactoryCache.cs
- AbsoluteQuery.cs
- ComPlusSynchronizationContext.cs
- AnimatedTypeHelpers.cs
- TreeBuilderBamlTranslator.cs
- EtwTrace.cs
- ConcurrentStack.cs
- DecimalAnimationBase.cs
- EndpointReference.cs
- TextFragmentEngine.cs
- VBIdentifierDesigner.xaml.cs
- RuntimeWrappedException.cs
- _BaseOverlappedAsyncResult.cs
- DuplexChannel.cs
- WebPartMinimizeVerb.cs
- ColumnPropertiesGroup.cs
- ColorAnimationUsingKeyFrames.cs
- TraceHelpers.cs
- DEREncoding.cs
- GridViewCellAutomationPeer.cs
- InternalTransaction.cs
- FixedDocumentPaginator.cs
- CqlBlock.cs
- SqlDuplicator.cs
- XPathItem.cs
- ColorKeyFrameCollection.cs
- FullTextBreakpoint.cs
- InternalRelationshipCollection.cs
- Ref.cs
- XmlNodeComparer.cs
- PackageDigitalSignatureManager.cs
- CookieProtection.cs
- AlphaSortedEnumConverter.cs
- WizardStepBase.cs
- WindowsTooltip.cs
- ObjectSecurity.cs
- CompositeTypefaceMetrics.cs
- ItemDragEvent.cs
- Stackframe.cs
- QuaternionValueSerializer.cs
- RemotingConfiguration.cs
- GrowingArray.cs
- CodeCatchClause.cs
- SymLanguageVendor.cs
- KeyInfo.cs
- HierarchicalDataBoundControlAdapter.cs
- StorageModelBuildProvider.cs
- OleDbError.cs
- BindingMAnagerBase.cs
- WorkflowDesigner.cs
- Listener.cs
- PreviewKeyDownEventArgs.cs
- CategoryGridEntry.cs
- TimerExtension.cs
- DelayedRegex.cs
- CodeRegionDirective.cs
- OrCondition.cs
- DictationGrammar.cs
- BinaryHeap.cs
- ProxyManager.cs
- ValuePatternIdentifiers.cs
- CounterCreationData.cs
- ListItemCollection.cs
- DtrList.cs
- PerformanceCounterNameAttribute.cs
- TimelineGroup.cs
- SeparatorAutomationPeer.cs
- ConfigXmlDocument.cs
- MenuEventArgs.cs
- FileChangesMonitor.cs
- ListViewPagedDataSource.cs
- XmlStreamStore.cs
- ZipIORawDataFileBlock.cs