Пример #1
0
        private void ExtractString(int MinTaille, long StartPos, long StopPos, short Performance, string FindString)
        {
            if (File.Exists(this._FileName))
            {
                if (File.Exists(tblCombo1.SelectedItem.Tag.ToString()))
                {
                    //Vide la liste de rechercher
                    lvFind.Items.Clear();

                    //Ouverture du fichier
                    FileInfo info = new FileInfo(this._FileName);
                    HexEdit.Load(ref this._FileName, (int)info.Length);

                    TBLStream tbl = new TBLStream(tblCombo1.SelectedItem.Tag.ToString());
                    tbl.Load();

                    int  ChunkSize = Performance * 10000;
                    long DataLen   = StopPos - StartPos;

                    if (DataLen > 0)
                    {
                        int i = (int)StartPos;
                        pb.Maximum = (int)DataLen;

                        string   buffer = "";
                        string[] bufferSplittedHexa;
                        string   dte    = "";
                        string   str    = "";
                        long     StrPos = 0;

                        //Commancement de la recherche des chaine
                        do
                        {
                            if (this._Cancel)
                            {
                                break;
                            }

                            buffer             = HexEdit.GetDataChunk(i);
                            bufferSplittedHexa = Convertir.StringHexa_LittleEndian(buffer, true).Trim().Split(new char[] { ' ' });
                            for (int j = 0; j < bufferSplittedHexa.Length; j++)
                            {
                                dte = tbl.FindTBLMatch(bufferSplittedHexa[j]);
                                if (dte != "#")
                                {
                                    str += dte;
                                }
                                else
                                {
                                    if (str.IndexOf(FindString, 0) != -1)
                                    {
                                        if (str.Length >= MinTaille)
                                        {
                                            ListViewItem item = new ListViewItem(Convertir.DecimalToHexa(StrPos));
                                            item.SubItems.Add(str);
                                            lvFind.Items.Add(item);
                                        }
                                    }
                                    str    = "";
                                    StrPos = i + j + 1;
                                }

                                if ((i + j) > DataLen)
                                {
                                    break;
                                }

                                if (j % 10000 == 0)
                                {
                                    pb.Value = i + j;
                                }
                            }
                            //Assignation
                            i += ChunkSize;
                        }while(i < DataLen);

                        //Reinitialise a 0
                        this.pb.Value         = 0;
                        this._Cancel          = false;
                        tbButtonFind.Enabled  = true;
                        tblButtonStop.Enabled = false;
                        panelParam.Enabled    = true;

                        if (lvFind.Items.Count == 0)
                        {
                            MessageBox.Show(this, this._String_NoItemFound,
                                            "Message",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show(this, lvFind.Items.Count + " " + this._String_TotalItem,
                                            "Message",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                    }     // Datalen > 0
                }         // TBL
            }             //Filename
        }