Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeProcessHandle.cs / 1305376 / 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; using System.Runtime.Versioning; namespace Microsoft.Win32.SafeHandles { [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) {} 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)] [ResourceExposure(ResourceScope.Machine)] 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; using System.Runtime.Versioning; namespace Microsoft.Win32.SafeHandles { [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) {} 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)] [ResourceExposure(ResourceScope.Machine)] 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
- ReverseComparer.cs
- BooleanProjectedSlot.cs
- ConstraintEnumerator.cs
- ApplyTemplatesAction.cs
- MsmqInputChannelListener.cs
- ObjectPersistData.cs
- HttpCookieCollection.cs
- ComponentResourceKey.cs
- TextAction.cs
- ClientFormsAuthenticationCredentials.cs
- ClientSideQueueItem.cs
- MultipleViewPattern.cs
- Imaging.cs
- BufferModesCollection.cs
- SafeNativeMethods.cs
- ThreadStateException.cs
- XmlSchemas.cs
- HwndHostAutomationPeer.cs
- XmlRawWriterWrapper.cs
- ReturnType.cs
- PrePrepareMethodAttribute.cs
- CodeNamespaceCollection.cs
- TraceFilter.cs
- NumericUpDownAcceleration.cs
- BitmapEffectInputData.cs
- InlineCollection.cs
- GridViewColumnHeaderAutomationPeer.cs
- ScrollProperties.cs
- DesignTimeXamlWriter.cs
- WindowsProgressbar.cs
- Logging.cs
- WebPartConnection.cs
- ScrollBar.cs
- PersistenceTypeAttribute.cs
- XmlSerializerVersionAttribute.cs
- EventDescriptorCollection.cs
- XmlSchemaAll.cs
- ChildTable.cs
- SmiEventSink_DeferedProcessing.cs
- SortExpressionBuilder.cs
- ActivationServices.cs
- AmbiguousMatchException.cs
- LayoutTableCell.cs
- AutoGeneratedField.cs
- FrameworkContentElementAutomationPeer.cs
- SqlPersonalizationProvider.cs
- DotExpr.cs
- TimeStampChecker.cs
- HostSecurityManager.cs
- XmlNode.cs
- Vector3dCollection.cs
- Helpers.cs
- ToolStripHighContrastRenderer.cs
- DataGridCellItemAutomationPeer.cs
- RecordManager.cs
- KernelTypeValidation.cs
- RecognizerStateChangedEventArgs.cs
- EntityViewGenerationConstants.cs
- TypedDataSourceCodeGenerator.cs
- Vector.cs
- CollectionEditor.cs
- WebServiceData.cs
- safelinkcollection.cs
- ArraySortHelper.cs
- AdCreatedEventArgs.cs
- QueueProcessor.cs
- FontFamily.cs
- HorizontalAlignConverter.cs
- GlobalId.cs
- CapiSafeHandles.cs
- Utilities.cs
- RadioButtonRenderer.cs
- SmtpReplyReaderFactory.cs
- CompilationPass2TaskInternal.cs
- DBSchemaTable.cs
- DataGridViewColumnConverter.cs
- GetPageCompletedEventArgs.cs
- SvcMapFileSerializer.cs
- AssociationTypeEmitter.cs
- GridViewRow.cs
- RuleSettings.cs
- ExpressionBuilderContext.cs
- RegistryExceptionHelper.cs
- SingleSelectRootGridEntry.cs
- WebBodyFormatMessageProperty.cs
- EntityDataSourceChangingEventArgs.cs
- AbandonedMutexException.cs
- SignedInfo.cs
- DataGridViewCheckBoxColumn.cs
- DynamicResourceExtensionConverter.cs
- WindowsListViewSubItem.cs
- UInt16Storage.cs
- WeakHashtable.cs
- RelOps.cs
- DynamicValidator.cs
- SystemIPAddressInformation.cs
- ConfigurationSettings.cs
- PageAdapter.cs
- odbcmetadatafactory.cs
- _NestedMultipleAsyncResult.cs