8 instantiations of SafeProcessHandle
aspire-tray (1)
WindowsTrayLauncher.cs (1)
164
var child = new
SafeProcessHandle
(process.Process, ownsHandle: true);
Aspire.Tray.Tests (1)
src\Aspire.Tray\Windows\WindowsTrayLauncher.cs (1)
164
var child = new
SafeProcessHandle
(process.Process, ownsHandle: true);
PresentationCore (1)
MS\Internal\DpiUtil\DpiUtil+ProcessDpiAwarenessHelper.cs (1)
103
using (var hProcess = new
SafeProcessHandle
(UnsafeNativeMethods.OpenProcess(NativeMethods.PROCESS_ALL_ACCESS, false, windowThreadProcessId), true))
System.Diagnostics.Process (5)
Microsoft\Win32\SafeHandles\SafeProcessHandle.cs (1)
28
internal static readonly SafeProcessHandle InvalidHandle = new
SafeProcessHandle
();
Microsoft\Win32\SafeHandles\SafeProcessHandle.Unix.cs (3)
102
processHandle = new
SafeProcessHandle
(waitStateHolder);
316
return new
SafeProcessHandle
(waitStateHolder!);
501
return new
SafeProcessHandle
(waitStateHolder!);
System\Diagnostics\Process.Unix.cs (1)
425
return new
SafeProcessHandle
(_waitStateHolder!.IncrementRefCount());
96 references to SafeProcessHandle
aspire-tray (12)
WindowsTrayLauncher.cs (12)
37
using
var
child = LaunchDetached(startInfo.FileName,
53
internal static async Task CompleteStartupAsync(
SafeProcessHandle
child, Func<Task> ready)
113
internal static unsafe
SafeProcessHandle
LaunchDetached(string executable, string commandLine, string workingDirectory)
120
using
var
shell = OpenDesktopShellProcess();
164
var
child = new SafeProcessHandle(process.Process, ownsHandle: true);
194
private static
SafeProcessHandle
OpenDesktopShellProcess()
206
var
shell = OpenProcess(createProcess | queryLimitedInformation, false, processId);
239
private static void TerminateAndWait(
SafeProcessHandle
child)
268
private static partial
SafeProcessHandle
OpenProcess(uint access, [MarshalAs(UnmanagedType.Bool)] bool inheritHandle, uint processId);
272
private static partial bool OpenProcessToken(
SafeProcessHandle
process, uint access, out SafeAccessTokenHandle token);
290
private static partial bool TerminateProcess(
SafeProcessHandle
process, uint exitCode);
293
private static partial uint WaitForSingleObject(
SafeProcessHandle
process, uint milliseconds);
Aspire.Tray.Tests (21)
Helpers\TestWindowsProcessJob.cs (6)
43
public void Assign(
SafeProcessHandle
process)
51
public bool Contains(
SafeProcessHandle
process)
61
public static int GetProcessId(
SafeProcessHandle
process)
78
private static partial uint GetNativeProcessId(
SafeProcessHandle
process);
89
private static partial bool AssignProcessToJobObject(SafeFileHandle job,
SafeProcessHandle
process);
93
private static partial bool IsProcessInJob(
SafeProcessHandle
process, SafeFileHandle job, [MarshalAs(UnmanagedType.Bool)] out bool result);
src\Aspire.Tray\Windows\WindowsTrayLauncher.cs (12)
37
using
var
child = LaunchDetached(startInfo.FileName,
53
internal static async Task CompleteStartupAsync(
SafeProcessHandle
child, Func<Task> ready)
113
internal static unsafe
SafeProcessHandle
LaunchDetached(string executable, string commandLine, string workingDirectory)
120
using
var
shell = OpenDesktopShellProcess();
164
var
child = new SafeProcessHandle(process.Process, ownsHandle: true);
194
private static
SafeProcessHandle
OpenDesktopShellProcess()
206
var
shell = OpenProcess(createProcess | queryLimitedInformation, false, processId);
239
private static void TerminateAndWait(
SafeProcessHandle
child)
268
private static partial
SafeProcessHandle
OpenProcess(uint access, [MarshalAs(UnmanagedType.Bool)] bool inheritHandle, uint processId);
272
private static partial bool OpenProcessToken(
SafeProcessHandle
process, uint access, out SafeAccessTokenHandle token);
290
private static partial bool TerminateProcess(
SafeProcessHandle
process, uint exitCode);
293
private static partial uint WaitForSingleObject(
SafeProcessHandle
process, uint milliseconds);
WindowsTrayLauncherTests.cs (3)
47
using
var
child = WindowsTrayLauncher.LaunchDetached(ping, $"\"{ping}\" -n 120 127.0.0.1", Environment.SystemDirectory);
70
var
childHandle = child.SafeHandle;
151
var
handle = child.SafeHandle;
netstandard (1)
netstandard.cs (1)
13
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.
SafeProcessHandle
))]
PresentationCore (1)
MS\Internal\DpiUtil\DpiUtil+ProcessDpiAwarenessHelper.cs (1)
103
using (
var
hProcess = new SafeProcessHandle(UnsafeNativeMethods.OpenProcess(NativeMethods.PROCESS_ALL_ACCESS, false, windowThreadProcessId), true))
System (1)
parent\ref\System.cs (1)
9
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.
SafeProcessHandle
))]
System.Diagnostics.PerformanceCounter (11)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\LibraryImports.g.cs (5)
462
internal static partial bool GetProcessTimes(global::Microsoft.Win32.SafeHandles.
SafeProcessHandle
handle, out long creation, out long exit, out long kernel, out long user)
475
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.
SafeProcessHandle
>.ManagedToUnmanagedIn __handle_native__marshaller = new();
652
internal static partial global::Microsoft.Win32.SafeHandles.
SafeProcessHandle
OpenProcess(int access, bool inherit, int processId)
659
global::Microsoft.Win32.SafeHandles.
SafeProcessHandle
__retVal = default;
662
global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.
SafeProcessHandle
>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
src\runtime\src\libraries\Common\src\Interop\Windows\Kernel32\Interop.GetProcessTimes.cs (1)
15
SafeProcessHandle
handle, out long creation, out long exit, out long kernel, out long user);
src\runtime\src\libraries\Common\src\Interop\Windows\Kernel32\Interop.OpenProcess.cs (1)
13
internal static partial
SafeProcessHandle
OpenProcess(
src\runtime\src\libraries\Common\src\Interop\Windows\Kernel32\Interop.ProcessWaitHandle.cs (1)
15
internal ProcessWaitHandle(
SafeProcessHandle
processHandle)
System\Diagnostics\SharedPerformanceCounter.cs (3)
49
using (
SafeProcessHandle
procHandle = Interop.Kernel32.OpenProcess(Interop.Advapi32.ProcessOptions.PROCESS_QUERY_INFORMATION, false, pid))
1303
using (
SafeProcessHandle
procHandle = Interop.Kernel32.OpenProcess(Interop.Advapi32.ProcessOptions.PROCESS_QUERY_INFORMATION, false, pid))
1335
using (
SafeProcessHandle
procHandle = Interop.Kernel32.OpenProcess(Interop.Advapi32.ProcessOptions.SYNCHRONIZE, false, pid))
System.Diagnostics.Process (49)
Microsoft\Win32\SafeHandles\SafeProcessHandle.cs (10)
28
internal static readonly
SafeProcessHandle
InvalidHandle = new SafeProcessHandle();
63
/// <returns>A <see cref="
SafeProcessHandle
"/> that represents the opened process.</returns>
86
public static
SafeProcessHandle
Open(int processId)
90
if (!TryOpenCore(processId, out
SafeProcessHandle
? handle, out int lastError))
102
/// <param name="processHandle">When this method returns <see langword="true"/>, contains the <see cref="
SafeProcessHandle
"/> for the opened process; otherwise, <see langword="null"/>.</param>
125
public static bool TryOpen(int processId, [NotNullWhen(true)] out
SafeProcessHandle
? processHandle)
148
/// <returns>A <see cref="
SafeProcessHandle
"/> representing the started process.</returns>
157
public static
SafeProcessHandle
Start(ProcessStartInfo startInfo)
167
internal static
SafeProcessHandle
Start(ProcessStartInfo startInfo, bool fallbackToNull)
451
var (handle, tcs) = ((
SafeProcessHandle
, TaskCompletionSource<bool>))state!;
Microsoft\Win32\SafeHandles\SafeProcessHandle.Unix.cs (9)
77
private static bool TryOpenCore(int processId, [NotNullWhen(true)] out
SafeProcessHandle
? processHandle, out int lastError)
202
private delegate
SafeProcessHandle
StartWithShellExecuteDelegate(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle, out ProcessWaitState.Holder? waitStateHolder);
205
private static
SafeProcessHandle
StartCore(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle, SafeHandle[]? inheritedHandlesSnapshot = null)
208
internal static
SafeProcessHandle
StartCore(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle,
246
internal static unsafe
SafeProcessHandle
StartWithCallback(ProcessStartInfo startInfo, SafeFileHandle? stdinFd, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle,
356
private static
SafeProcessHandle
StartWithShellExecute(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle,
390
SafeProcessHandle
processHandle = ForkAndExecProcess(
411
SafeProcessHandle
result = ForkAndExecProcess(
428
private static
SafeProcessHandle
ForkAndExecProcess(
System\Diagnostics\Process.cs (14)
31
private
SafeProcessHandle
? _processHandle;
121
public
SafeProcessHandle
SafeHandle
1213
private
SafeProcessHandle
GetOrOpenProcessHandle()
1229
private void SetProcessHandle(
SafeProcessHandle
processHandle)
1784
/// <inheritdoc cref="
SafeProcessHandle
.Signal(PosixSignal)"/>
1801
/// <inheritdoc cref="
SafeProcessHandle
.WaitForExit()"/>
1824
if (
SafeProcessHandle
.TryOpen(_processId, out
SafeProcessHandle
? processHandle))
1836
/// <inheritdoc cref="
SafeProcessHandle
.TryWaitForExit(TimeSpan, out ProcessExitStatus?)"/>
1860
if (
SafeProcessHandle
.TryOpen(_processId, out
SafeProcessHandle
? processHandle))
1871
/// <inheritdoc cref="
SafeProcessHandle
.WaitForExitAsync(CancellationToken)"/>
1894
if (
SafeProcessHandle
.TryOpen(_processId, out
SafeProcessHandle
? processHandle))
System\Diagnostics\Process.Scenarios.cs (6)
54
using
SafeProcessHandle
processHandle =
SafeProcessHandle
.Start(startInfo, fallbackToNull: true);
109
using
SafeProcessHandle
processHandle =
SafeProcessHandle
.Start(startInfo);
174
using
SafeProcessHandle
processHandle =
SafeProcessHandle
.Start(startInfo);
System\Diagnostics\Process.Unix.cs (6)
412
private
SafeProcessHandle
GetProcessHandle()
430
SafeProcessHandle
startedProcess =
SafeProcessHandle
.StartCore(startInfo, stdinHandle, stdoutHandle, stderrHandle, inheritedHandles, out ProcessWaitState.Holder? waitStateHolder);
436
SafeProcessHandle
startedProcess =
SafeProcessHandle
.StartWithCallback(startInfo, stdinHandle, stdoutHandle, stderrHandle, callback, out ProcessWaitState.Holder? waitStateHolder);
440
private bool SetProcessHandle(
SafeProcessHandle
startedProcess, ProcessWaitState.Holder waitStateHolder)
System\Diagnostics\ProcessStartInfo.cs (4)
153
/// The process will not begin execution until <see cref="
SafeProcessHandle
.Resume" /> is called
154
/// on the <see cref="
SafeProcessHandle
" /> returned by <see cref="
SafeProcessHandle
.Start(ProcessStartInfo)" />.
362
SafeProcessHandle
.EnsureShellExecuteFunc();