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
- CheckBoxBaseAdapter.cs
- SqlGatherConsumedAliases.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- HashStream.cs
- ImageMetadata.cs
- HttpHandlersSection.cs
- XmlUTF8TextReader.cs
- UnauthorizedWebPart.cs
- WaitHandle.cs
- RevocationPoint.cs
- OrderingQueryOperator.cs
- SqlCommand.cs
- HtmlUtf8RawTextWriter.cs
- ToolStrip.cs
- DesignerActionUI.cs
- Simplifier.cs
- PathGeometry.cs
- DataColumnMappingCollection.cs
- StyleHelper.cs
- DataObjectFieldAttribute.cs
- StringTraceRecord.cs
- ClaimSet.cs
- StringHandle.cs
- IndentedWriter.cs
- IISUnsafeMethods.cs
- SafeSecurityHelper.cs
- MailWebEventProvider.cs
- AnonymousIdentificationSection.cs
- AsynchronousChannelMergeEnumerator.cs
- CodeCommentStatement.cs
- Wildcard.cs
- PermissionRequestEvidence.cs
- ResourceReferenceExpressionConverter.cs
- COM2ExtendedTypeConverter.cs
- PageCache.cs
- DynamicDiscoSearcher.cs
- oledbconnectionstring.cs
- DesignTimeDataBinding.cs
- AppDomain.cs
- HtmlTable.cs
- MaskedTextProvider.cs
- ExtractCollection.cs
- XmlWellformedWriter.cs
- CodeRegionDirective.cs
- FixedSOMLineCollection.cs
- DetailsViewRow.cs
- PiiTraceSource.cs
- HwndSource.cs
- ObjectItemConventionAssemblyLoader.cs
- PerformanceCounter.cs
- JavaScriptString.cs
- DetailsViewUpdatedEventArgs.cs
- ResXResourceSet.cs
- SystemIPGlobalStatistics.cs
- EventMap.cs
- Rfc4050KeyFormatter.cs
- storagemappingitemcollection.viewdictionary.cs
- BulletedList.cs
- ModelVisual3D.cs
- DataTableTypeConverter.cs
- DeclarativeCatalogPart.cs
- GeometryCombineModeValidation.cs
- MemberListBinding.cs
- StateItem.cs
- securestring.cs
- TableProvider.cs
- NameNode.cs
- EventSetterHandlerConverter.cs
- DelegateSerializationHolder.cs
- PeerNameRecord.cs
- documentsequencetextpointer.cs
- ColorMatrix.cs
- ConfigurationValidatorAttribute.cs
- NamedPipeProcessProtocolHandler.cs
- Table.cs
- CacheSection.cs
- PermissionListSet.cs
- DataGridItemCollection.cs
- QilReplaceVisitor.cs
- DataGridPageChangedEventArgs.cs
- DetailsViewUpdateEventArgs.cs
- DbParameterHelper.cs
- PhysicalAddress.cs
- MailFileEditor.cs
- MulticastNotSupportedException.cs
- FailedToStartupUIException.cs
- DayRenderEvent.cs
- compensatingcollection.cs
- _ListenerRequestStream.cs
- MimeTypePropertyAttribute.cs
- DocumentDesigner.cs
- Timer.cs
- ExecutionEngineException.cs
- HashMembershipCondition.cs
- AudioFormatConverter.cs
- Line.cs
- ImageButton.cs
- Item.cs
- SendAgentStatusRequest.cs
- PreProcessInputEventArgs.cs