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
- ClickablePoint.cs
- LocalizedNameDescriptionPair.cs
- DodSequenceMerge.cs
- NativeCompoundFileAPIs.cs
- OverflowException.cs
- LineGeometry.cs
- InplaceBitmapMetadataWriter.cs
- CodeCommentStatement.cs
- TextAnchor.cs
- ContainerControl.cs
- CompiledQuery.cs
- OAVariantLib.cs
- SiteMapDataSourceView.cs
- OleDbPermission.cs
- ChtmlFormAdapter.cs
- IdentityModelDictionary.cs
- WebPartPersonalization.cs
- LinkLabel.cs
- EventMappingSettings.cs
- SecUtil.cs
- RenderingBiasValidation.cs
- FunctionImportElement.cs
- ExpressionBinding.cs
- WebServiceHandlerFactory.cs
- ExclusiveCanonicalizationTransform.cs
- RtfNavigator.cs
- DateTimeOffsetAdapter.cs
- XmlAttributeProperties.cs
- DataGridViewRowConverter.cs
- SizeKeyFrameCollection.cs
- ContractAdapter.cs
- RsaSecurityTokenAuthenticator.cs
- DesignerTransactionCloseEvent.cs
- ContextBase.cs
- WebPartEditorCancelVerb.cs
- DetailsViewCommandEventArgs.cs
- Registry.cs
- CustomTypeDescriptor.cs
- UnsafeNativeMethods.cs
- EnumBuilder.cs
- ContractSearchPattern.cs
- Rules.cs
- SimpleMailWebEventProvider.cs
- EncodingTable.cs
- GroupItem.cs
- OpenTypeLayout.cs
- ProcessModelInfo.cs
- ParserExtension.cs
- OLEDB_Util.cs
- BitmapVisualManager.cs
- TraceRecord.cs
- ArgumentReference.cs
- HttpListener.cs
- ListViewDataItem.cs
- webeventbuffer.cs
- DataSet.cs
- DataMemberConverter.cs
- FormsAuthenticationModule.cs
- NumberFunctions.cs
- ObjectDataSourceDisposingEventArgs.cs
- HtmlShim.cs
- FunctionDetailsReader.cs
- DomNameTable.cs
- MemberDescriptor.cs
- isolationinterop.cs
- RewritingPass.cs
- BamlWriter.cs
- ListViewTableRow.cs
- XmlSchemaAll.cs
- DocumentViewerAutomationPeer.cs
- StaticContext.cs
- ScriptingRoleServiceSection.cs
- BaseUriHelper.cs
- ValueOfAction.cs
- UnsafeNativeMethodsTablet.cs
- XamlReader.cs
- TypeSystemProvider.cs
- StreamAsIStream.cs
- httpapplicationstate.cs
- WmfPlaceableFileHeader.cs
- DataGridViewRowPostPaintEventArgs.cs
- ScriptReferenceBase.cs
- DefaultProxySection.cs
- RIPEMD160.cs
- HtmlInputText.cs
- ProcessHostServerConfig.cs
- AnnotationElement.cs
- DelegatedStream.cs
- MessageQueueException.cs
- SerializationInfoEnumerator.cs
- RangeValidator.cs
- SymbolTable.cs
- ExtendedProperty.cs
- ValidationSummary.cs
- ConfigurationValidatorAttribute.cs
- BulletChrome.cs
- System.Data_BID.cs
- DesignerEventService.cs
- ViewGenResults.cs
- StrokeNode.cs