-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLegacyLogItem.cs
More file actions
87 lines (65 loc) · 2.03 KB
/
Copy pathLegacyLogItem.cs
File metadata and controls
87 lines (65 loc) · 2.03 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
using System;
using System.IO;
using System.Text;
namespace evtsharp
{
public class LegacyLogItem
{
public LegacyLogItem (BinaryReader log)
{
long pos = log.BaseStream.Position;
log.BaseStream.Position -= 4;
uint el = log.ReadUInt32();
log.BaseStream.Position -= el - 4;
uint r = log.ReadUInt32();
uint rn = log.ReadUInt32();
uint tg = log.ReadUInt32();
uint tw = log.ReadUInt32();
uint eid = log.ReadUInt32();
ushort et = log.ReadUInt16();
ushort ns = log.ReadUInt16();
ushort ec = log.ReadUInt16();
ushort rf = log.ReadUInt16();
uint crn = log.ReadUInt32();
uint so = log.ReadUInt32 ();
uint usl = log.ReadUInt32();
uint uso = log.ReadUInt32();
uint dl = log.ReadUInt32();
uint dof = log.ReadUInt32();
StringBuilder sb = new StringBuilder();
char tmp = '\r';
while (tmp != '\0')
sb.Append(tmp = BitConverter.ToChar(log.ReadBytes(2),0));
this.SourceName = sb.ToString();
sb = new StringBuilder();
tmp = '\r';
while (tmp != '\0')
sb.Append(tmp = BitConverter.ToChar(log.ReadBytes(2),0));
this.ComputerName = sb.ToString();
byte[] uname = log.ReadBytes((int)usl);
this.UserSID = Encoding.ASCII.GetString(uname);
sb = new StringBuilder();
tmp = '\r';
while(tmp != '\0')
sb.Append(tmp = BitConverter.ToChar(log.ReadBytes(2),0));
this.Strings = sb.ToString();
this.Data = log.ReadBytes((int)dl);
this.TimeGenerated = GetTime(tg);
this.TimeWritten = GetTime(tw);
log.BaseStream.Position = pos;
}
public string SourceName { get; set; }
public string ComputerName { get; set; }
public string UserSID { get; set; }
public string Strings { get; set; }
public byte[] Data { get; set; }
public DateTime TimeGenerated { get; set; }
public DateTime TimeWritten { get; set; }
private DateTime GetTime(uint time)
{
DateTime output = new DateTime(1970, 1, 1, 0, 0, 0);
output = output.AddSeconds(time);
return output;
}
}
}