Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Microsoft.Diagnostics.Tracing;
- using Microsoft.Diagnostics.Tracing.Session;
- using System.Linq;
- using System.Text;
- namespace EtwFilter
- {
- class Program
- {
- static void Main(string[] args)
- {
- FilterTrace(args[0], args[1], Int32.Parse(args[2]));
- }
- private static void FilterTrace(String sourceFile, String destinationFile, int pid)
- {
- using ( var source = new ETWReloggerTraceEventSource(sourceFile, destinationFile) )
- {
- Console.WriteLine("Processing: {0}", sourceFile);
- long count = 0;
- long written = 0;
- source.AllEvents += (e) => {
- if ( ((++count) % 100000) == 0 )
- {
- Console.WriteLine("{0} events", count);
- }
- if ( e.ProcessID == pid )
- {
- source.WriteEvent(e);
- written++;
- }
- };
- source.Process();
- Console.WriteLine("Wrote {0} events.", written);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement