Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BinaryOperationBinder.cs
- ExceptionHelpers.cs
- MaskedTextBox.cs
- RawStylusInputCustomData.cs
- DeferredReference.cs
- BulletDecorator.cs
- ComEventsMethod.cs
- RequestCacheManager.cs
- TemplateControlParser.cs
- InkCollectionBehavior.cs
- FileSystemInfo.cs
- MediaContextNotificationWindow.cs
- HttpHostedTransportConfiguration.cs
- PageStatePersister.cs
- ConfigurationLocationCollection.cs
- CodeSnippetExpression.cs
- ResXFileRef.cs
- StatusBarItem.cs
- ChangeNode.cs
- TraceEventCache.cs
- ToolStripPanelRenderEventArgs.cs
- DiagnosticsConfigurationHandler.cs
- DataGridViewCellStyleEditor.cs
- SqlBuffer.cs
- OracleNumber.cs
- StoreUtilities.cs
- InstalledVoice.cs
- CharacterShapingProperties.cs
- assertwrapper.cs
- ExtenderProviderService.cs
- StagingAreaInputItem.cs
- SafeProcessHandle.cs
- ReaderWriterLock.cs
- NTAccount.cs
- DateTimeParse.cs
- SvcMapFileSerializer.cs
- RelationshipConverter.cs
- ReadWriteControlDesigner.cs
- Pkcs7Recipient.cs
- LinearGradientBrush.cs
- StylusPointProperty.cs
- ButtonColumn.cs
- Tokenizer.cs
- OdbcConnectionStringbuilder.cs
- SecUtil.cs
- FontWeightConverter.cs
- SqlParameterCollection.cs
- UserPreferenceChangedEventArgs.cs
- XmlAttributeAttribute.cs
- DecimalConverter.cs
- FixedSchema.cs
- RestHandler.cs
- TextBlockAutomationPeer.cs
- DataGridViewAccessibleObject.cs
- SafeCancelMibChangeNotify.cs
- VectorConverter.cs
- FunctionCommandText.cs
- DataGridViewRowPostPaintEventArgs.cs
- JapaneseCalendar.cs
- EventManager.cs
- TableLayoutCellPaintEventArgs.cs
- WebProxyScriptElement.cs
- AttributeCollection.cs
- SiteMapNodeItem.cs
- OLEDB_Enum.cs
- Switch.cs
- EventLogPermissionAttribute.cs
- future.cs
- PolicyException.cs
- TextElementEnumerator.cs
- ControlBuilderAttribute.cs
- ResXBuildProvider.cs
- DataGridViewButtonCell.cs
- XmlSchemas.cs
- SelectionHighlightInfo.cs
- AssemblyBuilder.cs
- TypeInitializationException.cs
- HttpWriter.cs
- DataGridRowDetailsEventArgs.cs
- ReliabilityContractAttribute.cs
- InputLangChangeRequestEvent.cs
- XmlValueConverter.cs
- _ScatterGatherBuffers.cs
- DesignerProperties.cs
- TypeSource.cs
- DbUpdateCommandTree.cs
- TemplatePartAttribute.cs
- ToolStripProgressBar.cs
- CursorInteropHelper.cs
- NetworkCredential.cs
- ValidationError.cs
- MaterialGroup.cs
- PeerNodeAddress.cs
- MemberInfoSerializationHolder.cs
- EdmProperty.cs
- AVElementHelper.cs
- ColorConvertedBitmap.cs
- AttributedMetaModel.cs
- SpinWait.cs
- LookupNode.cs