public void ProcessResponses(DebugMessage response) { string formatted = "RECEIVED: #" + response.ID.ToString() + " -> " + FormatResponseMessage(response); events[eventIndex++] = formatted; if (eventIndex == events.Length) eventIndex = 0; listBox1.Items.Clear(); int start = eventIndex; for (int i = 0; i < events.Length; i++) { start--; if (start < 0) start = events.Length - 1; if (events[start] == null) return; listBox1.Items.Add(events[start]); } }
public void Dispatch(DebugMessage response) { if (response == null) return; dispatchOutput.BeginInvoke((CallBack)dispatchOutput.ProcessResponses, new object[] { response }); }
public void ProcessResponses(DebugMessage response) { string formatted = events.Count.ToString() + ": " + FormatResponseMessage(response) + " (" + response.ID.ToString() + ")"; events.Add(formatted); if (listBox1.Items.Count == 25) { listBox1.Items.RemoveAt(listBox1.Items.Count - 1); } listBox1.Items.Insert(0, formatted); }
public bool SendCommand(DebugMessage message) { lock (sync) { if (!IsConnected) return false; message.ID = ++nextID; pending.Add(message.ID, message); SendCommandMessage(message); return true; } }
public void Dispatch(DebugMessage response) { if (response == null) return; dispatchOutput.BeginInvoke((SenderMesseageDelegate)dispatchOutput.ProcessResponses, new object[] { response }); if (response.Sender is Form) { (response.Sender as Form).BeginInvoke(response.SenderMethod, new object[] { response }); } else if (response.Sender is DockContent) { (response.Sender as DockContent).BeginInvoke(response.SenderMethod, new object[] { response }); } }
private void SendCommandMessage(DebugMessage message) { SendMagic(); SendInteger(message.ID); SendInteger(message.Code); if (message.CommandData == null) { SendInteger(0); SendInteger(message.Checksum); } else { SendInteger(message.CommandData.Length); SendInteger(message.Checksum); foreach (var b in message.CommandData) { SendByte(b); } } }
private string FormatResponseMessage(DebugMessage response) { switch (response.Code) { case Codes.Connected: return "Connected"; case Codes.Connecting: return "Connecting"; case Codes.Disconnected: return "Disconnected"; case Codes.UnknownData: return "Unknown Data: " + System.Text.Encoding.UTF8.GetString(response.ResponseData); case Codes.InformationalMessage: return "Informational Message: " + System.Text.Encoding.UTF8.GetString(response.ResponseData); case Codes.ErrorMessage: return "Error Message: " + System.Text.Encoding.UTF8.GetString(response.ResponseData); case Codes.WarningMessage: return "Warning Message: " + System.Text.Encoding.UTF8.GetString(response.ResponseData); case Codes.Ping: return "Pong"; case Codes.Alive: return "Alive"; case Codes.ReadCR3: return "ReadCR3"; case Codes.ReadMemory: return "ReadMemory"; case Codes.Scattered32BitReadMemory: return "Scattered32BitReadMemory"; case Codes.SendNumber: return "#: " + ((response.ResponseData[0] << 24) | (response.ResponseData[1] << 16) | (response.ResponseData[2] << 8) | response.ResponseData[3]).ToString(); default: return "Code: " + response.Code.ToString(); } }
private void DisplayMemory(DebugMessage message) { cbSelect.Enabled = Enabled; int start = message.GetInt32(0); int lines = message.GetInt32(4) / 16; uint at = (uint)start; try { string[] newlines = new string[lines]; for (int line = 0; line < lines; line++) { string l = at.ToString("X").PadLeft(8, '0') + ':'; string d = string.Empty; for (int x = 0; x < 16; x++) { byte mem = message.ResponseData[at - start + 8]; if (x % 4 == 0) l = l + ' '; l = l + mem.ToString("X").PadLeft(2, '0'); char b = (char)mem; d = d + (char.IsLetterOrDigit(b) ? b : '.'); at++; } newlines[line] = l + ' ' + d; } lbMemory.Lines = newlines; Status = string.Empty; } catch (Exception e) { Status = "Error: " + e.ToString(); } }
private void PostResponse(int id, int code, byte[] data) { lock (sync) { DebugMessage message; if (id == 0 || !pending.TryGetValue(id, out message)) { // message without command message = new DebugMessage(code, data); message.ID = id; // need to set a default notifier for this } else { pending.Remove(message.ID); } message.ResponseData = data; dispatchMethod(message); } }
private Packet CreatePacket(DebugMessage message) { var packet = new Packet(); packet.Add((byte)'!'); packet.Add(message.ID); packet.Add(message.Code); if (message.CommandData == null) { packet.Add((int)0); // length } else { packet.Add(message.CommandData.Count); // length foreach (var b in message.CommandData) { packet.Add(b); } } return(packet); }
private void CallBack_DisplayMemory(DebugMessage message) { BeginInvoke((MethodInvoker)delegate { DisplayMemory(message); }); }
private void UpdatePointers(DebugMessage message) { multibootStructure = (uint)message.GetUInt32(4); physicalPageFreeList = (uint)message.GetUInt32(12); }
private void ReadCR3(DebugMessage message) { cr3 = (uint)message.GetUInt32(0); cbSelect.Enabled = Enabled; if (cbSelect.SelectedIndex == -1) cbSelect.SelectedIndex = 0; }
private void SendCommandMessage(DebugMessage message) { SendMagic(); SendInteger(message.ID); SendInteger(message.Code); if (message.CommandData == null) { SendInteger(0); SendInteger(message.Checksum); } else { SendInteger(message.CommandData.Length); SendInteger(message.Checksum); foreach (var b in message.CommandData) SendByte(b); } }
private void SendCommandMessage(DebugMessage message) { AddSendPacket((byte)'M'); AddSendPacket((byte)'O'); AddSendPacket((byte)'S'); AddSendPacket((byte)'A'); crc = CRC.InitialCRC; // initialize the CRC (at the right spot) AddSendPacket(message.ID); AddSendPacket(message.Code); if (message.CommandData == null) { AddSendPacket(0); AddSendPacket(0); // checksum } else { AddSendPacket(message.CommandData.Count); // length foreach (var b in message.CommandData) { AddSendPacket(b); } AddSendPacket((int)crc); // checksum } SendPacket(); }
private void PostResponse(int id, int code, List<byte> data) { DebugMessage message = null; lock (sync) { if (id == 0 || !pending.TryGetValue(id, out message)) { // message without command message = new DebugMessage(code, data); message.ID = id; // need to set a default notifier for this } else { pending.Remove(message.ID); } message.ResponseData = data; } if (message != null) { globalDispatch?.Invoke(message); message.CallBack?.Invoke(message); } }
public bool SendCommand(DebugMessage message) { return DebugEngine.SendCommand(message); }
private void DisplayMemory(DebugMessage message) { Status = string.Empty; for (int i = 0; i < width * height * 2; i++) { memory[i] = message.ResponseData[i + 8]; } UpdateBitMap(); }
private void CallBack_ReadCR3(DebugMessage message) { BeginInvoke((MethodInvoker)delegate { ReadCR3(message); }); }
private void CallBack_UpdatePointers(DebugMessage message) { BeginInvoke((MethodInvoker)delegate { UpdatePointers(message); }); }
private static string FormatResponseMessage(DebugMessage response) { return response.ToString(); }