mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 21:08:51 +00:00
Increased responsiveness of timer, and made the queue threadsafe.
This commit is contained in:
parent
178a91974d
commit
9c06dedd71
3 changed files with 95 additions and 91 deletions
|
|
@ -316,6 +316,7 @@ namespace Cosmos.Compiler.DebugStub {
|
|||
Call<DebugStub.WriteAXToComPort>();
|
||||
|
||||
ESI = Memory["DebugEBP", 32];
|
||||
ESI.Add(4); // Dont transmit [EBP], its the saved EIP and not needed
|
||||
for (int i = 1; i <= xCount; i++) {
|
||||
Call("WriteByteToComPort");
|
||||
}
|
||||
|
|
@ -347,7 +348,7 @@ namespace Cosmos.Compiler.DebugStub {
|
|||
}
|
||||
}
|
||||
|
||||
public class ProcessCommand : CodeBlock {
|
||||
public class ProcessCommand : CodeBlock {
|
||||
// Modifies: AL, DX (ReadALFromComPort)
|
||||
// Returns: AL
|
||||
public override void Assemble() {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace Cosmos.Cosmos_VS_Windows
|
|||
{
|
||||
Queue<byte> mCommand;
|
||||
Queue<byte[]> mMessage;
|
||||
System.Timers.Timer mTimer = new System.Timers.Timer(250);
|
||||
System.Timers.Timer mTimer = new System.Timers.Timer(100);
|
||||
|
||||
/// Default constructor of the package.
|
||||
/// Inside this method you can place any initialization code that does not require
|
||||
|
|
@ -140,62 +140,65 @@ namespace Cosmos.Cosmos_VS_Windows
|
|||
}
|
||||
}
|
||||
|
||||
void ProcessMessage(object sender, EventArgs e)
|
||||
{
|
||||
byte xCmd = 0x0;
|
||||
byte[] xMsg = {0x0};
|
||||
if ((mCommand.Count > 0) && (mMessage.Count > 0))
|
||||
{
|
||||
xCmd = mCommand.Dequeue();
|
||||
xMsg = mMessage.Dequeue();
|
||||
void ProcessMessage(object sender, EventArgs e) {
|
||||
byte xCmd;
|
||||
byte[] xMsg;
|
||||
while (true) {
|
||||
lock (mCommand) {
|
||||
if (mCommand.Count == 0) {
|
||||
break;
|
||||
}
|
||||
xCmd = mCommand.Dequeue();
|
||||
xMsg = mMessage.Dequeue();
|
||||
}
|
||||
switch (xCmd)
|
||||
{
|
||||
case DwMsgType.Noop:
|
||||
break;
|
||||
switch (xCmd) {
|
||||
case DwMsgType.Noop:
|
||||
break;
|
||||
|
||||
case DwMsgType.Stack:
|
||||
if (StackTW.mUC != null) {
|
||||
StackTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
StackTW.mUC.UpdateStack(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case DwMsgType.Stack:
|
||||
if (StackTW.mUC != null) {
|
||||
StackTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
StackTW.mUC.UpdateStack(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case DwMsgType.Frame:
|
||||
if (StackTW.mUC != null) {
|
||||
StackTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
StackTW.mUC.UpdateFrame(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case DwMsgType.Frame:
|
||||
if (StackTW.mUC != null) {
|
||||
StackTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
StackTW.mUC.UpdateFrame(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case DwMsgType.Registers:
|
||||
if (RegistersTW.mUC != null) {
|
||||
RegistersTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
RegistersTW.mUC.Update(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case DwMsgType.Registers:
|
||||
if (RegistersTW.mUC != null) {
|
||||
RegistersTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
RegistersTW.mUC.Update(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case DwMsgType.Quit:
|
||||
//Close();
|
||||
break;
|
||||
case DwMsgType.Quit:
|
||||
//Close();
|
||||
break;
|
||||
|
||||
case DwMsgType.AssemblySource:
|
||||
if (AssemblyTW.mUC != null) {
|
||||
AssemblyTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
AssemblyTW.mUC.Update(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case DwMsgType.AssemblySource:
|
||||
if (AssemblyTW.mUC != null) {
|
||||
AssemblyTW.mUC.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
|
||||
AssemblyTW.mUC.Update(xMsg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PipeThread_DataPacketReceived(byte aCmd, byte[] aMsg)
|
||||
{
|
||||
void PipeThread_DataPacketReceived(byte aCmd, byte[] aMsg) {
|
||||
lock (mCommand) {
|
||||
mCommand.Enqueue(aCmd);
|
||||
mMessage.Enqueue(aMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,50 +12,50 @@ using System.Windows.Media.Imaging;
|
|||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Cosmos.Cosmos_VS_Windows
|
||||
{
|
||||
public partial class StackUC : UserControl
|
||||
{
|
||||
public StackUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
namespace Cosmos.Cosmos_VS_Windows {
|
||||
public partial class StackUC : UserControl {
|
||||
public StackUC() {
|
||||
InitializeComponent();
|
||||
|
||||
tboxSourceFrame.Text = "";
|
||||
tboxSourceStack.Text = "";
|
||||
}
|
||||
|
||||
public void UpdateFrame(byte[] aData)
|
||||
{
|
||||
string xData = BitConverter.ToString(aData);
|
||||
xData = xData.Trim();
|
||||
xData = xData.Replace("-", "");
|
||||
|
||||
var xSB = new StringBuilder();
|
||||
for (int i = 0; i < aData.Length; i += 8) {
|
||||
xSB.Insert(0, "[EBP + " + (i / 2) + "] 0x" + xData.Substring(i, 8) + "\n");
|
||||
}
|
||||
xSB.Insert(0, "Arguments\n");
|
||||
tboxSourceFrame.Text = xSB.ToString();
|
||||
}
|
||||
|
||||
public void UpdateStack(byte[] aData)
|
||||
{
|
||||
string xData = BitConverter.ToString(aData);
|
||||
xData = xData.Trim();
|
||||
xData = xData.Replace("-", "");
|
||||
|
||||
int xCount = xData.Length / 8;
|
||||
var xValues = new List<string>(xCount);
|
||||
for (int i = 0; i < xCount; i++) {
|
||||
xValues.Add(xData.Substring(i * 8, 8));
|
||||
}
|
||||
|
||||
var xSB = new StringBuilder();
|
||||
xSB.AppendLine("Stack Contents");
|
||||
for (int i = xCount - 1; i >= 0; i--) {
|
||||
xSB.AppendLine("[EBP - " + ((xCount - i) * 4) + "] 0x" + xValues[i]);
|
||||
}
|
||||
tboxSourceStack.Text = xSB.ToString();
|
||||
}
|
||||
tboxSourceFrame.Text = "";
|
||||
tboxSourceStack.Text = "";
|
||||
}
|
||||
|
||||
protected List<string> SplitValues(byte[] aData) {
|
||||
string xData = BitConverter.ToString(aData);
|
||||
xData = xData.Trim();
|
||||
xData = xData.Replace("-", "");
|
||||
|
||||
int xCount = xData.Length / 8;
|
||||
var xResult = new List<string>(xCount);
|
||||
for (int i = 0; i < xCount; i++) {
|
||||
xResult.Add(xData.Substring(i * 8, 8));
|
||||
}
|
||||
return xResult;
|
||||
}
|
||||
|
||||
public void UpdateFrame(byte[] aData) {
|
||||
var xValues = SplitValues(aData);
|
||||
int xCount = xValues.Count;
|
||||
var xSB = new StringBuilder();
|
||||
xSB.AppendLine("Arguments");
|
||||
for (int i = 0; i < xCount; i++) {
|
||||
// We start at EBP + 4, because [EBP] is not transmitted
|
||||
// ([EBP] is saved EIP, not needed)
|
||||
xSB.AppendLine("[EBP + " + (i * 4 + 4) + "] 0x" + xValues[i]);
|
||||
}
|
||||
tboxSourceFrame.Text = xSB.ToString();
|
||||
}
|
||||
|
||||
public void UpdateStack(byte[] aData) {
|
||||
var xValues = SplitValues(aData);
|
||||
int xCount = xValues.Count;
|
||||
var xSB = new StringBuilder();
|
||||
xSB.AppendLine("Locals and Stack");
|
||||
for (int i = 0; i < xCount; i++) {
|
||||
xSB.AppendLine("[EBP - " + ((xCount - i) * 4) + "] 0x" + xValues[i]);
|
||||
}
|
||||
tboxSourceStack.Text = xSB.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue