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
- CodeAttributeDeclaration.cs
- DBParameter.cs
- DataBoundLiteralControl.cs
- ControlBuilderAttribute.cs
- RepeaterItemEventArgs.cs
- Win32.cs
- InputLanguageCollection.cs
- Message.cs
- GorillaCodec.cs
- PerformanceCounterCategory.cs
- DataRowChangeEvent.cs
- LoginView.cs
- PointKeyFrameCollection.cs
- ChineseLunisolarCalendar.cs
- TypeListConverter.cs
- ClientScriptManager.cs
- UnmanagedMemoryStreamWrapper.cs
- DefinitionBase.cs
- SettingsPropertyWrongTypeException.cs
- SoapMessage.cs
- DbProviderServices.cs
- CommonProperties.cs
- BitmapEffectInput.cs
- ResourcesGenerator.cs
- Track.cs
- Tuple.cs
- ListMarkerLine.cs
- _HeaderInfoTable.cs
- SubtreeProcessor.cs
- TreeNodeClickEventArgs.cs
- String.cs
- CapacityStreamGeometryContext.cs
- CustomValidator.cs
- DateTimeConverter2.cs
- AutomationPropertyInfo.cs
- DataSourceCacheDurationConverter.cs
- CompModSwitches.cs
- Line.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- SchemaAttDef.cs
- EventProperty.cs
- XmlSchemas.cs
- ConfigXmlElement.cs
- nulltextnavigator.cs
- BufferedWebEventProvider.cs
- AuthenticationServiceManager.cs
- _StreamFramer.cs
- ClientRuntimeConfig.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- HttpResponseMessageProperty.cs
- ComPlusInstanceProvider.cs
- DataGridHeaderBorder.cs
- FormsAuthenticationModule.cs
- SafeIUnknown.cs
- RelationshipType.cs
- SerialErrors.cs
- XmlReturnWriter.cs
- CompilerErrorCollection.cs
- ThreadStartException.cs
- SymbolTable.cs
- oledbmetadatacolumnnames.cs
- FontUnit.cs
- Registry.cs
- WebPartTransformerCollection.cs
- RTTrackingProfile.cs
- ContextStaticAttribute.cs
- Pair.cs
- LogReservationCollection.cs
- SQLBytes.cs
- StatusBar.cs
- ControlAdapter.cs
- SR.cs
- FrameworkContentElementAutomationPeer.cs
- BindingObserver.cs
- AudioFileOut.cs
- ComboBoxItem.cs
- GlobalProxySelection.cs
- QueryComponents.cs
- NonVisualControlAttribute.cs
- KeyTimeConverter.cs
- InstanceOwner.cs
- SevenBitStream.cs
- DataGridItem.cs
- FontStretchConverter.cs
- NegotiateStream.cs
- CookielessHelper.cs
- EditingCoordinator.cs
- GeneratedCodeAttribute.cs
- LogStream.cs
- EdmComplexPropertyAttribute.cs
- IisHelper.cs
- OleDbDataAdapter.cs
- XmlNodeComparer.cs
- X509CertificateCollection.cs
- MediaContext.cs
- SocketException.cs
- QueryExecutionOption.cs
- Section.cs
- SQLInt64.cs
- FontDriver.cs