private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (saveDir != null) {
                long pointer;
                if (dataGridView1.Rows[e.RowIndex].Cells[1].Value == null) {
                    dataGridView1.Rows[e.RowIndex].Cells[1].Value = 0;
                }
                if (dataGridView1.Rows[e.RowIndex].Cells[2].Value == null) {
                    dataGridView1.Rows[e.RowIndex].Cells[2].Value = "int";
                }
                long.TryParse(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()
                    , System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat, out pointer);

                BigEndianBinaryReader saveFileBinaryReader = new BigEndianBinaryReader(new FileStream(saveDir + @"\USR-DATA", FileMode.Open));
                saveFileBinaryReader.BaseStream.Position = pointer;
                string type = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                if (type.Trim().Equals("int")) {
                    dataGridView1.Rows[e.RowIndex].Cells[3].Value =
                        saveFileBinaryReader.ReadInt32();
                } else if (type.Trim().Equals("uint")) {
                    dataGridView1.Rows[e.RowIndex].Cells[3].Value =
                        saveFileBinaryReader.ReadUInt32();
                } else if (type.Trim().Equals("short")) {
                    dataGridView1.Rows[e.RowIndex].Cells[3].Value =
                         saveFileBinaryReader.ReadInt16();
                } else if (type.Trim().Equals("ushort")) {
                    dataGridView1.Rows[e.RowIndex].Cells[3].Value =
                       saveFileBinaryReader.ReadUInt16();
                } else if (type.Trim().Equals("byte")) {
                    dataGridView1.Rows[e.RowIndex].Cells[3].Value =
                        saveFileBinaryReader.ReadByte();
                }
                saveFileBinaryReader.Close();
            } else {
                MessageBox.Show("無法讀取存檔");
            }
        }
 private void readExtensionFile(Stream inStream)
 {
     dataSet1.Tables["extensionTable"].Rows.Clear();
     dataSet1.ReadXml("extension.xml");
     BigEndianBinaryReader saveFileBinaryReader = new BigEndianBinaryReader(inStream);
     foreach (DataRow dr in dataSet1.Tables["extensionTable"].Rows) {
         long pointer;
         if (!long.TryParse(dr["hackOffset"].ToString(), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat, out pointer)) {
             MessageBox.Show("位置格式不正確");
             dataSet1.Tables["extensionTable"].Rows.Clear();
             return;
         }
         if (pointer > saveFileBinaryReader.BaseStream.Length) {
             MessageBox.Show("超過存檔可以表示的範圍");
             dataSet1.Tables["extensionTable"].Rows.Clear();
             return;
         }
         saveFileBinaryReader.BaseStream.Position = pointer;
         if (dr["hackType"].Equals("int")) {
             dr["hackValue"] = saveFileBinaryReader.ReadInt32();
         } else if (dr["hackType"].Equals("uint")) {
             dr["hackValue"] = (saveFileBinaryReader.ReadUInt32());
         } else if (dr["hackType"].Equals("short")) {
             dr["hackValue"] = saveFileBinaryReader.ReadInt16();
         } else if (dr["hackType"].Equals("ushort")) {
             dr["hackValue"] = saveFileBinaryReader.ReadUInt16();
         } else if (dr["hackType"].Equals("byte")) {
             dr["hackValue"] = saveFileBinaryReader.ReadByte();
         } else {
             MessageBox.Show("讀取失敗,不支援的數據格式");
             return;
         }
     }
 }
 private void button3_Click(object sender, EventArgs e)
 {
     if (saveDir != null) {
         dataSet1.Tables["extensionTable"].Rows.Clear();
         dataSet1.ReadXml("extension.xml");
         BigEndianBinaryReader saveFileBinaryReader = new BigEndianBinaryReader(new FileStream(saveDir + @"\USR-DATA", FileMode.Open));
         foreach (DataRow dr in dataSet1.Tables["extensionTable"].Rows) {
             long pointer;
             if (!long.TryParse(dr["hackOffset"].ToString(), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat, out pointer)) {
                 MessageBox.Show("位置格式不正確");
                 dataSet1.Tables["extensionTable"].Rows.Clear();
                 return;
             }
             if (pointer > saveFileBinaryReader.BaseStream.Length) {
                 MessageBox.Show("超過存檔可以表示的範圍");
                 dataSet1.Tables["extensionTable"].Rows.Clear();
                 return;
             }
             saveFileBinaryReader.BaseStream.Position = pointer;
             if (dr["hackType"].Equals("int")) {
                 dr["hackValue"] = saveFileBinaryReader.ReadInt32();
             } else if (dr["hackType"].Equals("uint")) {
                 dr["hackValue"] = saveFileBinaryReader.ReadUInt32();
             } else if (dr["hackType"].Equals("short")) {
                 dr["hackValue"] = saveFileBinaryReader.ReadInt16();
             } else if (dr["hackType"].Equals("ushort")) {
                 dr["hackValue"] = saveFileBinaryReader.ReadUInt16();
             } else if (dr["hackType"].Equals("byte")) {
                 dr["hackValue"] = saveFileBinaryReader.ReadByte();
             } else {
                 MessageBox.Show("讀取失敗,不支援的數據格式");
                 return;
             }
         }
         saveFileBinaryReader.Close();
     } else {
         MessageBox.Show("無法讀取存檔");
     }
 }