diff --git a/PS5 NOR Modifier/Form1.cs b/PS5 NOR Modifier/Form1.cs index 8f6dec8..fcecc0a 100644 --- a/PS5 NOR Modifier/Form1.cs +++ b/PS5 NOR Modifier/Form1.cs @@ -84,11 +84,15 @@ private void Form1_Load(object sender, EventArgs e) { // Upon first launch, we need to get a list of COM ports available for UART string[] ports = SerialPort.GetPortNames(); - comboComPorts.Items.Clear(); - comboComPorts.Items.AddRange(ports); - comboComPorts.SelectedIndex = 0; - btnConnectCom.Enabled = true; - btnDisconnectCom.Enabled = false; + if (ports != null && ports.Length > 0) + { + comboComPorts.Items.Clear(); + comboComPorts.Items.AddRange(ports); + comboComPorts.SelectedIndex = 0; + btnConnectCom.Enabled = true; + btnDisconnectCom.Enabled = false; + } + else MessageBox.Show("No available COM ports were detected.", "COM Ports", MessageBoxButtons.OK, MessageBoxIcon.Information); } // Declare offsets to detect console version @@ -827,11 +831,15 @@ private void btnRefreshPorts_Click(object sender, EventArgs e) { // When the "refresh ports" button is pressed, we need to refresh the list of available COM ports for UART string[] ports = SerialPort.GetPortNames(); - comboComPorts.Items.Clear(); - comboComPorts.Items.AddRange(ports); - comboComPorts.SelectedIndex = 0; - btnConnectCom.Enabled = true; - btnDisconnectCom.Enabled = false; + if (ports.Length > 0) + { + comboComPorts.Items.Clear(); + comboComPorts.Items.AddRange(ports); + comboComPorts.SelectedIndex = 0; + btnConnectCom.Enabled = true; + btnDisconnectCom.Enabled = false; + } + else MessageBox.Show("Not existing COM ports were found!", "COM Ports", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void btnConnectCom_Click(object sender, EventArgs e)