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
- IDQuery.cs
- NavigateUrlConverter.cs
- Size.cs
- QuaternionRotation3D.cs
- Font.cs
- ActiveXContainer.cs
- WebPartDescriptionCollection.cs
- Debug.cs
- GACMembershipCondition.cs
- webbrowsersite.cs
- SelectedGridItemChangedEvent.cs
- ListBoxChrome.cs
- SqlVisitor.cs
- Debug.cs
- UpDownBase.cs
- SemanticResultKey.cs
- Byte.cs
- UrlMappingsModule.cs
- CallbackValidatorAttribute.cs
- GeometryCombineModeValidation.cs
- CodeDOMProvider.cs
- XamlVector3DCollectionSerializer.cs
- DesignerTextBoxAdapter.cs
- CharAnimationUsingKeyFrames.cs
- ReadOnlyActivityGlyph.cs
- PropertyItem.cs
- PageThemeBuildProvider.cs
- xmlglyphRunInfo.cs
- SqlTopReducer.cs
- DictionaryContent.cs
- PropertyDescriptorGridEntry.cs
- StylusButtonCollection.cs
- DrawingGroup.cs
- DiagnosticTrace.cs
- DeferredReference.cs
- RegistryPermission.cs
- TextCompositionEventArgs.cs
- Imaging.cs
- ValidatorCollection.cs
- SafeEventLogWriteHandle.cs
- GenericQueueSurrogate.cs
- LogManagementAsyncResult.cs
- ColumnCollection.cs
- ColorBlend.cs
- _StreamFramer.cs
- cookieexception.cs
- TextRange.cs
- StylusButtonCollection.cs
- PersistenceProvider.cs
- XmlUrlResolver.cs
- AppliedDeviceFiltersEditor.cs
- EnumMember.cs
- UriParserTemplates.cs
- CopyNodeSetAction.cs
- HttpResponseHeader.cs
- TdsParserSessionPool.cs
- JsonWriterDelegator.cs
- FtpWebResponse.cs
- httpapplicationstate.cs
- ThreadInterruptedException.cs
- loginstatus.cs
- Mappings.cs
- DataGridViewCellValidatingEventArgs.cs
- HandoffBehavior.cs
- Exception.cs
- CommandDevice.cs
- HttpTransportSecurity.cs
- ServiceNameElement.cs
- EntityTypeEmitter.cs
- ToolStripContainer.cs
- AmbiguousMatchException.cs
- ServiceObjectContainer.cs
- XmlSchemaDatatype.cs
- GacUtil.cs
- StructuredProperty.cs
- ACL.cs
- TemplatePropertyEntry.cs
- RegisteredDisposeScript.cs
- XamlBrushSerializer.cs
- SpeechSeg.cs
- XmlQualifiedName.cs
- DataTrigger.cs
- Symbol.cs
- DataGridViewRowsRemovedEventArgs.cs
- LayoutTableCell.cs
- ZoneMembershipCondition.cs
- HttpCookiesSection.cs
- XmlSchemaIdentityConstraint.cs
- XmlSchemaSequence.cs
- StreamWriter.cs
- TripleDESCryptoServiceProvider.cs
- EmptyEnumerable.cs
- unsafeIndexingFilterStream.cs
- CornerRadiusConverter.cs
- PropertyPathWorker.cs
- FrameworkContextData.cs
- IOThreadScheduler.cs
- SQLResource.cs
- TrackingMemoryStreamFactory.cs
- SqlHelper.cs