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
- DataGridViewSelectedCellCollection.cs
- Interlocked.cs
- InputScopeNameConverter.cs
- MultiTouchSystemGestureLogic.cs
- WeakReferenceEnumerator.cs
- SubMenuStyle.cs
- XXXOnTypeBuilderInstantiation.cs
- DataColumnMapping.cs
- DataGridCommandEventArgs.cs
- StyleSheet.cs
- WebPartMovingEventArgs.cs
- StylusPlugInCollection.cs
- GridSplitterAutomationPeer.cs
- ContentPlaceHolder.cs
- RequestCacheValidator.cs
- AmbientLight.cs
- StorageConditionPropertyMapping.cs
- WebPartCancelEventArgs.cs
- WebConfigurationHost.cs
- XPathMultyIterator.cs
- FamilyCollection.cs
- SequentialUshortCollection.cs
- HostSecurityManager.cs
- DataRecordObjectView.cs
- ConfigurationValue.cs
- DrawingDrawingContext.cs
- MimeWriter.cs
- RowParagraph.cs
- XmlAnyElementAttribute.cs
- UnwrappedTypesXmlSerializerManager.cs
- PersianCalendar.cs
- VisualCollection.cs
- BidOverLoads.cs
- DependencyObjectType.cs
- TreeBuilder.cs
- CompilerWrapper.cs
- GeometryDrawing.cs
- SafeFileHandle.cs
- NamespaceDecl.cs
- DynamicRenderer.cs
- TypeToStringValueConverter.cs
- TreeNode.cs
- DataGridTableCollection.cs
- EncryptedPackage.cs
- AsyncPostBackErrorEventArgs.cs
- DrawingContextWalker.cs
- DockPatternIdentifiers.cs
- ItemContainerGenerator.cs
- ToolCreatedEventArgs.cs
- LineMetrics.cs
- SHA512.cs
- BitmapMetadataEnumerator.cs
- ByteAnimation.cs
- ReadOnlyCollectionBase.cs
- TableLayoutStyleCollection.cs
- ImageUrlEditor.cs
- X509CertificateClaimSet.cs
- DocumentEventArgs.cs
- Icon.cs
- DropDownButton.cs
- SelectionEditor.cs
- Formatter.cs
- CommandBinding.cs
- UserControlParser.cs
- ConcurrentQueue.cs
- ThemeInfoAttribute.cs
- LineSegment.cs
- RectangleConverter.cs
- WindowAutomationPeer.cs
- DecoderNLS.cs
- VScrollBar.cs
- FrameworkReadOnlyPropertyMetadata.cs
- DataObjectFieldAttribute.cs
- WinFormsComponentEditor.cs
- RegexCompiler.cs
- OciEnlistContext.cs
- FileNotFoundException.cs
- Duration.cs
- SourceFilter.cs
- DrawItemEvent.cs
- ReliableMessagingHelpers.cs
- Parser.cs
- ViewValidator.cs
- PeerApplication.cs
- ComplexPropertyEntry.cs
- metadatamappinghashervisitor.cs
- LinkLabel.cs
- AVElementHelper.cs
- webbrowsersite.cs
- IPAddressCollection.cs
- PresentationTraceSources.cs
- UpdateException.cs
- TagMapCollection.cs
- DataSourceXmlClassAttribute.cs
- Rect.cs
- WebPartZone.cs
- ScriptReference.cs
- LoadedOrUnloadedOperation.cs
- Image.cs
- MenuItemCollection.cs