Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- RelatedCurrencyManager.cs
- TdsParameterSetter.cs
- RoutedUICommand.cs
- EntityDescriptor.cs
- ItemCollection.cs
- LinearKeyFrames.cs
- WMIInterop.cs
- ErrorWrapper.cs
- EnumMember.cs
- EventProxy.cs
- SafeNativeMethods.cs
- FontFamilyConverter.cs
- File.cs
- LayoutTableCell.cs
- DateTimeAutomationPeer.cs
- AttributeQuery.cs
- CultureTable.cs
- CommentGlyph.cs
- SecurityHelper.cs
- ConsumerConnectionPointCollection.cs
- OutputWindow.cs
- RadioButton.cs
- StatusBar.cs
- ObjectListShowCommandsEventArgs.cs
- SamlDelegatingWriter.cs
- CodeMethodMap.cs
- Matrix3DValueSerializer.cs
- DispatcherOperation.cs
- PersistNameAttribute.cs
- Random.cs
- FragmentQueryProcessor.cs
- SQLConvert.cs
- FormsAuthenticationConfiguration.cs
- VariantWrapper.cs
- DesignTimeVisibleAttribute.cs
- ChildTable.cs
- BamlReader.cs
- FileLoadException.cs
- ReflectTypeDescriptionProvider.cs
- GiveFeedbackEventArgs.cs
- SingleKeyFrameCollection.cs
- Typography.cs
- NestedContainer.cs
- ExternalDataExchangeService.cs
- XPathException.cs
- TransactedReceiveScope.cs
- FileReader.cs
- ResetableIterator.cs
- BaseComponentEditor.cs
- ThaiBuddhistCalendar.cs
- WCFBuildProvider.cs
- ClrPerspective.cs
- ResourceType.cs
- AnonymousIdentificationSection.cs
- CachedPathData.cs
- PointConverter.cs
- DataGridViewColumnEventArgs.cs
- DataGridViewAddColumnDialog.cs
- UnmanagedMemoryStreamWrapper.cs
- DataServiceRequestArgs.cs
- NetSectionGroup.cs
- ErrorEventArgs.cs
- DbConnectionStringBuilder.cs
- BindingMemberInfo.cs
- BoolExpressionVisitors.cs
- PropertyNames.cs
- And.cs
- SafeMILHandle.cs
- DelegateSerializationHolder.cs
- NativeMethods.cs
- UInt16Storage.cs
- QueueProcessor.cs
- MetadataItemEmitter.cs
- WindowsSpinner.cs
- PerformanceCounterManager.cs
- TrackingParameters.cs
- TemplatedControlDesigner.cs
- HGlobalSafeHandle.cs
- PrintEvent.cs
- ClientTarget.cs
- ScrollViewerAutomationPeer.cs
- ValidatingReaderNodeData.cs
- NameValueCollection.cs
- MeasurementDCInfo.cs
- TableCellCollection.cs
- WebPartDescriptionCollection.cs
- COM2TypeInfoProcessor.cs
- WebScriptEnablingBehavior.cs
- HtmlEmptyTagControlBuilder.cs
- FastPropertyAccessor.cs
- HttpCookiesSection.cs
- CodeIdentifier.cs
- StylusOverProperty.cs
- X509Certificate.cs
- SrgsSubset.cs
- Identity.cs
- ProfilePropertyNameValidator.cs
- DefaultValidator.cs
- UnitControl.cs
- TextTreeRootNode.cs