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
- MatrixTransform.cs
- DBSqlParser.cs
- DataList.cs
- AutomationElementIdentifiers.cs
- SymbolTable.cs
- InternalRelationshipCollection.cs
- TextServicesCompartment.cs
- UnsafeNativeMethods.cs
- Color.cs
- IOThreadScheduler.cs
- SiteMapSection.cs
- ValueExpressions.cs
- SchemaTableColumn.cs
- HtmlInputHidden.cs
- RC2.cs
- KeyEventArgs.cs
- ObjectStorage.cs
- CollectionBase.cs
- XmlChildEnumerator.cs
- GlobalizationAssembly.cs
- IntSecurity.cs
- ScrollBar.cs
- StorageModelBuildProvider.cs
- FontDialog.cs
- SoapExtensionReflector.cs
- Code.cs
- TextServicesCompartment.cs
- ExpandedWrapper.cs
- PkcsUtils.cs
- XmlQueryOutput.cs
- DatePickerDateValidationErrorEventArgs.cs
- CheckedPointers.cs
- GeneratedContractType.cs
- UserInitiatedRoutedEventPermission.cs
- DispatcherExceptionEventArgs.cs
- InputManager.cs
- Int32Rect.cs
- XmlComplianceUtil.cs
- MDIClient.cs
- RecognitionEventArgs.cs
- AppDomainAttributes.cs
- DbModificationCommandTree.cs
- ExceptionTrace.cs
- OracleColumn.cs
- ManagementBaseObject.cs
- IDReferencePropertyAttribute.cs
- ContentPlaceHolder.cs
- IPAddressCollection.cs
- _NegotiateClient.cs
- SeekableReadStream.cs
- ClientRolePrincipal.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- MimeBasePart.cs
- UIPropertyMetadata.cs
- XmlAttributeCache.cs
- SchemaImporter.cs
- StrongNameUtility.cs
- DataGridViewComboBoxEditingControl.cs
- ProfileGroupSettingsCollection.cs
- webproxy.cs
- EditorPartCollection.cs
- ParallelTimeline.cs
- ContractInferenceHelper.cs
- IODescriptionAttribute.cs
- ScriptingSectionGroup.cs
- PrtCap_Public_Simple.cs
- DataGridHeaderBorder.cs
- BorderGapMaskConverter.cs
- CultureInfoConverter.cs
- TraceLevelHelper.cs
- WebPartConnectionsConnectVerb.cs
- HttpProcessUtility.cs
- EventBuilder.cs
- BamlLocalizationDictionary.cs
- GroupItem.cs
- ClientBuildManager.cs
- HebrewNumber.cs
- typedescriptorpermissionattribute.cs
- InternalTransaction.cs
- InputLanguageCollection.cs
- Pair.cs
- Knowncolors.cs
- SafeTimerHandle.cs
- ImageClickEventArgs.cs
- ElapsedEventArgs.cs
- InfoCardHelper.cs
- Size3DConverter.cs
- CodeGenerator.cs
- DiscreteKeyFrames.cs
- MultiAsyncResult.cs
- WebPartPersonalization.cs
- SiteMapDataSourceView.cs
- _NegoState.cs
- ChannelCacheSettings.cs
- CodeGen.cs
- UpdateRecord.cs
- RegistrationServices.cs
- CookielessHelper.cs
- UnitySerializationHolder.cs
- XhtmlConformanceSection.cs