Skip to content

Commit 781970e

Browse files
author
James Forshaw
committed
Added process times.
1 parent 56fde0c commit 781970e

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

NtApiDotNet/NtProcess.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,31 @@ public bool VirtualizationEnabled
22882288
/// </summary>
22892289
public long SecurityDomain => GetSecurityDomain();
22902290

2291+
/// <summary>
2292+
/// Get the creation time of the process.
2293+
/// </summary>
2294+
public DateTime CreateTime => DateTime.FromFileTime(Query<KernelUserTimes>(ProcessInformationClass.ProcessTimes).CreateTime.QuadPart);
2295+
/// <summary>
2296+
/// Get the exit time of the process.
2297+
/// </summary>
2298+
public DateTime ExitTime => DateTime.FromFileTime(Query<KernelUserTimes>(ProcessInformationClass.ProcessTimes).ExitTime.QuadPart);
2299+
/// <summary>
2300+
/// Get the time spent in the kernel.
2301+
/// </summary>
2302+
public long KernelTime => Query<KernelUserTimes>(ProcessInformationClass.ProcessTimes).KernelTime.QuadPart;
2303+
/// <summary>
2304+
/// Get the time spent in user mode.
2305+
/// </summary>
2306+
public long UserTime => Query<KernelUserTimes>(ProcessInformationClass.ProcessTimes).UserTime.QuadPart;
2307+
/// <summary>
2308+
/// Get the time spent in the kernel in seconds.
2309+
/// </summary>
2310+
public double KernelTimeSeconds => new TimeSpan(KernelTime).TotalSeconds;
2311+
/// <summary>
2312+
/// Get the time spent in user mode.
2313+
/// </summary>
2314+
public double UserTimeSeconds => new TimeSpan(UserTime).TotalSeconds;
2315+
22912316
#endregion
22922317

22932318
#region Static Properties

NtApiDotNet/NtProcessNative.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
using NtApiDotNet.Ndr;
1615
using System;
1716
using System.Runtime.InteropServices;
1817

0 commit comments

Comments
 (0)