public void SetCurrentFrame(IFrame currentFrame)
{
if (currentFrame == null || currentFrame.Function != _lastFunction)
{
instructionsListView.Items.Clear();
_lastFunction = null;
}
if (currentFrame != null)
{
if (currentFrame.Function == _lastFunction)
{
foreach (var item in instructionsListView.Items.Cast<MsilInstructionListViewItem>())
item.UpdateItem(currentFrame);
}
else
{
_lastFunction = currentFrame.Function;
var bytes = ((RuntimeFunction)currentFrame.Function).IlCode.GetBytes();
var disassembler = new MsilDisassembler(new MemoryStreamReader(bytes), new DefaultOperandResolver());
foreach (var instruction in disassembler.Disassemble())
{
var instructionBytes = new byte[instruction.Size];
Buffer.BlockCopy(bytes, instruction.Offset, instructionBytes, 0, instruction.Size);
var item = new MsilInstructionListViewItem(instruction, instructionBytes);
item.UpdateItem(currentFrame);
instructionsListView.Items.Add(item);
}
}
}
}