Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- LinkClickEvent.cs
- IFlowDocumentViewer.cs
- SystemIPv4InterfaceProperties.cs
- ThrowHelper.cs
- EventLogSession.cs
- _ConnectStream.cs
- StringBuilder.cs
- PagerSettings.cs
- TextViewDesigner.cs
- FactoryGenerator.cs
- RecordManager.cs
- FileStream.cs
- backend.cs
- WindowsToolbarAsMenu.cs
- SerialPinChanges.cs
- CodeMemberMethod.cs
- HttpBufferlessInputStream.cs
- RowType.cs
- ResXBuildProvider.cs
- CompositeScriptReference.cs
- RotateTransform3D.cs
- BaseValidator.cs
- DetailsViewRowCollection.cs
- followingsibling.cs
- ClientScriptManager.cs
- ToolStripPanelRenderEventArgs.cs
- ValidationError.cs
- DriveNotFoundException.cs
- QuaternionRotation3D.cs
- SqlGenericUtil.cs
- DeflateStream.cs
- UnsupportedPolicyOptionsException.cs
- BStrWrapper.cs
- DeviceContexts.cs
- Int16KeyFrameCollection.cs
- ApplicationManager.cs
- ProfilePropertyMetadata.cs
- Button.cs
- QilChoice.cs
- XmlSchemaImporter.cs
- TableRow.cs
- DataKeyCollection.cs
- Adorner.cs
- DelegateSerializationHolder.cs
- TaskForm.cs
- XmlEncodedRawTextWriter.cs
- PackagingUtilities.cs
- xdrvalidator.cs
- MemberAccessException.cs
- ListViewGroupItemCollection.cs
- XmlDataCollection.cs
- HttpServerUtilityBase.cs
- QueryStringConverter.cs
- WindowsTitleBar.cs
- Directory.cs
- ChtmlTextWriter.cs
- CqlErrorHelper.cs
- EndEvent.cs
- SAPICategories.cs
- AnimationClockResource.cs
- ObjectReferenceStack.cs
- PictureBox.cs
- ProcessModelInfo.cs
- DispatcherEventArgs.cs
- SymbolEqualComparer.cs
- BCryptNative.cs
- EditorPartCollection.cs
- RowBinding.cs
- ToolStripHighContrastRenderer.cs
- InheritanceService.cs
- XmlHierarchicalEnumerable.cs
- GridViewSelectEventArgs.cs
- SQLDateTimeStorage.cs
- HttpsHostedTransportConfiguration.cs
- ClientScriptManagerWrapper.cs
- StreamReader.cs
- QilParameter.cs
- Mutex.cs
- RoutedPropertyChangedEventArgs.cs
- SettingsBase.cs
- RoutedUICommand.cs
- XPathNavigatorKeyComparer.cs
- ForwardPositionQuery.cs
- HitTestParameters3D.cs
- ByteConverter.cs
- CatalogPart.cs
- Menu.cs
- ILGenerator.cs
- HTTP_SERVICE_CONFIG_URLACL_PARAM.cs
- ClosableStream.cs
- ListControlConvertEventArgs.cs
- SqlStatistics.cs
- ComponentCommands.cs
- WindowVisualStateTracker.cs
- TrailingSpaceComparer.cs
- QueryProcessor.cs
- PropertyGroupDescription.cs
- CodeAccessSecurityEngine.cs
- RelationshipWrapper.cs
- WebResourceUtil.cs