Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Highlights.cs
- DesignerCommandAdapter.cs
- Point3DAnimationBase.cs
- OrderedDictionaryStateHelper.cs
- PageParser.cs
- IndependentAnimationStorage.cs
- SqlDataSourceCache.cs
- BulletedList.cs
- DiscoveryClientBindingElement.cs
- RoutedEvent.cs
- OleStrCAMarshaler.cs
- HttpStreamXmlDictionaryWriter.cs
- MailBnfHelper.cs
- FieldReference.cs
- Token.cs
- PackagingUtilities.cs
- DataGridViewColumnEventArgs.cs
- HttpConfigurationContext.cs
- SmiContext.cs
- Trustee.cs
- PieceDirectory.cs
- FileDialog_Vista_Interop.cs
- RemotingAttributes.cs
- AdjustableArrowCap.cs
- VisualTreeHelper.cs
- SafeBitVector32.cs
- XmlProcessingInstruction.cs
- HttpPostServerProtocol.cs
- SlotInfo.cs
- ReferencedAssembly.cs
- WebReferencesBuildProvider.cs
- EdmComplexTypeAttribute.cs
- ExtentJoinTreeNode.cs
- CryptoConfig.cs
- EnumConverter.cs
- ChangePassword.cs
- MetaTableHelper.cs
- HttpProcessUtility.cs
- MonthChangedEventArgs.cs
- TemplateXamlTreeBuilder.cs
- DataPager.cs
- SqlColumnizer.cs
- Unit.cs
- CacheModeConverter.cs
- XmlElementAttribute.cs
- TypeSystem.cs
- XPathQueryGenerator.cs
- SafeProcessHandle.cs
- ArraySegment.cs
- XmlKeywords.cs
- EntityDataSourceState.cs
- TreeViewDesigner.cs
- EntityClientCacheKey.cs
- InfoCardBinaryReader.cs
- Effect.cs
- SequentialUshortCollection.cs
- XmlLangPropertyAttribute.cs
- TdsParserStaticMethods.cs
- EmptyStringExpandableObjectConverter.cs
- JobInputBins.cs
- _ProxyChain.cs
- LinqDataSourceUpdateEventArgs.cs
- _DynamicWinsockMethods.cs
- UpdatePanelTriggerCollection.cs
- EmbeddedObject.cs
- DefaultBindingPropertyAttribute.cs
- EncoderFallback.cs
- UnitySerializationHolder.cs
- Simplifier.cs
- UnionCodeGroup.cs
- CqlWriter.cs
- SQLGuidStorage.cs
- CssStyleCollection.cs
- SecurityProtocol.cs
- pingexception.cs
- CancelAsyncOperationRequest.cs
- TableLayoutPanelCellPosition.cs
- NamespaceDisplay.xaml.cs
- AsyncOperationLifetimeManager.cs
- AppSettingsReader.cs
- WindowsFormsSynchronizationContext.cs
- AstTree.cs
- SourceChangedEventArgs.cs
- DesignerCatalogPartChrome.cs
- TypeKeyValue.cs
- ResolveResponseInfo.cs
- GetPolicyDetailsRequest.cs
- SpeechSeg.cs
- HttpCapabilitiesBase.cs
- XamlPointCollectionSerializer.cs
- FormCollection.cs
- Viewport3DVisual.cs
- XmlSchemaNotation.cs
- TokenizerHelper.cs
- TimeoutValidationAttribute.cs
- TrackBarRenderer.cs
- InputBinding.cs
- precedingquery.cs
- EntryPointNotFoundException.cs
- TransactionFlowOption.cs