From 6e1c55fcc8791346aa45150af57723e2af6e5e86 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 8 Jan 2026 20:05:13 -0600
Subject: [PATCH 01/56] Create DiscoveryDevice.cs
---
DiscoveryDevice.cs | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 DiscoveryDevice.cs
diff --git a/DiscoveryDevice.cs b/DiscoveryDevice.cs
new file mode 100644
index 00000000..c36f18f9
--- /dev/null
+++ b/DiscoveryDevice.cs
@@ -0,0 +1,32 @@
+using System;
+
+namespace ProcessorEmulator
+{
+ public class DiscoveryDevice : IBusDevice
+ {
+ public uint StartAddress => 0x1FC00100; // Just after the Reset Vector
+ public uint Size => 0x100;
+
+ // A simple table defining the "Universe" of this machine
+ private readonly uint[] _configTable = new uint[] {
+ 0x4D495053, // Magic: "MIPS"
+ 0x10400000, // UART Base
+ 0x10000000, // Framebuffer Base
+ 640, // Screen Width
+ 480, // Screen Height
+ 0x0002A000 // Chipset ID (BCM7405)
+ };
+
+ public uint Read32(uint offset)
+ {
+ int index = (int)(offset / 4);
+ return (index < _configTable.Length) ? _configTable[index] : 0;
+ }
+
+ public void Write32(uint offset, uint value) { /* Read Only */ }
+ public void Write16(uint address, ushort value) { /* Read Only */ }
+ public void Write8(uint address, byte value) { /* Read Only */ }
+ public ushort Read16(uint address) { return 0; }
+ public byte Read8(uint address) { return 0; }
+ }
+}
From 37414745c0d7c956cfce4f2b92a73b6bb0cbaa55 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 8 Jan 2026 20:05:17 -0600
Subject: [PATCH 02/56] Update PlatformManager.cs
---
PlatformManager.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/PlatformManager.cs b/PlatformManager.cs
index a4a1a509..4b4e9e51 100644
--- a/PlatformManager.cs
+++ b/PlatformManager.cs
@@ -12,6 +12,7 @@ public static void ApplyConfiguration(string platform, MipsBus bus, CP0 cp0)
bus.AddDevice(new RamDevice(0x00000000, 128 * 1024 * 1024)); // 128MB RAM
bus.AddDevice(new BcmUart(0x10400000)); // Standard BCM UART
bus.AddDevice(new BcmInterruptController(0x10000000));
+ bus.AddDevice(new DiscoveryDevice());
break;
case "iguide":
From ffffaee7ac9021a27ca3e0b5f2fd35c72839ac6e Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 8 Jan 2026 20:12:03 -0600
Subject: [PATCH 03/56] Update EmulatorDisplay.cs
---
Emulation/EmulatorDisplay.cs | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/Emulation/EmulatorDisplay.cs b/Emulation/EmulatorDisplay.cs
index 6e5ed576..52e94de4 100644
--- a/Emulation/EmulatorDisplay.cs
+++ b/Emulation/EmulatorDisplay.cs
@@ -60,6 +60,34 @@ public EmulatorDisplay(GenericFramebuffer vram)
_backBuffer = new Bitmap(640, 480, PixelFormat.Format32bppRgb);
_screen.Image = _backBuffer;
+
+ InitializeHardwareMonitor();
+ }
+
+ private void InitializeHardwareMonitor()
+ {
+ // Creating a Windows 7 style 'Property Grid' or 'ListView'
+ ListView hardwareList = new ListView
+ {
+ //View = View.Details,
+ FullRowSelect = true,
+ GridLines = true,
+ Location = new Point(660, 12),
+ Size = new Size(250, 482),
+ //BackColor = SystemColors.Window,
+ //Font = new Font("Segoe UI", 9) // The Windows 7 standard font
+ };
+
+ hardwareList.Columns.Add("Component", 100);
+ hardwareList.Columns.Add("Address", 120);
+
+ hardwareList.Items.Add(new ListViewItem(new[] { "CPU Core", "MIPS32 R2" }));
+ hardwareList.Items.Add(new ListViewItem(new[] { "UART (Serial)", "0x10400000" }));
+ hardwareList.Items.Add(new ListViewItem(new[] { "Video RAM", "0x10000000" }));
+
+ this.Controls.Add(hardwareList);
+ // Expand the window to fit the monitor
+ this.Width += 270;
}
public void RenderFrame()
From 617b5327cdc89758fbb0ed10ccf7831b72bd3f93 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 8 Jan 2026 20:27:40 -0600
Subject: [PATCH 04/56] Update EmulatorConsole.cs
---
EmulatorConsole.cs | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff --git a/EmulatorConsole.cs b/EmulatorConsole.cs
index e4a3e6c5..02ad71b2 100644
--- a/EmulatorConsole.cs
+++ b/EmulatorConsole.cs
@@ -1,7 +1,6 @@
using System;
using System.Drawing;
using System.Windows.Forms;
-
using System.Linq;
namespace ProcessorEmulator
@@ -12,9 +11,8 @@ public partial class EmulatorConsole : Form
public EmulatorConsole()
{
- // Set the classic Win32 look
this.Text = "MIPS System Console";
- this.BackColor = SystemColors.Control; // Classic Gray
+ this.BackColor = SystemColors.Control;
this.Size = new Size(800, 600);
_terminal = new RichTextBox
@@ -42,22 +40,16 @@ public void AppendText(string text)
_terminal.SelectionStart = _terminal.Text.Length;
_terminal.ScrollToCaret();
}
-
- public void AppendChar(char c)
- {
- AppendText(c.ToString());
- }
+ // Intercepts key presses to send to the emulated UART.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
- // Convert the key to an ASCII character
char c = (char)0;
if (keyData == Keys.Enter) c = '\r';
else if (keyData == Keys.Back) c = '\b';
else if (keyData >= Keys.A && keyData <= Keys.Z)
{
- // Handle Shift for uppercase/lowercase
bool shift = (ModifierKeys & Keys.Shift) != 0;
c = (char)(keyData.ToString()[0]);
if (!shift) c = char.ToLower(c);
@@ -66,21 +58,16 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
c = keyData.ToString().Last();
}
- // Add more cases for symbols/space as needed...
else if (keyData == Keys.Space) c = ' ';
- if (c != 0)
+ // Send the character to the UART if it's a valid one.
+ if (c != 0 && Program.CurrentUart != null)
{
- // Access your UART instance and send the key
- // Assuming you have a reference to the active UART
- if (Program.CurrentUart != null)
- {
- Program.CurrentUart.SendKey(c);
- return true; // Mark as handled
- }
+ Program.CurrentUart.SendKey(c);
+ return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
-}
+}
\ No newline at end of file
From f5b494449ea37d966691d42edb081aa12ac6ce3c Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 8 Jan 2026 20:29:14 -0600
Subject: [PATCH 05/56] Added Llama proofing
do not touch the spaghetti
---
MainWindow.xaml | 558 +++---------------------------------------------
1 file changed, 25 insertions(+), 533 deletions(-)
diff --git a/MainWindow.xaml b/MainWindow.xaml
index f8477b91..cb596570 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -1,541 +1,33 @@
-
-
-
-
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
+ Title="MIPS Universal Emulator - Aero Classic" Height="700" Width="1000">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
\ No newline at end of file
From cf2b1c24a0af8db111bc2842519c952b38c81193 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 8 Jan 2026 20:32:40 -0600
Subject: [PATCH 06/56] Update ProcessorEmulator.csproj
Switch> enable
Switch > conf t
Switch # > exec timeout 00
---
ProcessorEmulator.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index 6ac40478..399661d7 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -2,7 +2,7 @@
WinExe
- net6.0-windows
+ net8.0-windows
true
true
@@ -17,7 +17,7 @@
-
+
From 4aa18eea32729652f9930800115cbfded4e48010 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 9 Jan 2026 17:28:29 -0600
Subject: [PATCH 07/56] Update MainWindow.xaml
---
MainWindow.xaml | 54 ++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/MainWindow.xaml b/MainWindow.xaml
index cb596570..44c3af91 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -2,32 +2,32 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
- Title="MIPS Universal Emulator - Aero Classic" Height="700" Width="1000">
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Title="MIPS Universal Emulator" Height="750" Width="1100"
+ Background="#F0F0F0" WindowStartupLocation="CenterScreen">
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
\ No newline at end of file
+
+
+
From b6857196205c905d0323f053545b9892c6ecbfbd Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 9 Jan 2026 17:33:55 -0600
Subject: [PATCH 08/56] Update MainWindow.xaml.cs
---
MainWindow.xaml.cs | 3387 +-------------------------------------------
1 file changed, 37 insertions(+), 3350 deletions(-)
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 2cf3ade1..98fa57f4 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -1,3376 +1,63 @@
-using ProcessorEmulator.Emulation;
-using ProcessorEmulator.Tools;
-using ProcessorEmulator.Network;
-using ProcessorEmulator; // Add this if PartitionAnalyzer is in the root namespace
using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Drawing;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Text.RegularExpressions;
-using System.Diagnostics;
-using Microsoft.Win32;
-using System.Threading.Tasks;
-using DiscUtils.Iso9660;
-using System.Text;
-using System.Windows.Media;
-// YAFFS handled by ExoticFilesystemManager
-using DiscUtils.Setup;
-using static ProcessorEmulator.Tools.ArchitectureDetector;
-// Removed UFS support
+using System.Windows.Forms;
namespace ProcessorEmulator
{
- public interface IMainWindow
+ public partial class MainWindow : Window
{
- TextBlock StatusBar { get; set; }
- PartitionAnalyzer PartitionAnalyzer { get; set; }
- InstructionDispatcher Dispatcher1 { get; set; }
+ // Our WinForms hardware components
+ private RichTextBox _serialConsole;
+ private PictureBox _videoDisplay;
- bool Equals(object obj);
- int GetHashCode();
- }
-
- // Add missing IQemuEmulator interface stub
- public interface IQemuEmulator : IEmulator
- {
- string GetQemuExecutablePath();
- string GetQemuArguments(string filePath);
- string GetQemuArguments(string filePath, string winceVersion);
- }
-
- public partial class MainWindow : Window, IMainWindow, System.ComponentModel.INotifyPropertyChanged
- {
- private IEmulator currentEmulator;
- public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
- private void OnPropertyChanged(string name) => PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(name));
- private string statusMessage = "Ready";
- private string glassStatus = "Glass: pending";
- public string StatusMessage { get => statusMessage; set { statusMessage = value; OnPropertyChanged(nameof(StatusMessage)); } }
- public string GlassStatus { get => glassStatus; set { glassStatus = value; OnPropertyChanged(nameof(GlassStatus)); } }
- ///
- /// Construct a minimal UI approximately matching the first tab so the window isn't blank
- /// when XAML/BAML loading fails.
- ///
- private void BuildFallbackUi()
- {
- this.Title = "Processor Emulator";
- this.Width = 1200;
- this.Height = 800;
- this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
-
- var dock = new DockPanel();
- this.Content = dock;
-
- var menu = new Menu();
- DockPanel.SetDock(menu, Dock.Top);
- menu.Items.Add(new MenuItem { Header = "_File" });
- menu.Items.Add(new MenuItem { Header = "_Edit" });
- menu.Items.Add(new MenuItem { Header = "_Help" });
- dock.Children.Add(menu);
-
- // Simplified fallback status area (avoid StatusBar type if WPF references fail)
- var statusPanel = new Border { BorderThickness = new Thickness(0,1,0,0), BorderBrush = System.Windows.Media.Brushes.Gray, Padding = new Thickness(4) };
- DockPanel.SetDock(statusPanel, Dock.Bottom);
- statusPanel.Child = new TextBlock { Text = "(Fallback UI)", FontStyle = FontStyles.Italic };
- dock.Children.Add(statusPanel);
-
- var tabs = new TabControl();
- dock.Children.Add(tabs);
-
- var tab = new TabItem { Header = "Emulation" };
- tabs.Items.Add(tab);
- var stack = new StackPanel { Margin = new Thickness(10) };
- tab.Content = stack;
- stack.Children.Add(new TextBlock { Text = "Firmware Emulation (Fallback)", FontWeight = FontWeights.Bold, FontSize = 16 });
-
- var gb = new GroupBox { Header = "1. Select Firmware", Margin = new Thickness(0, 10, 0, 10) };
- var dp = new DockPanel { Margin = new Thickness(5) };
- var tb = new TextBox { Width = 400 };
- dp.Children.Add(tb);
- var btn = new Button { Content = "Browse...", Width = 80, Margin = new Thickness(5, 0, 0, 0) };
- dp.Children.Add(btn);
- gb.Content = dp;
- stack.Children.Add(gb);
- }
-
- // Store selected firmware path and platform
- private string firmwarePath;
- private string selectedPlatform;
-
- // Universal Hypervisor Configuration
- private string selectedArchitecture = "Auto-Detect";
- private string selectedSecurityBypass = "Bypass All Security (Maximum Freedom)";
- private string selectedMemorySize = "Auto-Calculate (Recommended)";
- private string selectedCpuType = "Auto-Select (Recommended)";
- private string selectedMachineType = "Auto-Select (Recommended)";
- private string selectedAction = "Generic CPU/OS Emulation";
-
- // BOLT Bootloader Integration
- private BoltEmulatorBridge boltBridge;
- private bool boltInitialized;
-
- // Add default constructor for XAML
public MainWindow()
{
- try
- {
- SafeInitializeComponent();
- InitializeAero();
- SetupCustomTitleBar();
-
- // Initialize drag-and-drop for file support
- this.AllowDrop = true;
- this.Drop += MainWindow_Drop;
-
- // Initialize real-time emulation log panel
- InitializeLogPanel();
-
- // Initialize dropdown handlers
- this.Loaded += (s, e) => InitializeDropdownHandlers();
- this.Loaded += MainWindow_Loaded; // initialize view controls state
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"[MainWindow] Constructor error: {ex.Message}");
- MessageBox.Show($"Failed to initialize MainWindow: {ex.Message}", "Initialization Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- public MainWindow(IEmulator currentEmulator)
- {
- try
- {
- SafeInitializeComponent();
- InitializeAero();
- SetupCustomTitleBar();
- this.currentEmulator = currentEmulator;
- InitializeLogPanel();
-
- // Initialize dropdown handlers
- this.Loaded += (s, e) => InitializeDropdownHandlers();
- this.Loaded += MainWindow_Loaded;
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"[MainWindow] Constructor error: {ex.Message}");
- MessageBox.Show($"Failed to initialize MainWindow: {ex.Message}", "Initialization Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- // add a SafeInitializeComponent wrapper to fall back to BuildFallbackUi
- private void SafeInitializeComponent()
- {
- try
- {
- InitializeComponent(); // call the XAML-generated method
- }
- catch
- {
- BuildFallbackUi();
- }
- }
-
- ///
- /// Show QEMU installation status for real firmware emulation
- ///
- private void ShowQemuStatus()
- {
- try
- {
- string status = Tools.QemuInstaller.GetQemuStatus();
- StatusBarText(status);
-
- if (!Tools.QemuInstaller.IsQemuInstalled())
- {
- // Show installation prompt after a delay
- Task.Delay(2000).ContinueWith(_ =>
- {
- Application.Current.Dispatcher.Invoke(() =>
- {
- var result = MessageBox.Show(
- "🔧 Real Firmware Emulation Available!\n\n" +
- "Install QEMU to boot actual ARM/MIPS firmware instead of simulations.\n\n" +
- "Would you like installation instructions?",
- "Enable Real Emulation", MessageBoxButton.YesNo, MessageBoxImage.Information);
-
- if (result == MessageBoxResult.Yes)
- {
- Tools.QemuInstaller.ShowInstallationInstructions();
- }
- });
- });
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"Failed to show QEMU status: {ex.Message}");
- }
- }
-
- ///
- /// Initialize the real-time emulation log panel
- ///
- private void InitializeLogPanel()
- {
- try
- {
- logPanel = new EmulationLogPanel();
-
- // TODO: Find the log panel container in XAML and add our log panel
- // if (LogPanelContainer != null)
- // {
- // LogPanelContainer.Child = logPanel;
- // }
-
- Debug.WriteLine("[MainWindow] Log panel initialized successfully");
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"[MainWindow] Failed to initialize log panel: {ex.Message}");
- }
- }
-
- ///
- /// Initialize dropdown event handlers for Universal Hypervisor configuration
- ///
- private void InitializeDropdownHandlers()
- {
- try
- {
- // Architecture dropdown - with null check
- var archComboBox = this.FindName("ArchitectureComboBox") as ComboBox;
- if (archComboBox != null)
- {
- archComboBox.SelectionChanged += (s, e) =>
- {
- if (archComboBox.SelectedItem is ComboBoxItem item)
- {
- selectedArchitecture = item.Content.ToString();
- StatusBarText($"Architecture: {selectedArchitecture}");
- }
- };
- }
-
- // Security bypass dropdown - with null check
- var securityComboBox = this.FindName("SecurityBypassComboBox") as ComboBox;
- if (securityComboBox != null)
- {
- securityComboBox.SelectionChanged += (s, e) =>
- {
- if (securityComboBox.SelectedItem is ComboBoxItem item)
- {
- selectedSecurityBypass = item.Content.ToString();
- StatusBarText($"Security Level: {selectedSecurityBypass}");
- }
- };
- }
-
- // Memory size dropdown - with null check
- var memoryComboBox = this.FindName("MemorySizeComboBox") as ComboBox;
- if (memoryComboBox != null)
- {
- memoryComboBox.SelectionChanged += (s, e) =>
- {
- if (memoryComboBox.SelectedItem is ComboBoxItem item)
- {
- selectedMemorySize = item.Content.ToString();
- StatusBarText($"Memory: {selectedMemorySize}");
- }
- };
- }
-
- // CPU type dropdown - with null check
- var cpuComboBox = this.FindName("CpuTypeComboBox") as ComboBox;
- if (cpuComboBox != null)
- {
- cpuComboBox.SelectionChanged += (s, e) =>
- {
- if (cpuComboBox.SelectedItem is ComboBoxItem item)
- {
- selectedCpuType = item.Content.ToString();
- StatusBarText($"CPU: {selectedCpuType}");
- }
- };
- }
-
- // Firmware path text box - sync with firmwarePath variable
- var firmwarePathTextBox = this.FindName("FirmwarePathTextBox") as TextBox;
- if (firmwarePathTextBox != null)
- {
- firmwarePathTextBox.TextChanged += (s, e) =>
- {
- firmwarePath = firmwarePathTextBox.Text;
- if (!string.IsNullOrEmpty(firmwarePath))
- {
- StatusBarText($"Firmware path: {Path.GetFileName(firmwarePath)}");
- }
- };
- }
-
- Debug.WriteLine("[MainWindow] Dropdown handlers initialized successfully");
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"[MainWindow] Failed to initialize dropdown handlers: {ex.Message}");
- }
- }
-
- // All Tools classes are static - no need to instantiate
- private ExoticFilesystemManager fsManager = new();
- private InstructionDispatcher dispatcher = new();
-
- // Real-time emulation logging
- private EmulationLogPanel logPanel;
-
- public TextBlock StatusBar { get; set; } = new TextBlock(); // legacy interface compatibility
- public PartitionAnalyzer PartitionAnalyzer { get; set; } = null; // Static class, no instantiation needed
- public InstructionDispatcher Dispatcher1 { get => dispatcher; set => dispatcher = value; }
- PartitionAnalyzer IMainWindow.PartitionAnalyzer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
-
- private void StatusBarText(string text)
- {
- if (!Dispatcher.CheckAccess())
- {
- Dispatcher.Invoke(() => StatusBarText(text));
- return;
- }
- StatusMessage = text;
- }
-
- private IEmulator GetCurrentEmulator() => currentEmulator;
-
- ///
- /// Get configuration from dropdown selections for Universal Hypervisor
- ///
- private Dictionary GetHypervisorConfiguration()
- {
- var config = new Dictionary
- {
- ["Action"] = selectedAction,
- ["Architecture"] = selectedArchitecture,
- ["SecurityBypass"] = selectedSecurityBypass,
- ["MemorySize"] = selectedMemorySize,
- ["CpuType"] = selectedCpuType,
- ["MachineType"] = selectedMachineType,
- ["FirmwarePath"] = firmwarePath ?? ""
- };
-
- return config;
- }
-
- private void InitializeAero()
- {
- try
- {
- DataContext = this; // for bindings
- // Attempt full true Aero glass (Win7 style) first
- bool glassApplied = AeroGlassHelper.TryApplyTrueGlass(this);
- if (!glassApplied)
- {
- // fallback to partial frame extension (menu + status bar bands)
- glassApplied = AeroGlassHelper.TryApplyGlass(this);
- }
- if (glassApplied)
- {
- // Only make the chrome region show glass; leave content opaque (background is handled in XAML)
- this.Background = System.Windows.Media.Brushes.Transparent;
- GlassStatus = "Glass: on";
- }
- else
- {
- // Keep default window background so content is fully opaque
- this.ClearValue(Window.BackgroundProperty);
- GlassStatus = AeroGlassHelper.IsDwmEnabled() ? "Glass: off" : "Glass: unsupported";
- }
- }
- catch (Exception ex)
- {
- GlassStatus = $"Glass: error ({ex.Message.Split('\n')[0]})";
- }
- }
-
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- // Initialize theme menu state
- if (this.FindName("ThemeWin7") is MenuItem t7 && this.FindName("ThemeCarl") is MenuItem tc)
- {
- t7.IsCheckable = true;
- tc.IsCheckable = true;
- t7.IsChecked = AppThemeManager.Current == AppTheme.Windows7Aero;
- tc.IsChecked = AppThemeManager.Current == AppTheme.CarlMode;
- }
- }
-
- private void ThemeWin7_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- AppThemeManager.Apply(AppTheme.Windows7Aero, Application.Current);
- if (FindName("ThemeWin7") is MenuItem t7 && FindName("ThemeCarl") is MenuItem tc)
- { t7.IsChecked = true; tc.IsChecked = false; }
- }
- catch (Exception ex)
- {
- StatusBarText($"Theme apply error: {ex.Message}");
- }
- }
-
- private void ThemeCarl_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- AppThemeManager.Apply(AppTheme.CarlMode, Application.Current);
- if (FindName("ThemeWin7") is MenuItem t7 && FindName("ThemeCarl") is MenuItem tc)
- { t7.IsChecked = false; tc.IsChecked = true; }
- }
- catch (Exception ex)
- {
- StatusBarText($"Theme apply error: {ex.Message}");
- }
- }
-
- private void TintSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- try
- {
- // Adjust alpha of glass brushes live
- var app = Application.Current;
- byte a = (byte)Math.Max(0, Math.Min(255, e.NewValue));
- if (app.Resources["GlassMenuBackgroundBrush"] is SolidColorBrush mb)
- {
- var c = mb.Color; app.Resources["GlassMenuBackgroundBrush"] = new SolidColorBrush(Color.FromArgb(a, c.R, c.G, c.B));
- }
- if (app.Resources["GlassStatusBackgroundBrush"] is SolidColorBrush sb)
- {
- var c = sb.Color; app.Resources["GlassStatusBackgroundBrush"] = new SolidColorBrush(Color.FromArgb((byte)Math.Max(0, a - 20), c.R, c.G, c.B));
- }
- if (app.Resources["GlassPanelBrush"] is SolidColorBrush pb)
- {
- var c = pb.Color; app.Resources["GlassPanelBrush"] = new SolidColorBrush(Color.FromArgb((byte)Math.Max(0, a / 5), c.R, c.G, c.B));
- }
- }
- catch { }
- }
-
- // Setup custom title bar interactions: drag, buttons, and system menu
- private void SetupCustomTitleBar()
- {
- // Attach drag and context menu events to title bar elements
- var titleBarBorder = FindName("TitleBar") as UIElement;
- var titleBarGrid = FindName("PART_CustomTitleBar") as UIElement;
- void AttachDragAndMenu(UIElement element)
- {
- element.MouseLeftButtonDown += (s, e) =>
- {
- if (e.ClickCount == 2) ToggleMaximize(); else this.DragMove();
- };
- element.MouseRightButtonUp += (s, e) =>
- {
- var point = element.PointToScreen(e.GetPosition(element));
- System.Windows.SystemCommands.ShowSystemMenu(this, point);
- };
- }
- if (titleBarBorder != null) AttachDragAndMenu(titleBarBorder);
- if (titleBarGrid != null) AttachDragAndMenu(titleBarGrid);
- // Minimize button
- if (FindName("PART_MinButton") is Button minBtn)
- minBtn.Click += (s, e) => this.WindowState = WindowState.Minimized;
- // Maximize/restore button
- if (FindName("PART_MaxButton") is Button maxBtn)
- maxBtn.Click += (s, e) => ToggleMaximize();
- // Close button
- if (FindName("PART_CloseButton") is Button closeBtn)
- closeBtn.Click += (s, e) => this.Close();
- }
-
- // Toggle between maximized and normal window state
- private void ToggleMaximize()
- {
- this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
- }
-
- ///
- /// Main entry point for user actions. Uses dropdown selection instead of dialog.
- ///
- private async void StartEmulation_Click(object sender, RoutedEventArgs e)
- {
- // Use the selected action from the dropdown instead of showing a dialog
- string mainChoice = selectedAction;
- if (string.IsNullOrEmpty(mainChoice))
- {
- StatusBarText("Please select an action from the dropdown");
- return;
- }
-
- StatusBarText($"Starting: {mainChoice}");
-
- switch (mainChoice)
- {
- case "Generic CPU/OS Emulation":
- await HandleGenericEmulation();
- break;
- case "RDK-V Emulator":
- await HandleRdkVEmulation();
- break;
- case "RDK-B Emulator":
- await HandleRdkBEmulation();
- break;
- case "PowerPC Bootloader Demo":
- await HandlePowerPCBootloaderDemo();
- break;
- case "Dish Network Box/VxWorks Analysis":
- await HandleDishVxWorksAnalysis();
- break;
- case "Simulate SWM Switch/LNB":
- await HandleSwmLnbSimulation();
- break;
- case "Probe Filesystem":
- await HandleFilesystemProbe();
- break;
- case "Emulate CMTS Head End":
- await HandleCmtsEmulation();
- break;
- case "Uverse Box Emulator":
- await HandleUverseEmulation();
- break;
- case "Comcast X1 Platform Emulator":
- await HandleComcastX1Emulation();
- break;
- case "DirecTV Box/Firmware Analysis":
- await HandleDirectvAnalysis();
- break;
- case "Executable Analysis":
- await HandleExecutableAnalysis();
- break;
- case "Linux Filesystem Read/Write":
- await HandleLinuxFsReadWrite();
- break;
- case "Cross-Compile Binary":
- await HandleCrossCompile();
- break;
- case "Mount CE Filesystem":
- await HandleCeMount();
- break;
- case "Mount YAFFS Filesystem":
- await HandleYaffsMount();
- break;
- case "Mount ISO Filesystem":
- await HandleIsoMount();
- break;
- case "Mount EXT Filesystem":
- await HandleExtMount();
- break;
- case "Simulate SWM LNB":
- await HandleSwmLnbSimulation();
- break;
- case "Boot Firmware (Homebrew First)":
- await HandleBootFirmwareHomebrewFirst();
- break;
- case "Boot Firmware in Homebrew Emulator":
- await HandleBootFirmwareInHomebrew();
- break;
- case "Analyze Folder Contents":
- await HandleFolderAnalysis();
- break;
- case "Custom Hypervisor":
- await HandleCustomHypervisor();
- break;
- case "Windows CE Binary Execution":
- await HandleWindowsCEExecution();
- break;
- default:
- MessageBox.Show("Not implemented yet.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
- break;
- }
- }
-
- ///
- /// Emulates a CMTS head end with IPTV and DOCSIS networks.
- ///
- private async Task HandleCmtsEmulation()
- {
- var emu = new CMTSEmulator();
- emu.InitializeIPTV();
- StatusBarText("CMTS head end initialized.");
- ShowTextWindow("CMTS Emulation", new List { "IPTV and DOCSIS networks active." });
- await Task.CompletedTask;
+ InitializeComponent();
+ SetupClassicUI();
}
- private async Task HandleDishVxWorksAnalysis()
+ private void SetupClassicUI()
{
- var openFileDialog = new OpenFileDialog
- {
- Filter = "Dish/VxWorks Firmware (*.bin;*.img;*.fw)|*.bin;*.img;*.fw|All Files (*.*)|*.*"
+ // 1. Create the Video Tab (The XP/7 Pro look)
+ TabPage videoPage = new TabPage("Video Output");
+ _videoDisplay = new PictureBox {
+ Dock = DockStyle.Fill,
+ BackColor = System.Drawing.Color.Black,
+ SizeMode = PictureBoxSizeMode.CenterImage
};
- if (openFileDialog.ShowDialog() != true) return;
-
- string filePath = openFileDialog.FileName;
- StatusBarText("Analyzing Dish VxWorks firmware...");
- byte[] firmware = File.ReadAllBytes(filePath);
-
- try
- {
- var detector = new Tools.FileSystems.DvrVxWorksDetector();
- var (version, deviceType, encInfo) = detector.DetectVersion(firmware);
- var output = new List
- {
- $"Version: {version}",
- $"Device Type: {deviceType}",
- $"Encryption Algorithm: {encInfo.Algorithm}",
- $"Key Size: {encInfo.KeySize}",
- $"Key Material: {BitConverter.ToString(encInfo.KeyMaterial)}",
- $"IV: {BitConverter.ToString(encInfo.IV)}"
- };
- ShowTextWindow("Dish/VxWorks Analysis", output);
- StatusBarText("Dish VxWorks analysis complete.");
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Analysis error: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("Dish VxWorks analysis failed.");
- }
- await Task.CompletedTask;
- }
-
- private async Task HandleUverseEmulation()
- {
- try
- {
- // Ensure firmware path is set; prompt for U-verse dump if not selected
- if (string.IsNullOrEmpty(firmwarePath) || !File.Exists(firmwarePath))
- {
- var dlg = new OpenFileDialog
- {
- Title = "Select U-verse Firmware Dump",
- InitialDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "DVR", "Uverse_Stuff"),
- Filter = "Firmware Files (*.bin;*.img;*.exe)|*.bin;*.img;*.exe|Registry Files (*.hv)|*.hv|All Files (*.*)|*.*"
- };
- if (dlg.ShowDialog() != true) return;
- firmwarePath = dlg.FileName;
- StatusBarText($"Selected U-verse dump: {Path.GetFileName(firmwarePath)}");
- }
- StatusBarText(" Starting AT&T U-verse + Microsoft Mediaroom emulation...");
- // If this is a real U-verse dump, boot it with QEMU
- string uverseDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "DVR", "Uverse_Stuff");
- if (firmwarePath.StartsWith(uverseDir, StringComparison.OrdinalIgnoreCase))
- {
- StatusBarText("REAL BOOT: Starting QEMU to boot actual U-verse firmware...");
-
- string nkExePath = null;
- string registryPath = null;
-
- // If user selected the nk.bin directory, look inside it for nk.exe
- if (Directory.Exists(firmwarePath) && Path.GetFileName(firmwarePath) == "nk.bin")
- {
- nkExePath = Path.Combine(firmwarePath, "nk.exe");
- registryPath = Path.Combine(firmwarePath, "boot.hv");
- }
- // If user selected nk.exe directly
- else if (Path.GetFileName(firmwarePath) == "nk.exe")
- {
- nkExePath = firmwarePath;
- registryPath = Path.Combine(Path.GetDirectoryName(firmwarePath), "boot.hv");
- }
- // Otherwise, look for nk.exe in the same directory
- else
- {
- nkExePath = Path.Combine(Path.GetDirectoryName(firmwarePath), "nk.exe");
- registryPath = Path.Combine(Path.GetDirectoryName(firmwarePath), "boot.hv");
- }
-
- if (File.Exists(nkExePath))
- {
- StatusBarText("Found nk.exe - launching REAL QEMU MIPS emulation...");
- var qemuEmulator = new RealQemuEmulator();
- bool bootSuccess = await qemuEmulator.BootWinCEFirmware(nkExePath,
- File.Exists(registryPath) ? registryPath : null);
-
- if (bootSuccess)
- {
- StatusBarText("SUCCESS: Real U-verse WinCE firmware booted in QEMU!");
- return; // Exit here - QEMU is running
- }
- else
- {
- StatusBarText("QEMU launch failed - check QEMU installation");
- var failureResults = new List
- {
- "❌ QEMU Failed to Launch",
- "",
- $"Attempted to boot: {Path.GetFileName(nkExePath)}",
- $"QEMU Path: {qemuEmulator.GetQemuPath() ?? "Not found"}",
- "",
- "💡 Troubleshooting:",
- "1. Install QEMU: choco install qemu",
- "2. Or download from: https://qemu.weilnetz.de/w64/",
- "3. Ensure qemu-system-mips.exe is in PATH"
- };
- ShowTextWindow("QEMU Launch Failed", failureResults);
- return;
- }
- }
- else
- {
- StatusBarText($"nk.exe not found at: {nkExePath}");
- ShowTextWindow("Firmware Not Found", new List
- {
- "❌ WinCE Kernel Not Found",
- "",
- $"Expected: {nkExePath}",
- $"Selected: {firmwarePath}",
- "",
- "💡 Please select the nk.bin folder or nk.exe file directly"
- });
- return;
- }
- }
-
- // Check if this is an nk.bin kernel file
- if (Path.GetFileName(firmwarePath).ToLower() == "nk.bin")
- {
- StatusBarText(" Detected nk.bin - using comprehensive Mediaroom boot manager...");
-
- // Use the enhanced U-verse emulator with Mediaroom boot manager
- var uverseEmulator = new UverseEmulator();
-
- // Load the nk.bin kernel
- byte[] kernelData = File.ReadAllBytes(firmwarePath);
- if (!await uverseEmulator.LoadBootImage(kernelData))
- {
- throw new Exception("Failed to load U-verse boot image");
- }
-
- // Start comprehensive Mediaroom boot sequence
- bool bootSuccess = await uverseEmulator.StartEmulation();
-
- if (!bootSuccess)
- {
- StatusBarText(" Mediaroom boot failed - check boot log for details");
-
- // Show boot failure details
- var failureLog = uverseEmulator.GetBootLog();
- ShowTextWindow("U-verse + Mediaroom Boot Failure", failureLog);
- return;
- }
-
- // Show successful boot status
- var status = uverseEmulator.GetEmulationStatus();
- var bootLog = uverseEmulator.GetBootLog();
-
- var results = new List
- {
- " AT&T U-verse + Microsoft Mediaroom Boot Complete!",
- "",
- "=== System Status ===",
- $"Platform: {status["Platform"]}",
- $"File: {Path.GetFileName(firmwarePath)}",
- $"Initialized: {status["IsInitialized"]}",
- $"Boot Complete: {status["IsBootComplete"]}",
- $"Hardware: {((UverseHardwareConfig)status["HardwareConfig"]).Model}",
- "",
- "=== Boot Log (Last 15 entries) ===",
- };
-
- // Add recent boot log entries
- var recentLogs = bootLog.TakeLast(15);
- results.AddRange(recentLogs);
-
- results.Add("");
- results.Add(" AT&T U-verse IPTV Platform is fully operational!");
- results.Add(" Microsoft Mediaroom services are running");
- results.Add(" IPTV infrastructure is connected and ready");
-
- ShowTextWindow("U-verse + Mediaroom Emulation Success", results);
- StatusBarText(" U-verse + Mediaroom emulation started successfully");
- }
- else
- {
- // Use the enhanced U-verse emulator for other files
- StatusBarText(" Using enhanced U-verse + Mediaroom emulator...");
-
- // Detect if it's a signature file (.sig) or other content
- string ext = Path.GetExtension(firmwarePath).ToLowerInvariant();
-
- if (ext == ".sig" || ext == ".bin" || ext == ".img")
- {
- // Handle firmware-based U-verse emulation with Mediaroom boot
- StatusBarText($" Loading U-verse firmware: {Path.GetFileName(firmwarePath)}...");
-
- // Load firmware data
- byte[] firmwareData = File.ReadAllBytes(firmwarePath);
-
- // Create enhanced U-verse emulator
- var emulator = new UverseEmulator();
-
- // Load boot image
- if (!await emulator.LoadBootImage(firmwareData))
- {
- throw new Exception("Failed to load U-verse firmware");
- }
-
- // Start emulation with Mediaroom boot
- bool success = await emulator.StartEmulation();
-
- if (!success)
- {
- StatusBarText(" U-verse emulation failed");
- var failureLog = emulator.GetBootLog();
- ShowTextWindow("U-verse Emulation Failure", failureLog);
- return;
- }
-
- // Get status and show results
- var status = emulator.GetEmulationStatus();
- var bootStatus = status.ContainsKey("BootStatus") ? (Dictionary)status["BootStatus"] : null;
-
- var uverseLog = new List
- {
- " AT&T U-verse + Microsoft Mediaroom Emulation Complete!",
- "",
- "=== System Information ===",
- $"File: {Path.GetFileName(firmwarePath)}",
- $"Size: {firmwareData.Length:N0} bytes",
- $"Platform: {status["Platform"]}",
- $"Hardware: {((UverseHardwareConfig)status["HardwareConfig"]).Model}",
- $"Processor: {((UverseHardwareConfig)status["HardwareConfig"]).Processor}",
- $"Memory: {((UverseHardwareConfig)status["HardwareConfig"]).MemoryMB}MB",
- $"OS: {((UverseHardwareConfig)status["HardwareConfig"]).OS}",
- "",
- "=== Boot Status ===",
- $"Boot Stage: {bootStatus?["Stage"] ?? "Complete"}",
- $"Kernel Loaded: {bootStatus?["KernelLoaded"] ?? true}",
- $"Mediaroom Ready: {bootStatus?["MediaroomReady"] ?? true}",
- $"Components: {bootStatus?["ComponentsLoaded"] ?? "All"}",
- "",
- " Microsoft Mediaroom IPTV platform is operational",
- " AT&T U-verse services are running",
- " IPTV infrastructure connected"
- };
-
- ShowTextWindow("U-verse + Mediaroom Emulation", uverseLog);
- StatusBarText(" U-verse + Mediaroom emulation completed successfully");
- }
- else
- {
- // Generic firmware analysis for other U-verse files
- StatusBarText(" Analyzing U-verse firmware structure...");
-
- string extractDir = Path.Combine(Path.GetDirectoryName(firmwarePath),
- Path.GetFileNameWithoutExtension(firmwarePath) + "_extracted");
-
- await Task.Run(() => ArchiveExtractor.ExtractAndAnalyze(firmwarePath, extractDir));
- FirmwareAnalyzer.AnalyzeFirmwareArchive(firmwarePath, extractDir);
-
- var results = new List
- {
- " AT&T U-verse Firmware Analysis Complete",
- "",
- "=== Analysis Results ===",
- $"File: {Path.GetFileName(firmwarePath)}",
- $"Extracted to: {extractDir}",
- $"Type: {Path.GetExtension(firmwarePath)} firmware",
- "",
- " Check extracted directory for:",
- " WinCE kernel files (nk.bin)",
- " Mediaroom components",
- " Registry hives (*.hv)",
- " IPTV configuration files",
- " System overlays and modules",
- "",
- " Tip: If nk.bin is found, load it directly for full Mediaroom boot emulation"
- };
-
- ShowTextWindow("U-verse Firmware Analysis", results);
- }
-
- StatusBarText("U-verse content emulation completed");
- }
- }
- catch (Exception ex)
- {
- StatusBarText("U-verse emulation failed");
- ShowTextWindow("U-verse Emulation Error", new List
- {
- $"Error: {ex.Message}",
- $"File: {Path.GetFileName(firmwarePath)}",
- $"Stack: {ex.StackTrace}"
- });
- }
- }
+ videoPage.Controls.Add(_videoDisplay);
- ///
- /// Analyzes DirecTV firmware images for structure and content.
- ///
- private async Task HandleDirectvAnalysis()
- {
- var openFileDialog = new OpenFileDialog
- {
- Filter =
- "DirecTV Firmware Images (*.csw;*.bin;*.tar.csw.bin)|*.csw;*.bin;*.tar.csw.bin|" +
- "All Supported Files|*.csw;*.bin;*.tar.csw.bin|" +
- "All Files (*.*)|*.*"
+ // 2. Create the Serial Console Tab (The Terminal look)
+ TabPage consolePage = new TabPage("System Console");
+ _serialConsole = new RichTextBox {
+ Dock = DockStyle.Fill,
+ BackColor = System.Drawing.Color.Black,
+ ForeColor = System.Drawing.Color.Lime,
+ Font = new System.Drawing.Font("Lucida Console", 9f),
+ ReadOnly = true
};
- if (openFileDialog.ShowDialog() == true)
- {
- string filePath = openFileDialog.FileName;
- StatusBarText($"Selected firmware: {Path.GetFileName(filePath)}");
- string extractDir = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + "_extracted");
- try
- {
- // Extract archive and analyze file structure
- await Task.Run(() => ArchiveExtractor.ExtractAndAnalyze(filePath, extractDir));
- // Further analyze binaries in the extracted directory
- FirmwareAnalyzer.AnalyzeFirmwareArchive(filePath, extractDir);
- StatusBarText("Firmware extraction and analysis complete.");
- MessageBox.Show($"Firmware {Path.GetFileName(filePath)} extracted and analyzed to {extractDir}.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Analysis failed: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("Firmware analysis failed.");
- }
- }
- await Task.CompletedTask;
- }
+ consolePage.Controls.Add(_serialConsole);
- ///
- /// Analyzes arbitrary executables or binaries to detect architecture and format.
- ///
- private async Task HandleExecutableAnalysis()
- {
- // Select executable file
- var dlg = new OpenFileDialog
- {
- Filter = "Executables and Binaries (*.exe;*.dll;*.bin;*.so)|*.exe;*.dll;*.bin;*.so|All Files (*.*)|*.*"
- };
- if (dlg.ShowDialog() != true) return;
- string filePath = dlg.FileName;
- StatusBarText($"Analyzing executable: {Path.GetFileName(filePath)}");
- byte[] data = File.ReadAllBytes(filePath);
- // Determine format and architecture
- string format = (data.Length > 4 && data[0] == 0x7F && data[1] == (byte)'E' && data[2] == (byte)'L' && data[3] == (byte)'F') ? "ELF" : "PE";
- string arch = ArchitectureDetector.Detect(data);
- string bitness = "Unknown";
- if (format == "PE" && data.Length > 0x40)
- {
- int peOffset = BitConverter.ToInt32(data, 0x3C);
- ushort machine = BitConverter.ToUInt16(data, peOffset + 4);
- bitness = machine switch
- {
- 0x14c => "x86",
- 0x8664 => "x64",
- 0x1c0 => "ARM",
- 0xaa64 => "ARM64",
- _ => "Unknown"
- };
- }
- else if (format == "ELF" && data.Length > 5)
- {
- bitness = data[4] == 1 ? "32-bit" : data[4] == 2 ? "64-bit" : "Unknown";
- }
- var output = new List
- {
- $"File: {Path.GetFileName(filePath)}",
- $"Format: {format}",
- $"Architecture: {arch}",
- $"Bitness: {bitness}"
- };
- // Encourage contribution for unsupported chips
- var desc = ChipReferenceManager.GetInfo(arch);
- if (!string.IsNullOrEmpty(desc))
- output.Add($"Description: {desc}");
- else
- output.Add(ChipReferenceManager.GetContributionMessage(arch));
- ShowTextWindow("Executable Analysis", output);
- StatusBarText("Executable analysis complete.");
- // Prompt to launch emulator
- var choice = PromptUserForChoice("Launch emulator for this executable?", new[] { "Homebrew", "QEMU", "No" });
- if (choice == "Homebrew")
- {
- try
- {
- var home = new HomebrewEmulator();
- home.LoadBinary(data);
- home.Run();
- StatusBarText("Homebrew emulation complete.");
- }
- catch (NotImplementedException)
- {
- MessageBox.Show("Homebrew emulator not supported for this architecture.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
- }
- }
- else if (choice == "QEMU")
- {
- try
- {
- EmulatorLauncher.Launch(filePath, arch);
- StatusBarText("QEMU emulation started.");
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Emulation error: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- await Task.CompletedTask;
+ // Add them to the WindowsFormsHost container
+ MainTabs.TabPages.Add(videoPage);
+ MainTabs.TabPages.Add(consolePage);
}
- private async Task HandleFirmadyneEmulation()
+ private void LoadBinary_Click(object sender, RoutedEventArgs e)
{
- if (string.IsNullOrEmpty(firmwarePath))
- {
- MessageBox.Show("Please select a firmware file first.", "No Firmware Selected", MessageBoxButton.OK, MessageBoxImage.Warning);
- return;
- }
-
- StatusBarText("Starting Firmadyne-based emulation...");
- var logEntries = new List { "=== Firmadyne Firmware Extraction Pipeline ===" };
-
- try
- {
- string firmwareFile = firmwarePath;
- string workDir = Path.Combine(Path.GetTempPath(), "firmadyne_" + Path.GetFileNameWithoutExtension(firmwareFile));
- Directory.CreateDirectory(workDir);
-
- logEntries.Add($"Working directory: {workDir}");
- logEntries.Add($"Analyzing firmware: {Path.GetFileName(firmwareFile)}");
-
- // Step 1: Extract firmware using binwalk
- logEntries.Add("");
- logEntries.Add("=== Step 1: Firmware Extraction ===");
- await ExtractFirmwareWithBinwalk(firmwareFile, workDir, logEntries);
-
- // Step 2: Identify filesystem and architecture
- logEntries.Add("");
- logEntries.Add("=== Step 2: Filesystem Analysis ===");
- var fsInfo = await AnalyzeFirmwareFilesystem(workDir, logEntries);
-
- // Step 3: Create QEMU disk image
- logEntries.Add("");
- logEntries.Add("=== Step 3: QEMU Disk Image Creation ===");
- string diskImage = await CreateQemuDiskImage(fsInfo, workDir, logEntries);
-
- // Step 4: Launch QEMU emulation
- logEntries.Add("");
- logEntries.Add("=== Step 4: QEMU Emulation Launch ===");
- await LaunchQemuEmulation(fsInfo, diskImage, logEntries);
-
- StatusBarText("Firmadyne emulation complete - firmware extracted and running in QEMU.");
- }
- catch (Exception ex)
- {
- logEntries.Add($"ERROR: {ex.Message}");
- StatusBarText("Firmadyne emulation failed.");
- }
-
- ShowTextWindow("Firmadyne Emulation Pipeline", logEntries);
+ // Trigger your Smart Loader logic here
+ StatusText.Text = "Loading Binary...";
}
+ private void Exit_Click(object sender, RoutedEventArgs e) => this.Close();
- // Firmadyne Pipeline Implementation
-
- private class FirmwareInfo
- {
- public string Architecture { get; set; } = "unknown";
- public string RootfsPath { get; set; } = "";
- public string KernelPath { get; set; } = "";
- public string InitramfsPath { get; set; } = "";
- public List Filesystems { get; set; } = new List();
- }
-
- private async Task ExtractFirmwareWithBinwalk(string firmwareFile, string workDir, List log)
- {
- log.Add("Extracting firmware with binwalk...");
- ShowFunnyStatus("Firmware extraction");
-
- try
- {
- // Try using binwalk if available
- var psi = new ProcessStartInfo("binwalk", $"-e \"{firmwareFile}\" -C \"{workDir}\"")
- {
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- };
-
- using var proc = Process.Start(psi);
- await proc.WaitForExitAsync();
-
- if (proc.ExitCode == 0)
- {
- log.Add("Binwalk extraction successful");
- return;
- }
- }
- catch
- {
- log.Add("Binwalk not available, using built-in extraction...");
- }
-
- // Fallback: Use built-in firmware analyzer
- await Task.Run(() =>
- {
- try
- {
- FirmwareAnalyzer.AnalyzeFirmwareArchive(firmwareFile, workDir);
- log.Add("Built-in extraction completed");
- }
- catch (Exception ex)
- {
- log.Add($"Extraction failed: {ex.Message}");
- }
- });
- }
-
- private async Task AnalyzeFirmwareFilesystem(string workDir, List log)
- {
- var info = new FirmwareInfo();
-
- await Task.Run(() =>
- {
- log.Add("Scanning extracted files...");
-
- var allFiles = Directory.GetFiles(workDir, "*", SearchOption.AllDirectories);
- log.Add($"Found {allFiles.Length} extracted files");
-
- // Look for common filesystem indicators
- foreach (var file in allFiles)
- {
- var fileName = Path.GetFileName(file).ToLower();
- var ext = Path.GetExtension(file).ToLower();
-
- // Detect architecture from binary files
- if (fileName.Contains("vmlinux") || fileName.Contains("kernel"))
- {
- info.KernelPath = file;
- info.Architecture = DetectArchitectureFromElf(file);
- log.Add($"Kernel found: {Path.GetFileName(file)} ({info.Architecture})");
- }
-
- // Look for root filesystem
- if (fileName.Contains("rootfs") || fileName.Contains("squashfs") || ext == ".cramfs")
- {
- info.RootfsPath = file;
- info.Filesystems.Add(file);
- log.Add($"Filesystem found: {Path.GetFileName(file)}");
- }
-
- // Look for initramfs
- if (fileName.Contains("initramfs") || fileName.Contains("initrd"))
- {
- info.InitramfsPath = file;
- log.Add($"Initramfs found: {Path.GetFileName(file)}");
- }
- }
-
- // If no specific arch detected, try to detect from filesystem contents
- if (info.Architecture == "unknown" && !string.IsNullOrEmpty(info.RootfsPath))
- {
- info.Architecture = DetectArchitectureFromFilesystem(info.RootfsPath);
- log.Add($"Architecture detected from filesystem: {info.Architecture}");
- }
- });
-
- return info;
- }
-
- private string DetectArchitectureFromElf(string filePath)
- {
- try
- {
- var bytes = File.ReadAllBytes(filePath);
- if (bytes.Length < 20) return "unknown";
-
- // Check ELF magic
- if (bytes[0] != 0x7F || bytes[1] != 'E' || bytes[2] != 'L' || bytes[3] != 'F')
- return "unknown";
-
- // Get architecture from ELF header
- ushort machine = BitConverter.ToUInt16(bytes, 18);
- return machine switch
- {
- 0x3E => "x86_64",
- 0x03 => "x86",
- 0x28 => "arm",
- 0xB7 => "arm64",
- 0x08 => "mips",
- 0x14 => "ppc",
- 0x15 => "ppc64",
- 0x2B => "sparc",
- 0x2A => "sparc64",
- _ => "unknown"
- };
- }
- catch
- {
- return "unknown";
- }
- }
-
- private string DetectArchitectureFromFilesystem(string fsPath)
- {
- try
- {
- // Look for binaries in common locations
- var testPaths = new[] { "/bin/sh", "/bin/busybox", "/sbin/init" };
-
- // This is a simplified detection - in real implementation would mount and examine
- return "arm"; // Default for most embedded devices
- }
- catch
- {
- return "unknown";
- }
- }
-
- private async Task CreateQemuDiskImage(FirmwareInfo info, string workDir, List log)
- {
- string diskImage = Path.Combine(workDir, "firmware.qcow2");
-
- try
- {
- log.Add("Creating QEMU disk image...");
-
- // Create QEMU disk image
- var createCmd = $"create -f qcow2 \"{diskImage}\" 256M";
- await RunQemuCommand("qemu-img", createCmd, log);
-
- if (File.Exists(diskImage))
- {
- log.Add($"Disk image created: {diskImage}");
-
- // If we have a rootfs, try to write it to the disk
- if (!string.IsNullOrEmpty(info.RootfsPath))
- {
- await WriteFilesystemToDisk(info.RootfsPath, diskImage, log);
- }
- }
- else
- {
- throw new Exception("Failed to create disk image");
- }
- }
- catch (Exception ex)
- {
- log.Add($"Disk creation failed: {ex.Message}");
- log.Add("Creating dummy disk image for testing...");
-
- // Create a minimal disk image file as fallback
- await File.WriteAllBytesAsync(diskImage, new byte[256 * 1024 * 1024]);
- }
-
- return diskImage;
- }
-
- private async Task WriteFilesystemToDisk(string fsPath, string diskImage, List log)
- {
- try
- {
- log.Add("Writing filesystem to disk image...");
-
- // Use dd-like operation to write filesystem to disk
- var sourceBytes = await File.ReadAllBytesAsync(fsPath);
- var diskBytes = await File.ReadAllBytesAsync(diskImage);
-
- // Write filesystem at offset (simple approach)
- if (sourceBytes.Length <= diskBytes.Length)
- {
- Array.Copy(sourceBytes, 0, diskBytes, 0, sourceBytes.Length);
- await File.WriteAllBytesAsync(diskImage, diskBytes);
- log.Add("Filesystem written to disk image");
- }
- else
- {
- log.Add("Filesystem too large for disk image");
- }
- }
- catch (Exception ex)
- {
- log.Add($"Failed to write filesystem: {ex.Message}");
- }
- }
-
- private async Task LaunchQemuEmulation(FirmwareInfo info, string diskImage, List log)
- {
- try
- {
- log.Add("Launching QEMU emulation...");
-
- // Build QEMU command based on detected architecture
- var qemuCmd = BuildQemuCommand(info, diskImage);
- log.Add($"QEMU command: {qemuCmd}");
-
- // Launch QEMU in background
- await RunQemuCommand("qemu-system-" + info.Architecture, qemuCmd, log, isBackground: true);
-
- log.Add("QEMU emulation started successfully");
- log.Add("Check QEMU window for firmware boot process");
- }
- catch (Exception ex)
- {
- log.Add($"QEMU launch failed: {ex.Message}");
- log.Add("Note: Ensure QEMU is installed and in PATH");
- }
- }
-
- private string BuildQemuCommand(FirmwareInfo info, string diskImage)
- {
- var cmd = new List();
-
- // Basic VM configuration
- cmd.Add("-M virt"); // Use virt machine for ARM
- cmd.Add("-m 256M"); // 256MB RAM
- cmd.Add("-cpu cortex-a15"); // ARM CPU
-
- // Add disk
- cmd.Add($"-drive file=\"{diskImage}\",format=qcow2");
-
- // Add kernel if available
- if (!string.IsNullOrEmpty(info.KernelPath))
- {
- cmd.Add($"-kernel \"{info.KernelPath}\"");
- }
-
- // Add initrd if available
- if (!string.IsNullOrEmpty(info.InitramfsPath))
- {
- cmd.Add($"-initrd \"{info.InitramfsPath}\"");
- }
-
- // Network setup
- cmd.Add("-netdev user,id=net0");
- cmd.Add("-device virtio-net-device,netdev=net0");
-
- // Console setup
- cmd.Add("-nographic");
- cmd.Add("-serial mon:stdio");
-
- return string.Join(" ", cmd);
- }
-
- private async Task RunQemuCommand(string command, string args, List log, bool isBackground = false)
- {
- try
- {
- var psi = new ProcessStartInfo(command, args)
- {
- RedirectStandardOutput = !isBackground,
- RedirectStandardError = !isBackground,
- UseShellExecute = isBackground,
- CreateNoWindow = !isBackground
- };
-
- var proc = Process.Start(psi);
-
- if (isBackground)
- {
- log.Add($"Started background process: {command} {args}");
- return;
- }
-
- await proc.WaitForExitAsync();
-
- if (proc.ExitCode == 0)
- {
- log.Add($"Command successful: {command}");
- }
- else
- {
- var error = await proc.StandardError.ReadToEndAsync();
- log.Add($"Command failed: {error}");
- }
- }
- catch (Exception ex)
- {
- log.Add($"Failed to run {command}: {ex.Message}");
- }
- }
-
- private async Task HandleAzeriaEmulation()
- {
- if (string.IsNullOrEmpty(firmwarePath))
- {
- MessageBox.Show("Please select a firmware file first.", "No Firmware Selected", MessageBoxButton.OK, MessageBoxImage.Warning);
- return;
- }
-
- StatusBarText("Starting Azeria Labs ARM firmware emulation...");
- var logEntries = new List { "=== Azeria Labs ARM Firmware Emulation ===" };
-
- try
- {
- string firmwareFile = firmwarePath;
- logEntries.Add($"Firmware: {Path.GetFileName(firmwareFile)}");
- logEntries.Add("Following Azeria Labs methodology...");
-
- // Step 1: Analyze firmware binary
- logEntries.Add("");
- logEntries.Add("=== Step 1: Firmware Analysis ===");
- var firmwareInfo = await AnalyzeFirmwareBinary(firmwareFile, logEntries);
-
- // Step 2: Extract filesystem if embedded
- logEntries.Add("");
- logEntries.Add("=== Step 2: Filesystem Extraction ===");
- string extractedFs = await ExtractEmbeddedFilesystem(firmwareFile, logEntries);
-
- // Step 3: Setup QEMU environment
- logEntries.Add("");
- logEntries.Add("=== Step 3: QEMU Environment Setup ===");
- await SetupQemuForArm(firmwareInfo, logEntries);
-
- // Step 4: Create emulation environment
- logEntries.Add("");
- logEntries.Add("=== Step 4: ARM Emulation Launch ===");
- await LaunchArmEmulation(firmwareFile, extractedFs, firmwareInfo, logEntries);
-
- StatusBarText("Azeria ARM emulation setup complete.");
- }
- catch (Exception ex)
- {
- logEntries.Add($"ERROR: {ex.Message}");
- StatusBarText("Azeria ARM emulation failed.");
- }
-
- ShowTextWindow("Azeria Labs ARM Emulation", logEntries);
- }
-
- private async Task> AnalyzeFirmwareBinary(string firmwareFile, List log)
- {
- var info = new Dictionary();
-
- await Task.Run(() =>
- {
- try
- {
- var bytes = File.ReadAllBytes(firmwareFile);
- log.Add($"File size: {bytes.Length:N0} bytes");
-
- // Check for ELF header
- if (bytes.Length >= 4 && bytes[0] == 0x7F && bytes[1] == 'E' && bytes[2] == 'L' && bytes[3] == 'F')
- {
- info["type"] = "ELF";
- info["arch"] = DetectArchitectureFromElf(firmwareFile);
- log.Add($"ELF binary detected - Architecture: {info["arch"]}");
- }
- else
- {
- info["type"] = "raw";
- info["arch"] = "arm"; // Assume ARM for raw binaries
- log.Add("Raw binary detected - Assuming ARM architecture");
- }
-
- // Look for embedded strings
- var strings = ExtractStrings(bytes);
- var interestingStrings = strings.Where(s =>
- s.Contains("linux") || s.Contains("kernel") || s.Contains("init") ||
- s.Contains("busybox") || s.Contains("arm") || s.Contains("mips")).ToList();
-
- if (interestingStrings.Any())
- {
- log.Add("Interesting strings found:");
- foreach (var str in interestingStrings.Take(5))
- {
- log.Add($" '{str}'");
- }
- }
-
- // Detect load address patterns
- info["loadaddr"] = DetectLoadAddress(bytes);
- log.Add($"Suggested load address: {info["loadaddr"]}");
-
- }
- catch (Exception ex)
- {
- log.Add($"Analysis error: {ex.Message}");
- }
- });
-
- return info;
- }
-
- private List ExtractStrings(byte[] data)
- {
- var strings = new List();
- var current = new List();
-
- foreach (byte b in data)
- {
- if (b >= 32 && b <= 126) // Printable ASCII
- {
- current.Add(b);
- }
- else
- {
- if (current.Count >= 4) // Minimum string length
- {
- strings.Add(System.Text.Encoding.ASCII.GetString(current.ToArray()));
- }
- current.Clear();
- }
- }
-
- return strings;
- }
-
- private string DetectLoadAddress(byte[] data)
- {
- // Common ARM load addresses
- var commonAddresses = new[] { "0x80008000", "0x80010000", "0x40008000", "0x20008000" };
-
- // Look for patterns that might indicate load addresses
- // This is a simplified heuristic
- return "0x80008000"; // Default ARM kernel load address
- }
-
- private async Task ExtractEmbeddedFilesystem(string firmwareFile, List log)
- {
- string extractDir = Path.Combine(Path.GetTempPath(), "azeria_extracted");
-
- try
- {
- if (Directory.Exists(extractDir))
- Directory.Delete(extractDir, true);
- Directory.CreateDirectory(extractDir);
-
- log.Add("Extracting embedded filesystem...");
-
- // Use our firmware analyzer
- await Task.Run(() => FirmwareAnalyzer.AnalyzeFirmwareArchive(firmwareFile, extractDir));
-
- var extractedFiles = Directory.GetFiles(extractDir, "*", SearchOption.AllDirectories);
- log.Add($"Extracted {extractedFiles.Length} files to {extractDir}");
-
- // Look for filesystem images
- var fsImages = extractedFiles.Where(f =>
- f.EndsWith(".cramfs") || f.EndsWith(".squashfs") ||
- f.Contains("rootfs") || f.Contains("filesystem")).ToArray();
-
- if (fsImages.Any())
- {
- log.Add("Filesystem images found:");
- foreach (var img in fsImages)
- {
- log.Add($" {Path.GetFileName(img)}");
- }
- return fsImages[0];
- }
-
- log.Add("No specific filesystem images found");
- return extractDir;
- }
- catch (Exception ex)
- {
- log.Add($"Extraction failed: {ex.Message}");
- return "";
- }
- }
-
- private async Task SetupQemuForArm(Dictionary firmwareInfo, List log)
- {
- await Task.Run(() =>
- {
- log.Add("Setting up QEMU ARM environment...");
-
- // Check if QEMU is available
- try
- {
- var psi = new ProcessStartInfo("qemu-system-arm", "--version")
- {
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- };
-
- var proc = Process.Start(psi);
- proc.WaitForExit();
-
- if (proc.ExitCode == 0)
- {
- var version = proc.StandardOutput.ReadToEnd();
- log.Add($"QEMU found: {version.Split('\n')[0]}");
- }
- else
- {
- log.Add("QEMU not found - install QEMU for full emulation");
- }
- }
- catch
- {
- log.Add("QEMU not available - using built-in ARM emulator");
- }
-
- log.Add("ARM emulation environment ready");
- });
- }
-
- private async Task LaunchArmEmulation(string firmwareFile, string extractedFs, Dictionary info, List log)
- {
- try
- {
- log.Add("Launching ARM firmware emulation...");
-
- // Try QEMU first
- if (await TryLaunchQemuArm(firmwareFile, info, log))
- {
- log.Add("QEMU ARM emulation started successfully");
- return;
- }
-
- // Fallback to our custom ARM emulator
- log.Add("Falling back to custom ARM emulator...");
- await LaunchCustomArmEmulation(firmwareFile, log);
-
- }
- catch (Exception ex)
- {
- log.Add($"Emulation launch failed: {ex.Message}");
- }
- }
-
- private async Task TryLaunchQemuArm(string firmwareFile, Dictionary info, List log)
- {
- try
- {
- var args = new List
- {
- "-M versatilepb", // Versatile platform board
- "-cpu arm1176", // ARM1176 CPU
- "-m 256M", // 256MB RAM
- "-nographic", // No graphics
- "-serial stdio" // Serial console
- };
-
- // Add kernel if it's an ELF
- if (info.ContainsKey("type") && info["type"] == "ELF")
- {
- args.Add($"-kernel \"{firmwareFile}\"");
- }
- else
- {
- // For raw binaries, load at specific address
- string loadAddr = info.ContainsKey("loadaddr") ? info["loadaddr"] : "0x80008000";
- args.Add($"-device loader,file=\"{firmwareFile}\",addr={loadAddr}");
- }
-
- var cmdLine = string.Join(" ", args);
- log.Add($"QEMU command: qemu-system-arm {cmdLine}");
-
- var psi = new ProcessStartInfo("qemu-system-arm", cmdLine)
- {
- UseShellExecute = true, // Let QEMU run in its own window
- CreateNoWindow = false
- };
-
- await Task.Run(() => Process.Start(psi));
- return true;
- }
- catch
- {
- return false;
- }
- }
-
- private async Task LaunchCustomArmEmulation(string firmwareFile, List log)
- {
- try
- {
- log.Add("Starting real MIPS emulator...");
-
- // Use our RealMipsHypervisor for actual emulation
- var firmware = await File.ReadAllBytesAsync(firmwareFile);
- log.Add($"Loaded {firmware.Length:N0} bytes of firmware");
-
- // Launch real MIPS hypervisor
- var hypervisor = new RealMipsHypervisor();
- await hypervisor.StartEmulation(firmware);
-
- log.Add("Real MIPS emulation started");
- log.Add("Check hypervisor window for firmware execution");
- }
- catch (Exception ex)
- {
- log.Add($"Custom ARM emulation failed: {ex.Message}");
- }
- }
-
- // Core feature handlers
-
- ///
- /// Emulates an RDK-V set-top box using real QEMU hypervisor with firmware unpacking and live boot.
- ///
- private async Task HandleRdkVEmulation()
- {
- if (string.IsNullOrEmpty(firmwarePath))
- {
- ErrorManager.ShowError(ErrorManager.Codes.INVALID_PARAMETER, "No firmware file selected");
- return;
- }
-
- string path = firmwarePath;
- StatusBarText(ErrorManager.GetStatusMessage(ErrorManager.Codes.INITIALIZING));
-
- try
- {
- StatusBarText(" Initializing REAL hypervisor for live firmware boot...");
-
- // RDK-V is ARM-based, so we create an ARM emulator instance.
- IEmulator emulator = new ArmCpuEmulator();
-
- // Use the REAL hypervisor manager with the ARM emulator
- var hypervisor = new RealHypervisorManager(emulator);
-
- StatusBarText(" Unpacking firmware and launching QEMU hypervisor...");
-
- // Boot the firmware file in real QEMU emulation
- bool bootSuccess = await hypervisor.BootFirmwareFile(path);
-
- if (bootSuccess)
- {
- StatusBarText(" Real hypervisor launched - firmware is booting live!");
-
- // Show welcome message for first-time users
- if (IsFirstTimeExtraction())
- {
- ErrorManager.ShowSuccess(ErrorManager.Codes.WELCOME_MESSAGE);
- MarkFirstTimeExtractionDone();
- }
- }
- else
- {
- StatusBarText(" Hypervisor launch failed");
- ErrorManager.ShowError(ErrorManager.Codes.INITIALIZATION_FAILED, "Failed to launch real hypervisor");
- }
- }
- catch (FileNotFoundException)
- {
- ErrorManager.ShowError(ErrorManager.Codes.FILE_NOT_FOUND, $"RDK-V firmware: {path}");
- ErrorManager.LogError(ErrorManager.Codes.FILE_NOT_FOUND, path);
- }
- catch (UnauthorizedAccessException)
- {
- ErrorManager.ShowError(ErrorManager.Codes.ACCESS_DENIED, $"RDK-V firmware: {path}");
- ErrorManager.LogError(ErrorManager.Codes.ACCESS_DENIED, path);
- }
- catch (InvalidDataException)
- {
- ErrorManager.ShowError(ErrorManager.Codes.INVALID_FIRMWARE_FORMAT, $"RDK-V firmware: {path}");
- ErrorManager.LogError(ErrorManager.Codes.INVALID_FIRMWARE_FORMAT, path);
- }
- catch (Exception ex)
- {
- ErrorManager.ShowError(ErrorManager.Codes.EMULATION_FAILED, $"RDK-V firmware: {path}", ex);
- ErrorManager.LogError(ErrorManager.Codes.EMULATION_FAILED, path, ex);
- }
- await Task.CompletedTask;
- }
-
-
- ///
- /// Probes a disk image for partition tables.
- ///
- private async Task HandleFilesystemProbe()
- {
- var dlg = new OpenFileDialog { Filter = "Disk/Filesystem Images (*.img;*.bin)|*.img;*.bin|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Probing filesystem in {Path.GetFileName(path)}...");
- var data = File.ReadAllBytes(path);
- var parts = PartitionAnalyzer.Analyze(data);
- ShowTextWindow("Partition Analysis", parts);
- StatusBarText("Filesystem probe complete.");
- await Task.CompletedTask;
- }
-
-
- ///
- /// Handles Linux filesystem read/write operations.
- ///
- private async Task HandleLinuxFsReadWrite()
- {
- var dlg = new OpenFileDialog { Filter = "Linux Filesystem Images (*.img;*.bin;*.ext2;*.ext3;*.ext4)|*.img;*.bin;*.ext2;*.ext3;*.ext4|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Selected Linux FS image: {Path.GetFileName(path)}");
- var type = FilesystemProber.Probe(path);
- ShowTextWindow("Linux FS Probe", new List { $"Detected: {type}" });
- StatusBarText("Linux FS probe complete.");
- await Task.CompletedTask;
- }
-
- ///
- /// Cross-compiles a binary from one architecture to another.
- ///
- private async Task HandleCrossCompile()
- {
- var dlg = new OpenFileDialog { Filter = "Binaries (*.bin;*.exe;*.dll)|*.bin;*.exe;*.dll|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string inputPath = dlg.FileName;
- StatusBarText($"Cross-compiling {Path.GetFileName(inputPath)}...");
- byte[] inputData = File.ReadAllBytes(inputPath);
- string fromArch = ArchitectureDetector.Detect(inputData);
- var targets = new[] { "x86", "x64", "ARM", "ARM64" };
- string toArch = PromptUserForChoice("Select target architecture:", targets);
- if (string.IsNullOrEmpty(toArch)) return;
- // If this is a WinCE binary, launch emulator instead of static cross-compilation
- if (IsWinCEBinary(inputData))
- {
- MessageBox.Show("WinCE binary detected; launching built-in emulator.", "WinCE Detected", MessageBoxButton.OK, MessageBoxImage.Information);
- try
- {
- EmulatorLauncher.Launch(inputPath, fromArch);
- StatusBarText("WinCE emulation started.");
- }
- catch (Exception ex)
- {
- MessageBox.Show($"WinCE emulation error: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("WinCE emulation failed.");
- }
- return;
- }
- // perform translation/recompile
- byte[] outputData = ReadAndTranslateFile(inputPath, fromArch, toArch);
- var saveDlg = new SaveFileDialog { Filter = "Binary Output (*.bin)|*.bin|All Files (*.*)|*.*", FileName = Path.GetFileNameWithoutExtension(inputPath) + $"_{toArch}" };
- if (saveDlg.ShowDialog() != true) return;
- File.WriteAllBytes(saveDlg.FileName, outputData);
- ShowTextWindow("Cross-Compile Result", new List { $"Compiled from {fromArch} to {toArch} -> {Path.GetFileName(saveDlg.FileName)}" });
- StatusBarText("Cross-compilation complete.");
- await Task.CompletedTask;
- }
-
- private void ShowTextWindow(string title, List lines)
- {
- var win = new Window
- {
- Title = title,
- Width = 800,
- Height = 600,
- Content = new ScrollViewer
- {
- Content = new TextBox
- {
- Text = string.Join(Environment.NewLine, lines),
- IsReadOnly = true,
- AcceptsReturn = true,
- VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
- HorizontalScrollBarVisibility = ScrollBarVisibility.Auto
- }
- }
- };
- win.Show();
- }
-
- // Menu event handlers to toggle Unicorn engine usage
- private void UseUnicorn_Checked(object sender, RoutedEventArgs e)
- {
- BinaryTranslator.UseUnicornEngine = true;
- StatusBarText("Unicorn engine enabled");
- }
-
- private void UseUnicorn_Unchecked(object sender, RoutedEventArgs e)
- {
- BinaryTranslator.UseUnicornEngine = false;
- StatusBarText("Unicorn engine disabled");
- }
-
- private static bool IsWinCEBinary(byte[] binary)
- {
- // Check PE header and subsystem for WinCE
- if (binary.Length < 0x40) return false;
- // Check for PE signature
- if (binary[0] != 0x4D || binary[1] != 0x5A) return false;
- // More detailed PE header checks would go here
- return true;
- }
-
-
- ///
- /// Emulates an RDK-B broadband gateway using QEMU.
- ///
- private async Task HandleRdkBEmulation()
- {
- var openFileDialog = new OpenFileDialog
- {
- Filter = "RDK-B Firmware Images (*.bin;*.tar;*.tar.gz;*.tar.bz2)|*.bin;*.tar;*.tar.gz;*.tar.bz2|All Files (*.*)|*.*"
- };
- if (openFileDialog.ShowDialog() != true) return;
- string filePath = openFileDialog.FileName;
- StatusBarText($"Launching RDK-B emulator for {Path.GetFileName(filePath)}...");
- byte[] binary = File.ReadAllBytes(filePath);
- string arch = ArchitectureDetector.Detect(binary);
- try
- {
- EmulatorLauncher.Launch(filePath, arch, platform: "RDK-B");
- StatusBarText("RDK-B emulation started.");
- }
- catch (Exception ex)
- {
- MessageBox.Show($"RDK-B emulation error: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("RDK-B emulation failed.");
- }
- await Task.CompletedTask;
- }
-
- ///
- /// Demonstrates PowerPC bootloader functionality and emulation.
- ///
- private async Task HandlePowerPCBootloaderDemo()
- {
- var choice = PromptUserForChoice("PowerPC Bootloader Demo",
- new List { "Create Bootloader Only", "Load Firmware + Bootloader", "Show Bootloader Info" });
-
- if (string.IsNullOrEmpty(choice)) return;
-
- try
- {
- switch (choice)
- {
- case "Create Bootloader Only":
- StatusBarText("Creating PowerPC bootloader...");
- PowerPCBootloaderManager.LaunchPowerPCWithBootloader(null);
- StatusBarText("PowerPC bootloader demo started.");
- break;
-
- case "Load Firmware + Bootloader":
- var dlg = new OpenFileDialog
- {
- Filter = "PowerPC Firmware (*.bin;*.img;*.elf)|*.bin;*.img;*.elf|All Files (*.*)|*.*"
- };
- if (dlg.ShowDialog() == true)
- {
- StatusBarText($"Loading PowerPC firmware: {Path.GetFileName(dlg.FileName)}...");
- PowerPCBootloaderManager.LaunchPowerPCWithBootloader(dlg.FileName);
- StatusBarText("PowerPC emulation with firmware started.");
- }
- break;
-
- case "Show Bootloader Info":
- PowerPCBootloaderManager.ShowBootloaderInfo();
- StatusBarText("Displayed PowerPC bootloader information.");
- break;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"PowerPC bootloader error: {ex.Message}", "PowerPC Error",
- MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("PowerPC bootloader demo failed.");
- }
- await Task.CompletedTask;
- }
-
- // U-verse dump analysis for Data/DVR/Uverse_Stuff
- private async Task HandleUverseDumpAnalysis()
- {
- var baseDir = AppDomain.CurrentDomain.BaseDirectory;
- var dumpsPath = System.IO.Path.Combine(baseDir, "Data", "DVR", "Uverse_Stuff", "Dumps");
- if (!System.IO.Directory.Exists(dumpsPath))
- {
- MessageBox.Show("U-verse dumps folder not found:\n" + dumpsPath, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
- var files = System.IO.Directory.GetFiles(dumpsPath, "*", System.IO.SearchOption.AllDirectories);
- var records = new List();
- foreach (var file in files)
- {
- var info = new System.IO.FileInfo(file);
- byte[] data = System.IO.File.ReadAllBytes(file).Take(64).ToArray();
- string hex = BitConverter.ToString(data).Replace("-", " ");
- records.Add(new FileRecord { FilePath = file, Size = info.Length, HexPreview = hex });
- }
- var analysisWindow = new FolderAnalysisWindow(records);
- analysisWindow.Show();
- StatusBarText($"U-verse dump analysis: {files.Length} files loaded.");
- await Task.CompletedTask;
- }
-
- private void UverseDumpAnalysis_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleUverseDumpAnalysis();
- }
-
- ///
- /// Configure emulator settings based on platform detection results
- ///
- private void ConfigureEmulatorFromDetection(PlatformSignature platform)
- {
- try
- {
- // Set emulator type radio button based on detection (commented out due to XAML binding issues)
- // TODO: Fix XAML control binding issues
- /*
- switch (platform.EmulatorType)
- {
- case EmulatorType.HomebrewEmulator:
- if (HomebrewEmulatorRadio != null)
- HomebrewEmulatorRadio.IsChecked = true;
- break;
- case EmulatorType.QEMU:
- if (QemuEmulatorRadio != null)
- QemuEmulatorRadio.IsChecked = true;
- break;
- // Note: RetDecTranslatorRadio may not be accessible from code-behind
- }
- */
-
- // Set platform-specific configurations
- switch (platform.Name)
- {
- case "RDK-V":
- // Auto-select ARM architecture for RDK-V
- StatusBarText("Configured for RDK-V: ARM Cortex-A15, BCM7449 SoC");
- break;
- case "U-verse":
- // Auto-select MIPS for U-verse
- StatusBarText("Configured for U-verse: MIPS architecture, IPTV platform");
- break;
- case "DirecTV":
- // Auto-select MIPS for DirecTV
- StatusBarText("Configured for DirecTV: MIPS architecture, Satellite platform");
- break;
- case "Windows CE":
- // Auto-select ARM for WinCE
- StatusBarText("Configured for Windows CE: ARM architecture");
- break;
- case "VxWorks":
- StatusBarText("Configured for VxWorks: RTOS environment");
- break;
- case "Embedded Linux":
- StatusBarText("Configured for Embedded Linux: Generic ARM platform");
- break;
- }
-
- Debug.WriteLine($"[MainWindow] Auto-configured for platform: {platform.Name}");
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"[MainWindow] Configuration error: {ex.Message}");
- StatusBarText($"Auto-configuration failed: {ex.Message}");
- }
- }
-
- private void LoadFirmwareImage(string imagePath, string signaturePath)
- {
- // Copy firmware image to temp folder to avoid modifying originals
- string tempDir = Path.Combine(Path.GetTempPath(), "ProcessorEmulator", Guid.NewGuid().ToString());
- Directory.CreateDirectory(tempDir);
-
- string tempImagePath = Path.Combine(tempDir, Path.GetFileName(imagePath));
- File.Copy(imagePath, tempImagePath, overwrite: true);
-
- // PLATFORM AUTODETECTION - Analyze firmware to suggest platform
- StatusBarText("Analyzing firmware for platform detection...");
- var detectionResult = PlatformDetector.DetectPlatform(imagePath);
-
- // REGION AWARENESS - Analyze firmware regions for boot logic
- StatusBarText("Analyzing firmware regions...");
- var regionResult = FirmwareRegionAnalyzer.AnalyzeFirmware(imagePath);
-
- if (detectionResult.Success && detectionResult.DetectedPlatform != null)
- {
- var platform = detectionResult.DetectedPlatform;
- StatusBarText($"Platform detected: {platform.Name} (confidence: {detectionResult.Confidence:P1})");
-
- // Show detection results and recommendations
- var resultMessage = $" Platform Detection & Region Analysis Results:\n\n";
- resultMessage += $"Platform: {platform.Name}\n";
- resultMessage += $"Confidence: {detectionResult.Confidence:P1}\n";
- resultMessage += $"Architecture: {platform.Architecture}\n";
- resultMessage += $"SoC Family: {platform.SocFamily}\n";
- resultMessage += $"Recommended Emulator: {platform.EmulatorType}\n\n";
-
- // Add region analysis results
- if (regionResult.Success && regionResult.DetectedRegions.Any())
- {
- resultMessage += " Detected Firmware Regions:\n";
- foreach (var region in regionResult.DetectedRegions.Take(4))
- {
- resultMessage += $" {region.Name}: {region.Confidence:P1} confidence\n";
- resultMessage += $" Address: 0x{region.LoadAddress:X8}, Size: ~{region.EstimatedSize / 1024}KB\n";
- }
- resultMessage += "\n";
- }
-
- if (detectionResult.Recommendations.Any())
- {
- resultMessage += " Platform Recommendations:\n";
- foreach (var rec in detectionResult.Recommendations.Take(3))
- resultMessage += $" {rec}\n";
- resultMessage += "\n";
- }
-
- // Add boot sequence recommendations
- if (regionResult.Success && regionResult.BootSequence.Any())
- {
- resultMessage += " Recommended Boot Sequence:\n";
- foreach (var step in regionResult.BootSequence.Take(6))
- resultMessage += $"{step}\n";
- }
-
- MessageBox.Show(resultMessage, "Platform & Region Analysis Results",
- MessageBoxButton.OK, MessageBoxImage.Information);
-
- // Auto-configure emulator type based on detection
- ConfigureEmulatorFromDetection(platform);
-
- // Log platform and region information to emulation log
- if (logPanel != null)
- {
- logPanel.LogPeripheralTrap("ANALYZER", "Platform Detection",
- $"Detected {platform.Name} with {detectionResult.Confidence:P1} confidence");
-
- if (regionResult.Success)
- {
- logPanel.LogPeripheralTrap("ANALYZER", "Region Analysis",
- $"Found {regionResult.DetectedRegions.Count} firmware regions");
- }
- }
- }
- else
- {
- StatusBarText("Platform detection failed - proceeding with manual configuration");
- if (!string.IsNullOrEmpty(detectionResult.Error))
- {
- MessageBox.Show($"Platform detection failed: {detectionResult.Error}\n\nProceeding with manual configuration.",
- "Platform Detection", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
- }
-
- string chipsetName = null;
- string rootFilesystemType = null;
-
- // Only handle signature file if it is provided and exists
- string tempSignaturePath = null;
- if (!string.IsNullOrEmpty(signaturePath) && File.Exists(signaturePath))
- {
- tempSignaturePath = Path.Combine(tempDir, Path.GetFileName(signaturePath));
- File.Copy(signaturePath, tempSignaturePath, overwrite: true);
-
- // Try to parse signature/config file if present
- foreach (var line in File.ReadAllLines(tempSignaturePath))
- {
- if (line.StartsWith("CHIPSET=", StringComparison.OrdinalIgnoreCase))
- chipsetName = line.Substring("CHIPSET=".Length).Trim();
- if (line.StartsWith("FS=", StringComparison.OrdinalIgnoreCase))
- rootFilesystemType = line.Substring("FS=".Length).Trim();
- }
- }
-
- // If not found, use heuristics (scan firmware image for known patterns)
- if (chipsetName == null || rootFilesystemType == null)
- {
- byte[] fw = File.ReadAllBytes(tempImagePath);
- string fwStr = System.Text.Encoding.ASCII.GetString(fw);
-
- // Example heuristic: look for known chipset names
- if (fwStr.Contains("Contoso6311"))
- chipsetName = "Contoso6311";
- else if (fwStr.Contains("FooChip9000"))
- chipsetName = "FooChip9000";
- else if (fwStr.Contains("BCM7405"))
- chipsetName = "BCM7405";
- else if (fwStr.Contains("MIPS 4380") || fwStr.Contains("MIPS4380"))
- chipsetName = "MIPS4380";
- // Add more heuristics as needed
-
- // Example heuristic: look for filesystem markers
- if (fwStr.Contains("JFFS2"))
- rootFilesystemType = "JFFS2";
- else if (fwStr.Contains("UBIFS"))
- rootFilesystemType = "UBIFS";
- // Add more heuristics as needed
- }
-
- // If still not found, prompt user
- if (chipsetName == null)
- {
- chipsetName = PromptUserForInput("Chipset not detected. Please enter chipset name:");
- if (string.IsNullOrWhiteSpace(chipsetName))
- {
- MessageBox.Show("Chipset is required.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
- }
- if (rootFilesystemType == null)
- {
- rootFilesystemType = PromptUserForInput("Filesystem type not detected. Please enter filesystem type (e.g., JFFS2):");
- if (string.IsNullOrWhiteSpace(rootFilesystemType))
- {
- MessageBox.Show("Filesystem type is required.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
- }
-
- // Load Chipset Emulator
- string chipsetConfigPath = $"Configs/{chipsetName}.json";
- if (!fsManager.LoadChipsetEmulator(chipsetName, chipsetConfigPath))
- {
- MessageBox.Show($"Failed to load chipset emulator for {chipsetName}.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- // Mount Filesystem (example only supports JFFS2)
- string mountPoint = "/mnt/firmware";
- if (rootFilesystemType.Equals("JFFS2", StringComparison.OrdinalIgnoreCase))
- {
- fsManager.MountJFFS2(tempImagePath, mountPoint);
- }
- else
- {
- MessageBox.Show($"Filesystem type '{rootFilesystemType}' is not supported.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- // Helper to prompt user for input (simple dialog)
- private string PromptUserForInput(string message)
- {
- var inputDialog = new Window
- {
- Title = "Input Required",
- Width = 400,
- Height = 150,
- WindowStartupLocation = WindowStartupLocation.CenterOwner,
- ResizeMode = ResizeMode.NoResize,
- Owner = this
- };
- var stack = new StackPanel { Margin = new Thickness(10) };
- stack.Children.Add(new TextBlock { Text = message, Margin = new Thickness(0, 0, 0, 10) });
- var textBox = new TextBox { Margin = new Thickness(0, 0, 0, 10) };
- stack.Children.Add(textBox);
- var okButton = new Button { Content = "OK", Width = 80, IsDefault = true, HorizontalAlignment = HorizontalAlignment.Right };
- stack.Children.Add(okButton);
- inputDialog.Content = stack;
-
- string result = null;
- okButton.Click += (s, e) => { result = textBox.Text; inputDialog.DialogResult = true; inputDialog.Close(); };
- inputDialog.ShowDialog();
- return result;
- }
-
-
- private byte[] ReadAndTranslateFile(string filePath, string fromArch, string toArch)
- {
- // Load raw data
- byte[] data = File.ReadAllBytes(filePath);
- try
- {
- // Attempt static cross-translation via BinaryTranslator
- return BinaryTranslator.Translate(fromArch, toArch, data);
- }
- catch (NotImplementedException)
- {
- // Show "instructions unclear" error
- ErrorManager.ShowInstructionsUnclear($"Cross-compilation from {fromArch} to {toArch}");
- return data;
- }
- }
-
- // Removed override of Equals(object) because DependencyObject.Equals(object) is sealed and cannot be overridden.
-
- // Removed GetHashCode override because DependencyObject.GetHashCode() is sealed and cannot be overridden.
-
- // Add this method to handle File -> Open menu click - detect firmware type automatically
- private async void OpenMenuItem_Click(object sender, RoutedEventArgs e)
- {
- var dlg = new OpenFileDialog
- {
- Filter = "Firmware Files (*.bin;*.img;*.fw;*.rdk)|*.bin;*.img;*.fw;*.rdk|All Files (*.*)|*.*",
- Title = "Select Firmware File"
- };
-
- if (dlg.ShowDialog() != true) return;
-
- string filePath = dlg.FileName;
- StatusBarText($"Analyzing firmware: {Path.GetFileName(filePath)}");
-
- try
- {
- // Read file for analysis
- byte[] firmwareData = await File.ReadAllBytesAsync(filePath);
- string firmwareType = AnalyzeFileType(filePath, firmwareData);
-
- // Auto-detect firmware type and route to appropriate emulator
- if (firmwareType == "Comcast X1 Firmware")
- {
- await HandleComcastX1Emulation(filePath);
- }
- else
- {
- // Show a clean, minimal dialog for other firmware types
- var emulatorOptions = new List
- {
- "RDK-V Emulator",
- "RDK-B Emulator",
- "Uverse Box Emulator",
- "DirecTV Box/Firmware Analysis",
- "Generic CPU/OS Emulation",
- "Custom Hypervisor"
- };
-
- string selectedEmulator = PromptUserForChoice("Select emulator for this firmware:", emulatorOptions);
- if (string.IsNullOrEmpty(selectedEmulator)) return;
-
- // Route to the selected emulator with the file
- await RouteToSelectedEmulator(selectedEmulator, filePath);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Error opening firmware: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("Error opening firmware");
- }
- }
-
- ///
- /// Route to the selected emulator with a pre-selected firmware file
- ///
- private async Task RouteToSelectedEmulator(string emulatorName, string filePath)
- {
- switch (emulatorName)
- {
- case "RDK-V Emulator":
- await HandleRdkVEmulation();
- break;
- case "RDK-B Emulator":
- await HandleRdkBEmulation();
- break;
- case "Uverse Box Emulator":
- await HandleUverseEmulation();
- break;
- case "DirecTV Box/Firmware Analysis":
- await HandleDirectvAnalysis();
- break;
- case "Generic CPU/OS Emulation":
- await HandleGenericEmulation();
- break;
- case "Custom Hypervisor":
- await HandleCustomHypervisor();
- break;
- }
- }
-
- ///
- /// Analyze file type based on content and extension
- ///
- private string AnalyzeFileType(string filePath, byte[] fileData)
- {
- // Simple analysis based on file extension and content
- string extension = Path.GetExtension(filePath).ToLower();
- string content = Encoding.ASCII.GetString(fileData.Take(1024).ToArray());
-
- if (content.Contains("XG1") || content.Contains("BCM7449"))
- {
- return "Comcast X1 Firmware";
- }
-
- // Add more rules here for other firmware types
-
- return "Unknown";
- }
+ private void ShowMemoryMap_Click(object sender, RoutedEventArgs e) =>
+ System.Windows.MessageBox.Show("Displaying Resource Map...");
- ///
- /// Handle Comcast X1 emulation with a specific file
- ///
- private async Task HandleComcastX1Emulation(string filePath = null)
+ private void ShowInterrupts_Click(object sender, RoutedEventArgs e)
{
- if (string.IsNullOrEmpty(filePath))
- {
- var openFileDialog = new OpenFileDialog
- {
- Filter = "Comcast X1 Firmware (*.bin;*.rdk)|*.bin;*.rdk|All Files (*.*)|*.*"
- };
- if (openFileDialog.ShowDialog() != true) return;
- filePath = openFileDialog.FileName;
- }
-
- StatusBarText($"Starting Comcast X1 emulation for {Path.GetFileName(filePath)}...");
-
- try
- {
- // Use the simple firmware emulator for reliable operation
- var emulator = new SimpleFirmwareEmulator();
-
- // Load firmware
- if (await emulator.LoadFirmware(filePath))
- {
- // Start emulation
- if (await emulator.Start())
- {
- StatusBarText("Comcast X1 emulation started successfully!");
- }
- else
- {
- StatusBarText("Failed to start Comcast X1 emulation");
- }
- }
- else
- {
- StatusBarText("Failed to load Comcast X1 firmware");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Comcast X1 emulation failed: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- StatusBarText("Comcast X1 emulation failed.");
- }
- }
-
- ///
- /// Handle generic CPU/OS emulation
- ///
- private async Task HandleGenericEmulation()
- {
- // Get hypervisor configuration from UI
- var config = GetHypervisorConfiguration();
-
- // Launch hypervisor window with dummy hypervisor and platform name
- var hypervisorWindow = new HypervisorWindow(new RealMipsHypervisor(), "Generic Platform");
- hypervisorWindow.Show();
-
- StatusBarText("Generic hypervisor launched.");
- await Task.CompletedTask;
- }
-
- ///
- /// Handle custom hypervisor launch
- ///
- private async Task HandleCustomHypervisor()
- {
- // Get hypervisor configuration from UI
- var config = GetHypervisorConfiguration();
-
- // Launch hypervisor window with dummy hypervisor and platform name
- var hypervisorWindow = new HypervisorWindow(new RealMipsHypervisor(), "Custom Platform");
- hypervisorWindow.Show();
-
- StatusBarText("Custom hypervisor launched.");
- await Task.CompletedTask;
- }
-
- ///
- /// Handle drag-and-drop of firmware files
- ///
- private void MainWindow_Drop(object sender, DragEventArgs e)
- {
- if (e.Data.GetDataPresent(DataFormats.FileDrop))
- {
- string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
- if (files.Length > 0)
- {
- firmwarePath = files[0];
- StatusBarText($"Loaded firmware: {Path.GetFileName(firmwarePath)}");
-
- // Auto-detect and start emulation
- AutoDetectAndStartEmulation(firmwarePath);
- }
- }
- }
-
- ///
- /// Auto-detect firmware type and start appropriate emulation
- ///
- private async void AutoDetectAndStartEmulation(string filePath)
- {
- try
- {
- byte[] fileData = await File.ReadAllBytesAsync(filePath);
- string firmwareType = AnalyzeFileType(filePath, fileData);
-
- switch (firmwareType)
- {
- case "Comcast X1 Firmware":
- await HandleComcastX1Emulation(filePath);
- break;
- default:
- // Default to generic emulation if type is unknown
- await HandleGenericEmulation();
- break;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Failed to auto-start emulation: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- ///
- /// Handle folder analysis
- ///
- private async Task HandleFolderAnalysis()
- {
- // WPF does not have a native folder picker; use OpenFileDialog to pick a file inside the folder instead
- var openFile = new OpenFileDialog { Title = "Select any file inside the folder to analyze", Filter = "All Files (*.*)|*.*" };
- if (openFile.ShowDialog() != true)
- {
- return;
- }
- string folderPath = System.IO.Path.GetDirectoryName(openFile.FileName);
- var files = System.IO.Directory.GetFiles(folderPath);
- var items = new List();
- foreach (var file in files)
- {
- items.Add(new FileRecord
- {
- FilePath = file,
- Size = new System.IO.FileInfo(file).Length,
- HexPreview = string.Empty
- });
- }
- var analysisWindow = new FolderAnalysisWindow(items);
- analysisWindow.Show();
- StatusBarText($"Analyzing folder: {folderPath}");
- await Task.CompletedTask;
- }
-
- ///
- /// Handle SWM/LNB simulation
- ///
- private async Task HandleSwmLnbSimulation()
- {
- ProcessorEmulator.Emulation.SwmLnbEmulator.SendChannelMap();
- ShowTextWindow("SWM/LNB Simulation", new List { "SWM/LNB simulation running." });
- StatusBarText("SWM/LNB simulation started.");
- await Task.CompletedTask;
- }
-
- ///
- /// Handle filesystem mount for various types
- ///
- private async Task HandleCeMount()
- {
- var dlg = new OpenFileDialog { Filter = "WinCE Filesystem Images (*.img;*.bin)|*.img;*.bin|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Mounting WinCE FS from {Path.GetFileName(path)}...");
- // Logic to mount WinCE filesystem
- StatusBarText("WinCE FS mounted.");
- await Task.CompletedTask;
- }
-
- private async Task HandleYaffsMount()
- {
- var dlg = new OpenFileDialog { Filter = "YAFFS Filesystem Images (*.img;*.bin)|*.img;*.bin|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Mounting YAFFS from {Path.GetFileName(path)}...");
- // Logic to mount YAFFS filesystem
- StatusBarText("YAFFS mounted.");
- await Task.CompletedTask;
- }
-
- private async Task HandleIsoMount()
- {
- var dlg = new OpenFileDialog { Filter = "ISO Files (*.iso)|*.iso|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Mounting ISO from {Path.GetFileName(path)}...");
- // Logic to mount ISO filesystem
- StatusBarText("ISO mounted.");
- await Task.CompletedTask;
- }
-
- private async Task HandleExtMount()
- {
- var dlg = new OpenFileDialog { Filter = "EXT Filesystem Images (*.ext2;*.ext3;*.ext4)|*.ext2;*.ext3;*.ext4|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Mounting EXT FS from {Path.GetFileName(path)}...");
- // Logic to mount EXT filesystem
- StatusBarText("EXT FS mounted.");
-await Task.CompletedTask;
- }
-
- ///
- /// Handle booting firmware with homebrew emulator first
- ///
- private async Task HandleBootFirmwareHomebrewFirst()
- {
- var dlg = new OpenFileDialog { Filter = "Firmware Files (*.bin;*.img)|*.bin;*.img|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Booting firmware {Path.GetFileName(path)} with homebrew emulator...");
- // Logic to boot with homebrew emulator
- StatusBarText("Firmware booted with homebrew emulator.");
- await Task.CompletedTask;
- }
-
- ///
- /// Handle booting firmware in homebrew emulator
- ///
- private async Task HandleBootFirmwareInHomebrew()
- {
- var dlg = new OpenFileDialog { Filter = "Firmware Files (*.bin;*.img)|*.bin;*.img|All Files (*.*)|*.*" };
- if (dlg.ShowDialog() != true) return;
- string path = dlg.FileName;
- StatusBarText($"Booting firmware {Path.GetFileName(path)} in homebrew emulator...");
- // Logic to boot in homebrew emulator
- StatusBarText("Firmware booted in homebrew emulator.");
- await Task.CompletedTask;
- }
-
- ///
- /// Helper to prompt user for a choice from a list
- ///
- private string PromptUserForChoice(string message, IEnumerable choices)
- {
- var choiceDialog = new Window
- {
- Title = "Select an Option",
- Width = 400,
- Height = 200,
- WindowStartupLocation = WindowStartupLocation.CenterOwner,
- Owner = this
- };
-
- var stackPanel = new StackPanel { Margin = new Thickness(10) };
- stackPanel.Children.Add(new TextBlock { Text = message, Margin = new Thickness(0, 0, 0, 10) });
-
- var comboBox = new ComboBox { ItemsSource = choices, SelectedIndex = 0 };
- stackPanel.Children.Add(comboBox);
-
- var okButton = new Button { Content = "OK", Width = 80, IsDefault = true, Margin = new Thickness(0, 10, 0, 0), HorizontalAlignment = HorizontalAlignment.Right };
- stackPanel.Children.Add(okButton);
-
- choiceDialog.Content = stackPanel;
-
- string selectedChoice = null;
- okButton.Click += (s, e) =>
- {
- selectedChoice = comboBox.SelectedItem as string;
- choiceDialog.DialogResult = true;
- choiceDialog.Close();
- };
-
- choiceDialog.ShowDialog();
- return selectedChoice;
- }
-
- ///
- /// Check if this is the first time the user is running firmware extraction
- ///
- private bool IsFirstTimeExtraction()
- {
- // Simple check using a temp file
- string flagFile = Path.Combine(Path.GetTempPath(), "ProcessorEmulator_FirstTimeFlag.txt");
- return !File.Exists(flagFile);
- }
-
- ///
- /// Mark that the first-time extraction has been done
- ///
- private void MarkFirstTimeExtractionDone()
- {
- string flagFile = Path.Combine(Path.GetTempPath(), "ProcessorEmulator_FirstTimeFlag.txt");
- File.WriteAllText(flagFile, "done");
- }
-
- ///
- /// Show a funny status message during long operations
- ///
- private void ShowFunnyStatus(string operation)
- {
- var messages = new[]
- {
- "Reticulating splines...",
- "Charging flux capacitor...",
- "Aligning warp coils...",
- "Polishing the hyperdrive...",
- "Recalibrating the quantum carburetor...",
- "Defragging the reality matrix...",
- "Downloading more RAM...",
- "Reversing the polarity of the neutron flow..."
- };
- var random = new Random();
- StatusBarText($"{operation}: {messages[random.Next(messages.Length)]}");
- }
-
- // Missing event handlers referenced in XAML
- private void RdkVEmulator_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleRdkVEmulation();
- }
-
- private void BrowseFirmwareButton_Click(object sender, RoutedEventArgs e)
- {
- var openFileDialog = new OpenFileDialog
- {
- Filter = "Firmware Files (*.bin;*.img;*.exe)|*.bin;*.img;*.exe|All Files (*.*)|*.*"
- };
- if (openFileDialog.ShowDialog() == true)
- {
- firmwarePath = openFileDialog.FileName;
-
- // Update the UI text field
- if (this.FindName("FirmwarePathTextBox") is TextBox firmwarePathTextBox)
- {
- firmwarePathTextBox.Text = firmwarePath;
- }
-
- StatusBarText($"Selected firmware: {Path.GetFileName(firmwarePath)}");
- }
- }
-
- private void AnalyzeAllDvrData_Click(object sender, RoutedEventArgs e)
- {
- StatusBarText("Analyzing all DVR data...");
- // Implement DVR data analysis
- }
-
- private void ListDvrFirmware_Click(object sender, RoutedEventArgs e)
- {
- StatusBarText("Listing DVR firmware...");
- // Implement DVR firmware listing
- }
-
- private void ScanDvrData_Click(object sender, RoutedEventArgs e)
- {
- StatusBarText("Scanning DVR data...");
- // Implement DVR data scanning
- }
-
- private void AnalyzeFirmware_Click(object sender, RoutedEventArgs e)
- {
- StatusBarText("Analyzing firmware...");
- // Implement firmware analysis
- }
-
- // Additional missing event handlers
- private void UverseEmulator_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleUverseEmulation();
- }
-
-
- private void ComcastX1Emulator_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleComcastX1Emulation();
- }
-
-
- private void DirectvAnalysis_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleDirectvAnalysis();
- }
-
-
- private void RdkBEmulator_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleRdkBEmulation();
- }
-
-
- private void DishVxWorks_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleDishVxWorks();
- }
-
-
- private void PowerPCDemo_Click(object sender, RoutedEventArgs e)
- {
- _ = HandlePowerPCDemo();
- }
-
-
- private void GenericEmulation_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleGenericEmulation();
- }
-
-
- private void WindowsCEExecutor_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleWindowsCEExecution();
- }
-
-
- private void UniversalHypervisor_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleCustomHypervisor();
- }
-
-
- private void StopAllProcesses_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleStopAllProcesses();
- }
-
-
- private void ShowRunningProcesses_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleShowRunningProcesses();
- }
-
-
- private void ProcessMonitor_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleProcessMonitor();
- }
-
-
- private void ExtractFirmware_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleFirmwareExtraction();
- }
-
-
- private void DetectFileType_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleFileTypeDetection();
- }
-
-
- private void ExecutableAnalysis_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleExecutableAnalysis();
- }
-
-
- private void CrossCompile_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleCrossCompile();
- }
-
-
- private void AnalyzeFolder_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleFolderAnalysis();
- }
-
-
- private void SummarizeDvrData_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleDvrDataSummary();
- }
-
-
- private void MountIso_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleIsoMount();
- }
-
-
- private void MountExt_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleExtMount();
- }
-
-
- private void MountFat_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleFatMount();
- }
-
-
- private void MountSquashFs_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleSquashFsMount();
- }
-
-
- private void MountYaffs_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleYaffsMount();
- }
-
-
- private void MountCe_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleCeMount();
- }
-
-
- private void ProbeFilesystem_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleFilesystemProbe();
- }
-
-
- private void LinuxFsReadWrite_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleLinuxFsReadWrite();
- }
-
-
- private void SimulateSwmLnb_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleSwmLnbSimulation();
- }
-
-
- private void InitBoltButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltInit();
- }
-
-
- private void BoltCliButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltCli();
- }
-
-
- private void LoadFirmwareButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltLoadFirmware();
- }
-
-
- private void BoltBrowseFirmwareButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltBrowseFirmware();
- }
-
-
- private void MemTestButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltMemTest();
- }
-
-
- private void ShowDtbButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltShowDtb();
- }
-
-
- private void DumpMemoryButton_Click(object sender, RoutedEventArgs e)
- {
- _ = HandleBoltDumpMemory();
- }
-
- // Stub implementations for missing handlers
-
- private Task HandleDishVxWorks()
- {
- StatusBarText("Dish VxWorks analysis started");
- return Task.CompletedTask;
- }
-
-
- private Task HandlePowerPCDemo()
- {
- StatusBarText("PowerPC demo started");
- return Task.CompletedTask;
- }
-
-
- private Task HandleFirmwareExtraction()
- {
- StatusBarText("Firmware extraction started");
- return Task.CompletedTask;
- }
-
-
- private Task HandleFileTypeDetection()
- {
- StatusBarText("File type detection started");
- return Task.CompletedTask;
- }
-
-
- private Task HandleDvrDataSummary()
- {
- StatusBarText("DVR data summary started");
- return Task.CompletedTask;
- }
-
-
- private Task HandleFatMount()
- {
- StatusBarText("FAT filesystem mounted");
- return Task.CompletedTask;
- }
-
-
- private Task HandleSquashFsMount()
- {
- StatusBarText("SquashFS mounted");
- return Task.CompletedTask;
- }
-
-
- private Task HandleBoltInit()
- {
- StatusBarText("BOLT initialization started");
- return Task.CompletedTask;
- }
-
-
- private Task HandleBoltCli()
- {
- StatusBarText("BOLT CLI started");
- return Task.CompletedTask;
- }
-
- private Task HandleBoltLoadFirmware()
- {
- StatusBarText("BOLT firmware loading started");
- return Task.CompletedTask;
- }
-
- private Task HandleBoltBrowseFirmware()
- {
- StatusBarText("BOLT firmware browsing started");
- return Task.CompletedTask;
- }
-
- private Task HandleBoltMemTest()
- {
- StatusBarText("BOLT memory test started");
- return Task.CompletedTask;
- }
-
- private Task HandleBoltShowDtb()
- {
- StatusBarText("BOLT DTB display started");
- return Task.CompletedTask;
- }
-
- private Task HandleBoltDumpMemory()
- {
- StatusBarText("BOLT memory dump started");
- return Task.CompletedTask;
- }
-
-
- ///
- /// Handle Windows CE binary execution using cross-platform translation
- ///
- private async Task HandleWindowsCEExecution()
- {
- try
- {
- // Prompt user to select Windows CE binaries (allow multiple selection)
- var openFileDialog = new OpenFileDialog
- {
- Title = "Select Windows CE Binaries",
- Filter = "Windows CE Executables (*.exe)|*.exe|All Files (*.*)|*.*",
- InitialDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "DVR", "Uverse_Stuff"),
- Multiselect = true
- };
-
- if (openFileDialog.ShowDialog() != true)
- {
- StatusBarText("Windows CE execution cancelled");
- return;
- }
-
- string[] binaryPaths = openFileDialog.FileNames;
- StatusBarText($"Loading {binaryPaths.Length} Windows CE binaries...");
-
- // Ask user if they want concurrent or sequential execution
- var executionChoice = MessageBox.Show(
- $"Execute {binaryPaths.Length} binaries:\n\n" +
- "YES = Concurrently (all at once)\n" +
- "NO = Sequentially (one after another)\n" +
- "CANCEL = Abort execution",
- "Execution Mode",
- MessageBoxButton.YesNoCancel,
- MessageBoxImage.Question);
-
- if (executionChoice == MessageBoxResult.Cancel)
- {
- StatusBarText("Windows CE execution cancelled");
- return;
- }
-
- bool concurrent = executionChoice == MessageBoxResult.Yes;
-
- // Initialize Windows CE executor
- var executor = new WindowsCEExecutor();
- List results;
-
- if (concurrent)
- {
- StatusBarText($"Executing {binaryPaths.Length} binaries concurrently...");
- results = await executor.ExecuteMultipleAsync(binaryPaths);
- }
- else
- {
- StatusBarText($"Executing {binaryPaths.Length} binaries sequentially...");
- results = new List();
-
- for (int i = 0; i < binaryPaths.Length; i++)
- {
- StatusBarText($"Executing binary {i + 1}/{binaryPaths.Length}: {Path.GetFileName(binaryPaths[i])}");
- var result = await executor.ExecuteAsync(binaryPaths[i]);
- results.Add(result);
- }
- }
-
- // Display execution results
- var logEntries = new List
- {
- "=== Windows CE Multi-Binary Execution Results ===",
- $"Execution Mode: {(concurrent ? "Concurrent" : "Sequential")}",
- $"Total Binaries: {binaryPaths.Length}",
- $"Successful: {results.Count(r => r.Success)}",
- $"Failed: {results.Count(r => !r.Success)}",
- ""
- };
-
- for (int i = 0; i < results.Count; i++)
- {
- var result = results[i];
- var binary = Path.GetFileName(binaryPaths[i]);
-
- logEntries.Add($"=== {i + 1}. {binary} ===");
- logEntries.Add($"Process ID: {result.ProcessId}");
- logEntries.Add($"Architecture: {result.Architecture}");
- logEntries.Add($"Entry Point: 0x{result.EntryPoint:X8}");
- logEntries.Add($"Status: {(result.Success ? "SUCCESS" : "FAILED")}");
- logEntries.Add($"Exit Code: {result.ExitCode}");
- logEntries.Add($"Execution Time: {result.ExecutionTime.TotalMilliseconds:F0}ms");
-
- if (!result.Success && !string.IsNullOrEmpty(result.Error))
- {
- logEntries.Add($"Error: {result.Error}");
- }
-
- // Add recent log entries (last 5 lines)
- if (result.Log != null && result.Log.Count > 0)
- {
- logEntries.Add("Recent Log:");
- var recentLogs = result.Log.TakeLast(5);
- foreach (var log in recentLogs)
- {
- logEntries.Add($" {log}");
- }
- }
-
- logEntries.Add("");
- }
-
- // Show running processes
- var runningProcesses = executor.GetRunningProcesses();
- if (runningProcesses.Any(p => p.IsRunning))
- {
- logEntries.Add("=== Currently Running Processes ===");
- foreach (var proc in runningProcesses.Where(p => p.IsRunning))
- {
- logEntries.Add($"• {Path.GetFileName(proc.ExePath)} (PID: {proc.ProcessId})");
- logEntries.Add($" Runtime: {proc.RunTime.TotalSeconds:F1}s");
- }
- logEntries.Add("");
- logEntries.Add("Use 'Stop All Processes' button to terminate running executables.");
- }
-
- ShowTextWindow($"Windows CE Multi-Execution Results ({binaryPaths.Length} binaries)", logEntries);
-
- int successCount = results.Count(r => r.Success);
- StatusBarText($"Windows CE execution completed: {successCount}/{binaryPaths.Length} successful");
-
- // Offer to show individual process details
- if (results.Count > 1)
- {
- var detailChoice = MessageBox.Show(
- "Would you like to see detailed logs for individual processes?",
- "View Details",
- MessageBoxButton.YesNo,
- MessageBoxImage.Question);
-
- if (detailChoice == MessageBoxResult.Yes)
- {
- for (int i = 0; i < results.Count; i++)
- {
- var result = results[i];
- var binary = Path.GetFileName(binaryPaths[i]);
-
- var detailLog = new List
- {
- $"=== Detailed Log for {binary} ===",
- $"Process ID: {result.ProcessId}",
- $"Architecture: {result.Architecture}",
- $"Entry Point: 0x{result.EntryPoint:X8}",
- $"Status: {(result.Success ? "SUCCESS" : "FAILED")}",
- $"Exit Code: {result.ExitCode}",
- $"Execution Time: {result.ExecutionTime.TotalMilliseconds:F0}ms",
- ""
- };
-
- if (result.Log != null)
- {
- detailLog.AddRange(result.Log);
- }
-
- ShowTextWindow($"Detailed Log - {binary}", detailLog);
- }
- }
- }
- }
- catch (Exception ex)
- {
- var errorLog = new List
- {
- "=== Windows CE Multi-Execution Error ===",
- $"Error: {ex.Message}",
- $"Type: {ex.GetType().Name}",
- "",
- "=== Stack Trace ===",
- ex.StackTrace
- };
-
- ShowTextWindow("Windows CE Multi-Execution Error", errorLog);
- StatusBarText($"Windows CE execution error: {ex.Message}");
- }
- }
-
- ///
- /// Stop all running Windows CE processes
- ///
- private async Task HandleStopAllProcesses()
- {
- try
- {
- var executor = new WindowsCEExecutor();
- var runningProcesses = executor.GetRunningProcesses();
- var activeProcesses = runningProcesses.Where(p => p.IsRunning).ToList();
-
- if (!activeProcesses.Any())
- {
- StatusBarText("No running processes to stop");
- MessageBox.Show("No Windows CE processes are currently running.", "No Active Processes",
- MessageBoxButton.OK, MessageBoxImage.Information);
- return;
- }
-
- var confirmResult = MessageBox.Show(
- $"Stop {activeProcesses.Count} running Windows CE processes?\n\n" +
- string.Join("\n", activeProcesses.Select(p => $"• {Path.GetFileName(p.ExePath)} (Runtime: {p.RunTime.TotalSeconds:F1}s)")),
- "Confirm Stop All Processes",
- MessageBoxButton.YesNo,
- MessageBoxImage.Question);
-
- if (confirmResult == MessageBoxResult.Yes)
- {
- executor.StopAllProcesses();
- StatusBarText($"Stopped {activeProcesses.Count} Windows CE processes");
-
- var logEntries = new List
- {
- "=== Stopped Windows CE Processes ===",
- $"Total Processes Stopped: {activeProcesses.Count}",
- ""
- };
-
- foreach (var proc in activeProcesses)
- {
- logEntries.Add($"• {Path.GetFileName(proc.ExePath)}");
- logEntries.Add($" Process ID: {proc.ProcessId}");
- logEntries.Add($" Runtime: {proc.RunTime.TotalSeconds:F1}s");
- logEntries.Add("");
- }
-
- ShowTextWindow("Stopped Processes", logEntries);
- }
- else
- {
- StatusBarText("Process termination cancelled");
- }
- }
- catch (Exception ex)
- {
- StatusBarText($"Error stopping processes: {ex.Message}");
- MessageBox.Show($"Error stopping processes: {ex.Message}", "Error",
- MessageBoxButton.OK, MessageBoxImage.Error);
- }
-
- await Task.CompletedTask;
- }
-
- ///
- /// Show currently running Windows CE processes
- ///
- private async Task HandleShowRunningProcesses()
- {
- try
- {
- var executor = new WindowsCEExecutor();
- var processes = executor.GetRunningProcesses();
-
- var logEntries = new List
- {
- "=== Windows CE Process Status ===",
- $"Total Processes: {processes.Count}",
- $"Running: {processes.Count(p => p.IsRunning)}",
- $"Stopped: {processes.Count(p => !p.IsRunning)}",
- ""
- };
-
- if (processes.Any())
- {
- logEntries.Add("=== Process Details ===");
- foreach (var proc in processes.OrderByDescending(p => p.IsRunning).ThenBy(p => p.StartTime))
- {
- var status = proc.IsRunning ? "🟢 RUNNING" : "🔴 STOPPED";
- logEntries.Add($"{status} {Path.GetFileName(proc.ExePath)}");
- logEntries.Add($" Process ID: {proc.ProcessId}");
- logEntries.Add($" Architecture: {proc.Architecture}");
- logEntries.Add($" Started: {proc.StartTime:HH:mm:ss}");
-
- if (proc.IsRunning)
- {
- logEntries.Add($" Runtime: {proc.RunTime.TotalSeconds:F1}s");
- }
- else
- {
- logEntries.Add($" Stopped: {proc.StopTime?.ToString("HH:mm:ss") ?? "Unknown"}");
- logEntries.Add($" Exit Code: {proc.ExitCode}");
- logEntries.Add($" Total Runtime: {proc.RunTime.TotalSeconds:F1}s");
- }
-
- logEntries.Add("");
- }
- }
- else
- {
- logEntries.Add("No Windows CE processes have been executed yet.");
- }
-
- ShowTextWindow("Windows CE Process Status", logEntries);
- StatusBarText($"Displayed status for {processes.Count} processes");
- }
- catch (Exception ex)
- {
- StatusBarText($"Error retrieving process status: {ex.Message}");
- MessageBox.Show($"Error retrieving process status: {ex.Message}", "Error",
- MessageBoxButton.OK, MessageBoxImage.Error);
- }
-
- await Task.CompletedTask;
- }
-
- ///
- /// Open process monitor for real-time updates
- ///
- private async Task HandleProcessMonitor()
- {
- try
- {
- StatusBarText("Process monitor not implemented yet - use 'Show Running Processes' for current status");
-
- // For now, just show current status with refresh option
- var choice = MessageBox.Show(
- "Process Monitor is not yet implemented.\n\n" +
- "Would you like to see the current process status instead?",
- "Process Monitor",
- MessageBoxButton.YesNo,
- MessageBoxImage.Information);
-
- if (choice == MessageBoxResult.Yes)
- {
- await HandleShowRunningProcesses();
- }
- }
- catch (Exception ex)
- {
- StatusBarText($"Process monitor error: {ex.Message}");
- }
-
- await Task.CompletedTask;
+ System.Windows.MessageBox.Show("Displaying Interrupts...");
}
}
-}
+}
\ No newline at end of file
From a453749408b56c3cee8c0cc29700b9ef792fbabe Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 9 Jan 2026 23:39:40 -0600
Subject: [PATCH 09/56] Update MainWindow.xaml.cs
---
MainWindow.xaml.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 98fa57f4..96101f7e 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -60,4 +60,4 @@ private void ShowInterrupts_Click(object sender, RoutedEventArgs e)
System.Windows.MessageBox.Show("Displaying Interrupts...");
}
}
-}
\ No newline at end of file
+}
From 944f0e5b19c818102cf6b43644b06f42b56ee924 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 20:08:49 -0600
Subject: [PATCH 10/56] Bump .NET to 8 and add emulation features
Update CI/workflows to use .NET 8.0 and adjust README prerequisites/docs accordingly. Enhance ArmHypervisor: add multiple data-processing opcodes (TST, TEQ, CMN, ORR, BIC, MVN), implement ExecuteLoadStoreMultiple and LDM/STM disassembly. Extend MipsCpuEmulator with J/JAL/JALR-style handlers (j, jal), LUI and SLTI support. Refactor RDKVEmulator to use ArmHypervisor instance (remove raw register/memory management), run the hypervisor on a background thread, and expose hypervisor telemetry (PC/CPSR/instruction count). Misc: minor cleanup of unused usings and diagnostic messages.
---
.github/workflows/build.yml | 2 +-
.github/workflows/ci.yml | 2 +-
.github/workflows/dotnet-desktop-build.yml | 4 +-
ArmHypervisor.cs | 110 +++++++++++++++++++++
MipsCpuEmulator.cs | 45 +++++++++
RDKVEmulator.cs | 91 ++++++-----------
README.md | 8 +-
7 files changed, 195 insertions(+), 67 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 318b5282..56c987ed 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 6.0.x
+ dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ProcessorEmulator.csproj
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a9654729..31b1e599 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,7 +19,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore Processor-Emulator.sln
diff --git a/.github/workflows/dotnet-desktop-build.yml b/.github/workflows/dotnet-desktop-build.yml
index 35d42f4b..960b61ab 100644
--- a/.github/workflows/dotnet-desktop-build.yml
+++ b/.github/workflows/dotnet-desktop-build.yml
@@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '8.0.x'
# Restore NuGet packages before building
- name: Restore packages
run: dotnet restore ProcessorEmulator.csproj
@@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '8.0.x'
# Restore NuGet packages before building
- name: Restore packages
run: dotnet restore ProcessorEmulator.csproj
diff --git a/ArmHypervisor.cs b/ArmHypervisor.cs
index 44c0d6d3..a7f8340c 100644
--- a/ArmHypervisor.cs
+++ b/ArmHypervisor.cs
@@ -162,6 +162,11 @@ private void ExecuteInstruction()
{
executed = ExecuteLoadStore(instruction);
}
+ // Load/Store Multiple Instructions (bits 27-25 = 100)
+ else if ((instruction & 0x0E000000) == 0x08000000)
+ {
+ executed = ExecuteLoadStoreMultiple(instruction);
+ }
// Branch Instructions (bits 27-25 = 101)
else if ((instruction & 0x0E000000) == 0x0A000000)
{
@@ -210,15 +215,41 @@ private bool ExecuteDataProcessing(uint instruction)
result = (uint)addResult;
carryOut = addResult > 0xFFFFFFFF;
break;
+ case 0x8: // TST
+ result = rnValue & operand2;
+ setFlags = true;
+ rd = 16; // Don't write to any register
+ break;
+ case 0x9: // TEQ
+ result = rnValue ^ operand2;
+ setFlags = true;
+ rd = 16; // Don't write to any register
+ break;
case 0xA: // CMP (SUB but don't store result)
result = rnValue - operand2;
carryOut = rnValue >= operand2;
setFlags = true; // CMP always sets flags
rd = 16; // Don't write to any register
break;
+ case 0xB: // CMN
+ long cmnResult = (long)rnValue + operand2;
+ result = (uint)cmnResult;
+ carryOut = cmnResult > 0xFFFFFFFF;
+ setFlags = true;
+ rd = 16; // Don't write to any register
+ break;
+ case 0xC: // ORR
+ result = rnValue | operand2;
+ break;
case 0xD: // MOV
result = operand2;
break;
+ case 0xE: // BIC
+ result = rnValue & ~operand2;
+ break;
+ case 0xF: // MVN
+ result = ~operand2;
+ break;
default:
Debug.WriteLine($"[HV] Unhandled data processing opcode: 0x{opcode:X}");
return false;
@@ -297,6 +328,79 @@ private bool ExecuteLoadStore(uint instruction)
return true;
}
+ private bool ExecuteLoadStoreMultiple(uint instruction)
+ {
+ bool isLoad = (instruction & 0x00100000) != 0; // L bit
+ bool writeBack = (instruction & 0x00200000) != 0; // W bit
+ bool increment = (instruction & 0x00800000) != 0; // U bit
+ bool preIndex = (instruction & 0x01000000) != 0; // P bit
+ uint rn = (instruction >> 16) & 0xF; // Base register
+ uint regList = instruction & 0xFFFF;
+
+ uint address = registers[rn];
+ int regCount = 0;
+ for (int i = 0; i < 16; i++)
+ {
+ if ((regList & (1 << i)) != 0)
+ {
+ regCount++;
+ }
+ }
+
+ if (!increment) // Decrement
+ {
+ address -= (uint)(regCount * 4);
+ }
+ if (preIndex)
+ {
+ if (increment)
+ {
+ address += 4;
+ }
+ else
+ {
+ // address is already correct
+ }
+ }
+
+ for (int i = 0; i < 16; i++)
+ {
+ if ((regList & (1 << i)) != 0)
+ {
+ if (isLoad)
+ {
+ registers[i] = ReadMemory32(address);
+ Debug.WriteLine($"[HV] LDM: R{i} = 0x{registers[i]:X8} from [0x{address:X8}]");
+ }
+ else
+ {
+ WriteMemory32(address, registers[i]);
+ Debug.WriteLine($"[HV] STM: [0x{address:X8}] = 0x{registers[i]:X8}");
+ }
+ address += 4;
+ }
+ }
+
+ if (writeBack)
+ {
+ if (increment)
+ {
+ registers[rn] += (uint)(regCount * 4);
+ }
+ else
+ {
+ registers[rn] -= (uint)(regCount * 4);
+ }
+ }
+
+ if (!isLoad || (regList & (1 << 15)) == 0)
+ {
+ registers[15] += 4;
+ }
+
+ return true;
+ }
+
private bool ExecuteBranch(uint instruction)
{
bool isLink = (instruction & 0x01000000) != 0; // L bit
@@ -452,6 +556,12 @@ private string DecodeInstruction(uint instruction)
return isLoad ? $"LDR R{rd}, [R{rn}]" : $"STR R{rd}, [R{rn}]";
}
+ else if ((instruction & 0x0E000000) == 0x08000000) // Load/Store Multiple
+ {
+ bool isLoad = (instruction & 0x00100000) != 0;
+ uint rn = (instruction >> 16) & 0xF;
+ return isLoad ? $"LDM R{rn}" : $"STM R{rn}";
+ }
else if ((instruction & 0x0E000000) == 0x0A000000) // Branch
{
bool isLink = (instruction & 0x01000000) != 0;
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index f73e045a..6ff8fc01 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -96,12 +96,21 @@ private void DecodeAndExecute(uint instruction)
case 0x00: // R-type instructions
ExecuteRType(instruction);
break;
+ case 0x02: // j
+ ExecuteJ(instruction);
+ break;
+ case 0x03: // jal
+ ExecuteJal(instruction);
+ break;
case 0x10: // COP0 instructions
ExecuteCOP0(instruction);
break;
case 0x08: // addi
ExecuteAddImmediate(instruction);
break;
+ case 0x0A: // slti
+ ExecuteSlti(instruction);
+ break;
case 0x0C: // andi
ExecuteAndImmediate(instruction);
break;
@@ -111,6 +120,9 @@ private void DecodeAndExecute(uint instruction)
case 0x0E: // xori
ExecuteXorImmediate(instruction);
break;
+ case 0x0F: // lui
+ ExecuteLui(instruction);
+ break;
case 0x23: // lw
ExecuteLoadWord(instruction);
break;
@@ -136,6 +148,18 @@ private void DecodeAndExecute(uint instruction)
}
}
+ private void ExecuteJ(uint instruction)
+ {
+ uint target = instruction & 0x3FFFFFF;
+ programCounter = (programCounter & 0xF0000000) | (target << 2);
+ }
+
+ private void ExecuteJal(uint instruction)
+ {
+ registers[31] = programCounter + 4; // Return address is the instruction after the delay slot
+ ExecuteJ(instruction);
+ }
+
// MTC0: Move Control to Coprocessor 0 (Write to CP0)
// Format: mtc0 $rt, $rd
public void Execute_MTC0(uint rt, uint rd)
@@ -231,6 +255,27 @@ private void ExecuteRType(uint instruction)
};
}
+ private void ExecuteLui(uint instruction)
+ {
+ uint rt = (instruction >> 16) & 0x1F;
+ uint imm = instruction & 0xFFFF;
+ if (rt != 0)
+ {
+ registers[rt] = imm << 16;
+ }
+ }
+
+ private void ExecuteSlti(uint instruction)
+ {
+ uint rs = (instruction >> 21) & 0x1F;
+ uint rt = (instruction >> 16) & 0x1F;
+ int imm = (short)(instruction & 0xFFFF);
+ if (rt != 0)
+ {
+ registers[rt] = (int)registers[rs] < imm ? 1u : 0u;
+ }
+ }
+
private void ExecuteLoadWord(uint instruction)
{
uint baseReg = (instruction >> 21) & 0x1F;
diff --git a/RDKVEmulator.cs b/RDKVEmulator.cs
index 129eba00..8173edff 100644
--- a/RDKVEmulator.cs
+++ b/RDKVEmulator.cs
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
-using System.Windows;
using System.Diagnostics;
-using System.IO;
using System.Threading.Tasks;
-using ProcessorEmulator.Tools;
namespace ProcessorEmulator.Emulation
{
@@ -12,7 +9,7 @@ public class RDKVPlatformConfig
{
public string PlatformName { get; set; } // Comcast, Cox, Rogers, Shaw
public string ProcessorType { get; set; } // ARM, MIPS, etc.
- public long MemorySize { get; set; }
+ public long MemorySize { get; set; }
public bool IsDVR { get; set; }
public string FilesystemType { get; set; } // Custom filesystem type
public string DeviceModel { get; set; } // XG1V4, X1, etc.
@@ -36,13 +33,8 @@ public class RDKVEmulator : IChipsetEmulator
{
private readonly RDKVPlatformConfig config;
private byte[] firmwareData;
- private Dictionary mountedPartitions;
private bool isRunning;
-
- // Custom ARM CPU state for real execution
- private uint[] armRegisters = new uint[16]; // R0-R15 (PC is R15)
- private uint armCpsr = 0x10; // Current Program Status Register
- private byte[] hypervisorMemory;
+ private ArmHypervisor hypervisor;
// IChipsetEmulator implementation
public string Name => "RDK-V X1 Platform Emulator";
@@ -53,11 +45,7 @@ public class RDKVEmulator : IChipsetEmulator
public RDKVEmulator()
{
config = RDKVPlatformConfig.CreateArrisXG1V4Config();
- mountedPartitions = new Dictionary();
- hypervisorMemory = new byte[config.MemorySize];
-
- // Initialize ARM registers for boot
- ResetArmCpu();
+ hypervisor = new ArmHypervisor((uint)config.MemorySize);
}
public bool Initialize(string configPath)
@@ -67,50 +55,27 @@ public bool Initialize(string configPath)
Debug.WriteLine($"Config: {configPath ?? "Default"}");
Debug.WriteLine($"Platform: {config.DeviceModel} ({config.PlatformName})");
- ResetArmCpu();
+ Reset();
return true;
}
- public byte[] ReadRegister(long address)
+ public byte[] ReadRegister(long address)
{
- // Read from ARM register or memory-mapped register
- if (address < 16) // ARM general-purpose registers R0-R15
- {
- return BitConverter.GetBytes(armRegisters[address]);
- }
- else if (address < hypervisorMemory.Length)
+ if (address < 16)
{
- // Read from memory-mapped registers
- return new byte[] { hypervisorMemory[address] };
+ return BitConverter.GetBytes(hypervisor.GetRegister((int)address));
}
-
+ // Reading from memory-mapped registers is not implemented in this simplified version
return new byte[0];
}
- public void WriteRegister(long address, byte[] data)
+ public void WriteRegister(long address, byte[] data)
{
- // Write to ARM register or memory-mapped register
- if (address < 16 && data.Length >= 4) // ARM general-purpose registers R0-R15
- {
- armRegisters[address] = BitConverter.ToUInt32(data, 0);
- Debug.WriteLine($"ARM R{address} = 0x{armRegisters[address]:X8}");
- }
- else if (address < hypervisorMemory.Length && data.Length > 0)
+ if (address < 16 && data.Length >= 4)
{
- // Write to memory-mapped registers
- hypervisorMemory[address] = data[0];
+ hypervisor.SetRegister((int)address, BitConverter.ToUInt32(data, 0));
}
- }
-
- private void ResetArmCpu()
- {
- // Clear all ARM registers
- Array.Clear(armRegisters, 0, armRegisters.Length);
-
- // Set up default ARM Cortex-A15 state
- armRegisters[13] = (uint)(config.MemorySize - 0x1000); // Stack pointer (SP)
- armRegisters[15] = 0x00008000; // Program counter (PC) - Linux kernel entry
- armCpsr = 0x10; // User mode, ARM state
+ // Writing to memory-mapped registers is not implemented in this simplified version
}
public void LoadBinary(byte[] data)
@@ -125,7 +90,6 @@ public void LoadBinary(byte[] data)
Debug.WriteLine($"Platform: {config.DeviceModel} ({config.PlatformName})");
Debug.WriteLine($"Target CPU: {config.ProcessorType} ({SupportedArch})");
- // Analyze firmware type
string firmwareType = AnalyzeFirmwareType(data);
Debug.WriteLine($"Firmware Type: {firmwareType}");
}
@@ -174,12 +138,17 @@ public void Run()
try
{
- // Launch the REAL MIPS hypervisor
- var hypervisor = new RealMipsHypervisor();
- _ = Task.Run(async () => await hypervisor.StartEmulation(firmwareData));
+ hypervisor.LoadFirmware(firmwareData, 0x00008000); // Standard Linux kernel entry point
+
+ // Run the hypervisor on a background thread to keep the UI responsive
+ Task.Run(() => {
+ hypervisor.Start();
+ isRunning = false;
+ Debug.WriteLine("✅ ARM Hypervisor execution finished.");
+ });
- Debug.WriteLine("✅ Real MIPS Hypervisor launched successfully");
- Debug.WriteLine("🎯 Real MIPS emulation with native DLL integration");
+ Debug.WriteLine("✅ Real ARM Hypervisor launched successfully");
+ Debug.WriteLine("🎯 Real ARM emulation with custom hypervisor");
Debug.WriteLine("📺 Actual firmware execution - not simulated");
}
catch (Exception ex)
@@ -192,14 +161,18 @@ public void Run()
public void Stop()
{
- isRunning = false;
- Debug.WriteLine("🛑 RDK-V X1 Platform emulation stopped");
+ if (isRunning)
+ {
+ hypervisor.Stop();
+ isRunning = false;
+ Debug.WriteLine("🛑 RDK-V X1 Platform emulation stopped");
+ }
}
public void Reset()
{
Stop();
- ResetArmCpu();
+ hypervisor = new ArmHypervisor((uint)config.MemorySize);
Debug.WriteLine("🔄 RDK-V X1 Platform emulator reset");
}
@@ -212,9 +185,9 @@ public Dictionary GetEmulationState()
["ProcessorType"] = config.ProcessorType,
["MemorySize"] = config.MemorySize,
["IsRunning"] = isRunning,
- ["ARM_PC"] = $"0x{armRegisters[15]:X8}",
- ["ARM_SP"] = $"0x{armRegisters[13]:X8}",
- ["ARM_CPSR"] = $"0x{armCpsr:X8}",
+ ["ARM_PC"] = $"0x{hypervisor.GetPC():X8}",
+ ["ARM_CPSR"] = $"0x{hypervisor.GetCPSR():X8}",
+ ["InstructionCount"] = hypervisor.GetInstructionCount(),
["FirmwareLoaded"] = firmwareData != null,
["FirmwareSize"] = firmwareData?.Length ?? 0
};
diff --git a/README.md b/README.md
index 1508eaf5..1005252e 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,8 @@ This project can extract YAFFS filesystem images using the external `unyaffs` to
## Installation & Quick Start
### Prerequisites
-- **Windows**: .NET 6 or later
-- **Visual Studio**: 2022 or VS Code with C# extension
+- **Windows**: .NET 8 or later
+- **Visual Studio**: 2022 or later, or VS Code with C# extension
- **Optional**: UnicornEngine for enhanced ARM emulation
- **Optional**: RetDec decompiler for cross-architecture binary analysis
@@ -113,7 +113,7 @@ We welcome contributions to enhance the Processor-Emulator project!
1. **Target `dev` branch** for all pull requests
2. **Follow IChipsetEmulator pattern** for new platform emulators
3. **Implement real execution** - avoid synthetic/fake boot sequences
-4. **Test thoroughly** - verify firmware loading and execution on Windows/.NET 6
+- **Test thoroughly** - verify firmware loading and execution on Windows/.NET 8
5. **Document changes** - update README and include screenshots for UI changes
### Code Standards
@@ -202,7 +202,7 @@ This project emphasizes **authentic firmware execution** over simulation:
- Memory-mapped I/O simulation is **PARTIALLY WORKING**
- Large firmware file handling (>100MB) uses **chunked streaming** to avoid .NET limits
- Some advanced features are **WORK IN PROGRESS** - see status indicators above
-- Windows/.NET 6 focused - Linux support not currently implemented
+- Windows/.NET 8 focused - Linux support not currently implemented
## License
From 0be76f4f7a20960b4dca12ab39c3c11b04454996 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:12:20 -0600
Subject: [PATCH 11/56] Downgrade to .NET 5 and add MIPS emulation plumbing
Change CI/workflows, project target and docs to .NET 5 (actions/setup-dotnet versions and ProcessorEmulator TargetFramework, README updates). Add MIPS CP0 register support (EntryHi, EntryLo0, EntryLo1) with read/write handling and logging. Wire basic MIPS emulation into MediaroomBootManager: add using, fields for MipsBus/CP0/MipsCpu, load kernel into emulated memory, set PC/SP, execute a fixed instruction slice, and adjust async loading/registry mounting. Extend MipsCpuEmulator to handle addiu, sllv and srlv instructions. Also move UverseEmulator into ProcessorEmulator.Emulation namespace. These changes set up initial plumbing to run a basic WinCE kernel boot in the MIPS emulator and update build config to .NET 5.
---
.github/workflows/build.yml | 2 +-
.github/workflows/ci.yml | 2 +-
.github/workflows/dotnet-desktop-build.yml | 4 +-
CP0.cs | 47 ++++++++++++++++++++--
MediaroomBootManager.cs | 29 ++++++++++---
MipsCpuEmulator.cs | 9 +++++
ProcessorEmulator.csproj | 2 +-
README.md | 6 +--
UverseEmulator.cs | 3 +-
9 files changed, 85 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 56c987ed..1face64a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.x
+ dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore ProcessorEmulator.csproj
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 31b1e599..4028bf5e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,7 +19,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '5.0.x'
- name: Restore dependencies
run: dotnet restore Processor-Emulator.sln
diff --git a/.github/workflows/dotnet-desktop-build.yml b/.github/workflows/dotnet-desktop-build.yml
index 960b61ab..2ce3a757 100644
--- a/.github/workflows/dotnet-desktop-build.yml
+++ b/.github/workflows/dotnet-desktop-build.yml
@@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '5.0.x'
# Restore NuGet packages before building
- name: Restore packages
run: dotnet restore ProcessorEmulator.csproj
@@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '5.0.x'
# Restore NuGet packages before building
- name: Restore packages
run: dotnet restore ProcessorEmulator.csproj
diff --git a/CP0.cs b/CP0.cs
index 581df780..d71c08f7 100644
--- a/CP0.cs
+++ b/CP0.cs
@@ -5,6 +5,9 @@ namespace ProcessorEmulator.Emulation
public class CP0
{
private uint[] registers = new uint[32];
+ private uint _entryHi;
+ private uint _entryLo0;
+ private uint _entryLo1;
// MIPS CP0 Register Constants
private const int IndexReg = 0;
@@ -30,6 +33,10 @@ public class CP0
public uint EPC { get => registers[EPCReg]; set => registers[EPCReg] = value; }
public uint Count { get => registers[CountReg]; set => registers[CountReg] = value; }
public uint Compare { get => registers[CompareReg]; set => registers[CompareReg] = value; }
+ public uint EntryHi { get => _entryHi; set => _entryHi = value; }
+ public uint EntryLo0 { get => _entryLo0; set => _entryLo0 = value; }
+ public uint EntryLo1 { get => _entryLo1; set => _entryLo1 = value; }
+
public uint PRId { get; set; }
@@ -72,9 +79,26 @@ public void WriteRegister(int reg, uint value)
registers[CauseReg] = (registers[CauseReg] & ~clearMask) | (value & clearMask);
return;
}
-
- Console.WriteLine($"CP0 Write: Reg {reg} = 0x{value:X8}");
- registers[reg] = value;
+
+ switch(reg)
+ {
+ case EntryHiReg:
+ _entryHi = value;
+ Console.WriteLine($"CP0 Write: EntryHi = 0x{value:X8}");
+ break;
+ case EntryLo0Reg:
+ _entryLo0 = value;
+ Console.WriteLine($"CP0 Write: EntryLo0 = 0x{value:X8}");
+ break;
+ case EntryLo1Reg:
+ _entryLo1 = value;
+ Console.WriteLine($"CP0 Write: EntryLo1 = 0x{value:X8}");
+ break;
+ default:
+ Console.WriteLine($"CP0 Write: Reg {reg} = 0x{value:X8}");
+ registers[reg] = value;
+ break;
+ }
}
}
@@ -88,7 +112,22 @@ public uint ReadRegister(int reg)
if (reg >= 0 && reg < 32)
{
- uint value = registers[reg];
+ uint value;
+ switch(reg)
+ {
+ case EntryHiReg:
+ value = _entryHi;
+ break;
+ case EntryLo0Reg:
+ value = _entryLo0;
+ break;
+ case EntryLo1Reg:
+ value = _entryLo1;
+ break;
+ default:
+ value = registers[reg];
+ break;
+ }
// Console.WriteLine($"CP0 Read: Reg {reg} returns 0x{value:X8}"); // Too noisy for timer
return value;
}
diff --git a/MediaroomBootManager.cs b/MediaroomBootManager.cs
index 258f7b5f..1b0a6273 100644
--- a/MediaroomBootManager.cs
+++ b/MediaroomBootManager.cs
@@ -5,6 +5,7 @@
using System.Windows;
using System.Text;
using System.Linq;
+using ProcessorEmulator.Emulation; // Added for MipsCpuEmulator, MipsBus, CP0
namespace ProcessorEmulator
{
@@ -46,6 +47,10 @@ public class MediaroomBootManager
private bool isMediaroomReady = false;
private string baseFirmwarePath;
+ private MipsBus _mipsBus;
+ private CP0 _cp0;
+ private MipsCpuEmulator _mipsCpu;
+
// Boot sequence stages
private enum BootStage
{
@@ -73,6 +78,12 @@ public MediaroomBootManager(string firmwarePath = null)
LogBoot($"Target Platform: AT&T U-verse IPTV");
LogBoot($"Architecture: MIPS + WinCE + Mediaroom");
LogBoot($"Firmware Path: {baseFirmwarePath}");
+
+ // Initialize MIPS emulation components
+ _mipsBus = new MipsBus(RAM_SIZE); // Assuming RAM_SIZE for the bus
+ _cp0 = new CP0();
+ _mipsCpu = new MipsCpuEmulator(_mipsBus, _cp0);
+
}
///
@@ -227,8 +238,16 @@ private async Task BootWinCEKernel()
LogBoot($"Image base: 0x{kernelInfo.ImageBase:X8}");
LogBoot($"Image size: 0x{kernelInfo.ImageSize:X8}");
- // Simulate kernel loading
- await Task.Delay(1000);
+ // Load kernel data into MIPS bus memory
+ _mipsBus.WriteBytes(kernelInfo.ImageBase, kernelData);
+ _mipsCpu.SetRegister(MipsCpuEmulator.Register.PC, kernelInfo.EntryPoint); // Set PC
+ _mipsCpu.SetRegister(MipsCpuEmulator.Register.SP, WINCE_KERNEL_BASE + RAM_SIZE - 0x1000); // Set a basic stack pointer
+
+ LogBoot("🔄 Executing WinCE kernel...");
+ // Execute a fixed number of instructions to simulate initial kernel boot
+ // In a real scenario, this would run until a specific syscall or exception
+ _mipsCpu.Step(100000); // Execute 100,000 MIPS instructions
+
LogBoot("🔄 Loading kernel modules...");
var modules = new[]
@@ -244,16 +263,16 @@ private async Task BootWinCEKernel()
foreach (var module in modules)
{
- await Task.Delay(200);
+ // In a real scenario, these would be loaded by the emulated kernel
+ // and potentially involve more CPU execution.
LogBoot($" ↳ {module}");
}
// Mount registry hive
if (firmwareComponents.ContainsKey("default.hv"))
{
- await Task.Delay(500);
LogBoot("📋 Mounting registry hive...");
- await ParseRegistryHive();
+ await ParseRegistryHive(); // Still async, but doesn't block CPU
}
LogBoot("✅ WinCE kernel boot complete");
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index 6ff8fc01..e088a9ae 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -108,6 +108,9 @@ private void DecodeAndExecute(uint instruction)
case 0x08: // addi
ExecuteAddImmediate(instruction);
break;
+ case 0x09: // addiu
+ ExecuteAddImmediate(instruction); // ADDIU is handled by ADDI logic, no overflow trapping
+ break;
case 0x0A: // slti
ExecuteSlti(instruction);
break;
@@ -243,6 +246,12 @@ private void ExecuteRType(uint instruction)
case 0x02: // srl
registers[rd] = registers[rt] >> (int)shamt;
break;
+ case 0x04: // sllv
+ registers[rd] = registers[rt] << (int)registers[rs];
+ break;
+ case 0x06: // srlv
+ registers[rd] = registers[rt] >> (int)registers[rs];
+ break;
case 0x08: // jr
ExecuteJumpRegister(instruction);
break;
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index 399661d7..f8837a2c 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -2,7 +2,7 @@
WinExe
- net8.0-windows
+ net5.0-windows
true
true
diff --git a/README.md b/README.md
index 1005252e..47c1e079 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ This project can extract YAFFS filesystem images using the external `unyaffs` to
## Installation & Quick Start
### Prerequisites
-- **Windows**: .NET 8 or later
+- **Windows**: .NET 5 or later
- **Visual Studio**: 2022 or later, or VS Code with C# extension
- **Optional**: UnicornEngine for enhanced ARM emulation
- **Optional**: RetDec decompiler for cross-architecture binary analysis
@@ -113,7 +113,7 @@ We welcome contributions to enhance the Processor-Emulator project!
1. **Target `dev` branch** for all pull requests
2. **Follow IChipsetEmulator pattern** for new platform emulators
3. **Implement real execution** - avoid synthetic/fake boot sequences
-- **Test thoroughly** - verify firmware loading and execution on Windows/.NET 8
+- **Test thoroughly** - verify firmware loading and execution on Windows/.NET 5
5. **Document changes** - update README and include screenshots for UI changes
### Code Standards
@@ -202,7 +202,7 @@ This project emphasizes **authentic firmware execution** over simulation:
- Memory-mapped I/O simulation is **PARTIALLY WORKING**
- Large firmware file handling (>100MB) uses **chunked streaming** to avoid .NET limits
- Some advanced features are **WORK IN PROGRESS** - see status indicators above
-- Windows/.NET 8 focused - Linux support not currently implemented
+- Windows/.NET 5 focused - Linux support not currently implemented
## License
diff --git a/UverseEmulator.cs b/UverseEmulator.cs
index d468ec63..352ef13f 100644
--- a/UverseEmulator.cs
+++ b/UverseEmulator.cs
@@ -3,9 +3,8 @@
using System.Threading.Tasks;
using System.IO;
using System.Windows;
-using ProcessorEmulator.Tools;
-namespace ProcessorEmulator
+namespace ProcessorEmulator.Emulation
{
///
/// AT&T U-verse Content and Mediaroom emulator
From 85be0df80ec196d08e258f6b9e3def6112dbf0a2 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:19:54 -0600
Subject: [PATCH 12/56] Update CP0.cs
---
CP0.cs | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
diff --git a/CP0.cs b/CP0.cs
index d71c08f7..b0233f2b 100644
--- a/CP0.cs
+++ b/CP0.cs
@@ -40,6 +40,18 @@ public class CP0
public uint PRId { get; set; }
+ // TLB Entry structure
+ public struct TLBEntry
+ {
+ public uint EntryHi; // Virtual Page Number, ASID, VPN2
+ public uint EntryLo0; // PFN, C, D, V, G for even page
+ public uint EntryLo1; // PFN, C, D, V, G for odd page
+ public uint PageMask; // Page size
+ }
+
+ private const int TLB_ENTRIES = 16; // MIPS typically has 16 or 32 TLB entries
+ private TLBEntry[] _tlb = new TLBEntry[TLB_ENTRIES];
+
// Status Register bits
private const uint STATUS_IE_BIT = 1 << 0; // Interrupt Enable
private const uint STATUS_EXL_BIT = 1 << 1; // Exception Level
@@ -167,5 +179,106 @@ public bool ShouldTriggerInterrupt()
return interruptsEnabled && !inException && (interruptPending & interruptMask) != 0;
}
+
+ // MIPS TLB operations
+
+ ///
+ /// Reads the TLB entry specified by IndexReg into EntryHi, EntryLo0, EntryLo1, and PageMask.
+ ///
+ public void ReadTLBEntry()
+ {
+ int index = (int)(registers[IndexReg] & 0x1F); // Index is 5 bits
+ if (index < TLB_ENTRIES)
+ {
+ EntryHi = _tlb[index].EntryHi;
+ EntryLo0 = _tlb[index].EntryLo0;
+ EntryLo1 = _tlb[index].EntryLo1;
+ registers[PageMaskReg] = _tlb[index].PageMask;
+ Console.WriteLine($"CP0 TLBR: Read TLB entry {index}");
+ }
+ else
+ {
+ Console.WriteLine($"CP0 TLBR: Invalid TLB index {index}");
+ // In a real CPU, this might cause an exception or return garbage.
+ }
+ }
+
+ ///
+ /// Writes EntryHi, EntryLo0, EntryLo1, and PageMask to the TLB entry specified by IndexReg.
+ ///
+ public void WriteTLBEntryIndexed()
+ {
+ int index = (int)(registers[IndexReg] & 0x1F); // Index is 5 bits
+ if (index < TLB_ENTRIES)
+ {
+ _tlb[index].EntryHi = EntryHi;
+ _tlb[index].EntryLo0 = EntryLo0;
+ _tlb[index].EntryLo1 = EntryLo1;
+ _tlb[index].PageMask = registers[PageMaskReg];
+ Console.WriteLine($"CP0 TLBWI: Wrote TLB entry {index}");
+ }
+ else
+ {
+ Console.WriteLine($"CP0 TLBWI: Invalid TLB index {index}");
+ }
+ }
+
+ ///
+ /// Writes EntryHi, EntryLo0, EntryLo1, and PageMask to a random TLB entry.
+ /// (Simplified: for now, it's not truly random, just uses a fixed index after wired entries)
+ ///
+ public void WriteTLBEntryRandom()
+ {
+ // MIPS architecture has 'wired' entries that cannot be overwritten randomly.
+ // For simplicity, we'll assume a fixed set of wired entries (e.g., 0-7)
+ // and use a very simple 'random' for now (e.g., just write to index 8).
+ // A real Random register would decrement and wrap around.
+ int index = 8; // Example: Fixed non-wired entry
+ if (index < TLB_ENTRIES)
+ {
+ _tlb[index].EntryHi = EntryHi;
+ _tlb[index].EntryLo0 = EntryLo0;
+ _tlb[index].EntryLo1 = EntryLo1;
+ _tlb[index].PageMask = registers[PageMaskReg];
+ Console.WriteLine($"CP0 TLBWR: Wrote TLB entry randomly at {index}");
+ }
+ else
+ {
+ Console.WriteLine($"CP0 TLBWR: No random entry available (or TLB_ENTRIES is too small)");
+ }
+ }
+
+ ///
+ /// Searches the TLB for an entry matching EntryHi. If found, its index is written to IndexReg.
+ ///
+ public void ProbeTLB()
+ {
+ // MIPS TLBP instruction uses EntryHi to find a matching entry in the TLB.
+ // If found, Index register is updated with the entry's index.
+ // If not found, the P bit (bit 31) of Index register is set.
+
+ uint vpn2 = (EntryHi >> 13) & 0x7FFFF; // VPN2 from EntryHi (bits 13-31)
+ uint asid = EntryHi & 0xFF; // ASID from EntryHi (bits 0-7)
+
+ for (int i = 0; i < TLB_ENTRIES; i++)
+ {
+ // Extract VPN2 and ASID from stored TLB entry
+ uint tlbVpn2 = (_tlb[i].EntryHi >> 13) & 0x7FFFF;
+ uint tlbAsid = _tlb[i].EntryHi & 0xFF;
+
+ // For simplicity, ignore ASID for now (assume all entries are global or ASID matches)
+ // A real implementation would check the G bit and ASID match
+ if (tlbVpn2 == vpn2) // && (tlbAsid == asid || (_tlb[i].EntryLo0 & 1) != 0 || (_tlb[i].EntryLo1 & 1) != 0)) // Check G bit
+ {
+ registers[IndexReg] = (uint)i;
+ Console.WriteLine($"CP0 TLBP: Found match at index {i}");
+ return;
+ }
+ }
+
+ // No match found, set P bit (bit 31) in IndexReg
+ registers[IndexReg] = 0x80000000;
+ Console.WriteLine("CP0 TLBP: No match found");
+ }
}
}
\ No newline at end of file
From 94ba5934ed744a473ffb74fbf3373f63bf8dabd3 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:19:56 -0600
Subject: [PATCH 13/56] Update MediaroomBootManager.cs
---
MediaroomBootManager.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/MediaroomBootManager.cs b/MediaroomBootManager.cs
index 1b0a6273..8735144d 100644
--- a/MediaroomBootManager.cs
+++ b/MediaroomBootManager.cs
@@ -22,6 +22,9 @@ public class MediaroomBootManager
private const uint MEDIAROOM_BASE = 0x90000000;
private const uint RAM_SIZE = 128 * 1024 * 1024; // 128MB typical for U-verse STB
+ private const uint UART_BASE_ADDRESS = 0xB0000000;
+ private const uint UART_SIZE = 0x1000;
+
// Mediaroom-specific file paths
private readonly Dictionary RequiredFiles = new Dictionary
{
@@ -84,6 +87,9 @@ public MediaroomBootManager(string firmwarePath = null)
_cp0 = new CP0();
_mipsCpu = new MipsCpuEmulator(_mipsBus, _cp0);
+ // Add UART peripheral
+ _mipsBus.AddDevice(new MipsUart(UART_BASE_ADDRESS, UART_SIZE));
+
}
///
From 2ca739ba0c326b46a1b8eabf060708ca390c867d Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:19:59 -0600
Subject: [PATCH 14/56] Update XG1v4Emulator.cs
---
XG1v4Emulator.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/XG1v4Emulator.cs b/XG1v4Emulator.cs
index 75525628..8d13b964 100644
--- a/XG1v4Emulator.cs
+++ b/XG1v4Emulator.cs
@@ -10,7 +10,6 @@
using System.Security.Cryptography.X509Certificates;
using System.Linq;
using ProcessorEmulator.Emulation;
-using ProcessorEmulator.Tools;
namespace ProcessorEmulator
{
From 86a08804cab905987e0e1c2aeba51430bb131b2d Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:20:01 -0600
Subject: [PATCH 15/56] Update UnicornChipsetEmulator.cs
---
Tools/UnicornChipsetEmulator.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Tools/UnicornChipsetEmulator.cs b/Tools/UnicornChipsetEmulator.cs
index 01c88806..88531d0d 100644
--- a/Tools/UnicornChipsetEmulator.cs
+++ b/Tools/UnicornChipsetEmulator.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using ProcessorEmulator.Emulation;
namespace ProcessorEmulator.Tools
{
From 30f79d72806c1d7acfee8fb840c2067c652bd8de Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:20:03 -0600
Subject: [PATCH 16/56] Create MipsUart.cs
---
MipsUart.cs | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
create mode 100644 MipsUart.cs
diff --git a/MipsUart.cs b/MipsUart.cs
new file mode 100644
index 00000000..20ef1c60
--- /dev/null
+++ b/MipsUart.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Diagnostics;
+
+namespace ProcessorEmulator.Emulation
+{
+ ///
+ /// Simulates a basic MIPS UART (Universal Asynchronous Receiver/Transmitter)
+ /// for console output and basic input.
+ /// Implements IBusDevice to be memory-mapped on the MIPS bus.
+ ///
+ public class MipsUart : IBusDevice
+ {
+ public uint StartAddress { get; private set; }
+ public uint Size { get; private set; }
+
+ // Simplified UART registers
+ private const uint UART_DR = 0x0; // Data Register (Read/Write)
+ private const uint UART_SR = 0x4; // Status Register (Read-only for now)
+
+ private const uint STATUS_RX_READY = 0x1;
+ private const uint STATUS_TX_EMPTY = 0x2;
+
+ public MipsUart(uint startAddress, uint size)
+ {
+ StartAddress = startAddress;
+ Size = size;
+ Debug.WriteLine($"[MipsUart] Initialized at 0x{StartAddress:X8} with size 0x{Size:X8}");
+ }
+
+ public uint Read32(uint offset)
+ {
+ switch (offset)
+ {
+ case UART_SR:
+ // Always return TX_EMPTY and RX_READY for simplicity for now
+ return STATUS_RX_READY | STATUS_TX_EMPTY;
+ case UART_DR:
+ // Simulate receiving a character
+ // For now, no actual input. Returns 0.
+ return 0;
+ default:
+ Debug.WriteLine($"[MipsUart] Read from unknown register offset 0x{offset:X} at 0x{StartAddress + offset:X8}");
+ return 0;
+ }
+ }
+
+ public void Write32(uint offset, uint value)
+ {
+ switch (offset)
+ {
+ case UART_DR:
+ // Write to data register, treat as console output
+ Console.Write((char)value);
+ break;
+ default:
+ Debug.WriteLine($"[MipsUart] Write to unknown register offset 0x{offset:X} at 0x{StartAddress + offset:X8} with value 0x{value:X}");
+ break;
+ }
+ }
+
+ public byte Read8(uint offset)
+ {
+ return (byte)(Read32(offset) & 0xFF);
+ }
+
+ public void Write8(uint offset, byte value)
+ {
+ Write32(offset, value);
+ }
+
+ public ushort Read16(uint offset)
+ {
+ return (ushort)(Read32(offset) & 0xFFFF);
+ }
+
+ public void Write16(uint offset, ushort value)
+ {
+ Write32(offset, value);
+ }
+ }
+}
From 866188928d7f6b05918e2e4806812d3a9e00473d Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:20:06 -0600
Subject: [PATCH 17/56] Update MipsCpuEmulator.cs
---
MipsCpuEmulator.cs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index e088a9ae..b5511e20 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -205,6 +205,32 @@ private void ExecuteCOP0(uint instruction)
case 0x04: // MTC0
Execute_MTC0(rt, rd);
break;
+ case 0x10: // TLB operations (and ERET)
+ uint funct = instruction & 0x3F;
+ switch (funct)
+ {
+ case 0x01: // TLBR
+ _cp0.ReadTLBEntry();
+ break;
+ case 0x02: // TLBWI
+ _cp0.WriteTLBEntryIndexed();
+ break;
+ case 0x06: // TLBWR
+ _cp0.WriteTLBEntryRandom();
+ break;
+ case 0x08: // TLBP
+ _cp0.ProbeTLB();
+ break;
+ case 0x18: // ERET
+ // Already handled above, but good to have here for completeness/future refactor
+ _cp0.Status &= ~(1u << 1);
+ programCounter = _cp0.EPC;
+ break;
+ default:
+ TriggerException(10); // Reserved Instruction
+ break;
+ }
+ break;
default:
TriggerException(10); // Reserved Instruction
break;
From b3e1883115baab09d3ccc3f9d9d4268bc45fae27 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:20:08 -0600
Subject: [PATCH 18/56] Update MipsBus.cs
---
MipsBus.cs | 60 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 53 insertions(+), 7 deletions(-)
diff --git a/MipsBus.cs b/MipsBus.cs
index bcd88a91..34d09530 100644
--- a/MipsBus.cs
+++ b/MipsBus.cs
@@ -6,21 +6,67 @@ namespace ProcessorEmulator.Emulation
{
public class MipsBus
{
- public List Devices { get; } = new List();
+ private readonly List _devices = new List();
+ private readonly CP0 _cp0;
public bool IsBigEndian { get; set; } = false;
- public void AddDevice(IBusDevice device) => Devices.Add(device);
+ public MipsBus(CP0 cp0)
+ {
+ _cp0 = cp0;
+ }
+
+ public void AddDevice(IBusDevice device) => _devices.Add(device);
public uint Translate(uint vaddr)
{
- // kseg0 & kseg1 both map to the first 512MB of physical memory
- if (vaddr >= 0x80000000 && vaddr <= 0xBFFFFFFF)
+ // kseg0 (0x80000000 - 0x9FFFFFFF) and kseg1 (0xA0000000 - 0xBFFFFFFF)
+ // are unmapped (direct mapped) physical memory regions.
+ // No TLB lookup for these segments.
+ if ((vaddr >= 0x80000000 && vaddr <= 0x9FFFFFFF) || // kseg0
+ (vaddr >= 0xA0000000 && vaddr <= 0xBFFFFFFF)) // kseg1
{
- return vaddr & 0x1FFFFFFF;
+ return vaddr & 0x1FFFFFFF; // Direct map to lower 512MB physical
}
- // kuseg (0x00000000 - 0x7FFFFFFF)
- // For now, we treat this as a direct map until we finish the TLB
+ // kuseg (0x00000000 - 0x7FFFFFFF) - requires TLB lookup
+ // kseg2 (0xC0000000 - 0xDFFFFFFF) - requires TLB lookup
+ // kseg3 (0xE0000000 - 0xFFFFFFFF) - requires TLB lookup
+
+ // For now, let's focus on kuseg and a very simplified TLB lookup
+ // This is a placeholder for a proper multi-entry TLB
+ // We assume EntryHi holds the VPN and EntryLo0/1 hold the PPNs
+
+ // Simplified: Assume 4KB page size for now
+ const uint PageSize = 4 * 1024; // 4KB
+ const uint PageMask = ~(PageSize - 1); // Mask for page address
+
+ uint vpn = (vaddr & PageMask); // Virtual Page Number
+ uint pageOffset = (vaddr & (PageSize - 1)); // Offset within page
+
+ // Check if the current vaddr matches the EntryHi VPN
+ // In a real TLB, we'd search through multiple entries.
+ // For simplicity, we are assuming EntryHi/Lo registers define the *current* active translation.
+ if ((_cp0.EntryHi & PageMask) == vpn)
+ {
+ // Check if it's an even or odd page
+ // This is simplified and assumes a 2-page entry as defined by EntryLo0/EntryLo1
+ // based on MIPS architecture which typically uses odd/even pages for a single TLB entry
+ if ((vaddr & PageSize) == 0) // Even page
+ {
+ // Check valid and dirty bits if necessary
+ // For now, assume valid. PPN is bits 6-31 of EntryLo0
+ uint ppn = (_cp0.EntryLo0 & PageMask);
+ return ppn | pageOffset;
+ }
+ else // Odd page
+ {
+ uint ppn = (_cp0.EntryLo1 & PageMask);
+ return ppn | pageOffset;
+ }
+ }
+
+ // If no TLB match, or for other segments, for now, treat as direct map.
+ // In a full implementation, this would trigger a TLB Miss exception.
return vaddr;
}
From 5ced05139b3f9263ea35574f70bd8a872a88e9c2 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Wed, 4 Feb 2026 21:20:11 -0600
Subject: [PATCH 19/56] Update IChipsetEmulator.cs
---
IChipsetEmulator.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/IChipsetEmulator.cs b/IChipsetEmulator.cs
index dd4e3b5f..bc50c705 100644
--- a/IChipsetEmulator.cs
+++ b/IChipsetEmulator.cs
@@ -1,4 +1,4 @@
-namespace ProcessorEmulator.Tools
+namespace ProcessorEmulator.Emulation
{
public interface IChipsetEmulator
{
From 8ebc102548be6af5ef898b9bbe31f397937d413a Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 10:17:11 -0600
Subject: [PATCH 20/56] Update IChipsetEmulator.cs
---
IChipsetEmulator.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/IChipsetEmulator.cs b/IChipsetEmulator.cs
index bc50c705..1e025f1c 100644
--- a/IChipsetEmulator.cs
+++ b/IChipsetEmulator.cs
@@ -1,4 +1,4 @@
-namespace ProcessorEmulator.Emulation
+namespace ProcessorEmulator
{
public interface IChipsetEmulator
{
From 3ac83e9d73611612d04376d44a5608ce76eacdb4 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 10:17:14 -0600
Subject: [PATCH 21/56] Update RDKVEmulator.cs
---
RDKVEmulator.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/RDKVEmulator.cs b/RDKVEmulator.cs
index 8173edff..39b47ccc 100644
--- a/RDKVEmulator.cs
+++ b/RDKVEmulator.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
+using ProcessorEmulator; // Added for IChipsetEmulator
namespace ProcessorEmulator.Emulation
{
From 9079d997ed444bdd14581640713e138597b3ab06 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 10:17:19 -0600
Subject: [PATCH 22/56] Update UnicornChipsetEmulator.cs
---
Tools/UnicornChipsetEmulator.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Tools/UnicornChipsetEmulator.cs b/Tools/UnicornChipsetEmulator.cs
index 88531d0d..d07e71d6 100644
--- a/Tools/UnicornChipsetEmulator.cs
+++ b/Tools/UnicornChipsetEmulator.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using ProcessorEmulator.Emulation;
+using ProcessorEmulator; // Added for IChipsetEmulator
namespace ProcessorEmulator.Tools
{
From 98b9b0c8c7e17d2dd85c5f8cc2e38cc0c59f3f46 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 10:17:22 -0600
Subject: [PATCH 23/56] Update UverseEmulator.cs
---
UverseEmulator.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/UverseEmulator.cs b/UverseEmulator.cs
index 352ef13f..ada06375 100644
--- a/UverseEmulator.cs
+++ b/UverseEmulator.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using System.IO;
using System.Windows;
+using ProcessorEmulator; // Added for IChipsetEmulator
namespace ProcessorEmulator.Emulation
{
From 6816c9d133a6176dc69d259d7c6e771038b00e5d Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 14:38:52 -0600
Subject: [PATCH 24/56] Initialize MIPS emulator and add console logging
Instantiate a MIPS CPU emulator and wire its log output to the on-screen serial console. Added using directives for Dispatcher and the emulator namespace, declared a private _emulator field, and subscribe _emulator.OnLogMessage to a new AppendToSerialConsole method that uses Application.Current.Dispatcher.Invoke to perform thread-safe UI updates and auto-scroll the RichTextBox. Also added temporary placeholder classes for MipsBus and CP0 so the emulator can be constructed until proper implementations are provided.
---
MainWindow.xaml.cs | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 96101f7e..18ebc754 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -2,19 +2,49 @@
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
+using System.Windows.Threading; // Added for Dispatcher.Invoke
+using ProcessorEmulator.Emulation; // Added for MipsCpuEmulator
namespace ProcessorEmulator
{
+ // Placeholder for MipsBus - will be properly defined elsewhere
+ public class MipsBus
+ {
+ public uint Read32(uint address) { return 0; } // Placeholder
+ public void Write32(uint address, uint value) { /* Placeholder */ } // Placeholder
+ public uint Translate(uint address) { return address; } // Placeholder
+ }
+
+ // Placeholder for CP0 - will be properly defined elsewhere
+ public class CP0
+ {
+ public bool ShouldTriggerInterrupt() { return false; } // Placeholder
+ public void UpdateTimer(int cycles) { /* Placeholder */ } // Placeholder
+ public uint EPC { get; set; } // Placeholder
+ public uint Cause { get; set; } // Placeholder
+ public uint Status { get; set; } // Placeholder
+ public void ReadTLBEntry() { /* Placeholder */ } // Placeholder
+ public void WriteTLBEntryIndexed() { /* Placeholder */ } // Placeholder
+ public void WriteTLBEntryRandom() { /* Placeholder */ } // Placeholder
+ public void ProbeTLB() { /* Placeholder */ } // Placeholder
+ }
+
public partial class MainWindow : Window
{
// Our WinForms hardware components
private RichTextBox _serialConsole;
private PictureBox _videoDisplay;
+ private MipsCpuEmulator _emulator; // Declared MipsCpuEmulator
public MainWindow()
{
InitializeComponent();
SetupClassicUI();
+
+ // Instantiate MipsCpuEmulator and subscribe to its log event
+ // Using placeholder MipsBus and CP0 for now
+ _emulator = new MipsCpuEmulator(new MipsBus(), new CP0());
+ _emulator.OnLogMessage += AppendToSerialConsole;
}
private void SetupClassicUI()
@@ -44,6 +74,17 @@ private void SetupClassicUI()
MainTabs.TabPages.Add(consolePage);
}
+ private void AppendToSerialConsole(string message)
+ {
+ // Ensure UI update is on the correct thread
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ _serialConsole.AppendText(message);
+ _serialConsole.ScrollToEnd(); // Auto-scroll to the latest message
+ });
+ }
+
+
private void LoadBinary_Click(object sender, RoutedEventArgs e)
{
// Trigger your Smart Loader logic here
From 8c473a4ef8d804906533c7bbaffb435bcc1632ba Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 14:38:59 -0600
Subject: [PATCH 25/56] Update MipsCpuEmulator.cs
---
MipsCpuEmulator.cs | 224 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 172 insertions(+), 52 deletions(-)
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index b5511e20..f364dd16 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Windows;
+using System.Diagnostics; // Added for Debug.WriteLine
namespace ProcessorEmulator.Emulation
{
@@ -13,6 +14,10 @@ public class MipsCpuEmulator
private float[] floatingPointRegisters;
private readonly CP0 _cp0;
private readonly MipsBus _bus;
+ private VirtualRegistry _virtualRegistry; // Declared VirtualRegistry
+ private readonly string _logFilePath;
+
+ public event Action OnLogMessage; // Event for logging to UI
public MipsCpuEmulator(MipsBus bus, CP0 cp0)
{
@@ -21,6 +26,14 @@ public MipsCpuEmulator(MipsBus bus, CP0 cp0)
registers = new uint[RegisterCount];
floatingPointRegisters = new float[RegisterCount];
programCounter = 0xBFC00000; // MIPS Reset Vector
+ _virtualRegistry = new VirtualRegistry(); // Initialized VirtualRegistry
+ _logFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "emulator_log.txt"); // Log file in exe directory
+
+ // Clear log file on startup for fresh session
+ if (File.Exists(_logFilePath))
+ {
+ File.Delete(_logFilePath);
+ }
}
// Execute a single fetch/decode/execute cycle (or multiple cycles)
@@ -75,7 +88,7 @@ private void TriggerException(uint exceptionCode)
private uint FetchInstruction()
{
- uint instruction = _bus.Read32(programCounter);
+ uint instruction = ReadMemory32(programCounter); // Use new ReadMemory32
Console.WriteLine($"PC: 0x{programCounter:X8} -> PADDR: 0x{_bus.Translate(programCounter):X8}, INSTR: 0x{instruction:X8}");
programCounter += 4;
return instruction;
@@ -83,7 +96,52 @@ private uint FetchInstruction()
private uint FetchInstructionAt(uint vaddr)
{
- return _bus.Read32(vaddr);
+ return ReadMemory32(vaddr); // Use new ReadMemory32
+ }
+
+ // MMIO Interceptor
+ private uint ReadMemory32(uint address)
+ {
+ // Handle Hardware-Specific Registers (Broadcom/Mediaroom)
+ if (address >= 0x1F000000 && address <= 0x1F000FFF)
+ {
+ return HandlePeripheralRead(address);
+ }
+
+ // Standard RAM access
+ return _bus.Read32(address);
+ }
+
+ private void WriteMemory32(uint address, uint value)
+ {
+ // Handle Hardware-Specific Registers (Broadcom/Mediaroom)
+ if (address >= 0x1F000000 && address <= 0x1F000FFF)
+ {
+ HandlePeripheralWrite(address, value);
+ return;
+ }
+
+ // Standard RAM access
+ _bus.Write32(address, value);
+ }
+
+ private uint HandlePeripheralRead(uint address)
+ {
+ switch(address)
+ {
+ case 0x1F000020: // Example: Chip ID Register
+ Debug.WriteLine($"[MMIO] Reading Chip ID Register at 0x{address:X8}. Returning 0x7405.");
+ return 0x7405; // Return a Broadcom BCM7405 ID
+ default:
+ Debug.WriteLine($"[MMIO] Unhandled peripheral read at 0x{address:X8}. Returning 0.");
+ return 0;
+ }
+ }
+
+ private void HandlePeripheralWrite(uint address, uint value)
+ {
+ // For now, just log writes to unhandled peripheral registers.
+ Debug.WriteLine($"[MMIO] Unhandled peripheral write to 0x{address:X8} with value 0x{value:X8}.");
}
private void DecodeAndExecute(uint instruction)
@@ -153,60 +211,43 @@ private void DecodeAndExecute(uint instruction)
private void ExecuteJ(uint instruction)
{
+ uint oldPc = programCounter;
uint target = instruction & 0x3FFFFFF;
programCounter = (programCounter & 0xF0000000) | (target << 2);
+ LogBranch(oldPc, programCounter, "J");
}
private void ExecuteJal(uint instruction)
{
+ uint oldPc = programCounter;
registers[31] = programCounter + 4; // Return address is the instruction after the delay slot
ExecuteJ(instruction);
+ LogBranch(oldPc, programCounter, "JAL");
}
- // MTC0: Move Control to Coprocessor 0 (Write to CP0)
- // Format: mtc0 $rt, $rd
- public void Execute_MTC0(uint rt, uint rd)
- {
- uint value = registers[rt]; // Get value from general purpose register
- _cp0.WriteRegister((int)rd, value);
- }
- // MFC0: Move From Coprocessor 0 (Read from CP0)
- // Format: mfc0 $rt, $rd
- public void Execute_MFC0(uint rt, uint rd)
- {
- uint value = _cp0.ReadRegister((int)rd);
- registers[rt] = value; // Put CP0 value into general purpose register
- }
private void ExecuteCOP0(uint instruction)
{
- uint rs = (instruction >> 21) & 0x1F;
-
- // Check for ERET instruction
- if (rs == 0x10 && (instruction & 0x3F) == 0x18)
- {
- // ERET: Exception Return
- // 1. Clear Status.EXL bit
- _cp0.Status &= ~(1u << 1);
- // 2. Jump back to where the exception occurred
- programCounter = _cp0.EPC;
- return;
- }
-
- uint rt = (instruction >> 16) & 0x1F;
- uint rd = (instruction >> 11) & 0x1F;
+ // MIPS COP0 instructions: bits 25-21 determine the sub-operation (rs field)
+ uint rs = (instruction >> 21) & 0x1F;
+ uint rt = (instruction >> 16) & 0x1F; // General purpose register for data transfer
+ uint rd = (instruction >> 11) & 0x1F; // COP0 register index
- switch (rs)
+ // The 'funct' field is only used for R-type COP0 instructions (opcode 0x10, rs == 0x10)
+ uint funct = instruction & 0x3F;
+
+ switch (rs) // The 'rs' field (bits 25-21) defines the major COP0 operation
{
- case 0x00: // MFC0
- Execute_MFC0(rt, rd);
+ case 0x00: // MFC0 (Move From Coprocessor 0)
+ if (rt != 0) registers[rt] = _cp0.ReadRegister((int)rd);
break;
- case 0x04: // MTC0
- Execute_MTC0(rt, rd);
+
+ case 0x04: // MTC0 (Move To Coprocessor 0)
+ _cp0.WriteRegister((int)rd, registers[rt]);
break;
- case 0x10: // TLB operations (and ERET)
- uint funct = instruction & 0x3F;
+
+ case 0x10: // COP0 functions with 'funct' field (e.g., TLB operations, ERET)
switch (funct)
{
case 0x01: // TLBR
@@ -222,16 +263,21 @@ private void ExecuteCOP0(uint instruction)
_cp0.ProbeTLB();
break;
case 0x18: // ERET
- // Already handled above, but good to have here for completeness/future refactor
+ // ERET: Exception Return
+ // 1. Clear Status.EXL bit
_cp0.Status &= ~(1u << 1);
+ // 2. Jump back to where the exception occurred
programCounter = _cp0.EPC;
break;
default:
+ System.Diagnostics.Debug.WriteLine($"[MIPS] Unhandled COP0 funct: 0x{funct:X}");
TriggerException(10); // Reserved Instruction
break;
}
break;
+
default:
+ System.Diagnostics.Debug.WriteLine($"[MIPS] Unhandled COP0 sub-op (rs field): 0x{rs:X}");
TriggerException(10); // Reserved Instruction
break;
}
@@ -282,7 +328,7 @@ private void ExecuteRType(uint instruction)
ExecuteJumpRegister(instruction);
break;
case 0x0C: // syscall
- TriggerException(8); // Syscall exception
+ ExecuteSyscall(instruction); // Call the new ExecuteSyscall method
break;
default:
TriggerException(10); // Reserved Instruction
@@ -290,6 +336,49 @@ private void ExecuteRType(uint instruction)
};
}
+ private void ExecuteSyscall(uint instruction)
+ {
+ // MIPS convention: $v0 (register 2) holds the syscall ID.
+ uint syscallCode = registers[2];
+ LogSyscall(syscallCode, instruction); // Log the syscall
+
+ switch (syscallCode)
+ {
+ case 0x1D: // Hypothetical WinCE RegQueryValueExW
+ // Assuming $a0 (register 4) holds the address of the path string.
+ // This is a simplification; a real implementation would parse the string from memory.
+ // For now, we'll hardcode to the "IsAuthorized" key for demonstration.
+ registers[2] = _virtualRegistry.ReadValue("Software\\Microsoft\\Mediaroom\\Client\\IsAuthorized");
+ Debug.WriteLine($"[AUTH] App checked 'IsAuthorized' registry key via syscall 0x{syscallCode:X}. Returning: {registers[2]}");
+ break;
+ case 0x1001: // Hypothetical: Mediaroom Auth Check
+ SimulateAuthSuccess();
+ break;
+ case 0x2002: // Hypothetical: Graphics Draw (Placeholder)
+ RenderToWindowsForm();
+ break;
+ default:
+ Debug.WriteLine($"[MIPS] Unhandled Syscall: 0x{syscallCode:X}. Instruction: 0x{instruction:X8}");
+ // Optionally, trigger an exception or just return.
+ // For now, we'll just log and continue to avoid halting emulation.
+ break;
+ }
+ }
+
+ private void SimulateAuthSuccess()
+ {
+ // Tell the MIPS app: "Yes, this device is authorized"
+ registers[2] = 1; // Return true/success in $v0
+ registers[3] = 0; // Clear error codes in $v1
+ Debug.WriteLine("[AUTH] Spoofed Authorization Handshake: SUCCESS");
+ }
+
+ private void RenderToWindowsForm()
+ {
+ // Placeholder for future graphics rendering logic.
+ Debug.WriteLine("[GRAPHICS] RenderToWindowsForm: (Not yet implemented)");
+ }
+
private void ExecuteLui(uint instruction)
{
uint rt = (instruction >> 16) & 0x1F;
@@ -320,7 +409,7 @@ private void ExecuteLoadWord(uint instruction)
uint address = registers[baseReg] + (uint)offset;
if (rt != 0) // writes to R0 are discarded
{
- registers[rt] = _bus.Read32(address);
+ registers[rt] = ReadMemory32(address); // Use new ReadMemory32
}
}
@@ -331,43 +420,46 @@ private void ExecuteStoreWord(uint instruction)
int offset = (short)(instruction & 0xFFFF);
uint address = registers[baseReg] + (uint)offset;
- _bus.Write32(address, registers[rt]);
+ WriteMemory32(address, registers[rt]); // Use new WriteMemory32
}
private void ExecuteBranchEqual(uint instruction)
{
- // Note: This is a simplified implementation that does NOT handle the branch delay slot correctly
- // for exceptions. A full implementation would require more complex pipeline management.
uint rs = (instruction >> 21) & 0x1F;
uint rt = (instruction >> 16) & 0x1F;
- int offset = (short)(instruction & 0xFFFF);
-
- uint branchPC = programCounter; // PC is already advanced to next instruction
+ short offset = (short)(instruction & 0xFFFF); // Sign-extended offset
+
if (registers[rs] == registers[rt])
{
- programCounter = (branchPC) + (uint)(offset << 2);
+ uint oldPc = programCounter;
+ // MIPS branches are PC-relative: PC + 4 + (offset << 2)
+ // We use +4 because the PC has already advanced or is at the delay slot
+ programCounter += (uint)(offset << 2);
+ LogBranch(oldPc, programCounter, "BEQ");
}
}
private void ExecuteBranchNotEqual(uint instruction)
{
- // Note: Simplified implementation without correct delay slot exception handling.
uint rs = (instruction >> 21) & 0x1F;
uint rt = (instruction >> 16) & 0x1F;
- int offset = (short)(instruction & 0xFFFF);
+ short offset = (short)(instruction & 0xFFFF);
- uint branchPC = programCounter;
if (registers[rs] != registers[rt])
{
- programCounter = (branchPC) + (uint)(offset << 2);
+ uint oldPc = programCounter;
+ programCounter += (uint)(offset << 2);
+ LogBranch(oldPc, programCounter, "BNE");
}
}
private void ExecuteJumpRegister(uint instruction)
{
+ uint oldPc = programCounter;
// Note: Simplified implementation without correct delay slot exception handling.
uint rs = (instruction >> 21) & 0x1F;
programCounter = registers[rs];
+ LogBranch(oldPc, programCounter, "JR");
}
private static void HandleEmulatorError(string message)
@@ -433,5 +525,33 @@ public void SetRegister(int index, uint value)
}
public uint ProgramCounter => programCounter;
+
+ private void LogSyscall(uint syscallCode, uint instruction)
+ {
+ try
+ {
+ string logEntry = $"[SYSCALL] PC: 0x{programCounter:X8}, Syscall ID: 0x{syscallCode:X}, Instruction: 0x{instruction:X8}, R2($v0): 0x{registers[2]:X8}, R3($v1): 0x{registers[3]:X8}\n";
+ File.AppendAllText(_logFilePath, logEntry);
+ OnLogMessage?.Invoke(logEntry); // Invoke the event for UI
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine($"Error writing to syscall log: {ex.Message}");
+ }
+ }
+
+ private void LogBranch(uint oldPc, uint newPc, string branchType)
+ {
+ try
+ {
+ string logEntry = $"[BRANCH] PC (Before): 0x{oldPc:X8}, PC (After): 0x{newPc:X8}, Type: {branchType}\n";
+ File.AppendAllText(_logFilePath, logEntry);
+ OnLogMessage?.Invoke(logEntry); // Invoke the event for UI
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine($"Error writing to branch log: {ex.Message}");
+ }
+ }
}
}
\ No newline at end of file
From 0fef970ea66b75d224e44eb8cc2aae986557d2f0 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 14:39:04 -0600
Subject: [PATCH 26/56] Create VirtualRegistry.cs
---
VirtualRegistry.cs | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 VirtualRegistry.cs
diff --git a/VirtualRegistry.cs b/VirtualRegistry.cs
new file mode 100644
index 00000000..eec1e7c6
--- /dev/null
+++ b/VirtualRegistry.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+public class VirtualRegistry
+{
+ private Dictionary _hklm = new Dictionary();
+
+ public VirtualRegistry()
+ {
+ // Mediaroom often looks for these specific "Authorized" indicators
+ _hklm[@"Software\Microsoft\Mediaroom\Client\IsAuthorized"] = 1;
+ _hklm[@"Software\Microsoft\Mediaroom\Client\ProvisioningState"] = "Provisioned";
+ _hklm[@"Software\Microsoft\Mediaroom\Client\AccountGuid"] = "00000000-0000-0000-0000-000000000001";
+ _hklm[@"Hardware\SerialNumber"] = "SPOOFED12345";
+ }
+
+ public uint ReadValue(string path)
+ {
+ if (_hklm.ContainsKey(path))
+ {
+ var val = _hklm[path];
+ Debug.WriteLine($"[VirtualRegistry] Reading path '{path}', returning: {val}");
+ return val is int ? (uint)(int)val : 1; // Default to success for non-int values
+ }
+ Debug.WriteLine($"[VirtualRegistry] Path '{path}' not found. Returning 0.");
+ return 0; // Not found
+ }
+}
\ No newline at end of file
From efb6ff5ac570a6dc27b282b33246e184caeb085b Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:16:48 -0600
Subject: [PATCH 27/56] I give up
I dont have a clue what im doing this entire project is vibe coded and has becoem a mssive clusterfuck
---
App.xaml.cs | 2 +-
.../obj/BoltDemo.csproj.nuget.dgspec.json | 22 +----
.../obj/BoltDemo.csproj.nuget.g.props | 2 +-
.../obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs | 2 +-
.../net6.0/BoltDemo.AssemblyInfoInputs.cache | 2 +-
....GeneratedMSBuildEditorConfig.editorconfig | 2 +
.../Debug/net6.0/BoltDemo.GlobalUsings.g.cs | 14 +--
.../obj/Debug/net6.0/BoltDemo.assets.cache | Bin 152 -> 152 bytes
BoltDemo_Standalone/obj/project.assets.json | 28 +-----
BoltDemo_Standalone/obj/project.nuget.cache | 9 +-
Core/BaseIrExecutor.cs | 9 +-
Core/CpuState.cs | 6 +-
Core/IntermediateRepresentation.cs | 13 +++
DiscoveryDevice.cs | 1 +
MainWindow.cs | 88 ++++++++++++++++++
MainWindow.xaml.cs | 58 +++++-------
MipsCpuEmulator.cs | 8 +-
ProcessorEmulator.csproj | 6 +-
18 files changed, 168 insertions(+), 104 deletions(-)
create mode 100644 MainWindow.cs
diff --git a/App.xaml.cs b/App.xaml.cs
index 126bc3e1..074582d3 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -8,7 +8,7 @@
namespace ProcessorEmulator
{
- public partial class App : Application
+ public partial class App : System.Windows.Application
{
private static string StartupLogPath => System.IO.Path.Combine(System.IO.Path.GetTempPath(), "ProcessorEmulator_startup.log");
private static void Log(string line)
diff --git a/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.dgspec.json b/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.dgspec.json
index a5c10c37..5ae41b4f 100644
--- a/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.dgspec.json
+++ b/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.dgspec.json
@@ -38,7 +38,7 @@
"auditLevel": "low",
"auditMode": "direct"
},
- "SdkAnalysisLevel": "9.0.300"
+ "SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"net6.0": {
@@ -54,30 +54,12 @@
],
"assetTargetFallback": true,
"warn": true,
- "downloadDependencies": [
- {
- "name": "Microsoft.AspNetCore.App.Ref",
- "version": "[6.0.36, 6.0.36]"
- },
- {
- "name": "Microsoft.NETCore.App.Host.win-x64",
- "version": "[6.0.36, 6.0.36]"
- },
- {
- "name": "Microsoft.NETCore.App.Ref",
- "version": "[6.0.36, 6.0.36]"
- },
- {
- "name": "Microsoft.WindowsDesktop.App.Ref",
- "version": "[6.0.36, 6.0.36]"
- }
- ],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
- "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.300\\RuntimeIdentifierGraph.json"
+ "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.102\\RuntimeIdentifierGraph.json"
}
}
}
diff --git a/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.g.props b/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.g.props
index 4f31cb6c..f6a6ccb9 100644
--- a/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.g.props
+++ b/BoltDemo_Standalone/obj/BoltDemo.csproj.nuget.g.props
@@ -7,7 +7,7 @@
$(UserProfile)\.nuget\packages\
C:\Users\juler\.nuget\packages\
PackageReference
- 6.14.0
+ 7.0.0
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
index 3e48d297..662800a2 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
@@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+804bf781e2247bc2d60c687463eb00bdc6855b4e")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0fef970ea66b75d224e44eb8cc2aae986557d2f0")]
[assembly: System.Reflection.AssemblyProductAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyTitleAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
index 4c0f813c..a3c822de 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
@@ -1 +1 @@
-c8b6793e0acd9d438065242c46ec4e0309651be119b1a9ed9ffd903db716a9c8
+7afc21c9d54785501b637ce251e8be7117aad765325dad9a47d30b9c65b2ae6d
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GeneratedMSBuildEditorConfig.editorconfig b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GeneratedMSBuildEditorConfig.editorconfig
index 9d2239a4..62a2decb 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GeneratedMSBuildEditorConfig.editorconfig
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GeneratedMSBuildEditorConfig.editorconfig
@@ -1,5 +1,7 @@
is_global = true
build_property.TargetFramework = net6.0
+build_property.TargetFrameworkIdentifier = .NETCoreApp
+build_property.TargetFrameworkVersion = v6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GlobalUsings.g.cs b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GlobalUsings.g.cs
index 8578f3d0..d12bcbc7 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GlobalUsings.g.cs
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.GlobalUsings.g.cs
@@ -1,8 +1,8 @@
//
-global using global::System;
-global using global::System.Collections.Generic;
-global using global::System.IO;
-global using global::System.Linq;
-global using global::System.Net.Http;
-global using global::System.Threading;
-global using global::System.Threading.Tasks;
+global using System;
+global using System.Collections.Generic;
+global using System.IO;
+global using System.Linq;
+global using System.Net.Http;
+global using System.Threading;
+global using System.Threading.Tasks;
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.assets.cache b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.assets.cache
index bdf2aca5f6e667e23a299d7d9414f3ae98426f90..fa72048686f692d019d698e50d7078484a7422d4 100644
GIT binary patch
delta 55
zcmV-70LcHC0hj?PP)kQa3;+NC+oB~d)Y?(UHuhsKP+SFwcg _registers = new Dictionary(StringComparer.OrdinalIgnoreCase);
- private readonly List _memoryMap;
- private readonly Dictionary _ramRegions = new Dictionary();
+ private readonly List _memoryMap;
+ private readonly Dictionary _ramRegions = new Dictionary();
public int PrivilegeLevel { get; set; }
public ulong PC { get; set; }
- public IReadOnlyList MemoryMap => _memoryMap;
+ public IReadOnlyList MemoryMap => _memoryMap;
public bool IsLittleEndian { get; }
public ulong? LinkedAddress { get; set; }
diff --git a/Core/IntermediateRepresentation.cs b/Core/IntermediateRepresentation.cs
index e4458569..33bc832e 100644
--- a/Core/IntermediateRepresentation.cs
+++ b/Core/IntermediateRepresentation.cs
@@ -4,6 +4,19 @@
namespace ProcessorEmulator.Core
{
+ ///
+ /// Minimal IR value representation used for immediates inside the IR.
+ /// This is a lightweight wrapper to allow the rest of the IR code to compile.
+ ///
+ public readonly struct IrValue
+ {
+ public readonly long SignedValue;
+ public readonly ulong UnsignedValue;
+ public IrValue(long v) { SignedValue = v; UnsignedValue = (ulong)v; }
+ public IrValue(ulong v) { UnsignedValue = v; SignedValue = (long)v; }
+ public override string ToString() => SignedValue.ToString();
+ }
+
///
/// Defines the type of an IR operand.
///
diff --git a/DiscoveryDevice.cs b/DiscoveryDevice.cs
index c36f18f9..02c6ea9a 100644
--- a/DiscoveryDevice.cs
+++ b/DiscoveryDevice.cs
@@ -1,4 +1,5 @@
using System;
+using ProcessorEmulator.Emulation;
namespace ProcessorEmulator
{
diff --git a/MainWindow.cs b/MainWindow.cs
new file mode 100644
index 00000000..d37cc2c3
--- /dev/null
+++ b/MainWindow.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Drawing;
+using System.Windows;
+using System.Windows.Forms;
+using System.Windows.Threading; // Added for Dispatcher.Invoke
+using ProcessorEmulator.Emulation; // Added for MipsCpuEmulator
+
+namespace ProcessorEmulator
+{
+ // Use the real MipsBus and CP0 implementations from ProcessorEmulator.Emulation
+
+ public partial class MainWindow : Window
+ {
+ // Our WinForms hardware components
+ private RichTextBox _serialConsole;
+ private PictureBox _videoDisplay;
+ private MipsCpuEmulator _emulator; // Declared MipsCpuEmulator
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ SetupClassicUI();
+
+ // Instantiate real CP0 and MipsBus, then create the emulator and subscribe to logs
+ var cp0 = new CP0();
+ var bus = new MipsBus(cp0);
+ _emulator = new MipsCpuEmulator(bus, cp0);
+ _emulator.OnLogMessage += AppendToSerialConsole;
+ }
+
+ private void SetupClassicUI()
+ {
+ // 1. Create the Video Tab (The XP/7 Pro look)
+ TabPage videoPage = new TabPage("Video Output");
+ _videoDisplay = new PictureBox {
+ Dock = DockStyle.Fill,
+ BackColor = System.Drawing.Color.Black,
+ SizeMode = PictureBoxSizeMode.CenterImage
+ };
+ videoPage.Controls.Add(_videoDisplay);
+
+ // 2. Create the Serial Console Tab (The Terminal look)
+ TabPage consolePage = new TabPage("System Console");
+ _serialConsole = new RichTextBox {
+ Dock = DockStyle.Fill,
+ BackColor = System.Drawing.Color.Black,
+ ForeColor = System.Drawing.Color.Lime,
+ Font = new System.Drawing.Font("Lucida Console", 9f),
+ ReadOnly = true
+ };
+ consolePage.Controls.Add(_serialConsole);
+
+ // Add them to the WindowsFormsHost container
+ MainTabs.TabPages.Add(videoPage);
+ MainTabs.TabPages.Add(consolePage);
+ }
+
+ private void AppendToSerialConsole(string message)
+ {
+ // Ensure UI update is on the correct thread
+ // Use the WPF Dispatcher from this Window to avoid ambiguous 'Application' type
+ this.Dispatcher.Invoke(() =>
+ {
+ _serialConsole.AppendText(message);
+ // WinForms.RichTextBox doesn't have ScrollToEnd; use ScrollToCaret after moving selection
+ _serialConsole.SelectionStart = _serialConsole.Text.Length;
+ _serialConsole.ScrollToCaret(); // Auto-scroll to the latest message
+ });
+ }
+
+
+ private void LoadBinary_Click(object sender, RoutedEventArgs e)
+ {
+ // Trigger your Smart Loader logic here
+ StatusText.Text = "Loading Binary...";
+ }
+
+ private void Exit_Click(object sender, RoutedEventArgs e) => this.Close();
+
+ private void ShowMemoryMap_Click(object sender, RoutedEventArgs e) =>
+ System.Windows.MessageBox.Show("Displaying Resource Map...");
+
+ private void ShowInterrupts_Click(object sender, RoutedEventArgs e)
+ {
+ System.Windows.MessageBox.Show("Displaying Interrupts...");
+ }
+ }
+}
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 18ebc754..fc47a34e 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -1,39 +1,19 @@
using System;
using System.Drawing;
using System.Windows;
-using System.Windows.Forms;
+using WinForms = System.Windows.Forms;
using System.Windows.Threading; // Added for Dispatcher.Invoke
using ProcessorEmulator.Emulation; // Added for MipsCpuEmulator
namespace ProcessorEmulator
{
- // Placeholder for MipsBus - will be properly defined elsewhere
- public class MipsBus
- {
- public uint Read32(uint address) { return 0; } // Placeholder
- public void Write32(uint address, uint value) { /* Placeholder */ } // Placeholder
- public uint Translate(uint address) { return address; } // Placeholder
- }
-
- // Placeholder for CP0 - will be properly defined elsewhere
- public class CP0
- {
- public bool ShouldTriggerInterrupt() { return false; } // Placeholder
- public void UpdateTimer(int cycles) { /* Placeholder */ } // Placeholder
- public uint EPC { get; set; } // Placeholder
- public uint Cause { get; set; } // Placeholder
- public uint Status { get; set; } // Placeholder
- public void ReadTLBEntry() { /* Placeholder */ } // Placeholder
- public void WriteTLBEntryIndexed() { /* Placeholder */ } // Placeholder
- public void WriteTLBEntryRandom() { /* Placeholder */ } // Placeholder
- public void ProbeTLB() { /* Placeholder */ } // Placeholder
- }
+ // Use the real MipsBus and CP0 implementations from ProcessorEmulator.Emulation
public partial class MainWindow : Window
{
// Our WinForms hardware components
- private RichTextBox _serialConsole;
- private PictureBox _videoDisplay;
+ private WinForms.RichTextBox _serialConsole;
+ private WinForms.PictureBox _videoDisplay;
private MipsCpuEmulator _emulator; // Declared MipsCpuEmulator
public MainWindow()
@@ -41,28 +21,29 @@ public MainWindow()
InitializeComponent();
SetupClassicUI();
- // Instantiate MipsCpuEmulator and subscribe to its log event
- // Using placeholder MipsBus and CP0 for now
- _emulator = new MipsCpuEmulator(new MipsBus(), new CP0());
+ // Instantiate real CP0 and MipsBus, then create the emulator and subscribe to logs
+ var cp0 = new CP0();
+ var bus = new MipsBus(cp0);
+ _emulator = new MipsCpuEmulator(bus, cp0);
_emulator.OnLogMessage += AppendToSerialConsole;
}
private void SetupClassicUI()
{
// 1. Create the Video Tab (The XP/7 Pro look)
- TabPage videoPage = new TabPage("Video Output");
- _videoDisplay = new PictureBox {
- Dock = DockStyle.Fill,
+ WinForms.TabPage videoPage = new WinForms.TabPage("Video Output");
+ _videoDisplay = new WinForms.PictureBox {
+ Dock = WinForms.DockStyle.Fill,
BackColor = System.Drawing.Color.Black,
- SizeMode = PictureBoxSizeMode.CenterImage
+ SizeMode = WinForms.PictureBoxSizeMode.CenterImage
};
videoPage.Controls.Add(_videoDisplay);
// 2. Create the Serial Console Tab (The Terminal look)
- TabPage consolePage = new TabPage("System Console");
- _serialConsole = new RichTextBox {
- Dock = DockStyle.Fill,
- BackColor = System.Drawing.Color.Black,
+ WinForms.TabPage consolePage = new WinForms.TabPage("System Console");
+ _serialConsole = new WinForms.RichTextBox {
+ Dock = WinForms.DockStyle.Fill,
+ BackColor = System.Drawing.Color.Black,
ForeColor = System.Drawing.Color.Lime,
Font = new System.Drawing.Font("Lucida Console", 9f),
ReadOnly = true
@@ -77,10 +58,13 @@ private void SetupClassicUI()
private void AppendToSerialConsole(string message)
{
// Ensure UI update is on the correct thread
- Application.Current.Dispatcher.Invoke(() =>
+ // Use the WPF Dispatcher from this Window to avoid ambiguous 'Application' type
+ this.Dispatcher.Invoke(() =>
{
_serialConsole.AppendText(message);
- _serialConsole.ScrollToEnd(); // Auto-scroll to the latest message
+ // WinForms.RichTextBox doesn't have ScrollToEnd; use ScrollToCaret after moving selection
+ _serialConsole.SelectionStart = _serialConsole.Text.Length;
+ _serialConsole.ScrollToCaret(); // Auto-scroll to the latest message
});
}
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index f364dd16..c92e2004 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -19,6 +19,9 @@ public class MipsCpuEmulator
public event Action OnLogMessage; // Event for logging to UI
+ // Event for console-like output (guest prints)
+ public event Action? OnConsoleOutput;
+
public MipsCpuEmulator(MipsBus bus, CP0 cp0)
{
_bus = bus;
@@ -355,7 +358,10 @@ private void ExecuteSyscall(uint instruction)
SimulateAuthSuccess();
break;
case 0x2002: // Hypothetical: Graphics Draw (Placeholder)
- RenderToWindowsForm();
+ RenderToWindowsForm();
+ // Emit a console-visible message for now so UI can show progress
+ OnLogMessage?.Invoke($"[SYSCALL] Graphics/Print invoked at PC=0x{programCounter:X8} (code 0x{syscallCode:X})\n");
+ OnConsoleOutput?.Invoke($"[GUEST_PRINT] PC=0x{programCounter:X8} syscall=0x{syscallCode:X}\n");
break;
default:
Debug.WriteLine($"[MIPS] Unhandled Syscall: 0x{syscallCode:X}. Instruction: 0x{instruction:X8}");
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index f8837a2c..d3fa9985 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -2,7 +2,8 @@
WinExe
- net5.0-windows
+ net6.0-windows
+ enable
true
true
@@ -40,6 +41,9 @@
+
+
+
From 2d14a338775cc41442f41aa6007fe3adb2c0242f Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:27:47 -0600
Subject: [PATCH 28/56] Update BoltDemo.AssemblyInfo.cs
---
BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
index 662800a2..44d6d031 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
@@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0fef970ea66b75d224e44eb8cc2aae986557d2f0")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+efb6ff5ac570a6dc27b282b33246e184caeb085b")]
[assembly: System.Reflection.AssemblyProductAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyTitleAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
From be1b634aae85ed737b3038fa46a061ef7a655b06 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:27:49 -0600
Subject: [PATCH 29/56] Update BoltDemo.AssemblyInfoInputs.cache
---
.../obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
index a3c822de..091050ab 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
@@ -1 +1 @@
-7afc21c9d54785501b637ce251e8be7117aad765325dad9a47d30b9c65b2ae6d
+6da485e424b54c7b02b977455c32e103cebf85960b904a5f27f8d1724387e6da
From 75e7a15735197ae8ef8914e68d829b6b6f32a216 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:27:53 -0600
Subject: [PATCH 30/56] Update CpuState.cs
---
Core/CpuState.cs | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/Core/CpuState.cs b/Core/CpuState.cs
index 5a953afb..9bf867bc 100644
--- a/Core/CpuState.cs
+++ b/Core/CpuState.cs
@@ -31,6 +31,31 @@ public CpuState(List memoryMap, bool isLittleEndian, ulong startPC
}
}
+ // Compatibility overload: accept legacy ProcessorEmulator.MemoryRegion array
+ public CpuState(ProcessorEmulator.MemoryRegion[] legacyMemoryMap, bool isLittleEndian, ulong startPC = 0)
+ {
+ var converted = new List();
+ if (legacyMemoryMap != null)
+ {
+ foreach (var lm in legacyMemoryMap)
+ {
+ ulong start = lm.BaseAddress;
+ ulong size = lm.Size;
+ var name = $"LEGACY_{start:X}";
+ converted.Add(new ProcessorEmulator.Core.Emulation.MemoryRegion(name, start, size, ProcessorEmulator.Core.Emulation.MemoryRegionType.RAM));
+ }
+ }
+
+ _memoryMap = converted;
+ IsLittleEndian = isLittleEndian;
+ PC = startPC;
+
+ foreach (var ramRegion in _memoryMap.Where(r => r.Type == MemoryRegionType.RAM))
+ {
+ _ramRegions[ramRegion] = new byte[ramRegion.Size];
+ }
+ }
+
public ulong GetRegister(string name, BitWidth width)
{
_registers.TryGetValue(name, out ulong value);
From bb595ee8af7c71160d22a83047ce44d46db42a9a Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:27:56 -0600
Subject: [PATCH 31/56] Update HypervisorWindow.xaml.cs
---
HypervisorWindow.xaml.cs | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/HypervisorWindow.xaml.cs b/HypervisorWindow.xaml.cs
index a71b79e2..31f4e7bf 100644
--- a/HypervisorWindow.xaml.cs
+++ b/HypervisorWindow.xaml.cs
@@ -9,7 +9,7 @@ public partial class HypervisorWindow : Window
{
private readonly RealMipsHypervisor hypervisor;
private TextBox logBox;
- private TextBlock statusText;
+ private TextBox statusText;
private Button startButton;
private Button stopButton;
@@ -45,35 +45,44 @@ private void CreateUI()
Content = mainStack;
// Title
- var titleText = new TextBlock
+ var titleText = new TextBox
{
Text = "REAL MIPS EMULATOR",
FontSize = 36,
FontWeight = FontWeights.Bold,
Foreground = System.Windows.Media.Brushes.White,
HorizontalAlignment = HorizontalAlignment.Center,
- Margin = new Thickness(0, 20, 0, 0)
+ Margin = new Thickness(0, 20, 0, 0),
+ Background = System.Windows.Media.Brushes.Transparent,
+ BorderThickness = new Thickness(0),
+ IsReadOnly = true
};
mainStack.Children.Add(titleText);
// Subtitle
- var subtitleText = new TextBlock
+ var subtitleText = new TextBox
{
Text = "AT&T U-verse / Microsoft Mediaroom",
FontSize = 16,
Foreground = System.Windows.Media.Brushes.Gray,
- HorizontalAlignment = HorizontalAlignment.Center
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Background = System.Windows.Media.Brushes.Transparent,
+ BorderThickness = new Thickness(0),
+ IsReadOnly = true
};
mainStack.Children.Add(subtitleText);
// Status
- statusText = new TextBlock
+ statusText = new TextBox
{
Text = "Initializing...",
FontSize = 14,
Foreground = System.Windows.Media.Brushes.Yellow,
HorizontalAlignment = HorizontalAlignment.Center,
- Margin = new Thickness(0, 10, 0, 0)
+ Margin = new Thickness(0, 10, 0, 0),
+ Background = System.Windows.Media.Brushes.Transparent,
+ BorderThickness = new Thickness(0),
+ IsReadOnly = true
};
mainStack.Children.Add(statusText);
From 2307ae003dfc502c7ef6c7032bd9c408fb7e1039 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:27:58 -0600
Subject: [PATCH 32/56] Update MipsBus.cs
---
MipsBus.cs | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/MipsBus.cs b/MipsBus.cs
index 34d09530..5b6f8998 100644
--- a/MipsBus.cs
+++ b/MipsBus.cs
@@ -15,6 +15,15 @@ public MipsBus(CP0 cp0)
_cp0 = cp0;
}
+ // Convenience constructor used by older code paths that pass a RAM size.
+ public MipsBus(uint ramSize)
+ {
+ var cp0 = new CP0();
+ _cp0 = cp0;
+ // Create a RAM region starting at physical 0 of the provided size
+ AddDevice(new RamDevice(0, ramSize));
+ }
+
public void AddDevice(IBusDevice device) => _devices.Add(device);
public uint Translate(uint vaddr)
@@ -144,5 +153,16 @@ public void LoadData(uint paddr, byte[] data)
throw new Exception($"Cannot load data into device at address 0x{paddr:X8}");
}
}
+
+ // Compatibility helper: write a sequence of bytes to a virtual address.
+ // Some callers (boot managers) expect a WriteBytes method to bulk-load images.
+ public void WriteBytes(uint vaddr, byte[] data)
+ {
+ if (data == null) throw new ArgumentNullException(nameof(data));
+ for (int i = 0; i < data.Length; i++)
+ {
+ Write8(vaddr + (uint)i, data[i]);
+ }
+ }
}
}
\ No newline at end of file
From 348ad4ff6ae336572b94b135add70fbcfabcdab5 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:28:00 -0600
Subject: [PATCH 33/56] Update MipsCpuEmulator.cs
---
MipsCpuEmulator.cs | 96 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index c92e2004..4b12c737 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -7,6 +7,19 @@ namespace ProcessorEmulator.Emulation
{
public class MipsCpuEmulator
{
+ public enum Register
+ {
+ PC,
+ SP,
+ RA = 31,
+ V0 = 2,
+ V1 = 3,
+ A0 = 4,
+ A1 = 5,
+ A2 = 6,
+ A3 = 7
+ }
+
private const int RegisterCount = 32;
private uint[] registers;
@@ -39,6 +52,26 @@ public MipsCpuEmulator(MipsBus bus, CP0 cp0)
}
}
+ // Parameterless constructor for legacy callers (InstructionDispatcher, tests, etc.)
+ public MipsCpuEmulator()
+ {
+ var cp0 = new CP0();
+ var bus = new MipsBus(cp0);
+
+ _bus = bus;
+ _cp0 = cp0;
+ registers = new uint[RegisterCount];
+ floatingPointRegisters = new float[RegisterCount];
+ programCounter = 0xBFC00000; // MIPS Reset Vector
+ _virtualRegistry = new VirtualRegistry();
+ _logFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "emulator_log.txt");
+
+ if (File.Exists(_logFilePath))
+ {
+ File.Delete(_logFilePath);
+ }
+ }
+
// Execute a single fetch/decode/execute cycle (or multiple cycles)
public void Step(int count = 1)
{
@@ -530,6 +563,62 @@ public void SetRegister(int index, uint value)
registers[index] = value;
}
+ // Convenience helpers for callers that reference named registers (used by boot manager code)
+ public uint GetRegister(Register reg)
+ {
+ switch (reg)
+ {
+ case Register.PC: return programCounter;
+ case Register.SP: return registers[29];
+ case Register.RA: return registers[31];
+ case Register.V0: return registers[2];
+ case Register.V1: return registers[3];
+ default:
+ // For argument registers and others, map where possible
+ return reg switch
+ {
+ Register.A0 => registers[4],
+ Register.A1 => registers[5],
+ Register.A2 => registers[6],
+ Register.A3 => registers[7],
+ _ => 0u
+ };
+ }
+ }
+
+ public void SetRegister(Register reg, uint value)
+ {
+ switch (reg)
+ {
+ case Register.PC:
+ programCounter = value;
+ break;
+ case Register.SP:
+ registers[29] = value;
+ break;
+ case Register.RA:
+ registers[31] = value;
+ break;
+ case Register.V0:
+ registers[2] = value;
+ break;
+ case Register.V1:
+ registers[3] = value;
+ break;
+ case Register.A0:
+ registers[4] = value; break;
+ case Register.A1:
+ registers[5] = value; break;
+ case Register.A2:
+ registers[6] = value; break;
+ case Register.A3:
+ registers[7] = value; break;
+ default:
+ // no-op for unknown/unused named registers
+ break;
+ }
+ }
+
public uint ProgramCounter => programCounter;
private void LogSyscall(uint syscallCode, uint instruction)
@@ -559,5 +648,12 @@ private void LogBranch(uint oldPc, uint newPc, string branchType)
Debug.WriteLine($"Error writing to branch log: {ex.Message}");
}
}
+
+ // Public wrapper used by other components to dispatch a single instruction
+ // This allows InstructionDispatcher to forward instructions to this emulator.
+ public void DispatchInstruction(uint instruction, string sourceArch)
+ {
+ DecodeAndExecute(instruction);
+ }
}
}
\ No newline at end of file
From 6cd19b0a8f8547181e7805e28cdff252d7aa134b Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:28:03 -0600
Subject: [PATCH 34/56] Update ProcessorEmulator.csproj
---
ProcessorEmulator.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index d3fa9985..24a864f2 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -1,4 +1,4 @@
-
+
WinExe
From 6648b1de36cc0a9f5e3079ac9e5ffb41fd88d551 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:28:42 -0600
Subject: [PATCH 35/56] Update CpuState.cs
---
Core/CpuState.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Core/CpuState.cs b/Core/CpuState.cs
index 9bf867bc..cea3e37b 100644
--- a/Core/CpuState.cs
+++ b/Core/CpuState.cs
@@ -18,9 +18,9 @@ public class CpuState : ICpuState, IMemoryManager
public bool IsLittleEndian { get; }
public ulong? LinkedAddress { get; set; }
- public CpuState(List memoryMap, bool isLittleEndian, ulong startPC = 0)
+ public CpuState(List memoryMap, bool isLittleEndian, ulong startPC = 0)
{
- _memoryMap = memoryMap ?? new List();
+ _memoryMap = memoryMap ?? new List();
IsLittleEndian = isLittleEndian;
PC = startPC;
@@ -67,27 +67,27 @@ public void SetRegister(string name, ulong value, BitWidth width)
_registers[name] = value;
}
- private MemoryRegion HandleLazyAllocation(ulong address)
+ private ProcessorEmulator.Core.Emulation.MemoryRegion HandleLazyAllocation(ulong address)
{
const ulong pageSize = 4096;
ulong startAddress = address / pageSize * pageSize; // Align to 4KB boundary
Console.WriteLine($"[ADAPTIVE BUS]: New memory region discovered at 0x{address:X}. Mapping temporary 4KB RAM at 0x{startAddress:X}.");
- var newRegion = new MemoryRegion($"RAM_Lazy_{startAddress:X}", startAddress, pageSize, MemoryRegionType.RAM);
+ var newRegion = new ProcessorEmulator.Core.Emulation.MemoryRegion($"RAM_Lazy_{startAddress:X}", startAddress, pageSize, ProcessorEmulator.Core.Emulation.MemoryRegionType.RAM);
_memoryMap.Add(newRegion);
_ramRegions[newRegion] = new byte[pageSize];
return newRegion;
}
- private (MemoryRegion region, byte[] buffer) GetRegionAndBufferForAddress(ulong address)
+ private (ProcessorEmulator.Core.Emulation.MemoryRegion region, byte[] buffer) GetRegionAndBufferForAddress(ulong address)
{
foreach (var region in _memoryMap)
{
if (region.Contains(address))
{
- if (region.Type == MemoryRegionType.RAM)
+ if (region.Type == ProcessorEmulator.Core.Emulation.MemoryRegionType.RAM)
{
return (region, _ramRegions[region]);
}
From dab710f4d1fe9cc472e7189de13ab5ac855b6139 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:46:11 -0600
Subject: [PATCH 36/56] Update EmulatorConsole.cs
---
EmulatorConsole.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/EmulatorConsole.cs b/EmulatorConsole.cs
index 02ad71b2..56593d2b 100644
--- a/EmulatorConsole.cs
+++ b/EmulatorConsole.cs
@@ -41,6 +41,12 @@ public void AppendText(string text)
_terminal.ScrollToCaret();
}
+ // Append a single character (used as a callback from UART/OnCharReceived)
+ public void AppendChar(char c)
+ {
+ AppendText(c.ToString());
+ }
+
// Intercepts key presses to send to the emulated UART.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
From e955c1597239dd4927b77523e42269658800614c Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:46:13 -0600
Subject: [PATCH 37/56] Update MipsBus.cs
---
MipsBus.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/MipsBus.cs b/MipsBus.cs
index 5b6f8998..e84016a9 100644
--- a/MipsBus.cs
+++ b/MipsBus.cs
@@ -10,6 +10,13 @@ public class MipsBus
private readonly CP0 _cp0;
public bool IsBigEndian { get; set; } = false;
+ // Parameterless ctor for legacy callers that expect `new MipsBus()`
+ public MipsBus()
+ {
+ var cp0 = new CP0();
+ _cp0 = cp0;
+ }
+
public MipsBus(CP0 cp0)
{
_cp0 = cp0;
@@ -26,6 +33,9 @@ public MipsBus(uint ramSize)
public void AddDevice(IBusDevice device) => _devices.Add(device);
+ // Expose devices collection for legacy callers
+ public IEnumerable Devices => _devices;
+
public uint Translate(uint vaddr)
{
// kseg0 (0x80000000 - 0x9FFFFFFF) and kseg1 (0xA0000000 - 0xBFFFFFFF)
From d412a2db9338e403b110c9538e3327c59ef7b2e2 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:46:16 -0600
Subject: [PATCH 38/56] Update MipsCpuEmulator.cs
---
MipsCpuEmulator.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/MipsCpuEmulator.cs b/MipsCpuEmulator.cs
index 4b12c737..5dc69048 100644
--- a/MipsCpuEmulator.cs
+++ b/MipsCpuEmulator.cs
@@ -655,5 +655,15 @@ public void DispatchInstruction(uint instruction, string sourceArch)
{
DecodeAndExecute(instruction);
}
+
+ // Simple run loop used by legacy callers that expect a continuous emulation.
+ // Runs until the hosting thread is aborted or an exception occurs.
+ public void Run()
+ {
+ while (true)
+ {
+ Step(1);
+ }
+ }
}
}
\ No newline at end of file
From 5a129cbc21192ed26d49fd6ae0e28daab19ef49a Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:55:59 -0600
Subject: [PATCH 39/56] Create HypervisorWindow.cs
---
HypervisorWindow.cs | 193 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 193 insertions(+)
create mode 100644 HypervisorWindow.cs
diff --git a/HypervisorWindow.cs b/HypervisorWindow.cs
new file mode 100644
index 00000000..060e1632
--- /dev/null
+++ b/HypervisorWindow.cs
@@ -0,0 +1,193 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Threading;
+
+namespace ProcessorEmulator
+{
+ public partial class HypervisorWindow : Window
+ {
+ private readonly RealMipsHypervisor hypervisor;
+ private TextBox logBox;
+ private TextBox statusText;
+ private Button startButton;
+ private Button stopButton;
+
+ // Parameterless constructor for XAML designer and tooling
+ public HypervisorWindow()
+ {
+ InitializeComponent();
+ this.hypervisor = new RealMipsHypervisor();
+ this.Title = "Real MIPS Hypervisor";
+
+ CreateUI();
+ this.hypervisor.OnRealExecution += AppendLog;
+ }
+
+ public HypervisorWindow(RealMipsHypervisor hypervisor, string platformName)
+ {
+ InitializeComponent();
+ this.hypervisor = hypervisor ?? new RealMipsHypervisor();
+ this.Title = $"Real MIPS Hypervisor - {platformName}";
+
+ CreateUI();
+ this.hypervisor.OnRealExecution += AppendLog;
+ }
+
+ // Constructor for backward compatibility
+ public HypervisorWindow(object legacyHypervisor, string platformName)
+ {
+ // Create new real hypervisor if old one is passed
+ this.hypervisor = new RealMipsHypervisor();
+ this.Title = $"Real MIPS Hypervisor - {platformName}";
+
+ CreateUI();
+ this.hypervisor.OnRealExecution += AppendLog;
+ }
+
+ private void CreateUI()
+ {
+ // Set window properties directly
+ Width = 800;
+ Height = 600;
+ Background = System.Windows.Media.Brushes.Black;
+ WindowStartupLocation = WindowStartupLocation.CenterOwner;
+
+ var mainStack = new StackPanel();
+ Content = mainStack;
+
+ // Title
+ var titleText = new TextBox
+ {
+ Text = "REAL MIPS EMULATOR",
+ FontSize = 36,
+ FontWeight = FontWeights.Bold,
+ Foreground = System.Windows.Media.Brushes.White,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Margin = new Thickness(0, 20, 0, 0),
+ Background = System.Windows.Media.Brushes.Transparent,
+ BorderThickness = new Thickness(0),
+ IsReadOnly = true
+ };
+ mainStack.Children.Add(titleText);
+
+ // Subtitle
+ var subtitleText = new TextBox
+ {
+ Text = "AT&T U-verse / Microsoft Mediaroom",
+ FontSize = 16,
+ Foreground = System.Windows.Media.Brushes.Gray,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Background = System.Windows.Media.Brushes.Transparent,
+ BorderThickness = new Thickness(0),
+ IsReadOnly = true
+ };
+ mainStack.Children.Add(subtitleText);
+
+ // Status
+ statusText = new TextBox
+ {
+ Text = "Initializing...",
+ FontSize = 14,
+ Foreground = System.Windows.Media.Brushes.Yellow,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Margin = new Thickness(0, 10, 0, 0),
+ Background = System.Windows.Media.Brushes.Transparent,
+ BorderThickness = new Thickness(0),
+ IsReadOnly = true
+ };
+ mainStack.Children.Add(statusText);
+
+ // Log area
+ var border = new Border
+ {
+ BorderThickness = new Thickness(2),
+ BorderBrush = System.Windows.Media.Brushes.Gray,
+ Margin = new Thickness(10),
+ Background = System.Windows.Media.Brushes.Black
+ };
+ mainStack.Children.Add(border);
+
+ var scrollViewer = new ScrollViewer
+ {
+ VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
+ HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
+ };
+ border.Child = scrollViewer;
+
+ logBox = new TextBox
+ {
+ Background = System.Windows.Media.Brushes.Black,
+ Foreground = System.Windows.Media.Brushes.LightGreen,
+ IsReadOnly = true,
+ TextWrapping = TextWrapping.Wrap,
+ FontFamily = new System.Windows.Media.FontFamily("Consolas"),
+ BorderThickness = new Thickness(0),
+ AcceptsReturn = true
+ };
+ scrollViewer.Content = logBox;
+
+ // Buttons
+ var buttonStack = new StackPanel
+ {
+ Orientation = Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Margin = new Thickness(0, 10, 0, 10)
+ };
+ mainStack.Children.Add(buttonStack);
+
+ startButton = new Button
+ {
+ Content = "Start U-verse",
+ Width = 120,
+ Margin = new Thickness(5)
+ };
+ startButton.Click += Start_Click;
+ buttonStack.Children.Add(startButton);
+
+ stopButton = new Button
+ {
+ Content = "Stop",
+ Width = 100,
+ Margin = new Thickness(5),
+ IsEnabled = false
+ };
+ stopButton.Click += Stop_Click;
+ buttonStack.Children.Add(stopButton);
+ }
+
+ private void AppendLog(string message)
+ {
+ // Marshal to UI thread
+ Dispatcher.Invoke(() =>
+ {
+ var timestamp = DateTime.Now.ToString("HH:mm:ss");
+ logBox.AppendText($"[{timestamp}] {message}\n");
+ logBox.ScrollToEnd();
+ statusText.Text = message;
+ });
+ }
+
+ private async void Start_Click(object sender, RoutedEventArgs e)
+ {
+ startButton.IsEnabled = false;
+ stopButton.IsEnabled = true;
+
+ // Start real U-verse emulation
+ bool success = await hypervisor.StartEmulation();
+ if (!success)
+ {
+ AppendLog("❌ Failed to start U-verse emulation");
+ startButton.IsEnabled = true;
+ stopButton.IsEnabled = false;
+ }
+ }
+
+ private void Stop_Click(object sender, RoutedEventArgs e)
+ {
+ hypervisor.StopEmulation();
+ startButton.IsEnabled = true;
+ stopButton.IsEnabled = false;
+ }
+ }
+}
From ddb55e70b2ba700308c966bf3d8946df894d0e43 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:56:03 -0600
Subject: [PATCH 40/56] Update HypervisorWindow.xaml.cs
---
HypervisorWindow.xaml.cs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/HypervisorWindow.xaml.cs b/HypervisorWindow.xaml.cs
index 31f4e7bf..060e1632 100644
--- a/HypervisorWindow.xaml.cs
+++ b/HypervisorWindow.xaml.cs
@@ -13,9 +13,21 @@ public partial class HypervisorWindow : Window
private Button startButton;
private Button stopButton;
+ // Parameterless constructor for XAML designer and tooling
+ public HypervisorWindow()
+ {
+ InitializeComponent();
+ this.hypervisor = new RealMipsHypervisor();
+ this.Title = "Real MIPS Hypervisor";
+
+ CreateUI();
+ this.hypervisor.OnRealExecution += AppendLog;
+ }
+
public HypervisorWindow(RealMipsHypervisor hypervisor, string platformName)
{
- this.hypervisor = hypervisor;
+ InitializeComponent();
+ this.hypervisor = hypervisor ?? new RealMipsHypervisor();
this.Title = $"Real MIPS Hypervisor - {platformName}";
CreateUI();
From fc122d91e45e05ad832061b6ede52fdab9d56aba Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:56:28 -0600
Subject: [PATCH 41/56] Update ProcessorEmulator.csproj
---
ProcessorEmulator.csproj | 51 ++++------------------------------------
1 file changed, 4 insertions(+), 47 deletions(-)
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index 24a864f2..6002b012 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -1,54 +1,11 @@
-
+
WinExe
- net6.0-windows
- enable
+ net8.0-windows
true
-
- true
- true
- ProcessorEmulator
- ProcessorEmulator
-
- false
-
- false
+ enable
+ enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From 187ac425064b726dc40d4106b50b9f7235d04bac Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 15:56:34 -0600
Subject: [PATCH 42/56] Update HypervisorWindow.xaml.cs
---
HypervisorWindow.xaml.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/HypervisorWindow.xaml.cs b/HypervisorWindow.xaml.cs
index 060e1632..3b11e2d7 100644
--- a/HypervisorWindow.xaml.cs
+++ b/HypervisorWindow.xaml.cs
@@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
+using System.Windows.Media;
namespace ProcessorEmulator
{
From f9c308750146306d7c8dee6f81658ff6c18c28e1 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 16:01:10 -0600
Subject: [PATCH 43/56] Update HypervisorWindow.cs
---
HypervisorWindow.cs | 198 ++------------------------------------------
1 file changed, 7 insertions(+), 191 deletions(-)
diff --git a/HypervisorWindow.cs b/HypervisorWindow.cs
index 060e1632..f1c3d96a 100644
--- a/HypervisorWindow.cs
+++ b/HypervisorWindow.cs
@@ -1,193 +1,9 @@
-using System;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Threading;
+// This file was a duplicate of the XAML-backed code-behind and has been
+// emptied to avoid ambiguous partial-class definitions. The real implementation
+// lives in HypervisorWindow.xaml.cs which is generated/maintained for the
+// XAML-backed window. Keeping an empty placeholder file prevents accidental
+// reintroduction of duplicate members while preserving repository history.
-namespace ProcessorEmulator
-{
- public partial class HypervisorWindow : Window
- {
- private readonly RealMipsHypervisor hypervisor;
- private TextBox logBox;
- private TextBox statusText;
- private Button startButton;
- private Button stopButton;
+// If you need to add non-XAML partial members for `HypervisorWindow`, add
+// only methods or properties that don't duplicate generated members.
- // Parameterless constructor for XAML designer and tooling
- public HypervisorWindow()
- {
- InitializeComponent();
- this.hypervisor = new RealMipsHypervisor();
- this.Title = "Real MIPS Hypervisor";
-
- CreateUI();
- this.hypervisor.OnRealExecution += AppendLog;
- }
-
- public HypervisorWindow(RealMipsHypervisor hypervisor, string platformName)
- {
- InitializeComponent();
- this.hypervisor = hypervisor ?? new RealMipsHypervisor();
- this.Title = $"Real MIPS Hypervisor - {platformName}";
-
- CreateUI();
- this.hypervisor.OnRealExecution += AppendLog;
- }
-
- // Constructor for backward compatibility
- public HypervisorWindow(object legacyHypervisor, string platformName)
- {
- // Create new real hypervisor if old one is passed
- this.hypervisor = new RealMipsHypervisor();
- this.Title = $"Real MIPS Hypervisor - {platformName}";
-
- CreateUI();
- this.hypervisor.OnRealExecution += AppendLog;
- }
-
- private void CreateUI()
- {
- // Set window properties directly
- Width = 800;
- Height = 600;
- Background = System.Windows.Media.Brushes.Black;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
-
- var mainStack = new StackPanel();
- Content = mainStack;
-
- // Title
- var titleText = new TextBox
- {
- Text = "REAL MIPS EMULATOR",
- FontSize = 36,
- FontWeight = FontWeights.Bold,
- Foreground = System.Windows.Media.Brushes.White,
- HorizontalAlignment = HorizontalAlignment.Center,
- Margin = new Thickness(0, 20, 0, 0),
- Background = System.Windows.Media.Brushes.Transparent,
- BorderThickness = new Thickness(0),
- IsReadOnly = true
- };
- mainStack.Children.Add(titleText);
-
- // Subtitle
- var subtitleText = new TextBox
- {
- Text = "AT&T U-verse / Microsoft Mediaroom",
- FontSize = 16,
- Foreground = System.Windows.Media.Brushes.Gray,
- HorizontalAlignment = HorizontalAlignment.Center,
- Background = System.Windows.Media.Brushes.Transparent,
- BorderThickness = new Thickness(0),
- IsReadOnly = true
- };
- mainStack.Children.Add(subtitleText);
-
- // Status
- statusText = new TextBox
- {
- Text = "Initializing...",
- FontSize = 14,
- Foreground = System.Windows.Media.Brushes.Yellow,
- HorizontalAlignment = HorizontalAlignment.Center,
- Margin = new Thickness(0, 10, 0, 0),
- Background = System.Windows.Media.Brushes.Transparent,
- BorderThickness = new Thickness(0),
- IsReadOnly = true
- };
- mainStack.Children.Add(statusText);
-
- // Log area
- var border = new Border
- {
- BorderThickness = new Thickness(2),
- BorderBrush = System.Windows.Media.Brushes.Gray,
- Margin = new Thickness(10),
- Background = System.Windows.Media.Brushes.Black
- };
- mainStack.Children.Add(border);
-
- var scrollViewer = new ScrollViewer
- {
- VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
- HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
- };
- border.Child = scrollViewer;
-
- logBox = new TextBox
- {
- Background = System.Windows.Media.Brushes.Black,
- Foreground = System.Windows.Media.Brushes.LightGreen,
- IsReadOnly = true,
- TextWrapping = TextWrapping.Wrap,
- FontFamily = new System.Windows.Media.FontFamily("Consolas"),
- BorderThickness = new Thickness(0),
- AcceptsReturn = true
- };
- scrollViewer.Content = logBox;
-
- // Buttons
- var buttonStack = new StackPanel
- {
- Orientation = Orientation.Horizontal,
- HorizontalAlignment = HorizontalAlignment.Center,
- Margin = new Thickness(0, 10, 0, 10)
- };
- mainStack.Children.Add(buttonStack);
-
- startButton = new Button
- {
- Content = "Start U-verse",
- Width = 120,
- Margin = new Thickness(5)
- };
- startButton.Click += Start_Click;
- buttonStack.Children.Add(startButton);
-
- stopButton = new Button
- {
- Content = "Stop",
- Width = 100,
- Margin = new Thickness(5),
- IsEnabled = false
- };
- stopButton.Click += Stop_Click;
- buttonStack.Children.Add(stopButton);
- }
-
- private void AppendLog(string message)
- {
- // Marshal to UI thread
- Dispatcher.Invoke(() =>
- {
- var timestamp = DateTime.Now.ToString("HH:mm:ss");
- logBox.AppendText($"[{timestamp}] {message}\n");
- logBox.ScrollToEnd();
- statusText.Text = message;
- });
- }
-
- private async void Start_Click(object sender, RoutedEventArgs e)
- {
- startButton.IsEnabled = false;
- stopButton.IsEnabled = true;
-
- // Start real U-verse emulation
- bool success = await hypervisor.StartEmulation();
- if (!success)
- {
- AppendLog("❌ Failed to start U-verse emulation");
- startButton.IsEnabled = true;
- stopButton.IsEnabled = false;
- }
- }
-
- private void Stop_Click(object sender, RoutedEventArgs e)
- {
- hypervisor.StopEmulation();
- startButton.IsEnabled = true;
- stopButton.IsEnabled = false;
- }
- }
-}
From ba717d190018a2b7da8d97c735cf994d369f2bd2 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 17:50:19 -0600
Subject: [PATCH 44/56] Update MainWindow.xaml
---
MainWindow.xaml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 44c3af91..75a8bda3 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
+ xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
Title="MIPS Universal Emulator" Height="750" Width="1100"
Background="#F0F0F0" WindowStartupLocation="CenterScreen">
@@ -25,9 +26,9 @@
-
+
-
+
From 771d45452fcc8b10e4c9dc1f14c193c6daa7ba1b Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 17:51:52 -0600
Subject: [PATCH 45/56] Update ProcessorEmulator.csproj
---
ProcessorEmulator.csproj | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index 6002b012..ee1a7d35 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -4,6 +4,8 @@
WinExe
net8.0-windows
true
+ true
+ false
enable
enable
From f5fa26d977407573dc40af91e57e4acfe67c1b02 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 18:26:17 -0600
Subject: [PATCH 46/56] Update Win7Chrome.cs
---
Win7Chrome.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Win7Chrome.cs b/Win7Chrome.cs
index a2cd5124..0360a533 100644
--- a/Win7Chrome.cs
+++ b/Win7Chrome.cs
@@ -63,7 +63,7 @@ private static void ToggleMaxRestore(Window w)
w.WindowState = w.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
}
- public static Brush GenerateNoiseBrush(int size = 64, byte alpha = 18)
+ public static System.Windows.Media.Brush GenerateNoiseBrush(int size = 64, byte alpha = 18)
{
var wb = new WriteableBitmap(size, size, 96, 96, PixelFormats.Bgra32, null);
int stride = size * 4;
From 1465a1de8720f769fb38c8de7bbcccb0e199c953 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 18:26:22 -0600
Subject: [PATCH 47/56] Update ProcessorEmulator.csproj
---
ProcessorEmulator.csproj | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index ee1a7d35..ceb9985a 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -10,4 +10,18 @@
enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 2decb704b13ca9dc54f44fc303027476fc15c53a Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Thu, 5 Feb 2026 18:26:33 -0600
Subject: [PATCH 48/56] Update .gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index db046cb0..5091d2ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,4 @@ MipsBranchTest/obj/Debug/net6.0-windows/MipsBranchTest.csproj.FileListAbsolute.t
*.ps1
/.vscode
.geminiignore
+duplicate_definitions_report.md
From f0c97b77590945c191666871c4311470c0b7a181 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 10:37:52 -0600
Subject: [PATCH 49/56] Update SyncScheduler.cs
---
Emulation/SyncEngine/SyncScheduler.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Emulation/SyncEngine/SyncScheduler.cs b/Emulation/SyncEngine/SyncScheduler.cs
index 7923a74a..96c179c0 100644
--- a/Emulation/SyncEngine/SyncScheduler.cs
+++ b/Emulation/SyncEngine/SyncScheduler.cs
@@ -16,7 +16,7 @@ public class SyncScheduler
private readonly EntitlementManager entitlementManager;
private readonly CMTSResponder cmtsResponder;
- private readonly Timer syncTimer;
+ private readonly System.Threading.Timer syncTimer;
private readonly List syncHistory;
private bool isRunning;
private CancellationTokenSource cancellationTokenSource;
@@ -34,7 +34,7 @@ public SyncScheduler()
cancellationTokenSource = new CancellationTokenSource();
// Start sync timer (runs every 30 minutes)
- syncTimer = new Timer(OnSyncTimer, null, TimeSpan.Zero, TimeSpan.FromMinutes(30));
+ syncTimer = new System.Threading.Timer(OnSyncTimer, null, TimeSpan.Zero, TimeSpan.FromMinutes(30));
Debug.WriteLine("[SyncScheduler] Sync scheduler initialized");
}
From 7a47de25eecb09486b5429e0a96d3006c83f7d8e Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 10:37:55 -0600
Subject: [PATCH 50/56] Update ProcessorEmulator.csproj
---
ProcessorEmulator.csproj | 1 +
1 file changed, 1 insertion(+)
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index ceb9985a..211e675b 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -22,6 +22,7 @@
+
From c98174850c248b56d06384f1bec6f73f423de3de Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 10:42:23 -0600
Subject: [PATCH 51/56] Update Windows7ThemeManager.cs
---
Windows7ThemeManager.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Windows7ThemeManager.cs b/Windows7ThemeManager.cs
index 4807cc38..1947d1b3 100644
--- a/Windows7ThemeManager.cs
+++ b/Windows7ThemeManager.cs
@@ -19,7 +19,7 @@ internal static class Windows7ThemeManager
public static bool IsApplied => applied;
- public static void Apply(Application app)
+ public static void Apply(System.Windows.Application app)
{
if (app == null || applied) return;
// Snapshot original relevant resources
@@ -65,7 +65,7 @@ public static void Apply(Application app)
applied = true;
}
- public static void Restore(Application app)
+ public static void Restore(System.Windows.Application app)
{
if (!applied || app == null || backup == null) return;
foreach (var key in backup.Keys)
@@ -75,7 +75,7 @@ public static void Restore(Application app)
applied = false;
}
- private static Color? GetColorizationColor()
+ private static System.Windows.Media.Color? GetColorizationColor()
{
try
{
From 3a5d5ea2a06ebef7e28c4acdefb709934d00acd4 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 13:03:57 -0600
Subject: [PATCH 52/56] Update RealHypervisorDisplay.cs
---
RealHypervisorDisplay.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/RealHypervisorDisplay.cs b/RealHypervisorDisplay.cs
index fbb73f08..4a29304b 100644
--- a/RealHypervisorDisplay.cs
+++ b/RealHypervisorDisplay.cs
@@ -52,7 +52,7 @@ private void ShowRealTimeHypervisor(byte[] firmware, string platformName)
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto
};
- var logTextBlock = new TextBox()
+ var logTextBlock = new System.Windows.Controls.TextBox()
{
IsReadOnly = true,
FontFamily = new System.Windows.Media.FontFamily("Consolas"),
@@ -142,7 +142,7 @@ private void ShowRealTimeHypervisor(byte[] firmware, string platformName)
window.Show();
}
- private void ExecuteHypervisor(TextBox logTextBlock, CancellationToken cancellationToken)
+ private void ExecuteHypervisor(System.Windows.Controls.TextBox logTextBlock, CancellationToken cancellationToken)
{
try
{
@@ -237,7 +237,7 @@ private string DecodeInstruction(uint instruction)
return "ARM_INST";
}
- private void ShowBootProgress(TextBox logTextBlock, int cycle)
+ private void ShowBootProgress(System.Windows.Controls.TextBox logTextBlock, int cycle)
{
switch (cycle)
{
@@ -268,7 +268,7 @@ private void ShowBootProgress(TextBox logTextBlock, int cycle)
}
}
- private void LogMessage(TextBox textBox, string message)
+ private void LogMessage(System.Windows.Controls.TextBox textBox, string message)
{
Application.Current.Dispatcher.Invoke(() => {
textBox.AppendText($"[{DateTime.Now:HH:mm:ss.fff}] {message}\n");
From 510fa6da2e9fa243e5b3fbb3a35ffc6d705bb3be Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 13:08:57 -0600
Subject: [PATCH 53/56] Update MainWindow.Themes.cs
---
MainWindow.Themes.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MainWindow.Themes.cs b/MainWindow.Themes.cs
index 87c6f8a5..42cc9d38 100644
--- a/MainWindow.Themes.cs
+++ b/MainWindow.Themes.cs
@@ -7,12 +7,12 @@ namespace ProcessorEmulator
{
public partial class MainWindow
{
- private ComboBox runtimeThemeCombo;
+ private System.Windows.Controls.ComboBox runtimeThemeCombo;
private TextBlock runtimeGlassText;
private void ThemeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- if (sender is ComboBox cb && cb.SelectedItem is ComboBoxItem item)
+ if (sender is System.Windows.Controls.ComboBox cb && cb.SelectedItem is ComboBoxItem item)
{
string name = item.Content?.ToString() ?? "Win95";
SwitchTheme(name);
From 7ee33583ef83e579bd25db47d196af9000a359a6 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 20:54:24 -0600
Subject: [PATCH 54/56] Don' think these are cirtical but i'll submit anyways,
---
BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs | 2 +-
.../obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
index 44d6d031..951b0301 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfo.cs
@@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+efb6ff5ac570a6dc27b282b33246e184caeb085b")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+510fa6da2e9fa243e5b3fbb3a35ffc6d705bb3be")]
[assembly: System.Reflection.AssemblyProductAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyTitleAttribute("BoltDemo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
index 091050ab..e040be26 100644
--- a/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
+++ b/BoltDemo_Standalone/obj/Debug/net6.0/BoltDemo.AssemblyInfoInputs.cache
@@ -1 +1 @@
-6da485e424b54c7b02b977455c32e103cebf85960b904a5f27f8d1724387e6da
+86cc116b25dfe63cfdc820e94796b6d487fe6cc62d57683ae144a2c8144611c9
From a508af0698e939a52405d703c210a84b8385f338 Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 21:09:11 -0600
Subject: [PATCH 55/56] Ambiguity Fixes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
oh ambiguity , you're the one for me
and this fix created more errors. IM LOVIN IT. Why did i choose C# 🆘 why just why
---
AppThemeManager.cs | 1 +
Core/IntermediateRepresentation.cs | 2 +-
Emulation/DisplayWindow.cs | 1 +
Emulation/EmulatorWindow.xaml.cs | 1 +
EmulationLogPanel.cs | 8 +++++++-
ErrorManager.cs | 1 +
HypervisorWindow.xaml.cs | 2 ++
ProcessorEmulator.csproj | 1 +
8 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/AppThemeManager.cs b/AppThemeManager.cs
index 80110063..39ccbf60 100644
--- a/AppThemeManager.cs
+++ b/AppThemeManager.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Windows;
using System.Runtime.Versioning;
+using Application = System.Windows.Application;
namespace ProcessorEmulator
{
diff --git a/Core/IntermediateRepresentation.cs b/Core/IntermediateRepresentation.cs
index 33bc832e..571c4874 100644
--- a/Core/IntermediateRepresentation.cs
+++ b/Core/IntermediateRepresentation.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Numerics;
-namespace ProcessorEmulator.Core
+namespace ProcessorEmulator.Core.IR
{
///
/// Minimal IR value representation used for immediates inside the IR.
diff --git a/Emulation/DisplayWindow.cs b/Emulation/DisplayWindow.cs
index c737a0a0..0c63c2bc 100644
--- a/Emulation/DisplayWindow.cs
+++ b/Emulation/DisplayWindow.cs
@@ -4,6 +4,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
+using Image = System.Windows.Controls.Image;
namespace ProcessorEmulator.Emulation
{
diff --git a/Emulation/EmulatorWindow.xaml.cs b/Emulation/EmulatorWindow.xaml.cs
index 9bd9c899..fee785ee 100644
--- a/Emulation/EmulatorWindow.xaml.cs
+++ b/Emulation/EmulatorWindow.xaml.cs
@@ -5,6 +5,7 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Diagnostics;
+using Timer = System.Threading.Timer;
namespace ProcessorEmulator.Emulation
{
diff --git a/EmulationLogPanel.cs b/EmulationLogPanel.cs
index d2bd13bc..3a518ce0 100644
--- a/EmulationLogPanel.cs
+++ b/EmulationLogPanel.cs
@@ -5,10 +5,16 @@
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
+using MessageBox = System.Windows.MessageBox;
+using Brushes = System.Windows.Media.Brushes;
using System.Diagnostics;
using System.Threading;
using System.Linq;
using System.Text;
+using UserControl = System.Windows.Controls.UserControl;
+using ListView = System.Windows.Controls.ListView;
+using Timer = System.Threading.Timer;
+using Brush = System.Windows.Media.Brush;
namespace ProcessorEmulator
{
@@ -24,7 +30,7 @@ public partial class EmulationLogPanel : UserControl, INotifyPropertyChanged
private volatile bool isEnabled = true;
private int maxLogEntries = 1000;
- public event PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler? PropertyChanged;
public ObservableCollection LogEntries => logEntries;
diff --git a/ErrorManager.cs b/ErrorManager.cs
index 963a86b0..dd778bea 100644
--- a/ErrorManager.cs
+++ b/ErrorManager.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Windows;
+using MessageBox = System.Windows.MessageBox;
namespace ProcessorEmulator
{
diff --git a/HypervisorWindow.xaml.cs b/HypervisorWindow.xaml.cs
index 3b11e2d7..f5c13c23 100644
--- a/HypervisorWindow.xaml.cs
+++ b/HypervisorWindow.xaml.cs
@@ -3,6 +3,8 @@
using System.Windows.Controls;
using System.Windows.Threading;
using System.Windows.Media;
+using TextBox = System.Windows.Controls.TextBox;
+using Button = System.Windows.Controls.Button;
namespace ProcessorEmulator
{
diff --git a/ProcessorEmulator.csproj b/ProcessorEmulator.csproj
index 211e675b..2f6cc8ea 100644
--- a/ProcessorEmulator.csproj
+++ b/ProcessorEmulator.csproj
@@ -23,6 +23,7 @@
+
From adb72d05b0484e568a33bf5828b9c6729d55771b Mon Sep 17 00:00:00 2001
From: Julian R <25588072+julerobb1@users.noreply.github.com>
Date: Fri, 6 Feb 2026 21:09:15 -0600
Subject: [PATCH 56/56] Update MainWindow.Themes.cs
---
MainWindow.Themes.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/MainWindow.Themes.cs b/MainWindow.Themes.cs
index 42cc9d38..1498d48f 100644
--- a/MainWindow.Themes.cs
+++ b/MainWindow.Themes.cs
@@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using MessageBox = System.Windows.MessageBox;
namespace ProcessorEmulator
{