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
- TcpConnectionPoolSettingsElement.cs
- ExplicitDiscriminatorMap.cs
- Bind.cs
- ProtocolsConfigurationEntry.cs
- Brush.cs
- SecureStringHasher.cs
- ToolStripLabel.cs
- MaskedTextProvider.cs
- KeyGestureConverter.cs
- SqlDataSourceDesigner.cs
- ClientType.cs
- SqlBulkCopy.cs
- SqlRecordBuffer.cs
- TextChange.cs
- SessionPageStateSection.cs
- ButtonFieldBase.cs
- TraceContextRecord.cs
- InfoCardBaseException.cs
- SqlClientWrapperSmiStreamChars.cs
- RequiredArgumentAttribute.cs
- WebServiceMethodData.cs
- XamlFigureLengthSerializer.cs
- InputProcessorProfilesLoader.cs
- HtmlWindowCollection.cs
- dataprotectionpermission.cs
- ExpressionLink.cs
- GPRECTF.cs
- HttpServerVarsCollection.cs
- MILUtilities.cs
- DomainUpDown.cs
- AuthenticationConfig.cs
- SponsorHelper.cs
- COAUTHINFO.cs
- WindowsTokenRoleProvider.cs
- MetaType.cs
- DataStorage.cs
- HostTimeoutsElement.cs
- SmtpAuthenticationManager.cs
- AdornerPresentationContext.cs
- KeyedHashAlgorithm.cs
- UriTemplateLiteralQueryValue.cs
- SettingsSection.cs
- PageAdapter.cs
- MonikerSyntaxException.cs
- EditorPartCollection.cs
- Helper.cs
- ObjectDataSourceMethodEventArgs.cs
- GPPOINTF.cs
- BindToObject.cs
- RequestStatusBarUpdateEventArgs.cs
- SqlRetyper.cs
- HttpGetProtocolImporter.cs
- Object.cs
- BindingUtils.cs
- FilterableAttribute.cs
- AuthenticationService.cs
- SqlNode.cs
- SqlDeflator.cs
- PerfProviderCollection.cs
- Baml2006SchemaContext.cs
- WorkflowNamespace.cs
- HttpHeaderCollection.cs
- HostedTcpTransportManager.cs
- HashCryptoHandle.cs
- DomainConstraint.cs
- ViewgenGatekeeper.cs
- MemberAssignment.cs
- SafeMILHandle.cs
- SchemaNotation.cs
- DataRowExtensions.cs
- XPathEmptyIterator.cs
- SafeLibraryHandle.cs
- HttpResponse.cs
- UnsafeNetInfoNativeMethods.cs
- AsyncInvokeOperation.cs
- Message.cs
- BitVec.cs
- PageAdapter.cs
- AccessibleObject.cs
- FtpCachePolicyElement.cs
- Mapping.cs
- RegionData.cs
- ExternalException.cs
- ApplicationFileCodeDomTreeGenerator.cs
- CapabilitiesAssignment.cs
- TimeBoundedCache.cs
- XmlDocumentSchema.cs
- TreeNodeConverter.cs
- _DigestClient.cs
- SignedXml.cs
- RegexCapture.cs
- ResourcePart.cs
- SafeCertificateContext.cs
- SqlGatherConsumedAliases.cs
- DefaultTextStore.cs
- MessageHeaders.cs
- TypeLoadException.cs
- RegisteredScript.cs
- SupportsEventValidationAttribute.cs
- DecoderNLS.cs