Skip to content

Commit c14d792

Browse files
committed
update
1 parent fd257f7 commit c14d792

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

ch11_reading_offline_hives/NodeKey.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public NodeKey (BinaryReader hive)
3434
private void ReadNodeStructure(BinaryReader hive) {
3535
byte[] buf = hive.ReadBytes(4);
3636

37-
if (buf[0] != 110 || buf[1] != 107)
37+
if (buf [0] != 0x6e || buf [1] != 0x6b)
3838
throw new NotSupportedException("Bad nk header");
3939

4040
long startingOffset = hive.BaseStream.Position;
4141
this.IsRootKey = (buf[2] == 0x2c) ? true : false;
4242

43-
this.Timestamp = DateTime.FromFileTime(BitConverter.ToInt64(hive.ReadBytes(8), 0));
43+
this.Timestamp = DateTime.FromFileTime(hive.ReadInt64());
4444

4545
hive.BaseStream.Position += 4;
4646

ch11_reading_offline_hives/Program.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ class MainClass
88
public static void Main (string[] args)
99
{
1010
RegistryHive hive = new RegistryHive (args [0]);
11-
12-
if (hive.WasExported)
13-
Console.Write ("This hive was exported. ");
1411

15-
Console.WriteLine("The rootkey's name is " + hive.RootKey + ".");
12+
Console.WriteLine("The rootkey's name is " + hive.RootKey.Name);
1613
}
1714
}
1815
}

ch11_reading_offline_hives/RegistryHive.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ public RegistryHive(string file)
2121
if (buf[0] != 'r' || buf[1] != 'e' || buf[2] != 'g' || buf[3] != 'f')
2222
throw new NotSupportedException();
2323

24-
reader.ReadBytes(8);
25-
buf = reader.ReadBytes(8);
26-
//Array.Reverse(buf);
27-
long timestamp = BitConverter.ToInt64 (buf, 0);
28-
//long timestamp = reader.ReadInt64 ();
29-
DateTime time = DateTime.FromBinary (timestamp);
30-
31-
this.WasExported = (timestamp == 0) ? true : false;
32-
3324
//fast-forward
3425
reader.BaseStream.Position += (4096 + 32 + 4)-reader.BaseStream.Position;
3526

ch11_reading_offline_hives/ValueKey.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public ValueKey (BinaryReader hive)
1515

1616
this.NameLength = hive.ReadInt16();
1717
this.DataLength = hive.ReadInt32 ();
18-
//this.DataLength = BitConverter.ToInt32(hive.ReadBytes(4),0);
1918

2019
byte[] databuf = hive.ReadBytes(4);
2120

0 commit comments

Comments
 (0)