Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeProcessHandle.cs / 1 / SafeProcessHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeProcessHandle ** ** A wrapper for a process handle ** ** ===========================================================*/ using System; using System.Security; using System.Diagnostics; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { internal static SafeProcessHandle InvalidHandle = new SafeProcessHandle(IntPtr.Zero); // Note that OpenProcess returns 0 on failure internal SafeProcessHandle() : base(true) {} [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] internal SafeProcessHandle(IntPtr handle) : base (true) { SetHandle(handle); } // Not currently called //[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] //internal SafeProcessHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) { // SetHandle(existingHandle); //} [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)] internal static extern SafeProcessHandle OpenProcess(int access, bool inherit, int processId); internal void InitialSetHandle(IntPtr h){ Debug.Assert(base.IsInvalid, "Safe handle should only be set once"); base.handle = h; } override protected bool ReleaseHandle() { return SafeNativeMethods.CloseHandle(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeProcessHandle ** ** A wrapper for a process handle ** ** ===========================================================*/ using System; using System.Security; using System.Diagnostics; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { internal static SafeProcessHandle InvalidHandle = new SafeProcessHandle(IntPtr.Zero); // Note that OpenProcess returns 0 on failure internal SafeProcessHandle() : base(true) {} [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] internal SafeProcessHandle(IntPtr handle) : base (true) { SetHandle(handle); } // Not currently called //[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] //internal SafeProcessHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) { // SetHandle(existingHandle); //} [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)] internal static extern SafeProcessHandle OpenProcess(int access, bool inherit, int processId); internal void InitialSetHandle(IntPtr h){ Debug.Assert(base.IsInvalid, "Safe handle should only be set once"); base.handle = h; } override protected bool ReleaseHandle() { return SafeNativeMethods.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
- Evidence.cs
- SqlNotificationEventArgs.cs
- PersianCalendar.cs
- LogManagementAsyncResult.cs
- ObjectHandle.cs
- Size3D.cs
- RuntimeIdentifierPropertyAttribute.cs
- CustomCategoryAttribute.cs
- SplitContainer.cs
- Graph.cs
- SchemaCollectionPreprocessor.cs
- AnnotationComponentChooser.cs
- SymmetricCryptoHandle.cs
- SqlProvider.cs
- SqlProcedureAttribute.cs
- ScriptReferenceBase.cs
- ProvidersHelper.cs
- DodSequenceMerge.cs
- IndexingContentUnit.cs
- DataStreamFromComStream.cs
- SimpleApplicationHost.cs
- EntityDataSourceReferenceGroup.cs
- RequestCacheEntry.cs
- InvalidEnumArgumentException.cs
- PointCollection.cs
- XmlCharCheckingWriter.cs
- AccessorTable.cs
- UpdateExpressionVisitor.cs
- AppearanceEditorPart.cs
- RecognizeCompletedEventArgs.cs
- CodeVariableReferenceExpression.cs
- AssemblyCacheEntry.cs
- Run.cs
- EventManager.cs
- MemberInfoSerializationHolder.cs
- PerformanceCounterCategory.cs
- ControlBuilder.cs
- documentsequencetextview.cs
- DefinitionBase.cs
- IxmlLineInfo.cs
- HtmlControlPersistable.cs
- SmiEventSink_DeferedProcessing.cs
- EntityParameter.cs
- SqlServer2KCompatibilityAnnotation.cs
- ToolStripPanel.cs
- ListManagerBindingsCollection.cs
- Transform3D.cs
- BookmarkUndoUnit.cs
- WCFBuildProvider.cs
- PolicyVersionConverter.cs
- DataGridViewCheckBoxCell.cs
- ColorConverter.cs
- ImageSource.cs
- WizardPanelChangingEventArgs.cs
- RefType.cs
- AssociationSetMetadata.cs
- UTF8Encoding.cs
- PresentationTraceSources.cs
- Parser.cs
- EntityDescriptor.cs
- PeerCollaborationPermission.cs
- BindingCollectionElement.cs
- MediaPlayerState.cs
- MaskedTextBox.cs
- Bind.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- ExpressionVisitorHelpers.cs
- GlyphRun.cs
- ConfigXmlElement.cs
- DiscoveryServerProtocol.cs
- SystemEvents.cs
- Thread.cs
- CompilerParameters.cs
- SqlDataSourceCommandEventArgs.cs
- ScriptModule.cs
- Brush.cs
- WindowShowOrOpenTracker.cs
- InheritanceAttribute.cs
- UIInitializationException.cs
- WindowsTokenRoleProvider.cs
- DocumentViewerAutomationPeer.cs
- TagMapInfo.cs
- ToolStripManager.cs
- ToolStripSystemRenderer.cs
- EditorPart.cs
- CharacterBuffer.cs
- Comparer.cs
- TypeDelegator.cs
- PolyBezierSegmentFigureLogic.cs
- DateTime.cs
- Classification.cs
- StyleHelper.cs
- VirtualPath.cs
- nulltextcontainer.cs
- GZipStream.cs
- RequestTimeoutManager.cs
- ItemCheckedEvent.cs
- Color.cs
- DesignerDataRelationship.cs
- FragmentQuery.cs