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
- IImplicitResourceProvider.cs
- XmlHierarchicalDataSourceView.cs
- SQLChars.cs
- FormsAuthenticationConfiguration.cs
- TrackingConditionCollection.cs
- SqlAggregateChecker.cs
- RootBrowserWindowAutomationPeer.cs
- ListViewInsertedEventArgs.cs
- TreeIterators.cs
- RC2.cs
- HyperLink.cs
- ListViewTableRow.cs
- SecurityState.cs
- ResourceIDHelper.cs
- CharacterBuffer.cs
- MenuItem.cs
- CacheChildrenQuery.cs
- EmptyElement.cs
- SchemaCompiler.cs
- TemplateBaseAction.cs
- DataErrorValidationRule.cs
- odbcmetadatacolumnnames.cs
- SoapAttributes.cs
- SiteMapNode.cs
- WindowsHyperlink.cs
- WorkflowWebService.cs
- HiddenField.cs
- XmlKeywords.cs
- KeyboardNavigation.cs
- DataViewListener.cs
- HtmlFormParameterReader.cs
- CommonServiceBehaviorElement.cs
- ThicknessConverter.cs
- ToolboxItemFilterAttribute.cs
- AutomationPropertyChangedEventArgs.cs
- DuplicateDetector.cs
- AuthorizationRule.cs
- FindCriteriaElement.cs
- SpeechAudioFormatInfo.cs
- FigureParaClient.cs
- SqlUnionizer.cs
- TextEditorTyping.cs
- OrderedDictionary.cs
- MergeFilterQuery.cs
- XmlAttributeOverrides.cs
- OutOfProcStateClientManager.cs
- NamedPermissionSet.cs
- FormsIdentity.cs
- FileReservationCollection.cs
- DataTable.cs
- TypedTableBaseExtensions.cs
- Point.cs
- TextTreeText.cs
- SuppressIldasmAttribute.cs
- ExpressionBinding.cs
- ContextMenuService.cs
- ObjectRef.cs
- DomainConstraint.cs
- GradientStop.cs
- GetLedgerRequest.cs
- CompressEmulationStream.cs
- WebPartZoneBase.cs
- FilterableData.cs
- DebugControllerThread.cs
- DbReferenceCollection.cs
- XsltLoader.cs
- MdiWindowListStrip.cs
- SkinBuilder.cs
- PermissionAttributes.cs
- WCFBuildProvider.cs
- UriExt.cs
- CorrelationTokenInvalidatedHandler.cs
- TopClause.cs
- CommonXSendMessage.cs
- ContentPosition.cs
- PopOutPanel.cs
- ListBoxItemWrapperAutomationPeer.cs
- SaveFileDialog.cs
- UserPreference.cs
- Content.cs
- GeneralTransform3DGroup.cs
- SingleSelectRootGridEntry.cs
- EventDriven.cs
- WebPartCancelEventArgs.cs
- PreviewPrintController.cs
- DrawingAttributes.cs
- Renderer.cs
- ContractUtils.cs
- PageHandlerFactory.cs
- DateTimeFormatInfo.cs
- Pair.cs
- GenericEnumerator.cs
- ImportDesigner.xaml.cs
- StyleBamlRecordReader.cs
- XmlDataImplementation.cs
- ComEventsMethod.cs
- KeyValueConfigurationCollection.cs
- SafeMILHandle.cs
- ActivitiesCollection.cs
- XmlNamespaceMappingCollection.cs