forked from DaxxTrias/Process.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessExtensions.cs
More file actions
31 lines (30 loc) · 1.27 KB
/
ProcessExtensions.cs
File metadata and controls
31 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProcessNET.Native.Types;
using ProcessNET.Utilities;
namespace ProcessNET.Extensions
{
public static class ProcessExtensions
{
public static IList<ProcessThread> GetThreads(this System.Diagnostics.Process process)
{
return process.Threads.Cast<ProcessThread>().ToList();
}
public static IList<ProcessModule> GetModules(this System.Diagnostics.Process process)
{
return process.Modules.Cast<ProcessModule>().ToList();
}
public static SafeMemoryHandle Open(this System.Diagnostics.Process process, ProcessAccessFlags processAccessFlags = ProcessAccessFlags.AllAccess)
{
return MemoryHelper.OpenProcess(processAccessFlags, process.Id);
}
public static string GetVersionInfo(this System.Diagnostics.Process process)
{
return
$"{process.MainModule.FileVersionInfo.FileDescription} {process.MainModule.FileVersionInfo.FileMajorPart}.{process.MainModule.FileVersionInfo.FileMinorPart}.{process.MainModule.FileVersionInfo.FileBuildPart} {process.MainModule.FileVersionInfo.FilePrivatePart}";
}
}
}