Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigXmlDocument.cs
- XPathAncestorQuery.cs
- OleDbEnumerator.cs
- FontUnitConverter.cs
- SqlFormatter.cs
- RubberbandSelector.cs
- RowType.cs
- SwitchAttribute.cs
- PathFigure.cs
- Point.cs
- ISAPIRuntime.cs
- FileSystemInfo.cs
- DataGridItemCollection.cs
- DetailsViewDeletedEventArgs.cs
- ChtmlTextWriter.cs
- RootProjectionNode.cs
- EmptyWorkItem.cs
- SqlNodeAnnotations.cs
- FileDialog.cs
- ExceptionUtil.cs
- HtmlInputPassword.cs
- SafeNativeMethods.cs
- Win32Native.cs
- PropertyMappingExceptionEventArgs.cs
- MailDefinition.cs
- SQLInt64Storage.cs
- ProfessionalColorTable.cs
- DataControlLinkButton.cs
- AdCreatedEventArgs.cs
- QueuedDeliveryRequirementsMode.cs
- StrokeNode.cs
- SessionStateContainer.cs
- DelimitedListTraceListener.cs
- MergablePropertyAttribute.cs
- SimpleWebHandlerParser.cs
- WebPartExportVerb.cs
- PtsPage.cs
- MethodImplAttribute.cs
- ScrollPattern.cs
- AssemblyCollection.cs
- ServiceNameElement.cs
- DataObject.cs
- EventWaitHandle.cs
- MemoryFailPoint.cs
- FileRecordSequence.cs
- WindowHelperService.cs
- Point3DConverter.cs
- CodeTypeConstructor.cs
- CachedRequestParams.cs
- OperationAbortedException.cs
- CellTreeNode.cs
- VideoDrawing.cs
- GrammarBuilderPhrase.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- DecoratedNameAttribute.cs
- OrderByLifter.cs
- DockPattern.cs
- SystemIcmpV4Statistics.cs
- DeclarativeConditionsCollection.cs
- ParsedAttributeCollection.cs
- Int64Converter.cs
- COM2ExtendedTypeConverter.cs
- JsonSerializer.cs
- SqlGenerator.cs
- SineEase.cs
- X509Chain.cs
- Point4D.cs
- AsynchronousChannelMergeEnumerator.cs
- ConnectionManager.cs
- Mapping.cs
- EntityViewGenerator.cs
- ScriptingProfileServiceSection.cs
- SQLMembershipProvider.cs
- ConsoleKeyInfo.cs
- MetadataUtil.cs
- ScalarOps.cs
- Vector3DValueSerializer.cs
- Light.cs
- DocumentPageView.cs
- XslUrlEditor.cs
- SmtpSection.cs
- BindingContext.cs
- SqlDependency.cs
- ResourcesBuildProvider.cs
- FileUtil.cs
- WorkflowMessageEventArgs.cs
- InternalDispatchObject.cs
- Html32TextWriter.cs
- ExpressionConverter.cs
- DataGridViewCellStyle.cs
- DependencyObject.cs
- COM2Enum.cs
- ScriptingSectionGroup.cs
- StringResourceManager.cs
- BitmapPalette.cs
- SqlDataSourceCache.cs
- Application.cs
- DataGridViewCellPaintingEventArgs.cs
- XmlNamespaceMapping.cs
- ContractNamespaceAttribute.cs