예제 #1
0
        private void button_CheckRealSize_Click(object sender, EventArgs e)
        {
            if (comboBox_Disk.SelectedIndex == -1)
            {
                MessageBox.Show("Please sectet the disk at fisrt!", "Warning!");
                return;
            }

            long tmp_max_lba = Convert.ToInt64(textBox_Sector.Text);

            T = new Zgke.DriverLoader(comboBox_Disk.SelectedItem.ToString(), tmp_max_lba * 2);

            tmp_max_lba = tmp_max_lba / 8 * 8;
            while (true)
            {
                Console.WriteLine("Check lba:{0}", tmp_max_lba);

                manual_data_buffer = T.ReadSector(tmp_max_lba, 8);
                if (manual_data_buffer == null)
                {
                    break;
                }
                tmp_max_lba += 8;
            }

            textBox_Progress.Text = "Check lba:" + tmp_max_lba.ToString();

            textBox_Byte.Text   = (tmp_max_lba * 512).ToString();
            textBox_Sector.Text = tmp_max_lba.ToString();
            textBox_GB.Text     = ((tmp_max_lba * 512) / 1024 / 1024 / 1024).ToString();

            T.Close();
        }
예제 #2
0
        private void button_Write_Click(object sender, EventArgs e)
        {
            if (comboBox_Disk.SelectedIndex == -1)
            {
                MessageBox.Show("Please sectet the disk at fisrt!", "Warning!");
                return;
            }

            if ((manual_data_buffer == null) ||
                (manual_data_buffer.Length != Convert.ToInt32(textBox_PaddingLength.Text.Trim()))
                )
            {
                MessageBox.Show("Please fullfill the data buffer before write", "Warning!");
                return;
            }

            int max_lba = Convert.ToInt32(textBox_Sector.Text) - 1;

            T = new Zgke.DriverLoader(comboBox_Disk.SelectedItem.ToString(), max_lba);

            int lba    = Convert.ToInt32(textBox_lba.Text);
            int length = Convert.ToInt32(textBox_Length.Text);

            T.WritSector(manual_data_buffer, lba, length);
            T.Close();
        }
예제 #3
0
        private void button_Read_Click(object sender, EventArgs e)
        {
            if (comboBox_Disk.SelectedIndex == -1)
            {
                MessageBox.Show("Please sectet the disk at fisrt!", "Warning!");
                return;
            }

            int max_lba = Convert.ToInt32(textBox_Sector.Text) - 1;

            T = new Zgke.DriverLoader(comboBox_Disk.SelectedItem.ToString(), max_lba);

            int lba    = Convert.ToInt32(textBox_lba.Text);
            int length = Convert.ToInt32(textBox_Length.Text);

            manual_data_buffer = T.ReadSector(lba, length);
            T.Close();

            textBox_Data.Text = T.GetString(manual_data_buffer);
        }
예제 #4
0
        private void button_Copy_Click(object sender, EventArgs e)
        {
            if (comboBox_Disk.SelectedIndex == -1)
            {
                MessageBox.Show("Please sectet the target disk!", "Error!");
                return;
            }

            if (disk_has_file_system == true)
            {
                //DialogResult result = DialogResult.Cancel;
                //result = MessageBox.Show("Write to the disk with FILE SYSTEM??", "Warning!",
                //     MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                MessageBox.Show("Write to the disk with FILE SYSTEM!", "Error!");
                return;
            }

            if (fileName == null)
            {
                MessageBox.Show("Please sectet the source image!", "Error!");
                return;
            }

            int max_lba = Convert.ToInt32(textBox_Sector.Text) - 1;

            T = new Zgke.DriverLoader(comboBox_Disk.SelectedItem.ToString(), max_lba);

            // 读取文件
            try
            {
                br = new BinaryReader(new FileStream(fileName, FileMode.Open));
            }
            catch (IOException x)
            {
                MessageBox.Show(x.Message, "Error!");
                return;
            }

            if (T == null)
            {
                MessageBox.Show("File stream error!", "Error!", MessageBoxButtons.OK);
                return;
            }


            DialogResult res1 = DialogResult.Cancel;

            res1 = MessageBox.Show("start copy from [" + textBox_ImgPath.Text +
                                   "] to [" + comboBox_Disk.SelectedItem.ToString() + "] ?", "Start Copy?",
                                   MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (res1 == DialogResult.OK)
            {
                //确定按钮的方法
            }
            else
            {
                br.Close();
                return;                //取消按钮的方法
            }

            DialogResult res2 = DialogResult.Cancel;

            res2 = MessageBox.Show("Write to the disk without zero data", "Warning!",
                                   MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (res2 != DialogResult.OK)
            {
                return;
            }

            /**********************创建线程****************************/
            string strInfo;

            Thread_Read = new Thread(new ThreadStart(Thread_Read_Entry));   //实例化Thread线程对象

            strInfo  = string.Empty;
            strInfo  = "The managed Thread ID:" + Thread_Read.ManagedThreadId + "\n";
            strInfo += "Thread Name:" + Thread_Read.Name + "\n";
            strInfo += "Thread State:" + Thread_Read.ThreadState.ToString() + "\n";
            strInfo += "Thread Priority:" + Thread_Read.Priority.ToString() + "\n";
            strInfo += "Is Backgroud" + Thread_Read.IsBackground + "\n";
            Console.WriteLine(strInfo);

            Thread_Read.IsBackground = true; //设置为后台程序,它的主线程结束,它也一起结束
            Thread_Read.Start();             //启动线程


            Thread_Write = new Thread(new ThreadStart(Thread_Write_Entry));             //实例化Thread线程对象

            strInfo  = string.Empty;
            strInfo  = "The managed Thread ID:" + Thread_Write.ManagedThreadId + "\n";
            strInfo += "Thread Name:" + Thread_Write.Name + "\n";
            strInfo += "Thread State:" + Thread_Write.ThreadState.ToString() + "\n";
            strInfo += "Thread Priority:" + Thread_Write.Priority.ToString() + "\n";
            strInfo += "Is Backgroud" + Thread_Write.IsBackground + "\n";
            Console.WriteLine(strInfo);

            Thread_Write.IsBackground = true;            //设置为后台程序,它的主线程结束,它也一起结束
            Thread_Write.Start();                        //启动线程

            /**********************创建线程****************************/
        }