private void UpdateDisplay(ulong address, byte[] memory) { SetupGrid(); string opinstruction = "N/A"; if (address == InstructionPointer) { var disassembler = new Disassembler("x86"); disassembler.SetMemory(memory, address); foreach (var instruction in disassembler.Decode()) { opinstruction = instruction.Instruction; break; } } var elements = new object[dataGridView1.ColumnCount]; elements[0] = Platform.InstructionPointer.ToHex(); elements[1] = opinstruction; int index = 2; foreach (var register in Platform.Registers) { elements[index++] = register.ToHex(); } dataGridView1.Rows.Add(elements); }
private void UpdateDisplay(ulong address, byte[] memory) { instructions.Clear(); var disassembler = new Disassembler("x86"); disassembler.SetMemory(memory, address); foreach (var instruction in disassembler.Decode()) { var addr = MainForm.ParseAddress(instruction.Instruction); var info = MainForm.GetAddressInfo(addr); var entry = new MethodInstructionEntry() { IP = instruction.Address, // Offset? Length = instruction.Length, Instruction = instruction.Instruction, Info = info }; instructions.Add(entry); } }
private void Decode() { var code = _ram[_registers.PC]; var opcode = OpcodeMap.GetOpcode(code); var disassembler = new Disassembler(this); var instruction = disassembler.Decode(opcode, _ram[_registers.PC, _registers.PC + opcode.Bytes]); instruction.Item1.Invoke(this, instruction.Item2); _registers.PC += opcode.Bytes; }
private void UpdateDisplay(ulong address, byte[] memory) { if (address != InstructionPointer) { return; } var disassembler = new Disassembler("x86"); disassembler.SetMemory(memory, address); tbInstruction.Text = "Unable to decode!"; foreach (var instruction in disassembler.Decode()) { tbInstruction.Text = instruction.Instruction; break; } }
private void UpdateDisplay(ulong address, byte[] memory) { instructions.Clear(); var disassembler = new Disassembler("x86"); disassembler.SetMemory(memory, address); foreach (var instruction in disassembler.Decode()) { var entry = new InstructionEntry() { IP = instruction.Address, Length = instruction.Length, Instruction = instruction.Instruction.ToString() }; instructions.Add(entry); } }
protected void TraceDisassembly() { var trace = CreateTraceLog(); if (trace == null) { return; } // Create a byte array from the symbol stream var symbol = Linker.GetSymbol(Method.FullName); var stream = symbol.Stream; var oldPosition = stream.Position; var length = (int)stream.Length; var memory = new byte[length]; stream.Position = 0; stream.Read(memory, 0, length); stream.Position = oldPosition; var disassembler = new Disassembler(Architecture.PlatformName); disassembler.SetMemory(memory, 0); var list = disassembler.Decode(); if (list != null) { foreach (var instr in list) { trace.Log(instr.Full); } } else { PostEvent(CompilerEvent.Error, $"Failed disassembly for method {MethodCompiler.Method}"); } }
private void UpdateDisplay(ulong address, byte[] memory) { instructions.Clear(); var disassembler = new Disassembler("x86"); disassembler.SetMemory(memory, address); foreach (var instruction in disassembler.Decode()) { var text = instruction.Instruction.Replace('\t', ' '); var info = string.Empty; var value = ParseAddress(text); if (value != 0) { var symbol = DebugSource.GetFirstSymbolsStartingAt(value); if (symbol != null) { info = symbol.Name; } } var entry = new MethodInstructionEntry() { IP = instruction.Address, // Offset? Length = instruction.Length, Instruction = text, Info = info }; instructions.Add(entry); } }