/// <summary>
/// Disassembles bytes to a collection of assembly instructions.
/// </summary>
/// <param name="rawStartOffset">The starting offset</param>
/// <param name="length">The length. This value is overwritten when the last instruction's bounds are outside of the bounds.</param>
/// <returns></returns>
public InstructionCollection Disassemble(long rawStartOffset, long length)
{
reader.BaseStream.Position = rawStartOffset;
InstructionCollection instructions = new InstructionCollection();
long offset = rawStartOffset;
long endOffset = rawStartOffset + length;
while (reader.BaseStream.Position < endOffset)
{
x86Instruction instruction = DisassembleNextInstruction();
instructions.Add(instruction);
offset += instruction.Size;
reader.BaseStream.Position = offset;
}
// reader.Dispose();
return(instructions);
}