diff --git a/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml b/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml index a08eea19b..daae4765e 100644 --- a/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml +++ b/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml @@ -3,7 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - mc:Ignorable="d" - d:DesignHeight="23" d:DesignWidth="143"> - + mc:Ignorable="d"> + diff --git a/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml.cs b/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml.cs index b62aa5779..a95a2d0ed 100644 --- a/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml.cs +++ b/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml.cs @@ -18,20 +18,44 @@ namespace Cosmos.Cosmos_VS_Windows { InitializeComponent(); } + protected void UpdateDisplay() { + if (mValue.HasValue) { + tblkData.Text = mPrefix + mValue.Value.ToString("X" + mDigits); + } else { + tblkData.Text = mPrefix + (new string('-', mDigits)); + } + tblkData.Foreground = mPrevValue == mValue ? Brushes.Black : Brushes.Red; + } + protected UInt32? mPrevValue; protected UInt32? mValue; public UInt32? Value { + get { return mValue; } + set { mValue = value; - if (mValue.HasValue) { - tblkData.Text = "0x" + mValue.Value.ToString("X8"); - } else { - tblkData.Text = "0x--------"; - } - tblkData.Foreground = mPrevValue == mValue ? Brushes.Black : Brushes.Red; + UpdateDisplay(); mPrevValue = mValue; } - get { return mValue; } + } + + protected string mPrefix = "0x"; + public string Prefix { + get { return mPrefix; } + set { + mPrefix = value; + UpdateDisplay(); + } + } + + protected int mDigits = 8; + public int Digits { + get { return mDigits; } + set { + mDigits = value; + UpdateDisplay(); + } } } + } diff --git a/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml b/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml index 4bba11ab3..9a654366f 100644 --- a/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml +++ b/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml @@ -5,25 +5,80 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0" mc:Ignorable="d" - d:DesignHeight="166" d:DesignWidth="300" Name="CosmosRegistersUserControl" - Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}"> + Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}" xmlns:my="clr-namespace:Cosmos.Cosmos_VS_Windows"> - - EAXEBXECXEDX - - AXBXCXDX - - AHBHCHDH - - ALBLCLDL - - - - ESPEBPESIEDI - - EIPFlags - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml.cs b/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml.cs index 7f8653bc0..56f96daa0 100644 --- a/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml.cs +++ b/source2/VSIP/Cosmos.VS.Windows/RegistersUC.xaml.cs @@ -20,58 +20,25 @@ namespace Cosmos.Cosmos_VS_Windows { public partial class RegistersUC : UserControl { - public RegistersUC() - { + public RegistersUC() { InitializeComponent(); - runEAX.Text = "0x--------"; - runAX.Text = "----"; - runAH.Text = "--"; - runAL.Text = "--"; - runEBX.Text = "0x--------"; - runBX.Text = "----"; - runBH.Text = "--"; - runBL.Text = "--"; - runECX.Text = "0x--------"; - runCX.Text = "----"; - runCH.Text = "--"; - runCL.Text = "--"; - runEDX.Text = "0x--------"; - runDX.Text = "----"; - runDH.Text = "--"; - runDL.Text = "--"; - runEBP.Text = "0x--------"; - runESI.Text = "0x--------"; - runEDI.Text = "0x--------"; - runESP.Text = "0x--------"; - runEIP.Text = "0x-------"; - runFlags.Text = "--------"; - } + } - protected void UpdateRegisters(byte[] aData, int aOffset, Run a32, Run a16, Run a8Hi, Run a8Lo) + protected void UpdateRegisters(byte[] aData, int aOffset, DataBytesUC a32, DataBytesUC a16, DataBytesUC a8Hi, DataBytesUC a8Lo) { - byte x8Lo = aData[aOffset]; - byte x8Hi = aData[aOffset + 1]; - SetText(a8Lo, x8Lo.ToString("X2")); - SetText(a8Hi, x8Hi.ToString("X2")); - SetText(a16, x8Hi.ToString("X2") + x8Lo.ToString("X2")); + a8Lo.Value = aData[aOffset]; + a8Hi.Value = aData[aOffset + 1]; + a16.Value = a8Hi.Value << 8 | a8Lo.Value; UpdateRegister32(aData, aOffset, a32); } - protected void UpdateRegister32(byte[] aData, int aOffset, Run a32) - { - UInt32 x32 = (UInt32) - (aData[aOffset + 3] << 24 | - aData[aOffset + 2] << 16 | - aData[aOffset + 1] << 8 | - aData[aOffset]); - SetText(a32, "0x" + x32.ToString("X8")); - } - - protected void SetText(Run aLabel, string aText) - { - string xOldContent = (string)aLabel.Text; - aLabel.Text = aText; - aLabel.Foreground = (xOldContent == aText) ? Brushes.Black : Brushes.Red; + protected void UpdateRegister32(byte[] aData, int aOffset, DataBytesUC a32) { + UInt32 x32 = (UInt32) + (aData[aOffset + 3] << 24 | + aData[aOffset + 2] << 16 | + aData[aOffset + 1] << 8 | + aData[aOffset]); + a32.Value = x32; } public void Update(byte[] aData) @@ -92,15 +59,15 @@ namespace Cosmos.Cosmos_VS_Windows // ESP 32 // EIP 36 // - UpdateRegisters(aData, 28, runEAX, runAX, runAH, runAL); - UpdateRegisters(aData, 16, runEBX, runBX, runBH, runBL); - UpdateRegisters(aData, 24, runECX, runCX, runCH, runCL); - UpdateRegisters(aData, 20, runEDX, runDX, runDH, runDL); - UpdateRegister32(aData, 8, runEBP); - UpdateRegister32(aData, 4, runESI); - UpdateRegister32(aData, 0, runEDI); - UpdateRegister32(aData, 32, runESP); - UpdateRegister32(aData, 36, runEIP); + UpdateRegisters(aData, 28, dataEAX, dataAX, dataAH, dataAL); + UpdateRegisters(aData, 16, dataEBX, dataBX, dataBH, dataBL); + UpdateRegisters(aData, 24, dataECX, dataCX, dataCH, dataCL); + UpdateRegisters(aData, 20, dataEDX, dataDX, dataDH, dataDL); + UpdateRegister32(aData, 8, dataEBP); + UpdateRegister32(aData, 4, dataESI); + UpdateRegister32(aData, 0, dataEDI); + UpdateRegister32(aData, 32, dataESP); + UpdateRegister32(aData, 36, dataEIP); //TODO: Flags } }