This repository was archived by the owner on Apr 20, 2018. It is now read-only.
forked from microsoft/Tx
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathProgram.cs
More file actions
94 lines (78 loc) · 3.01 KB
/
Program.cs
File metadata and controls
94 lines (78 loc) · 3.01 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reactive;
using System.Reflection;
using Tx.Windows;
namespace TxFmt
{
internal class Program
{
private static void Main(string[] args)
{
if (args.Length < 2)
{
Console.WriteLine(
@"Usage: TxFmt files...
Supported files are
.man : Manifest
.etl : Event Trace Log
.evtx : Event Log");
Environment.Exit(1);
}
try
{
var pb = new Playback();
string asmDir = Path.Combine(Path.GetTempPath(), "TxFmt");
if (Directory.Exists(asmDir))
Directory.Delete(asmDir, true);
Directory.CreateDirectory(asmDir);
foreach (string a in args)
{
string ext = Path.GetExtension(a).ToLower();
switch (ext)
{
case ".etl":
pb.AddEtlFiles(a);
break;
case ".evtx":
pb.AddLogFiles(a);
break;
case ".man":
string manifest = File.ReadAllText(a);
Dictionary<string, string> generated = ManifestParser.Parse(manifest);
string assemblyPath = Path.Combine(asmDir, Path.ChangeExtension(Path.GetFileName(a), ".dll"));
AssemblyBuilder.OutputAssembly(generated, new string[]{}, assemblyPath);
break;
default:
throw new Exception("unknown extension " + ext);
}
}
var knownTypes = new List<Type>();
foreach (string a in Directory.GetFiles(asmDir, "*.dll"))
{
Assembly assembly = Assembly.LoadFrom(a);
knownTypes.AddRange(assembly.GetTypes());
}
pb.KnownTypes = knownTypes.ToArray();
IObservable<SystemEvent> all = pb.GetObservable<SystemEvent>();
all.Subscribe(e=>
{
if (!e.ToString().StartsWith(" DocumentServiceId"))
{
Console.WriteLine("{0} {1}", e.Header.EventId, e.ToString());
};
});
pb.Run();
}
catch (Exception ex)
{
ConsoleColor color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine(ex.Message + "\n\n" + ex.StackTrace);
Console.ForegroundColor = color;
}
}
}
}