forked from jbevain/cecil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryStreamReader.cs
54 lines (44 loc) · 975 Bytes
/
BinaryStreamReader.cs
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
//
// Author:
// Jb Evain ([email protected])
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
using System.IO;
namespace Mono.Cecil.PE {
class BinaryStreamReader : BinaryReader {
public int Position {
get { return (int) BaseStream.Position; }
set { BaseStream.Position = value; }
}
public int Length {
get { return (int) BaseStream.Length; }
}
public BinaryStreamReader (Stream stream)
: base (stream)
{
}
public void Advance (int bytes)
{
BaseStream.Seek (bytes, SeekOrigin.Current);
}
public void MoveTo (uint position)
{
BaseStream.Seek (position, SeekOrigin.Begin);
}
public void Align (int align)
{
align--;
var position = Position;
Advance (((position + align) & ~align) - position);
}
public DataDirectory ReadDataDirectory ()
{
return new DataDirectory (ReadUInt32 (), ReadUInt32 ());
}
}
}