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
- CustomActivityDesigner.cs
- DataStreamFromComStream.cs
- DataGridViewRowCollection.cs
- MergablePropertyAttribute.cs
- CommonEndpointBehaviorElement.cs
- VariableElement.cs
- Light.cs
- ContentElement.cs
- Unit.cs
- TagPrefixInfo.cs
- _ListenerRequestStream.cs
- CustomAttributeFormatException.cs
- Debug.cs
- BrowserCapabilitiesFactoryBase.cs
- FirstMatchCodeGroup.cs
- StateManagedCollection.cs
- HandledMouseEvent.cs
- DiscoveryDocumentSerializer.cs
- SymmetricSecurityProtocolFactory.cs
- ListView.cs
- LeftCellWrapper.cs
- DomNameTable.cs
- ModelItemDictionary.cs
- dataobject.cs
- TreeChangeInfo.cs
- SoapSchemaMember.cs
- WebPartHeaderCloseVerb.cs
- safelink.cs
- CodeExpressionStatement.cs
- PrtTicket_Base.cs
- PathFigure.cs
- XmlSignificantWhitespace.cs
- securitycriticaldataClass.cs
- ObjectSecurity.cs
- CodeSubDirectoriesCollection.cs
- SafeViewOfFileHandle.cs
- ListBox.cs
- BaseContextMenu.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- SimpleTableProvider.cs
- StubHelpers.cs
- RepeaterItemEventArgs.cs
- SQLStringStorage.cs
- AlphabeticalEnumConverter.cs
- MappingItemCollection.cs
- Identifier.cs
- InvalidPrinterException.cs
- FontCacheLogic.cs
- XmlSerializerNamespaces.cs
- Comparer.cs
- InstanceStoreQueryResult.cs
- ResourceDictionaryCollection.cs
- QueryInterceptorAttribute.cs
- ObjectManager.cs
- Switch.cs
- PromptStyle.cs
- Validator.cs
- InternalBase.cs
- ReverseQueryOperator.cs
- TrackingParticipant.cs
- Tracking.cs
- ServiceHost.cs
- Psha1DerivedKeyGenerator.cs
- CodeObjectCreateExpression.cs
- TimeSpanMinutesConverter.cs
- QilTargetType.cs
- ProviderException.cs
- SqlVersion.cs
- ListItemsCollectionEditor.cs
- IdentityManager.cs
- FormatConvertedBitmap.cs
- GeneralTransform3DCollection.cs
- SocketPermission.cs
- DbDataReader.cs
- WSSecurityTokenSerializer.cs
- Root.cs
- X509ServiceCertificateAuthenticationElement.cs
- CompModSwitches.cs
- CodeMethodInvokeExpression.cs
- SByteStorage.cs
- IdentitySection.cs
- SHA1CryptoServiceProvider.cs
- RangeContentEnumerator.cs
- SQLGuid.cs
- EdmComplexPropertyAttribute.cs
- GenericWebPart.cs
- Function.cs
- ControlPager.cs
- _RequestCacheProtocol.cs
- ProfileInfo.cs
- SizeChangedInfo.cs
- CodeLabeledStatement.cs
- HorizontalAlignConverter.cs
- DocumentXPathNavigator.cs
- DbParameterCollectionHelper.cs
- UIElement3D.cs
- TrustManagerPromptUI.cs
- HttpCookieCollection.cs
- StrokeCollection.cs
- PropertyIDSet.cs