mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 21:38:52 +00:00
This commit is contained in:
parent
4d98fc9c37
commit
015a0bcceb
4 changed files with 128 additions and 83 deletions
|
|
@ -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">
|
||||
<TextBlock Name="tblkData" />
|
||||
mc:Ignorable="d">
|
||||
<TextBlock Name="tblkData" Text="0x--------" />
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
<WrapPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="5">EAX<LineBreak/>EBX<LineBreak/>ECX<LineBreak/>EDX</TextBlock>
|
||||
<TextBlock Margin="5"><Run Name="runEAX" Text="0x00000000"/><LineBreak/><Run Name="runEBX" Text="0x00000000"/><LineBreak/><Run Name="runECX" Text="0x00000000"/><LineBreak/><Run Name="runEDX" Text="0x00000000"/></TextBlock>
|
||||
<TextBlock Margin="5">AX<LineBreak/>BX<LineBreak/>CX<LineBreak/>DX</TextBlock>
|
||||
<TextBlock Margin="5"><Run Name="runAX" Text="0x0000"/><LineBreak/><Run Name="runBX" Text="0x0000"/><LineBreak/><Run Name="runCX" Text="0x0000"/><LineBreak/><Run Name="runDX" Text="0x0000"/></TextBlock>
|
||||
<TextBlock Margin="5">AH<LineBreak/>BH<LineBreak/>CH<LineBreak/>DH</TextBlock>
|
||||
<TextBlock Margin="5"><Run Name="runAH" Text="0x00"/><LineBreak/><Run Name="runBH" Text="0x00"/><LineBreak/><Run Name="runCH" Text="0x00"/><LineBreak/><Run Name="runDH" Text="0x00"/></TextBlock>
|
||||
<TextBlock Margin="5">AL<LineBreak/>BL<LineBreak/>CL<LineBreak/>DL</TextBlock>
|
||||
<TextBlock Margin="5"><Run Name="runAL" Text="0x00"/><LineBreak/><Run Name="runBL" Text="0x00"/><LineBreak/><Run Name="runCL" Text="0x00"/><LineBreak/><Run Name="runDL" Text="0x00"/></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="5">ESP<LineBreak/>EBP<LineBreak/>ESI<LineBreak/>EDI</TextBlock>
|
||||
<TextBlock Margin="5"><Run Name="runESP" Text="0x00000000"/><LineBreak/><Run Name="runEBP" Text="0x00000000"/><LineBreak/><Run Name="runESI" Text="0x00000000"/><LineBreak/><Run Name="runEDI" Text="0x00000000"/></TextBlock>
|
||||
<TextBlock Margin="5">EIP<LineBreak/>Flags</TextBlock>
|
||||
<TextBlock Margin="5"><Run Name="runEIP" Text="0x00000000"/><LineBreak/><Run Name="runFlags" Text="--------"/></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<TextBlock Text="EAX" />
|
||||
<TextBlock Text="EBX" />
|
||||
<TextBlock Text="ECX" />
|
||||
<TextBlock Text="EDX" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<my:DataBytesUC x:Name="dataEAX" />
|
||||
<my:DataBytesUC x:Name="dataEBX" />
|
||||
<my:DataBytesUC x:Name="dataECX" />
|
||||
<my:DataBytesUC x:Name="dataEDX" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<TextBlock Text="AX" />
|
||||
<TextBlock Text="BX" />
|
||||
<TextBlock Text="CX" />
|
||||
<TextBlock Text="DX" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<my:DataBytesUC Prefix="" Digits="4" x:Name="dataAX" />
|
||||
<my:DataBytesUC Prefix="" Digits="4" x:Name="dataBX" />
|
||||
<my:DataBytesUC Prefix="" Digits="4" x:Name="dataCX" />
|
||||
<my:DataBytesUC Prefix="" Digits="4" x:Name="dataDX" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<TextBlock Text="AH" />
|
||||
<TextBlock Text="BH" />
|
||||
<TextBlock Text="CH" />
|
||||
<TextBlock Text="DH" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataAH" />
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataBH" />
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataCH" />
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataDH" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<TextBlock Text="AL" />
|
||||
<TextBlock Text="BL" />
|
||||
<TextBlock Text="CL" />
|
||||
<TextBlock Text="DL" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataAL" />
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataBL" />
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataCL" />
|
||||
<my:DataBytesUC Prefix="" Digits="2" x:Name="dataDL" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<TextBlock Text="ESP" />
|
||||
<TextBlock Text="EBP" />
|
||||
<TextBlock Text="ESI" />
|
||||
<TextBlock Text="EDI" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<my:DataBytesUC x:Name="dataESP" />
|
||||
<my:DataBytesUC x:Name="dataEBP" />
|
||||
<my:DataBytesUC x:Name="dataESI" />
|
||||
<my:DataBytesUC x:Name="dataEDI" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<TextBlock Text="EIP" />
|
||||
<TextBlock Text="Flags" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,0,5,0">
|
||||
<my:DataBytesUC x:Name="dataEIP" />
|
||||
<my:DataBytesUC x:Name="dataFlags" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue