Ejemplo n.º 1
0
        private void readDtbInfo()
        {
            byte[] bTmp;
            int    offsetdtb = 0;
            long   ret;

            if (iVersion == 2)
            {
                offsetdtb = 108;
            }
            else if (iVersion == 3)
            {
                offsetdtb = 108 + 16;
            }
            FileStream sourcefile = new FileStream(dtimgFileName, FileMode.Open);

            for (int i = 0; i < mDtbparts.Count; i++)
            {
                DTB_entryV3 infopart = mDtbparts[i] as DTB_entryV3;
                if (infopart.iOffset != 0)
                {
                    bTmp = new byte[2];
                    sourcefile.Seek(infopart.iOffset + offsetdtb - 5, SeekOrigin.Begin);
                    ret = sourcefile.Read(bTmp, 0, bTmp.Length);
                    int len = BitConverter.ToInt16(bTmp, 0);

                    bTmp = new byte[len];
                    sourcefile.Seek(infopart.iOffset + offsetdtb, SeekOrigin.Begin);
                    ret = sourcefile.Read(bTmp, 0, bTmp.Length);
                    String sTmp = ASCIIEncoding.Default.GetString(bTmp);
                    dgvInfo.Rows[i].Cells[13].Value = sTmp;
                }
            }
            sourcefile.Close();
        }
Ejemplo n.º 2
0
        //List<DTB_entry> mDtbparts
        private void FillInfoList()
        {
            dtb_list = new List <DTB_single>();
            List <UInt32> offset_list = new List <UInt32>();

            for (int i = 0; i < mDtbparts.Count; i++)
            {
                DTB_entryV3 infopart = mDtbparts[i] as DTB_entryV3;
                dgvInfo.RowCount++;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[0].Value = infopart.No.ToString();
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[1].Value = infopart.Platform_id;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[2].Value = infopart.Variant_id;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[3].Value = infopart.Subtype_id;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[4].Value = infopart.Soc_rev;

                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[5].Value = infopart.Pmic0;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[6].Value = infopart.Pmic1;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[7].Value = infopart.Pmic2;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[8].Value = infopart.Pmic3;


                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[9].Value  = infopart.Offset;
                dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[10].Value = infopart.Size;
                if (infopart.iOffset != 0)
                {
                    DataGridViewButtonCell dgvbc = new DataGridViewButtonCell();
                    dgvbc.Value = "Save";
                    dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[12] = dgvbc;
                    if (!offset_list.Contains(infopart.iOffset))
                    {
                        offset_list.Add(infopart.iOffset);
                        DTB_single dtb_find = new DTB_single();
                        dtb_find.iOffset = infopart.iOffset;
                        dtb_find.iSize   = infopart.iSize;
                        dtb_find.No      = dtb_list.Count + 1;
                        dtb_find.dtbfile = "dtb" + dtb_find.No.ToString();
                        dtb_list.Add(dtb_find);
                        mDtbparts[i].dtbfile = dtb_find.dtbfile;
                        dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[11].Value = dtb_find.dtbfile;
                    }
                    else
                    {
                        dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[11].Value = "";
                        mDtbparts[i].dtbfile = "";
                    }
                }
                else
                {
                    DataGridViewTextBoxCell dgvbc = new DataGridViewTextBoxCell();
                    dgvbc.Value = "";
                    dgvInfo.Rows[dgvInfo.RowCount - 1].Cells[12] = dgvbc;
                }
            }
            for (int i = 0; i < mDtbparts.Count; i++)
            {
                DTB_entryV3 infopart = mDtbparts[i] as DTB_entryV3;
                if (dgvInfo.Rows[i].Cells[11].Value == "" & infopart.iOffset != 0)
                {
                    for (int j = 0; j < dtb_list.Count; j++)
                    {
                        if (dtb_list[j].iOffset == infopart.iOffset)
                        {
                            dgvInfo.Rows[i].Cells[11].Value = dtb_list[j].dtbfile;
                            mDtbparts[i].dtbfile            = dtb_list[j].dtbfile;
                        }
                    }
                }
            }
            readDtbInfo();
        }
Ejemplo n.º 3
0
        private void GetFileInfo(String FileName)
        {
            byte[]     bMAGIC     = new byte[4];
            byte[]     bVERSION   = new byte[4];
            byte[]     bNUM       = new byte[4];
            byte[]     bDTB_entry = new byte[0];
            UInt32     iNum;
            long       ret;
            String     sMagic;
            FileStream sourcefile = new FileStream(FileName, FileMode.Open);

            //MAGIC ("QCDT")
            sourcefile.Seek(MAGIC_offset, SeekOrigin.Begin);
            ret = sourcefile.Read(bMAGIC, 0, 4);
            if (ret != 4)
            {
                MessageBox.Show("Read File Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            sMagic = System.Text.Encoding.ASCII.GetString(bMAGIC);
            if (!sMagic.Equals("QCDT"))
            {
                MessageBox.Show("This is'n a dt.img File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //VERSION
            sourcefile.Seek(VERSION_offset, SeekOrigin.Begin);
            ret = sourcefile.Read(bVERSION, 0, 4);
            if (ret != 4)
            {
                MessageBox.Show("Read File Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            iVersion = BitConverter.ToUInt32(bVERSION, 0);
            if (iVersion != 2 & iVersion != 3)
            {
                StringBuilder sInfo = new StringBuilder("dt.img version:");
                sInfo.AppendLine(iVersion.ToString());
                sInfo.AppendLine("this tool support : version 2 & version 3");
                MessageBox.Show(sInfo.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //num of DTBs
            sourcefile.Seek(NUM_offset, SeekOrigin.Begin);
            ret = sourcefile.Read(bNUM, 0, 4);
            if (ret != 4)
            {
                MessageBox.Show("Read File Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            iNum = (BitConverter.ToUInt32(bNUM, 0) + 1) / 2;
            if (iNum == 0)
            {
                MessageBox.Show("Read File Error,no DTBs found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //DTB_entry table
            sourcefile.Seek(DTB_entry_offset, SeekOrigin.Begin);

            if (iVersion == 2)
            {
                bDTB_entry = new byte[DTB_entry_size_v2];
            }
            else if (iVersion == 3)
            {
                bDTB_entry = new byte[DTB_entry_size_v3];
            }

            for (int i = 0; i < iNum; i++)
            {
                ret = sourcefile.Read(bDTB_entry, 0, bDTB_entry.Length);
                if (ret != bDTB_entry.Length)
                {
                    MessageBox.Show("Read File Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DTB_entryV3 dtbpart = new DTB_entryV3(bDTB_entry);
                dtbpart.No = i + 1;
                mDtbparts.Add(dtbpart);
                sourcefile.Seek(bDTB_entry.Length, SeekOrigin.Current);
            }

            sourcefile.Close();
            setListTitleV3();
            FillInfoList();
        }