Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / Security / SafeSecurityHandles.cs / 1 / SafeSecurityHandles.cs
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. // 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. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UIntPtr.cs
- MethodExecutor.cs
- WebPart.cs
- DataGridViewAutoSizeModeEventArgs.cs
- Positioning.cs
- TextBoxView.cs
- XmlEntity.cs
- CachedPathData.cs
- HandleDictionary.cs
- EncryptedXml.cs
- LoginCancelEventArgs.cs
- ThousandthOfEmRealDoubles.cs
- AQNBuilder.cs
- RegexGroup.cs
- TextEndOfParagraph.cs
- CheckBoxDesigner.cs
- DiscoveryClientReferences.cs
- MasterPageParser.cs
- MulticastOption.cs
- RequestTimeoutManager.cs
- StretchValidation.cs
- BitmapMetadataBlob.cs
- Slider.cs
- XLinq.cs
- Repeater.cs
- MultiPageTextView.cs
- HostingEnvironment.cs
- InheritanceService.cs
- BaseTreeIterator.cs
- ContainerCodeDomSerializer.cs
- MemberAccessException.cs
- DataListGeneralPage.cs
- EndPoint.cs
- ClientScriptManager.cs
- UriExt.cs
- TableDetailsRow.cs
- HtmlFormWrapper.cs
- DataGridViewBand.cs
- XsltLibrary.cs
- ProfileModule.cs
- ButtonBaseAutomationPeer.cs
- RequestDescription.cs
- PreviewKeyDownEventArgs.cs
- HybridWebProxyFinder.cs
- ToolTip.cs
- PageTheme.cs
- HashCryptoHandle.cs
- VirtualizingStackPanel.cs
- HostProtectionPermission.cs
- BrowserDefinition.cs
- ManagementClass.cs
- GridItemCollection.cs
- EpmContentDeSerializer.cs
- Scanner.cs
- TriggerBase.cs
- FindCriteriaElement.cs
- BitmapDecoder.cs
- MessageBox.cs
- TableRow.cs
- MaskInputRejectedEventArgs.cs
- DataServiceRequest.cs
- ProxyAttribute.cs
- SafeNativeMethods.cs
- HostedImpersonationContext.cs
- Polyline.cs
- TickBar.cs
- COMException.cs
- NativeMethods.cs
- FixedSOMPageConstructor.cs
- ConfigurationSectionGroupCollection.cs
- PeerObject.cs
- RenderDataDrawingContext.cs
- MouseButtonEventArgs.cs
- ConsoleKeyInfo.cs
- ExcCanonicalXml.cs
- HttpRuntimeSection.cs
- Label.cs
- ReadOnlyAttribute.cs
- Console.cs
- Stacktrace.cs
- DoubleLinkList.cs
- ApplicationFileCodeDomTreeGenerator.cs
- _LoggingObject.cs
- FastEncoder.cs
- GiveFeedbackEventArgs.cs
- DataTableMapping.cs
- prompt.cs
- ComboBoxAutomationPeer.cs
- UserControlBuildProvider.cs
- StartUpEventArgs.cs
- BulletedList.cs
- OrderedDictionaryStateHelper.cs
- Repeater.cs
- FixedSOMContainer.cs
- AllMembershipCondition.cs
- MaskedTextBox.cs
- SortedList.cs
- DocumentSequenceHighlightLayer.cs
- AuthorizationRule.cs
- PinnedBufferMemoryStream.cs