Code:
/ FX-1434 / FX-1434 / 1.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
- BooleanSwitch.cs
- GCHandleCookieTable.cs
- RightNameExpirationInfoPair.cs
- ParagraphResult.cs
- URL.cs
- DbFunctionCommandTree.cs
- NetNamedPipeSecurityElement.cs
- TypeGeneratedEventArgs.cs
- XmlSignatureProperties.cs
- XhtmlBasicTextBoxAdapter.cs
- EditorBrowsableAttribute.cs
- WebFormsRootDesigner.cs
- TypedAsyncResult.cs
- LayoutTableCell.cs
- AssemblyAttributes.cs
- QueryProcessor.cs
- SqlXml.cs
- EntityTypeEmitter.cs
- X509SecurityToken.cs
- ReadWriteSpinLock.cs
- ProfileBuildProvider.cs
- ToolboxDataAttribute.cs
- AtomMaterializerLog.cs
- DurableEnlistmentState.cs
- ImageBrush.cs
- JournalEntryStack.cs
- Exceptions.cs
- KeyTime.cs
- FontDialog.cs
- TextEmbeddedObject.cs
- ModelVisual3D.cs
- SQLDouble.cs
- log.cs
- WindowProviderWrapper.cs
- PageMediaSize.cs
- XsltFunctions.cs
- ComponentChangingEvent.cs
- PageAsyncTaskManager.cs
- UndoEngine.cs
- GeneralTransform.cs
- MetabaseSettingsIis7.cs
- PageAdapter.cs
- DocumentGridContextMenu.cs
- FontFamily.cs
- Message.cs
- SchemaType.cs
- HtmlTableRow.cs
- coordinatorfactory.cs
- Object.cs
- CompilerInfo.cs
- CharacterMetricsDictionary.cs
- Clock.cs
- RolePrincipal.cs
- DependencyPropertyAttribute.cs
- InternalConfigRoot.cs
- ToolZone.cs
- _BufferOffsetSize.cs
- StringTraceRecord.cs
- WebPartMovingEventArgs.cs
- JavascriptCallbackBehaviorAttribute.cs
- WebPartCloseVerb.cs
- Vector3DConverter.cs
- ExcludePathInfo.cs
- ExpandSegmentCollection.cs
- SeekStoryboard.cs
- unsafeIndexingFilterStream.cs
- SharedStatics.cs
- EncodingInfo.cs
- DataGridViewUtilities.cs
- SmiXetterAccessMap.cs
- ADMembershipUser.cs
- RedBlackList.cs
- ToolStripScrollButton.cs
- HtmlContainerControl.cs
- ArraySegment.cs
- DbProviderFactory.cs
- LinearGradientBrush.cs
- DefaultBindingPropertyAttribute.cs
- EmptyEnumerable.cs
- ComponentChangingEvent.cs
- Highlights.cs
- FamilyTypefaceCollection.cs
- DataGridViewCellStyleConverter.cs
- ArrayHelper.cs
- TreeNodeBinding.cs
- Globals.cs
- ToolStripPanelCell.cs
- ListenerElementsCollection.cs
- ImageAttributes.cs
- WebPartConnectionsEventArgs.cs
- BaseTemplateCodeDomTreeGenerator.cs
- PathSegment.cs
- EUCJPEncoding.cs
- DataSourceSelectArguments.cs
- ComPlusContractBehavior.cs
- MemoryStream.cs
- SqlCacheDependencyDatabase.cs
- HostingEnvironmentSection.cs
- ContextStack.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs