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
- LongValidatorAttribute.cs
- DefaultEventAttribute.cs
- DataControlFieldHeaderCell.cs
- TargetParameterCountException.cs
- MediaElement.cs
- PtsHost.cs
- SEHException.cs
- wmiprovider.cs
- ValueUtilsSmi.cs
- GridViewUpdatedEventArgs.cs
- RangeContentEnumerator.cs
- LinqDataSourceValidationException.cs
- EventLogEntry.cs
- Color.cs
- StateItem.cs
- RoleExceptions.cs
- OutputCacheSection.cs
- ByteStack.cs
- HexParser.cs
- GroupPartitionExpr.cs
- SetIterators.cs
- TemplateParser.cs
- GenericUI.cs
- Part.cs
- Baml2006KnownTypes.cs
- PKCS1MaskGenerationMethod.cs
- EntitySqlQueryBuilder.cs
- CopyEncoder.cs
- DataGridBoundColumn.cs
- AttachedAnnotationChangedEventArgs.cs
- QilVisitor.cs
- ControlType.cs
- EntityStoreSchemaGenerator.cs
- VirtualizedCellInfoCollection.cs
- SoapMessage.cs
- IteratorDescriptor.cs
- ChannelManagerBase.cs
- XmlSerializationWriter.cs
- SigningCredentials.cs
- CopyOnWriteList.cs
- InputManager.cs
- XmlHierarchyData.cs
- OracleDateTime.cs
- CodeDomLocalizationProvider.cs
- XmlTypeAttribute.cs
- ItemCollection.cs
- Shape.cs
- BinaryCommonClasses.cs
- Utility.cs
- ReverseInheritProperty.cs
- DataGridViewSelectedColumnCollection.cs
- MatrixTransform.cs
- InternalBufferManager.cs
- DataGridItem.cs
- ParamArrayAttribute.cs
- TreeViewImageKeyConverter.cs
- DesignerSerializationManager.cs
- MachineSettingsSection.cs
- validationstate.cs
- PrintEvent.cs
- Coordinator.cs
- PropertyEntry.cs
- TypeConverterValueSerializer.cs
- SmiMetaDataProperty.cs
- HtmlEncodedRawTextWriter.cs
- PageParserFilter.cs
- HostingPreferredMapPath.cs
- EventProvider.cs
- ValidationSummary.cs
- XmlAnyAttributeAttribute.cs
- GenericTypeParameterConverter.cs
- LinqTreeNodeEvaluator.cs
- HMACRIPEMD160.cs
- _NtlmClient.cs
- Decorator.cs
- NTAccount.cs
- SourceFileBuildProvider.cs
- RecordConverter.cs
- ExtensionWindowResizeGrip.cs
- DataBoundControl.cs
- MulticastDelegate.cs
- UIntPtr.cs
- AspNetHostingPermission.cs
- DataGridRowClipboardEventArgs.cs
- WorkflowServiceBehavior.cs
- ColorTranslator.cs
- ContentPropertyAttribute.cs
- FlowDocument.cs
- EditorBrowsableAttribute.cs
- IncrementalReadDecoders.cs
- GridItemCollection.cs
- ResXFileRef.cs
- HighlightComponent.cs
- ParameterToken.cs
- CurrentChangedEventManager.cs
- ECDsa.cs
- InternalRelationshipCollection.cs
- InternalBase.cs
- AutomationPattern.cs
- OutputCacheSettingsSection.cs