/// <summary> /// Gets the ending position /// </summary> /// <returns>Position.</returns> public Position GetEndingPosition() { var end = DebugEngineProxy.Execute("!tt 100"); // todo: get from trace_info var endMatch = Regex.Match(end, "Setting position: (?<pos>[A-F0-9]+:[A-F0-9]+)"); return(Position.Parse(endMatch.Groups["pos"].Value)); }
/// <summary> /// Positionses this instance. /// </summary> /// <returns>PositionsResult.</returns> public PositionsResult Positions() { var positionsText = DebugEngineProxy.Execute("!positions"); var records = ParsePositionsCommandText(positionsText); return(new PositionsResult(records)); }
/// <summary> /// Gets the stack frames. /// </summary> /// <param name="threadId">The thread identifier.</param> /// <returns>IEnumerable<StackFrame>.</returns> public IEnumerable <StackFrame> GetStackFrames(int threadId) { var command = $"k"; var raw = DebugEngineProxy.Execute(threadId, command); return(ExtractStackFrames(raw)); }
/// <summary> /// Gets the disassembly lines. /// </summary> /// <param name="threadId">The thread identifier.</param> /// <param name="numInstructions">The number instructions.</param> /// <returns>IEnumerable<DisassemblyLine></returns> /// <exception cref="ArgumentOutOfRangeException">Number of instructions must be > 0</exception> public IEnumerable <DisassemblyLine> GetDisassemblyLines(int threadId, int numInstructions) { if (numInstructions <= 0) { throw new ArgumentOutOfRangeException(nameof(numInstructions), "Number of instructions must be > 0"); } var ipRegister = DebugEngineProxy.Is32Bit ? "eip" : "rip"; var instructionText = DebugEngineProxy.Execute(threadId, $"u {ipRegister} L{numInstructions:X}"); var matches = Regex.Matches(instructionText, @"(?<ip>[a-fA-F0-9`]+)\s+(?<opcode>[a-fA-F0-9]+)\s+(?<ins>\w+)\s+(?<extra>.+)?"); var list = new List <DisassemblyLine>(); foreach (var match in matches.Cast <Match>()) { var ip = match.Groups["ip"].Success ? Convert.ToUInt64(match.Groups["ip"].Value.Replace("`", ""), 16) : 0; byte[] opcode = null; if (match.Groups["opcode"].Success) { opcode = ByteArrayBuilder.StringToByteArray(match.Groups["opcode"].Value); } var instruction = match.Groups["ins"].Success ? match.Groups["ins"].Value : ""; var note = match.Groups["extra"].Success ? match.Groups["extra"].Value : ""; var newLine = new DisassemblyLine(ip, opcode, instruction, note); list.Add(newLine); } return(list); }
/// <summary> /// Gets the current stack trace. /// </summary> /// <returns>StackTrace.</returns> public StackTrace GetCurrentStackTrace() { var stackTrace = DebugEngineProxy.Execute("k"); var frames = ExtractStackFrames(stackTrace); return(new StackTrace(frames)); }
/// <summary> /// Is32s the bit. /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> internal bool Is32Bit() { if (!_is32Bit.HasValue) { _is32Bit = Regex.Match(DebugEngineProxy.Execute("!peb"), @"PEB at (?<peb>[a-fA-F0-9]+)").Groups["peb"] .Value .Length == 8; } return(_is32Bit.Value); }
/// <summary> /// Sets the position. /// </summary> /// <param name="position">The position.</param> public SetPositionResult SetPosition(Position position) { var result = new SetPositionResult(); var output = DebugEngineProxy.Execute($"!tt {position}"); var match = Regex.Match(output, "Time Travel Position: (?<pos>[a-f0-9]+:[a-f0-9]+)", RegexOptions.IgnoreCase); if (!match.Success) { throw new ApplicationException( $"Attempted to set position to {position}, but was unable to process the output"); } result.ActualPosition = Position.Parse(match.Groups["pos"].Value); var breakpointMatch = Regex.Match(output, @"Breakpoint (?<bp>\d+) hit"); if (breakpointMatch.Success) { result.BreakpointHit = Convert.ToInt32(breakpointMatch.Groups["bp"].Value); } return(result); }
/// <summary> /// Sets the position. /// </summary> /// <param name="position">The position.</param> public void SetPosition(Position position) { DebugEngineProxy.Execute($"!tt {position}"); }
/// <summary> /// Sets the write access breakpoint. /// </summary> /// <param name="length">The length.</param> /// <param name="address">The address.</param> public void SetWriteAccessBreakpoint(int length, ulong address) { ValidateLength(length); DebugEngineProxy.Execute($"ba w{length} {address:X}"); }
/// <summary> /// Sets the breakpoint by mask. /// </summary> /// <param name="moduleMask">The module mask.</param> /// <param name="functionMask">The function mask.</param> public void SetBreakpointByMask(string moduleMask, string functionMask) { DebugEngineProxy.Execute($"bm {moduleMask}!{functionMask}"); }
/// <summary> /// Clears the breakpoints. /// </summary> public void ClearBreakpoints() { DebugEngineProxy.Execute($"bc *"); }