Exemplo n.º 1
0
        public override void OnPause()
        {
            btnContinue.Enabled = true;
            btnPause.Enabled    = false;

            ReturnAddress = 0;

            if (StackFrame == 0 || InstructionPointer == 0 || StackPointer == 0)
            {
                return;
            }

            // FIXME: x86 specific implementation
            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            if (symbol != null)
            {
                // new stack frame has not been setup
                MemoryCache.ReadMemory(StackPointer, NativeIntegerSize * 2, OnMemoryReadPrologue);
                return;
            }

            symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - 2);

            if (symbol != null)
            {
                // new stack frame has not been setup
                MemoryCache.ReadMemory(StackPointer + NativeIntegerSize, NativeIntegerSize * 2, OnMemoryReadPrologue);
                return;
            }

            MemoryCache.ReadMemory(StackFrame, NativeIntegerSize * 2, OnMemoryRead);
        }
Exemplo n.º 2
0
        protected override void UpdateDisplay()
        {
            ClearDisplay();

            if (StackFrame == 0 || InstructionPointer == 0 || StackPointer == 0)
            {
                return;
            }

            AddSymbol(InstructionPointer, StackFrame, StackPointer);

            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            if (symbol != null)
            {
                // new stack frame has not been setup
                MemoryCache.ReadMemory(StackPointer, NativeIntegerSize, OnMemoryReadPrologue);
                return;
            }

            symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - Platform.FirstPrologueInstructionSize);

            if (symbol != null)
            {
                // new stack frame has not been setup
                MemoryCache.ReadMemory(StackPointer + NativeIntegerSize, NativeIntegerSize, OnMemoryReadPrologue);
                return;
            }

            MemoryCache.ReadMemory(StackFrame, NativeIntegerSize * 2, OnMemoryRead);
        }
Exemplo n.º 3
0
        public override void OnPause()
        {
            treeView1.Nodes.Clear();

            if (StackFrame == 0 || InstructionPointer == 0 || StackPointer == 0)
            {
                return;
            }

            AddSymbol(InstructionPointer);

            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            if (symbol != null)
            {
                // new stack frame has not been setup
                MemoryCache.ReadMemory(StackPointer, NativeIntegerSize, OnMemoryReadPrologue);
                return;
            }

            symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - Platform.FirstPrologueInstructionSize);

            if (symbol != null)
            {
                // new stack frame has not been setup
                MemoryCache.ReadMemory(StackPointer + NativeIntegerSize, NativeIntegerSize, OnMemoryReadPrologue);
                return;
            }

            MemoryCache.ReadMemory(StackFrame, NativeIntegerSize * 2, OnMemoryRead);
        }
Exemplo n.º 4
0
        public override void OnPause()
        {
            this.method = null;
            stackentries.Clear();

            if (Platform == null)
            {
                return;
            }

            if (Platform.Registers == null)
            {
                return;
            }

            if (StackFrame == 0 || StackPointer == 0)
            {
                return;
            }

            method = DebugSource.GetMethod(InstructionPointer);

            if (method == null)
            {
                return;
            }

            if (method.ParameterStackSize == 0)
            {
                return;
            }

            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            ulong paramStart = StackFrame + (NativeIntegerSize * 2);

            if (symbol != null)
            {
                // new stack frame has not been setup
                paramStart = StackPointer + NativeIntegerSize;
            }
            else
            {
                symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - Platform.FirstPrologueInstructionSize);

                if (symbol != null)
                {
                    // new stack frame has not been setup
                    paramStart = StackPointer + (NativeIntegerSize * 2);
                }
            }

            MemoryCache.ReadMemory(paramStart, method.ParameterStackSize, OnMemoryRead);
        }
Exemplo n.º 5
0
        protected override void UpdateDisplay()
        {
            method = null;
            ClearDisplay();

            if (StackFrame == 0 || StackPointer == 0)
            {
                return;
            }

            method = DebugSource.GetMethod(InstructionPointer);

            if (method == null)
            {
                return;
            }

            if (method.ParameterStackSize == 0)
            {
                return;
            }

            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            ulong paramStart = StackFrame + (NativeIntegerSize * 2);

            if (symbol != null)
            {
                // new stack frame has not been setup
                paramStart = StackPointer + NativeIntegerSize;
            }
            else
            {
                symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - Platform.FirstPrologueInstructionSize);

                if (symbol != null)
                {
                    // new stack frame has not been setup
                    paramStart = StackPointer + (NativeIntegerSize * 2);
                }
            }

            MemoryCache.ReadMemory(paramStart, method.ParameterStackSize, OnMemoryRead);
        }
Exemplo n.º 6
0
        private void UpdateDisplay(ulong address, byte[] memory)
        {
            instructions.Clear();

            var mode = ArchitectureMode.x86_32;             // todo:

            using (var disasm = new Disassembler(memory, mode, address, true, Vendor.Any))
            {
                var translator = new SharpDisasm.Translators.IntelTranslator()
                {
                    IncludeAddress = false,
                    IncludeBinary  = false
                };

                foreach (var instruction in disasm.Disassemble())
                {
                    var text = translator.Translate(instruction);

                    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.Offset,
                        Length      = instruction.Length,
                        Instruction = text,
                        Info        = info
                    };

                    instructions.Add(entry);
                }
            }
        }
Exemplo n.º 7
0
        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);
            }
        }