public byte[] InspectMemory(ushort startAddress, ushort size) { List <byte> memory = new List <byte>(); while (size > 0) { byte length = (byte)(size < 256 ? size : 0); ReadMemoryResponse response = SendAndReceive <ReadMemoryResponse>(new ReadMemoryRequest(startAddress, length), 2000); ushort bytesRead = (ushort)response.Memory.Length; memory.AddRange(response.Memory); startAddress += bytesRead; size -= bytesRead; } return(memory.ToArray()); }
public void SetBreakpoint(ushort address, string name = null) { // Check whether breakpoint already exists DebugBreakpoint breakpoint = breakpoints.Where(bp => bp.Address == address).FirstOrDefault(); if (breakpoint == null) { return; } // First read instruction at breakpoint location ReadMemoryResponse response = engine.SendAndReceive <ReadMemoryResponse>(new ReadMemoryRequest(address, 1)); byte instruction = response.Memory[0]; // Overwrite memory with BRK (0x00) command engine.SendAndWait(new WriteMemoryRequest(address, 0, new byte[] { 0x00 })); // Store breakpoint for later breakpoint = new DebugBreakpoint(address, instruction); breakpoints.Add(breakpoint); }
public static IDebugResponse CreateResponse(DebugCommand command) { IDebugResponse response = null; switch (command) { case DebugCommand.Continue: response = new DebugResponse <ContinueRequest>(); break; case DebugCommand.ReceiveRegisters: response = new DebugResponse <ReceiveRegistersRequest>(); break; case DebugCommand.WriteMemory: return(null); //response = new DebugResponse<WriteMemoryRequest>(); case DebugCommand.ReadMemory: response = new ReadMemoryResponse(); break; case DebugCommand.SendRegisters: response = new SendRegistersResponse(); break; case DebugCommand.DownloadScreen: response = new DownloadScreenResponse(); break; default: return(null); } response.AddBytes(new byte[1] { (byte)command }); return(response); }