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
- StringWriter.cs
- ProofTokenCryptoHandle.cs
- JsonReader.cs
- MetadataResolver.cs
- ThumbAutomationPeer.cs
- ZipIOLocalFileHeader.cs
- OLEDB_Util.cs
- TaskDesigner.cs
- InvokeBase.cs
- ListChangedEventArgs.cs
- ConnectionPool.cs
- ContractBase.cs
- NavigationCommands.cs
- TargetConverter.cs
- HandlerMappingMemo.cs
- DataGridViewRowCollection.cs
- ConstraintEnumerator.cs
- RuleCache.cs
- XmlDocumentSerializer.cs
- BufferedStream.cs
- ProfileManager.cs
- PopupEventArgs.cs
- MemberBinding.cs
- QilUnary.cs
- GroupPartitionExpr.cs
- EditorPart.cs
- DataGridViewRowCollection.cs
- Properties.cs
- ReflectionPermission.cs
- SkinBuilder.cs
- ToolStripContainer.cs
- DataGridViewRowsRemovedEventArgs.cs
- InputQueueChannel.cs
- odbcmetadatafactory.cs
- ReflectionTypeLoadException.cs
- SafeSecurityHandles.cs
- DataServices.cs
- DataTemplateKey.cs
- NativeCppClassAttribute.cs
- KerberosRequestorSecurityToken.cs
- CodeExporter.cs
- FlowPosition.cs
- WindowsPrincipal.cs
- BoundPropertyEntry.cs
- ClientSettingsStore.cs
- Imaging.cs
- HttpDictionary.cs
- AvTraceFormat.cs
- DocumentsTrace.cs
- RequestCachePolicy.cs
- UrlPath.cs
- JournalEntryStack.cs
- X509Extension.cs
- ScriptResourceAttribute.cs
- InstanceNormalEvent.cs
- Descriptor.cs
- SystemIPGlobalProperties.cs
- DrawingGroup.cs
- WindowsListViewScroll.cs
- Delegate.cs
- Rect3D.cs
- TextTreeTextBlock.cs
- XamlFigureLengthSerializer.cs
- Transform3DGroup.cs
- Bezier.cs
- BooleanStorage.cs
- SymLanguageType.cs
- HttpResponse.cs
- MemberProjectionIndex.cs
- AnnotationStore.cs
- HTMLTagNameToTypeMapper.cs
- ClassGenerator.cs
- Trace.cs
- UIPermission.cs
- NamedPipeChannelListener.cs
- DataServiceQueryContinuation.cs
- QueryStringParameter.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- ServicesUtilities.cs
- ResourceProviderFactory.cs
- FullTrustAssembliesSection.cs
- Point4D.cs
- mactripleDES.cs
- ContentIterators.cs
- TrayIconDesigner.cs
- Missing.cs
- GlobalAllocSafeHandle.cs
- SiteMapPath.cs
- BasicBrowserDialog.designer.cs
- BasePropertyDescriptor.cs
- XmlArrayItemAttributes.cs
- GeometryCombineModeValidation.cs
- InvokePatternIdentifiers.cs
- ViewPort3D.cs
- TextBoxAutoCompleteSourceConverter.cs
- FlowDocumentReader.cs
- Rotation3DAnimation.cs
- BookmarkCallbackWrapper.cs
- QueryCursorEventArgs.cs
- ConnectAlgorithms.cs