void Disassemble()
{
items.Clear();
x86disassembler.CurrentOffset = startOffset;
try
{
//uint lastOffset = 0;
while (x86disassembler.CurrentOffset < endOffset)
{
// Debugging purposes:
//if (lastOffset == x86disassembler.CurrentOffset)
// System.Diagnostics.Debugger.Break();
//lastOffset = x86disassembler.CurrentOffset;
x86Instruction instruction = x86disassembler.DisassembleNextInstruction();
ListViewItem item = new ListViewItem(new string[] {
instruction.Offset.FileOffset.ToString("X8"),
BytesToString(instruction.OpCode.OpCodeBytes) + " " + BytesToString(instruction.OperandBytes),
instruction.ToAsmString().ToLower(),
string.Empty,
}) { Tag = instruction };
item.UseItemStyleForSubItems = false;
if (instruction.OpCode.Name.StartsWith("CALL"))
item.SubItems[2].BackColor = Color.Cyan;
if (instruction.OpCode.Name.StartsWith("J"))
item.SubItems[2].BackColor = Color.Yellow;
items.Add(item);
Invoke(new Action(() =>
{
double currentValue = x86disassembler.CurrentOffset - startOffset;
double max = endOffset - startOffset;
progressBar.Value = (int)(currentValue / max * 100);
}));
}
}
catch (Exception ex)
{
items.Add(new ListViewItem(new string[] {
x86disassembler.CurrentOffset.ToString("X8"),
"Error",
ex.GetType().FullName,
ex.Message,
ex.ToString(),
}));
}
}