/// <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); }
/* * Todo: add ability to tag all frames in a range e.g. thread 1 from a to b or all threads a to b0 */ /// <summary> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <returns>Task.</returns> /// <exception cref="ArgumentNullException">args</exception> /// <exception cref="ArgumentOutOfRangeException"></exception> public void Process(string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (!args.Any()) { // list tags at the current position var tags = ServerClient.GetRecentTags(10); var output = FormatTagsForOutput(tags); DebugEngineProxy.WriteLine(output); } else { var command = args[0]; switch (command) { case "add": var addOptions = ExtractAddOptions(args.Skip(1)); AddTag(addOptions); break; // todo: edit, delete default: throw new ArgumentOutOfRangeException($"Unknown subcommand {command}"); } } }
/// <summary> /// Indexes the breakpoint hits. /// </summary> /// <param name="options">The options.</param> internal virtual void IndexBreakpointHits(IndexOptions options) { var end = GetEndingPosition(options); var start = GetStartingPosition(options); var curPos = TimeTravelFacade.SetPosition(start).ActualPosition; BreakpointFacade.ClearBreakpoints(); SetBreakpoints(options); while (curPos <= end) { DebugEngineProxy.RunUntilBreak(); curPos = TimeTravelFacade.GetCurrentPosition(); if (curPos <= end) UpsertCurrentPosition(options); for (int i = 0; i < options.Step; i++) { var newPosition = new Position(curPos.High, curPos.Low + 1); var posRes = TimeTravelFacade.SetPosition(newPosition); curPos = posRes.ActualPosition; if (posRes.BreakpointHit.HasValue) i = -1; if (curPos >= end) return; UpsertCurrentPosition(options); } } }
/// <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)); }
public static void DebugExtensionNotify(uint Notify, ulong Argument) { if (Notify == 2) { if (!showedIntro) { var assembly = Assembly.GetExecutingAssembly(); var path = Path.Combine(Path.GetDirectoryName(assembly.Location), "mcfly.log"); log = new DefaultLog(path); InitApi(log); var types = assembly.GetTypes().Where(x => typeof(IInjectable).IsAssignableFrom(x)); log.Debug($"Injectable types: {string.Join(", ", types.Select(x => x.FullName))}"); var typeCatalog = new TypeCatalog(types); compositionContainer = new CompositionContainer(typeCatalog); log.Debug("Creating debug engine proxy"); var dbgEng = new DebugEngineProxy(control, client, registers, systemObjects, debugDataSpaces); log.Debug("Composing debug engine"); compositionContainer.ComposeExportedValue <IDebugEngineProxy>(dbgEng); compositionContainer.ComposeExportedValue(log); PopulateSettings(); app = compositionContainer.GetExportedValue <McFlyApp>(); WriteLine("When this baby hits 88 miles per hour... you're gonna see some serious shit."); showedIntro = true; } } }
/// <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> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <returns>Task.</returns> /// <exception cref="ArgumentNullException">args</exception> /// <exception cref="ArgumentOutOfRangeException"> /// args /// or /// args /// </exception> public void Process(string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (args.Length != 1) { throw new ArgumentOutOfRangeException(nameof(args), $"SettingsMethod expects exactly 1 argument, but was given {args.Length}"); } switch (args[0].ToLower()) { case "list": foreach (var settings in AllSettings) { DebugEngineProxy.WriteLine(settings.GetType().FullName); DebugEngineProxy.WriteLine(JsonConvert.SerializeObject(settings, Formatting.Indented)); } break; case "reload": McFlyExtension.PopulateSettings(); break; case "open": var p = System.Diagnostics.Process.Start(McFlyExtension.GetLogPath()); break; default: throw new ArgumentOutOfRangeException(nameof(args), $"Settings takes 3 commands: list, reload, or open. Found {args[0]}"); } }
/// <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> /// 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> /// Processes the internal. /// </summary> /// <param name="startingPosition">The starting position.</param> /// <param name="endingPosition">The ending position.</param> /// <param name="options">The options.</param> internal void ProcessInternal(Position startingPosition, Position endingPosition, IndexOptions options) { SetBreakpoints(options); TimeTravelFacade.SetPosition(startingPosition); // loop through all the set break points and record relevant values var frames = new List <Frame>(); Position last = null; /* * todo: PRIORITY FIX */ while (true) // todo: have better abstraction... while(!TimeTravelFacade.RunTo(endingPosition)) { DebugEngineProxy.RunUntilBreak(); var positions = TimeTravelFacade.Positions(); var breakRecord = positions.CurrentThreadResult; if (last == breakRecord.Position) { break; } var newFrames = CreateFramesForUpsert(positions, breakRecord, options); frames.AddRange(newFrames); foreach (var optionsMemoryRange in options?.MemoryRanges ?? new List <MemoryRange>()) { var bytes = DebugEngineProxy.ReadVirtualMemory(optionsMemoryRange); // todo: errors? ServerClient.AddMemoryRange(new MemoryChunk { MemoryRange = optionsMemoryRange, Bytes = bytes, Position = breakRecord.Position }); } last = breakRecord.Position; } try { ServerClient.UpsertFrames(frames); } catch (Exception e) { Log.Error($"Error persisting frames: {e.GetType().FullName} - {e.Message}"); DebugEngineProxy.WriteLine($"Error persisting frames: {e.GetType().FullName} - {e.Message}"); } }
/// <summary> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <returns>Task.</returns> public void Process(string[] args) { if (IsEmptyArgs(args)) { var commandListing = GetCommandListing(); DebugEngineProxy.WriteLine(commandListing); return; } if (IsSingleCommand(args)) { var commandHelp = GetCommandHelp(args[0]); DebugEngineProxy.WriteLine(commandHelp); } }
/// <summary> /// Upserts the current position. /// </summary> /// <param name="options">The options.</param> internal virtual void UpsertCurrentPosition(IndexOptions options) { var positions = TimeTravelFacade.Positions(); var frames = CreateFramesForUpsert(positions); ServerClient.UpsertFrames(frames); foreach (var optionsMemoryRange in options?.MemoryRanges ?? new List<MemoryRange>()) { var bytes = DebugEngineProxy.ReadVirtualMemory(optionsMemoryRange); // todo: errors? ServerClient.AddMemoryRange(new MemoryChunk { MemoryRange = optionsMemoryRange, Bytes = bytes, Position = positions.CurrentThreadResult.Position }); } }
/// <summary> /// Gets the current frame. /// </summary> /// <returns>Frame.</returns> public Frame GetCurrentFrame() { var position = GetCurrentPosition(); var currentStack = StackFacade.GetCurrentStackTrace(); var registers = RegisterFacade.GetCurrentRegisterSet(Register.All); var disassembly = DisassemblyFacade.GetDisassemblyLines(1).Single(); return(new Frame { Position = position, StackTrace = currentStack, RegisterSet = registers, DisassemblyLine = disassembly, ThreadId = DebugEngineProxy.GetCurrentThreadId() }); }
/// <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 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> /// 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> /// Di /// </summary> /// <param name="numInstructions">The number instructions.</param> /// <returns>IEnumerable<DisassemblyLine>.</returns> public IEnumerable <DisassemblyLine> GetDisassemblyLines(int numInstructions) { var threadId = DebugEngineProxy.GetCurrentThreadId(); return(GetDisassemblyLines(threadId, numInstructions)); }
/// <summary> /// Gets the registers. /// </summary> /// <param name="threadId">The thread identifier.</param> /// <param name="registers">The registers.</param> /// <returns>RegisterSet.</returns> public RegisterSet GetCurrentRegisterSet(int threadId, IEnumerable <Register> registers) { var registerSet = new RegisterSet(); foreach (var register in registers) { var bytes = DebugEngineProxy.GetRegisterValue(threadId, register); if (register == Register.Af) { registerSet.Af = Convert.ToBoolean(bytes[0]); } else if (register == Register.Ah) { registerSet.Ah = bytes[0]; } else if (register == Register.Al) { registerSet.Al = bytes[0]; } else if (register == Register.Ax) { registerSet.Ax = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Bh) { registerSet.Bh = bytes[0]; } else if (register == Register.Bl) { registerSet.Bl = bytes[0]; } else if (register == Register.Bp) { registerSet.Bp = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Bpl) { registerSet.Bpl = bytes[0]; } else if (register == Register.Brfrom) { registerSet.Brfrom = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Brto) { registerSet.Brto = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Bx) { registerSet.Bx = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Cf) { registerSet.Cf = Convert.ToBoolean(bytes[0]); } else if (register == Register.Ch) { registerSet.Ch = bytes[0]; } else if (register == Register.Cl) { registerSet.Cl = bytes[0]; } else if (register == Register.Cs) { registerSet.Cs = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Cx) { registerSet.Cx = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Df) { registerSet.Df = Convert.ToBoolean(bytes[0]); } else if (register == Register.Dh) { registerSet.Dh = bytes[0]; } else if (register == Register.Di) { registerSet.Di = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Dil) { registerSet.Dil = bytes[0]; } else if (register == Register.Dl) { registerSet.Dl = bytes[0]; } else if (register == Register.Dr0) { registerSet.Dr0 = DebugEngineProxy.Is32Bit ? BitConverter.ToUInt32(bytes, 0) : BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Dr1) { registerSet.Dr1 = DebugEngineProxy.Is32Bit ? BitConverter.ToUInt32(bytes, 0) : BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Dr2) { registerSet.Dr2 = DebugEngineProxy.Is32Bit ? BitConverter.ToUInt32(bytes, 0) : BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Dr3) { registerSet.Dr3 = DebugEngineProxy.Is32Bit ? BitConverter.ToUInt32(bytes, 0) : BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Dr6) { registerSet.Dr6 = DebugEngineProxy.Is32Bit ? BitConverter.ToUInt32(bytes, 0) : BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Dr7) { registerSet.Dr7 = DebugEngineProxy.Is32Bit ? BitConverter.ToUInt32(bytes, 0) : BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Ds) { registerSet.Ds = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Dx) { registerSet.Dx = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Eax) { registerSet.Eax = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Ebp) { registerSet.Ebp = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Ebx) { registerSet.Ebx = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Ecx) { registerSet.Ecx = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Edi) { registerSet.Edi = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Edx) { registerSet.Edx = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Efl) { registerSet.Efl = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Eip) { registerSet.Eip = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Es) { registerSet.Es = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Esi) { registerSet.Esi = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Esp) { registerSet.Esp = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Exfrom) { registerSet.Exfrom = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Exto) { registerSet.Exto = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Fl) { registerSet.Fl = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Fopcode) { registerSet.Fopcode = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Fpcw) { registerSet.Fpcw = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Fpdp) { registerSet.Fpdp = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Fpdpsel) { registerSet.Fpdpsel = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Fpip) { registerSet.Fpip = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Fpipsel) { registerSet.Fpipsel = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Fpsw) { registerSet.Fpsw = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Fptw) { registerSet.Fptw = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Fs) { registerSet.Fs = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Gs) { registerSet.Gs = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.If) { registerSet.If = Convert.ToBoolean(bytes[0]); } else if (register == Register.Iopl) { registerSet.Iopl = bytes[0]; } else if (register == Register.Ip) { registerSet.Ip = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Mm0) { registerSet.Mm0 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm1) { registerSet.Mm1 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm2) { registerSet.Mm2 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm3) { registerSet.Mm3 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm4) { registerSet.Mm4 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm5) { registerSet.Mm5 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm6) { registerSet.Mm6 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mm7) { registerSet.Mm7 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Mxcsr) { registerSet.Mxcsr = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.Of) { registerSet.Of = Convert.ToBoolean(bytes[0]); } else if (register == Register.Pf) { registerSet.Pf = Convert.ToBoolean(bytes[0]); } else if (register == Register.R10) { registerSet.R10 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R10b) { registerSet.R10b = bytes[0]; } else if (register == Register.R10d) { registerSet.R10d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R10w) { registerSet.R10w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R11) { registerSet.R11 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R11b) { registerSet.R11b = bytes[0]; } else if (register == Register.R11d) { registerSet.R11d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R11w) { registerSet.R11w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R12) { registerSet.R12 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R12b) { registerSet.R12b = bytes[0]; } else if (register == Register.R12d) { registerSet.R12d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R12w) { registerSet.R12w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R13) { registerSet.R13 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R13b) { registerSet.R13b = bytes[0]; } else if (register == Register.R13d) { registerSet.R13d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R13w) { registerSet.R13w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R14) { registerSet.R14 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R14b) { registerSet.R14b = bytes[0]; } else if (register == Register.R14d) { registerSet.R14d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R14w) { registerSet.R14w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R15) { registerSet.R15 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R15b) { registerSet.R15b = bytes[0]; } else if (register == Register.R15d) { registerSet.R15d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R15w) { registerSet.R15w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R8) { registerSet.R8 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R8b) { registerSet.R8b = bytes[0]; } else if (register == Register.R8d) { registerSet.R8d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R8w) { registerSet.R8w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.R9) { registerSet.R9 = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.R9b) { registerSet.R9b = bytes[0]; } else if (register == Register.R9d) { registerSet.R9d = BitConverter.ToUInt32(bytes, 0); } else if (register == Register.R9w) { registerSet.R9w = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Rax) { registerSet.Rax = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rbp) { registerSet.Rbp = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rbx) { registerSet.Rbx = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rcx) { registerSet.Rcx = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rdi) { registerSet.Rdi = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rdx) { registerSet.Rdx = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rip) { registerSet.Rip = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rsi) { registerSet.Rsi = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Rsp) { registerSet.Rsp = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Sf) { registerSet.Sf = Convert.ToBoolean(bytes[0]); } else if (register == Register.Si) { registerSet.Si = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Sil) { registerSet.Sil = bytes[0]; } else if (register == Register.Sp) { registerSet.Sp = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.Spl) { registerSet.Spl = bytes[0]; } else if (register == Register.Ss) { registerSet.Ss = BitConverter.ToUInt16(bytes, 0); } else if (register == Register.St0) { registerSet.St0 = bytes.Take(10).ToArray(); } else if (register == Register.St1) { registerSet.St1 = bytes.Take(10).ToArray(); } else if (register == Register.St2) { registerSet.St2 = bytes.Take(10).ToArray(); } else if (register == Register.St3) { registerSet.St3 = bytes.Take(10).ToArray(); } else if (register == Register.St4) { registerSet.St4 = bytes.Take(10).ToArray(); } else if (register == Register.St5) { registerSet.St5 = bytes.Take(10).ToArray(); } else if (register == Register.St6) { registerSet.St6 = bytes.Take(10).ToArray(); } else if (register == Register.St7) { registerSet.St7 = bytes.Take(10).ToArray(); } else if (register == Register.Tf) { registerSet.Tf = Convert.ToBoolean(bytes[0]); } else if (register == Register.Vif) { registerSet.Vif = Convert.ToBoolean(bytes[0]); } else if (register == Register.Vip) { registerSet.Vip = Convert.ToBoolean(bytes[0]); } else if (register == Register.Xmm0) { registerSet.Xmm0 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm0h) { registerSet.Xmm0h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm0l) { registerSet.Xmm0l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm1) { registerSet.Xmm1 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm10) { registerSet.Xmm10 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm10h) { registerSet.Xmm10h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm10l) { registerSet.Xmm10l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm11) { registerSet.Xmm11 = bytes.Take(16).ToArray(); ; } else if (register == Register.Xmm11h) { registerSet.Xmm11h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm11l) { registerSet.Xmm11l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm12) { registerSet.Xmm12 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm12h) { registerSet.Xmm12h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm12l) { registerSet.Xmm12l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm13) { registerSet.Xmm13 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm13h) { registerSet.Xmm13h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm13l) { registerSet.Xmm13l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm14) { registerSet.Xmm14 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm14h) { registerSet.Xmm14h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm14l) { registerSet.Xmm14l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm15) { registerSet.Xmm15 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm15h) { registerSet.Xmm15h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm15l) { registerSet.Xmm15l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm1h) { registerSet.Xmm1h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm1l) { registerSet.Xmm1l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm2) { registerSet.Xmm2 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm2h) { registerSet.Xmm2h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm2l) { registerSet.Xmm2l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm3) { registerSet.Xmm3 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm3h) { registerSet.Xmm3h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm3l) { registerSet.Xmm3l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm4) { registerSet.Xmm4 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm4h) { registerSet.Xmm4h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm4l) { registerSet.Xmm4l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm5) { registerSet.Xmm5 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm5h) { registerSet.Xmm5h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm5l) { registerSet.Xmm5l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm6) { registerSet.Xmm6 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm6h) { registerSet.Xmm6h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm6l) { registerSet.Xmm6l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm7) { registerSet.Xmm7 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm7h) { registerSet.Xmm7h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm7l) { registerSet.Xmm7l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm8) { registerSet.Xmm8 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm8h) { registerSet.Xmm8h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm8l) { registerSet.Xmm8l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm9) { registerSet.Xmm9 = bytes.Take(16).ToArray(); } else if (register == Register.Xmm9h) { registerSet.Xmm9h = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Xmm9l) { registerSet.Xmm9l = BitConverter.ToUInt64(bytes, 0); } else if (register == Register.Ymm0) { registerSet.Ymm0 = bytes; } else if (register == Register.Ymm0h) { registerSet.Ymm0h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm0l) { registerSet.Ymm0l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm1) { registerSet.Ymm1 = bytes; } else if (register == Register.Ymm10) { registerSet.Ymm10 = bytes; } else if (register == Register.Ymm10h) { registerSet.Ymm10h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm10l) { registerSet.Ymm10l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm11) { registerSet.Ymm11 = bytes; } else if (register == Register.Ymm11h) { registerSet.Ymm11h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm11l) { registerSet.Ymm11l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm12) { registerSet.Ymm12 = bytes; } else if (register == Register.Ymm12h) { registerSet.Ymm12h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm12l) { registerSet.Ymm12l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm13) { registerSet.Ymm13 = bytes; } else if (register == Register.Ymm13h) { registerSet.Ymm13h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm13l) { registerSet.Ymm13l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm14) { registerSet.Ymm14 = bytes; } else if (register == Register.Ymm14h) { registerSet.Ymm14h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm14l) { registerSet.Ymm14l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm15) { registerSet.Ymm15 = bytes; } else if (register == Register.Ymm15h) { registerSet.Ymm15h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm15l) { registerSet.Ymm15l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm1h) { registerSet.Ymm1h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm1l) { registerSet.Ymm1l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm2) { registerSet.Ymm2 = bytes; } else if (register == Register.Ymm2h) { registerSet.Ymm2h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm2l) { registerSet.Ymm2l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm3) { registerSet.Ymm3 = bytes; } else if (register == Register.Ymm3h) { registerSet.Ymm3h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm3l) { registerSet.Ymm3l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm4) { registerSet.Ymm4 = bytes; } else if (register == Register.Ymm4h) { registerSet.Ymm4h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm4l) { registerSet.Ymm4l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm5) { registerSet.Ymm5 = bytes; } else if (register == Register.Ymm5h) { registerSet.Ymm5h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm5l) { registerSet.Ymm5l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm6) { registerSet.Ymm6 = bytes; } else if (register == Register.Ymm6h) { registerSet.Ymm6h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm6l) { registerSet.Ymm6l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm7) { registerSet.Ymm7 = bytes; } else if (register == Register.Ymm7h) { registerSet.Ymm7h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm7l) { registerSet.Ymm7l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm8) { registerSet.Ymm8 = bytes; } else if (register == Register.Ymm8h) { registerSet.Ymm8h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm8l) { registerSet.Ymm8l = bytes.Take(16).ToArray(); } else if (register == Register.Ymm9) { registerSet.Ymm9 = bytes; } else if (register == Register.Ymm9h) { registerSet.Ymm9h = bytes.Take(16).ToArray(); } else if (register == Register.Ymm9l) { registerSet.Ymm9l = bytes.Take(16).ToArray(); } else if (register == Register.Zf) { registerSet.Zf = Convert.ToBoolean(bytes[0]); } } return(registerSet); }
/// <summary> /// Clears the breakpoints. /// </summary> public void ClearBreakpoints() { DebugEngineProxy.Execute($"bc *"); }
/// <summary> /// Gets the current register set. /// </summary> /// <param name="registers">The registers.</param> /// <returns>RegisterSet.</returns> public RegisterSet GetCurrentRegisterSet(IEnumerable <Register> registers) { return(GetCurrentRegisterSet(DebugEngineProxy.GetCurrentThreadId(), registers)); }
/// <summary> /// Sets the position. /// </summary> /// <param name="position">The position.</param> public void SetPosition(Position position) { DebugEngineProxy.Execute($"!tt {position}"); }