Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / SafeProcessHandle.cs / 1305600 / SafeProcessHandle.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // // History: // 10/04/2003 : [....] Created //--------------------------------------------------------------------------- using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Windows.Automation; using Microsoft.Win32.SafeHandles; using MS.Win32; namespace MS.Internal.AutomationProxies { internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { // This constructor is used by the P/Invoke marshaling layer // to allocate a SafeHandle instance. P/Invoke then does the // appropriate method call, storing the handle in this class. private SafeProcessHandle() : base(true) {} internal SafeProcessHandle(IntPtr hwnd) : base(true) { uint processId; if (hwnd == IntPtr.Zero) { processId = UnsafeNativeMethods.GetCurrentProcessId(); } else { // Get process id... Misc.GetWindowThreadProcessId(hwnd, out processId); } // handle might be used to query for Wow64 information (_QUERY_), or to do cross-process allocs (VM_*) SetHandle(Misc.OpenProcess(NativeMethods.PROCESS_QUERY_INFORMATION | NativeMethods.PROCESS_VM_OPERATION | NativeMethods.PROCESS_VM_READ | NativeMethods.PROCESS_VM_WRITE, false, processId, hwnd)); } // Uncomment this if & only if we need a constructor // that takes a handle from external code //internal SafeProcessHandle(IntPtr preexistingHandle, bool ownsHandle) : base(ownsHandle) //{ // SetHandle(preexistingHandle); //} // protected override bool ReleaseHandle() { return Misc.CloseHandle(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FrameAutomationPeer.cs
- ByteStream.cs
- LOSFormatter.cs
- DataObjectAttribute.cs
- BamlResourceSerializer.cs
- TypeUtils.cs
- CopyNodeSetAction.cs
- TemporaryBitmapFile.cs
- RepeaterDataBoundAdapter.cs
- ProfileSection.cs
- StreamReader.cs
- WindowsIdentity.cs
- XmlSerializationReader.cs
- ContextMenuStripGroupCollection.cs
- GenerateTemporaryTargetAssembly.cs
- PeerNearMe.cs
- MediaEntryAttribute.cs
- SymmetricSecurityProtocolFactory.cs
- StubHelpers.cs
- GifBitmapEncoder.cs
- SiteMapSection.cs
- SplitterCancelEvent.cs
- TextParaClient.cs
- XDRSchema.cs
- PointCollectionValueSerializer.cs
- RootNamespaceAttribute.cs
- PropertyEntry.cs
- GenerateScriptTypeAttribute.cs
- DynamicDiscoSearcher.cs
- CalendarDay.cs
- ToolStripInSituService.cs
- ResourceManager.cs
- ManipulationStartedEventArgs.cs
- CompositeCollectionView.cs
- IisTraceWebEventProvider.cs
- TemplateParser.cs
- ConfigurationElementProperty.cs
- FixedStringLookup.cs
- TypeToken.cs
- FileDialogCustomPlace.cs
- DocumentCollection.cs
- RepeaterCommandEventArgs.cs
- HttpHeaderCollection.cs
- CodeAttributeDeclaration.cs
- ExceptionUtil.cs
- ScriptReferenceEventArgs.cs
- LocalizationParserHooks.cs
- DataFormats.cs
- MsdtcWrapper.cs
- DbReferenceCollection.cs
- Sql8ConformanceChecker.cs
- VisualBasic.cs
- Compiler.cs
- ExpressionEvaluator.cs
- SQLDateTimeStorage.cs
- ButtonColumn.cs
- SchemaSetCompiler.cs
- SymLanguageVendor.cs
- BinHexEncoding.cs
- versioninfo.cs
- RegisteredHiddenField.cs
- Unit.cs
- ControlValuePropertyAttribute.cs
- ContentTextAutomationPeer.cs
- ConsumerConnectionPoint.cs
- TextEditorLists.cs
- SpeakInfo.cs
- OleDbMetaDataFactory.cs
- Cursors.cs
- AmbientLight.cs
- ProfilePropertySettingsCollection.cs
- GuidTagList.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- Point.cs
- cookiecontainer.cs
- Task.cs
- PKCS1MaskGenerationMethod.cs
- SiteMapDesignerDataSourceView.cs
- XmlDocumentFragment.cs
- ObjectStorage.cs
- RtType.cs
- UTF32Encoding.cs
- ImmutableAssemblyCacheEntry.cs
- XmlByteStreamReader.cs
- ListViewItem.cs
- OleDbSchemaGuid.cs
- ProfileSettings.cs
- FileEnumerator.cs
- IDQuery.cs
- ApplicationContext.cs
- XmlCollation.cs
- X509CertificateTrustedIssuerElementCollection.cs
- SingleAnimationUsingKeyFrames.cs
- PropertyIdentifier.cs
- KeyedQueue.cs
- Debug.cs
- IsolatedStorage.cs
- ReflectPropertyDescriptor.cs
- ServiceObjectContainer.cs
- TagPrefixCollection.cs