Ejemplo n.º 1
0
        /// <summary>
        /// Writes the Xbox EEPROM using the specified serial port.
        /// </summary>
        /// <param name="port"></param>
        private void ArduinoPromWrite(string port)
        {
            using (SerialPort serial = new SerialPort(port, _arduinoPromBaudRate))
            {
                serial.RtsEnable    = serial.DtrEnable = true;
                serial.WriteTimeout = _arduinoPromTimeout;
                serial.Open();

                // send the write command and the data to be written
                byte[] encryptedEepromData = _eeprom.Save();
                byte[] writeCommand        = new byte[] { 0x1 };
                serial.Write(writeCommand, 0, writeCommand.Length);
                serial.Write(encryptedEepromData, 0, encryptedEepromData.Length);

                // ~10ms delay per byte (256 of them) on the Xbox side...
                Thread.Sleep(3000); // TODO: async progress bar? probably not worth it for 3 seconds

                // read the status response
                if (serial.ReadByte() != 0)
                {
                    throw new Exception("Unknown write failure.");
                }

                // make sure everything's in sync
                if (serial.BytesToRead != 0 || serial.BytesToWrite != 0)
                {
                    throw new Exception("Serial stream desync.");
                }
            }
        }
Ejemplo n.º 2
0
        private void mnuSaveAs_Click(object sender, EventArgs e)
        {
            if (!ValidateFormData())
            {
                return;
            }

            UpdateEepromFromForm();

            if ((EepromVersion)cmbVersion.SelectedValue == EepromVersion.Unknown)
            {
                MessageBox.Show("The security section will not be updated while the version is unknown. This may be desired if editing an EEPROM version not supported by this tool.", "Unknown EEPROM Version",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.Filter = "Xbox EEPROM (*.bin) |*.bin";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    _eeprom.Save(sfd.FileName);
                }
            }
        }