Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6eb2a84
Update README.md
shiroinekotfs Sep 5, 2025
8788c5b
fix for improper disposing
shiroinekotfs Sep 5, 2025
5eeafbb
change to dismount from pcip and renable
shiroinekotfs Sep 5, 2025
eb4cde5
Update MachineMethods.cs
anhvlttfs Sep 8, 2025
fca3d35
update for mid-disable dev
anhvlttfs Sep 9, 2025
42a916c
change to ms documentation
anhvlttfs Sep 9, 2025
01a67aa
remove unncessary classes
anhvlttfs Oct 4, 2025
1814cf2
Merge pull request #5 from tfslabs/dda-on-client-of-phase-2
shiroinekotfs Dec 2, 2025
f10a585
update for about window
shiroinekotfs Dec 2, 2025
1e2a6d2
update connection form
shiroinekotfs Dec 2, 2025
a7684b5
add exception handler
shiroinekotfs Dec 2, 2025
ff8f8b9
Delete WMIDefaultValues.cs
shiroinekotfs Dec 2, 2025
c28a3d7
add comments for main windows
shiroinekotfs Dec 2, 2025
6b39b33
Update CheckForAssignableDevice.xaml.cs
shiroinekotfs Dec 2, 2025
8996dc3
Update ChangeMemorySpace.xaml.cs
shiroinekotfs Dec 2, 2025
a00f958
Update AddDevice.xaml.cs
shiroinekotfs Dec 2, 2025
a160b11
Update HyperVStatus.xaml.cs
shiroinekotfs Dec 2, 2025
e53558f
Update HyperV-DPD.csproj
shiroinekotfs Dec 2, 2025
64ee362
Update MachineMethods.cs
shiroinekotfs Dec 2, 2025
34e0f3d
Update MainWindow.xaml.cs
shiroinekotfs Dec 2, 2025
3782e4a
Update MachineMethods.cs
shiroinekotfs Dec 2, 2025
4a9a529
Update MachineMethods.cs
shiroinekotfs Dec 2, 2025
61ad0a5
Update AddDevice.xaml.cs
shiroinekotfs Dec 2, 2025
d2cd8a8
Update ChangeMemorySpace.xaml.cs
shiroinekotfs Dec 2, 2025
66cc5a0
Update MachineMethods.cs
shiroinekotfs Dec 2, 2025
345aa08
Update CheckForAssignableDevice.xaml.cs
shiroinekotfs Dec 2, 2025
27a532a
Update CheckForAssignableDevice.xaml.cs
shiroinekotfs Dec 2, 2025
a9179bb
Update CheckForAssignableDevice.xaml.cs
shiroinekotfs Dec 2, 2025
6a0c838
Update CheckForAssignableDevice.xaml.cs
shiroinekotfs Dec 2, 2025
94b502f
refactor for readable
shiroinekotfs Dec 3, 2025
1f43602
update for non-pci device list
shiroinekotfs Dec 3, 2025
60222a9
update with disclosng resources
shiroinekotfs Dec 3, 2025
7505ab5
update the UI
shiroinekotfs Dec 3, 2025
788d5f3
fix for disposing wmi res
shiroinekotfs Dec 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions About.xaml.cs

This file was deleted.

107 changes: 83 additions & 24 deletions AddDevice.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,70 @@
using System.Linq;
using System.Management;
using System.Windows;

using TheFlightSims.HyperVDPD.DefaultUI;
using TheFlightSims.HyperVDPD.WMIProperties;

/*
* Primary namespace for HyperV-DPD application
* It contains the main window and all related methods for the core application
*/
namespace TheFlightSims.HyperVDPD
{
/*
* Add Device Window class
* It is used to add device into the selected VM
*/
public partial class AddDevice : Window
{
////////////////////////////////////////////////////////////////
/// Global Properties and Constructors Region
/// This region contains global properties and constructors
/// for the MachineMethods class.
////////////////////////////////////////////////////////////////

/*
* Global properties
* deviceId: Device ID of the selected device
* machine: WMI namespace of the machine
*/

protected string deviceId;
protected MachineMethods machine;

/*
* Constructor of the MainWindow class
* Initializes the components and sets up event handlers
*/
public AddDevice(MachineMethods machine)
{
this.machine = machine;
machine.Connect("root\\cimv2");
InitializeComponent();
}


////////////////////////////////////////////////////////////////
/// User Action Methods Region
/// This region contains methods that handle user actions.
/// For example, button clicks, changes in order.
////////////////////////////////////////////////////////////////

/*
* Button and UI methods behaviour....
* Actions for button "Add Device"
*/

private void AddDeviceButton_Click(object sender, RoutedEventArgs e)
{
// If the selected item is not null (nothing is selected), proceed
if (DeviceList.SelectedItem != null)
{
deviceId = DeviceList.SelectedItem.GetType().GetProperty("DeviceId").GetValue(DeviceList.SelectedItem, null).ToString();
DialogResult = true;
}
else
{
MessageBox.Show(
// Notify user if nothing is selected
_ = MessageBox.Show(
"Please select a device to add.",
"Warning",
MessageBoxButton.OK,
Expand All @@ -40,53 +74,78 @@ private void AddDeviceButton_Click(object sender, RoutedEventArgs e)
}
}

/*
* Actions for button "Close"
*/
private void AddDeviceCloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}

////////////////////////////////////////////////////////////////
/// Non-User Action Methods Region
///
/// This region contains methods that do not handle user actions.
///
/// Think about this is the back-end section.
/// It should not be in a seperated class, because it directly interacts with the UI elements.
////////////////////////////////////////////////////////////////

/*
* Non-button methods
* Start getting the device ID
*/

public string GetDeviceId()
{

UpdateDevices();
ShowDialog();
_ = ShowDialog();

// Return the device ID back to the main windows
return deviceId;
}

private void UpdateDevices()
/*
* Update device list
*/
private async void UpdateDevices()
{
// Clear the device list
DeviceList.Items.Clear();

try
{
foreach (ManagementObject device in machine.GetObjects("Win32_PnPEntity", "Status, PNPClass, Name, DeviceID").Cast<ManagementObject>())
// Loop for devices in Win32_PnPEntity
using (ManagementObjectCollection pnpEntityList = machine.GetObjects("Win32_PnPEntity", "Status, PNPClass, Name, DeviceID"))
{
string deviceStatus = device["Status"]?.ToString() ?? "Unknown";
string deviceType = device["PNPClass"]?.ToString() ?? "Unknown";
string deviceName = device["Name"]?.ToString() ?? "Unknown";
string deviceId = device["DeviceID"]?.ToString() ?? "Unknown";

if (!deviceId.StartsWith("PCI"))
foreach (ManagementObject device in pnpEntityList.Cast<ManagementObject>())
{
continue;
}
string deviceStatus = device["Status"]?.ToString() ?? "Unknown";
string deviceType = device["PNPClass"]?.ToString() ?? "Unknown";
string deviceName = device["Name"]?.ToString() ?? "Unknown";
string deviceId = device["DeviceID"]?.ToString() ?? "Unknown";

DeviceList.Items.Add(new
{
DeviceStatus = deviceStatus,
DeviceType = deviceType,
DeviceName = deviceName,
DeviceId = deviceId
});
// If the device is not PCI, skip to the next device
if (!deviceId.StartsWith("PCI"))
{
device.Dispose();
continue;
}

_ = DeviceList.Items.Add(new
{
DeviceStatus = deviceStatus,
DeviceType = deviceType,
DeviceName = deviceName,
DeviceId = deviceId
});

device.Dispose();
}
}
}
catch (Exception ex)
{
WMIDefaultValues.HandleException(ex, machine.GetComputerName());
(new ExceptionView()).HandleException(ex);
}
}
}
Expand Down
57 changes: 46 additions & 11 deletions ChangeMemorySpace.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,60 @@
using System;
using System.Windows;
using System.Windows;

/*
* Primary namespace for HyperV-DPD application
* It contains the main window and all related methods for the core application
*/
namespace TheFlightSims.HyperVDPD
{
/*
* Change Memory Space Window
*/
public partial class ChangeMemorySpace : Window
{
////////////////////////////////////////////////////////////////
/// Global Properties and Constructors Region
/// This region contains global properties and constructors
/// for the MachineMethods class.
////////////////////////////////////////////////////////////////

/*
* Global properties
* memRange as tuple of low and high memory
*/
protected (UInt64 lowMem, UInt64 highMem) memRange;
protected (ulong lowMem, ulong highMem) memRange;

// Constructor of the Change Memory space window
public ChangeMemorySpace(string vmName)
{
Title += $" for {vmName}";
InitializeComponent();
}

////////////////////////////////////////////////////////////////
/// User Action Methods Region
/// This region contains methods that handle user actions.
/// For example, button clicks, changes in order.
////////////////////////////////////////////////////////////////

/*
* Button-based methods
* Actions for button "Confirm"
*/
private void Confirm_Button(object sender, RoutedEventArgs e)
{
if (UInt64.TryParse(LowMemory_TextBox.Text, out UInt64 lowMemCompare) && UInt64.TryParse(HighMemory_TextBox.Text, out UInt64 highMemCompare))
// Try to parse number in the box
if (ulong.TryParse(LowMemory_TextBox.Text, out ulong lowMemCompare) && ulong.TryParse(HighMemory_TextBox.Text, out ulong highMemCompare))
{
if ((lowMemCompare >= 128 && lowMemCompare <= 3584) && (highMemCompare >= 4096 && highMemCompare <= (UInt64.MaxValue - 2)))
// Check for low MMIO and high MMIO. If valid, return the value
if ((lowMemCompare >= 128 && lowMemCompare <= 3584) && (highMemCompare >= 4096 && highMemCompare <= (ulong.MaxValue - 2)))
{
memRange.lowMem = lowMemCompare;
memRange.highMem = highMemCompare;
DialogResult = true;
}
else
{
MessageBox.Show(
// Notify user for invalid valid input
_ = MessageBox.Show(
"Make sure the Low MMIO Gap is in range (128, 3584) and High MMIO is larger than 4096",
"Warning",
MessageBoxButton.OK,
Expand All @@ -41,7 +64,7 @@ private void Confirm_Button(object sender, RoutedEventArgs e)
}
else
{
MessageBox.Show(
_ = MessageBox.Show(
"Please enter a positive integer in both box.",
"Warning",
MessageBoxButton.OK,
Expand All @@ -50,17 +73,29 @@ private void Confirm_Button(object sender, RoutedEventArgs e)
}
}

/*
* Action for button "Cancel"
*/
private void Cancel_Button(object sender, RoutedEventArgs e)
{
Close();
}

////////////////////////////////////////////////////////////////
/// Non-User Action Methods Region
///
/// This region contains methods that do not handle user actions.
///
/// Think about this is the back-end section.
/// It should not be in a seperated class, because it directly interacts with the UI elements.
////////////////////////////////////////////////////////////////

/*
* Non-button methods
* Return Value
*/
public (UInt64, UInt64) ReturnValue()
public (ulong, ulong) ReturnValue()
{
ShowDialog();
_ = ShowDialog();

return memRange;
}
Expand Down
Loading
Loading