public class BinaryReader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
EPOCH_OFFSET |
static int[][] |
INDEX_ARRAYS |
Constructor and Description |
---|
BinaryReader(BinaryReader binaryReader,
int position)
Constructs a binary reader with the given one's byte array and an arbitrary position
|
BinaryReader(byte[] bytes)
Creates a BinaryReader for the given bytes
|
BinaryReader(java.io.InputStream inputStream,
int size)
Reads size bytes from the inputStream and creates a BinaryReader for them
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes()
Returns the backing byte array
|
int |
getPosition()
Returns the current position of the BinaryReader
|
int |
peek()
Returns the byte that would be read without changing the position
|
byte[] |
peekBytes(int length)
Returns the next length bytes without changing the position
|
int |
read()
Reads a single byte
|
java.lang.String |
readAndBase64EncodeBinary(int length)
Reads length bytes and Bas64 encodes them
|
void |
readBytes(byte[] buf,
int offset,
int length)
Reads the next length bytes into the buf buffer at a given offset
|
byte[] |
readBytes(int length)
Reads the next length bytes
|
com.google.common.primitives.UnsignedInteger |
readDWord()
Reads 4 bytes in little endian order and returns the UnsignedInteger value
|
com.google.common.primitives.UnsignedInteger |
readDWordBE()
Reads 4 bytes in big endian order and returns the UnsignedInteger value
|
java.util.Date |
readFileTime()
Reads a timestamp that is the number of hundreds of nanoseconds since Jan 1 1601
(see http://integriography.wordpress.com/2010/01/16/using-phython-to-parse-and-present-windows-64-bit-timestamps/)
|
java.lang.String |
readGuid()
Reads an Evtx formatted guid (16 bytes arranged into the grouping described by INDEX_ARRAYS)
|
com.google.common.primitives.UnsignedLong |
readQWord()
Reads 8 bytes in litte endian order and returns the UnsignedLong value
|
java.lang.String |
readString(int length)
Reads a string made up of single byte characters
|
int |
readWord()
Reads 2 bytes in little endian order and returns the int value
|
int |
readWordBE()
Reads 2 bytes in big endian order and returns the int value
|
java.lang.String |
readWString(int length)
Reads a string encoded with UTF_16LE of a given length
|
void |
skip(int bytes)
Skips bytes in the BinaryReader
|
public static final long EPOCH_OFFSET
public static final int[][] INDEX_ARRAYS
public BinaryReader(BinaryReader binaryReader, int position)
binaryReader
- the source BinaryReaderposition
- the new positionpublic BinaryReader(java.io.InputStream inputStream, int size) throws java.io.IOException
inputStream
- the input streamsize
- the number of bytesjava.io.IOException
- if there is an error reading from the input streampublic BinaryReader(byte[] bytes)
bytes
- the bytespublic int read()
public int peek()
public byte[] peekBytes(int length)
length
- the number of bytespublic byte[] readBytes(int length)
length
- the number of bytespublic void readBytes(byte[] buf, int offset, int length)
buf
- the bufferoffset
- the offsetlength
- the number of bytespublic java.lang.String readGuid()
public java.lang.String readString(int length) throws java.io.IOException
length
- the lengthjava.io.IOException
- if the String wasn't null terminatedpublic java.lang.String readWString(int length)
length
- the number of characterspublic com.google.common.primitives.UnsignedLong readQWord()
public com.google.common.primitives.UnsignedInteger readDWord()
public com.google.common.primitives.UnsignedInteger readDWordBE()
public int readWord()
public int readWordBE()
public java.util.Date readFileTime()
public java.lang.String readAndBase64EncodeBinary(int length)
length
- the number of bytespublic void skip(int bytes)
bytes
- the number of bytes to skippublic int getPosition()
public byte[] getBytes()