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
- TempFiles.cs
- StringArrayConverter.cs
- Char.cs
- sqlcontext.cs
- FixedSOMTextRun.cs
- RecommendedAsConfigurableAttribute.cs
- SparseMemoryStream.cs
- MenuItemBindingCollection.cs
- DataGridCommandEventArgs.cs
- IApplicationTrustManager.cs
- CollectionAdapters.cs
- PartialCachingAttribute.cs
- SwitchCase.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- InfoCardPolicy.cs
- NativeCompoundFileAPIs.cs
- WindowsFormsHelpers.cs
- WpfXamlType.cs
- ZoneButton.cs
- StrongNameUtility.cs
- Substitution.cs
- Cursor.cs
- ThumbAutomationPeer.cs
- SourceFilter.cs
- PnrpPermission.cs
- UrlMapping.cs
- SchemaTableColumn.cs
- TextPatternIdentifiers.cs
- StaticSiteMapProvider.cs
- ButtonAutomationPeer.cs
- UniqueIdentifierService.cs
- MethodToken.cs
- GeneralTransformGroup.cs
- XmlAttributeProperties.cs
- PointAnimationClockResource.cs
- XmlSchemaAnnotation.cs
- Crc32Helper.cs
- OptimalTextSource.cs
- WindowsPrincipal.cs
- Constraint.cs
- ProxyWebPart.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DataGridCommandEventArgs.cs
- X509ThumbprintKeyIdentifierClause.cs
- WinInetCache.cs
- BinHexDecoder.cs
- BrowsableAttribute.cs
- SHA1Managed.cs
- ConfigsHelper.cs
- ProgressBar.cs
- OLEDB_Enum.cs
- SqlMethodTransformer.cs
- InstancePersistenceContext.cs
- WindowsListViewScroll.cs
- DesignerDataParameter.cs
- KeyTime.cs
- ComplexPropertyEntry.cs
- XmlTextWriter.cs
- MimePart.cs
- ConstraintConverter.cs
- ProfileParameter.cs
- BitmapEffectInputConnector.cs
- ArgumentException.cs
- DeferredElementTreeState.cs
- TextCollapsingProperties.cs
- XmlMtomWriter.cs
- TdsRecordBufferSetter.cs
- FontResourceCache.cs
- CommandEventArgs.cs
- MD5CryptoServiceProvider.cs
- ISAPIWorkerRequest.cs
- SharedHttpTransportManager.cs
- SequentialUshortCollection.cs
- DllNotFoundException.cs
- TypeConverter.cs
- DocumentCollection.cs
- DescendantBaseQuery.cs
- HttpRuntimeSection.cs
- LocalizableResourceBuilder.cs
- XmlRootAttribute.cs
- TemplateXamlParser.cs
- KeyValuePair.cs
- StringDictionary.cs
- WindowsEditBox.cs
- OracleParameterBinding.cs
- NativeWindow.cs
- ReadOnlyHierarchicalDataSource.cs
- XmlLangPropertyAttribute.cs
- SearchExpression.cs
- ApplicationManager.cs
- WmlTextViewAdapter.cs
- DBSchemaTable.cs
- XmlUtil.cs
- ResizeGrip.cs
- FormViewCommandEventArgs.cs
- OneOfElement.cs
- NgenServicingAttributes.cs
- HttpRuntime.cs
- DefaultHttpHandler.cs
- Win32Exception.cs