Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Diagnostics.Tracing;
  4. using Microsoft.Diagnostics.Tracing.Session;
  5. using System.Linq;
  6. using System.Text;
  7.  
  8. namespace EtwFilter
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. FilterTrace(args[0], args[1], Int32.Parse(args[2]));
  15. }
  16.  
  17. private static void FilterTrace(String sourceFile, String destinationFile, int pid)
  18. {
  19. using ( var source = new ETWReloggerTraceEventSource(sourceFile, destinationFile) )
  20. {
  21. Console.WriteLine("Processing: {0}", sourceFile);
  22. long count = 0;
  23. long written = 0;
  24. source.AllEvents += (e) => {
  25. if ( ((++count) % 100000) == 0 )
  26. {
  27. Console.WriteLine("{0} events", count);
  28. }
  29. if ( e.ProcessID == pid )
  30. {
  31. source.WriteEvent(e);
  32. written++;
  33. }
  34. };
  35. source.Process();
  36. Console.WriteLine("Wrote {0} events.", written);
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement