Code:
/ DotNET / DotNET / 8.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
- IBuiltInEvidence.cs
- CacheSection.cs
- TabItemWrapperAutomationPeer.cs
- documentation.cs
- Page.cs
- MSHTMLHost.cs
- EntityStoreSchemaFilterEntry.cs
- StorageComplexTypeMapping.cs
- ClientScriptManagerWrapper.cs
- DataServiceBuildProvider.cs
- DataGridViewCellLinkedList.cs
- WorkflowFileItem.cs
- IMembershipProvider.cs
- ScrollProperties.cs
- CellPartitioner.cs
- DbTransaction.cs
- FileDataSourceCache.cs
- ShapeTypeface.cs
- WindowsPen.cs
- DataSourceControl.cs
- newinstructionaction.cs
- LassoSelectionBehavior.cs
- ItemsChangedEventArgs.cs
- Int32Converter.cs
- SecurityElement.cs
- WSFederationHttpBindingCollectionElement.cs
- SoapAttributeAttribute.cs
- BezierSegment.cs
- RemoteWebConfigurationHost.cs
- CompositeCollection.cs
- Hash.cs
- ProvideValueServiceProvider.cs
- SkipStoryboardToFill.cs
- Model3D.cs
- CopyEncoder.cs
- DateTimeConverter2.cs
- CaseStatementSlot.cs
- Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
- AttachedPropertyMethodSelector.cs
- DesignerDataSourceView.cs
- ProfilePropertySettingsCollection.cs
- LayoutEngine.cs
- RangeBaseAutomationPeer.cs
- TypefaceMap.cs
- NullReferenceException.cs
- Span.cs
- RenderingBiasValidation.cs
- FormViewUpdatedEventArgs.cs
- IDReferencePropertyAttribute.cs
- ButtonChrome.cs
- CharAnimationUsingKeyFrames.cs
- CacheEntry.cs
- ChildTable.cs
- SafeLocalMemHandle.cs
- SubMenuStyle.cs
- AcceptorSessionSymmetricMessageSecurityProtocol.cs
- XmlIterators.cs
- SafeNativeMethodsMilCoreApi.cs
- HandlerBase.cs
- TextStore.cs
- WindowsComboBox.cs
- oledbmetadatacolumnnames.cs
- ToolBar.cs
- ProcessModuleCollection.cs
- RegionData.cs
- SystemParameters.cs
- HScrollBar.cs
- XPathNavigatorReader.cs
- _HTTPDateParse.cs
- WebPartDescription.cs
- CompositeScriptReferenceEventArgs.cs
- SmiMetaDataProperty.cs
- XmlWhitespace.cs
- Color.cs
- SiteMapNodeItemEventArgs.cs
- FramingChannels.cs
- BitStack.cs
- Typeface.cs
- Funcletizer.cs
- ControllableStoryboardAction.cs
- EntityDataSourceDesignerHelper.cs
- InheritanceContextHelper.cs
- SharedPersonalizationStateInfo.cs
- SourceFileInfo.cs
- DependencyObjectProvider.cs
- GeneralTransform3DTo2DTo3D.cs
- Rect3D.cs
- MetadataItem.cs
- ParseHttpDate.cs
- MemberProjectionIndex.cs
- ListViewDeletedEventArgs.cs
- DatagridviewDisplayedBandsData.cs
- DependencyPropertyChangedEventArgs.cs
- AdCreatedEventArgs.cs
- XmlSchemaGroup.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- EditorZone.cs
- InputBuffer.cs
- CompModSwitches.cs
- ClientRuntimeConfig.cs