This repository was archived by the owner on Mar 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCmdLineExample.cs
More file actions
52 lines (47 loc) · 1.77 KB
/
CmdLineExample.cs
File metadata and controls
52 lines (47 loc) · 1.77 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Threading;
using System.Linq;
namespace TracePeek
{
class Program
{
static int Main(string[] args)
{
if(args == null || args.Length == 0 || args[0].Contains("?"))
{
Console.WriteLine(CmdLineInfo);
return 1;
}
var consoleCancellationRequested = false;
var thisTracePeekSession = new TracePeekController();
thisTracePeekSession.OnTracePeekEvent += (eventProjection) =>
{
Console.WriteLine(eventProjection);
};
thisTracePeekSession.EnableProviders(args);
Console.WriteLine("Listener starting up...");
thisTracePeekSession.StartPeek();
Console.WriteLine("Listener running.");
Console.WriteLine("Press ALT+s to stop");
while(!consoleCancellationRequested)
{
var keyPress = Console.ReadKey(true);
if (keyPress.Modifiers.HasFlag(ConsoleModifiers.Alt) && keyPress.KeyChar == 's')
{
Console.WriteLine("Cleaning up...");
consoleCancellationRequested = true;
thisTracePeekSession.StopPeek();
}
}
return 0;
}
private const string CmdLineInfo = @"
TracePeek.exe is a thin demo wrapper for TracePeek.dll.
For rich usage scenarios consider using the TracePeek powershell module or writing code against TracePeek.dll.
For a quick cmdline demo using TracePeek.exe, specify an ETW provider on the cndline, such as:
TracePeek.exe Microsoft-Windows-Wordpad
and then launch Wordpad while the trace is running to see the events.
";
}
}