Add() public méthode

public Add ( SymbolHelper value ) : int
value SymbolHelper
Résultat int
Exemple #1
0
 private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List <CodeBlock> newCodeBlocks)
 {
     //if (newSymbol.Length >= 800) return false;
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Flash_start_address == newSymbol.Flash_start_address)
         {
             //   Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
             return(false);
         }
     }
     newSymbols.Add(newSymbol);
     newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
     return(true);
 }
Exemple #2
0
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List <CodeBlock> newCodeBlocks)
        {
            bool found  = true;
            int  offset = 0;

            while (found)
            {
                int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] {
                    0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A
                }, new byte[10] {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1
                });
                if (SVBLAddress > 0)
                {
                    //Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
                    SymbolHelper shsvbl = new SymbolHelper();
                    shsvbl.Category            = "Detected maps";
                    shsvbl.Subcategory         = "Limiters";
                    shsvbl.Flash_start_address = SVBLAddress - 2;

                    // if value = 0xC3 0x00 -> two more back
                    int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.EDC15M);
                    if (testValue[0] == 0xC300)
                    {
                        shsvbl.Flash_start_address -= 2;
                    }

                    shsvbl.Varname   = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) + "]";
                    shsvbl.Length    = 2;
                    shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
                    newSymbols.Add(shsvbl);
                    offset = SVBLAddress + 1;
                }
                else
                {
                    found = false;
                }
            }
        }
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            bool found = true;
            int offset = 0;
            while (found)
            {
                int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] { 0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A }, new byte[10] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                if (SVBLAddress > 0)
                {
                    //Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
                    SymbolHelper shsvbl = new SymbolHelper();
                    shsvbl.Category = "Detected maps";
                    shsvbl.Subcategory = "Limiters";
                    shsvbl.Flash_start_address = SVBLAddress - 2;

                    // if value = 0xC3 0x00 -> two more back
                    int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.EDC15C);
                    if (testValue[0] == 0xC300) shsvbl.Flash_start_address -= 2;

                    shsvbl.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) + "]";
                    shsvbl.Length = 2;
                    shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
                    newSymbols.Add(shsvbl);
                    offset = SVBLAddress + 1;
                }
                else found = false;
            }
        }
 private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List<CodeBlock> newCodeBlocks)
 {
     if (newSymbol.Length >= 800) return false;
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Flash_start_address == newSymbol.Flash_start_address)
         {
             //   Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
             return false;
         }
     }
     newSymbols.Add(newSymbol);
     newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
     return true;
 }
        public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
        {
            bool found = true;
            int offset = 0;
            while (found)
            {
                int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] { 0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A }, new byte[10] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                ///int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[16] { 0xD2, 0x00, 0xFC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xC3, 0x00, 0x00 }, new byte[16] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 });

                if (SVBLAddress > 0)
                {
                    //Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
                    SymbolHelper shsvbl = new SymbolHelper();
                    shsvbl.Category = "Detected maps";
                    shsvbl.Subcategory = "Limiters";
                    shsvbl.Flash_start_address = SVBLAddress - 2;
                    //shsvbl.Flash_start_address = SVBLAddress + 16;

                    // if value = 0xC3 0x00 -> two more back
                    int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.EDC15P6);
                    if (testValue[0] == 0xC300) shsvbl.Flash_start_address -= 2;

                    shsvbl.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) +"]";
                    shsvbl.Length = 2;
                    shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
                    newSymbols.Add(shsvbl);

                    int MAPMAFSwitch = Tools.Instance.findSequence(allBytes, SVBLAddress - 0x100, new byte[8] { 0x41, 0x02, 0xFF, 0xFF, 0x00, 0x01, 0x01, 0x00 }, new byte[8] { 1, 1, 0, 0, 1, 1, 1, 1 });
                    if (MAPMAFSwitch > 0)
                    {
                        MAPMAFSwitch += 2;
                        SymbolHelper mapmafsh = new SymbolHelper();
                        //mapmafsh.BitMask = 0x0101;
                        mapmafsh.Category = "Detected maps";
                        mapmafsh.Subcategory = "Switches";
                        mapmafsh.Flash_start_address = MAPMAFSwitch;
                        mapmafsh.Varname = "MAP/MAF switch (0 = MAF, 257/0x101 = MAP)" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks);
                        mapmafsh.Length = 2;
                        mapmafsh.CodeBlock = DetermineCodeBlockByByAddress(mapmafsh.Flash_start_address, newCodeBlocks);
                        newSymbols.Add(mapmafsh);
                        Console.WriteLine("Found MAP MAF switch @ " + MAPMAFSwitch.ToString("X8"));
                    }

                    offset = SVBLAddress + 1;
                }
                else found = false;
            }
        }
 private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List<CodeBlock> newCodeBlocks)
 {
     if (newSymbol.Length >= 800) return false;
     foreach (SymbolHelper sh in newSymbols)
     {
         if (sh.Flash_start_address == newSymbol.Flash_start_address)
         {
             //   Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
             return false;
         }
         // not allowed to overlap
        /* else if (newSymbol.Flash_start_address > sh.Flash_start_address && newSymbol.Flash_start_address < (sh.Flash_start_address + sh.Length))
         {
             Console.WriteLine("Overlapping map: " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_length.ToString() + " x " + sh.Y_axis_length.ToString());
             Console.WriteLine("Overlapping new: " + newSymbol.Flash_start_address.ToString("X8") + " " + newSymbol.X_axis_length.ToString() + " x " + newSymbol.Y_axis_length.ToString());
             return false;
         }*/
     }
     newSymbols.Add(newSymbol);
     newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
     return true;
 }
 private void FindMAPMAFSwitch(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
 {
     foreach (CodeBlock cb in newCodeBlocks)
     {
         if (cb.CodeID > 0)
         {
             Console.WriteLine("codeblock " + cb.CodeID.ToString() + " address " + cb.StartAddress.ToString("X8") + " adrid " + cb.AddressID.ToString("X8"));
             int MAPMAFSwitch = cb.AddressID - 8;
             // read data
             if ((allBytes[MAPMAFSwitch] == 0x01 && allBytes[MAPMAFSwitch + 1] == 0x01) || (allBytes[MAPMAFSwitch ] == 0x00 && allBytes[MAPMAFSwitch + 1] == 0x00))
             {
                 // verify validity
                 SymbolHelper mapmafsh = new SymbolHelper();
                 //mapmafsh.BitMask = 0x0101;
                 mapmafsh.Category = "Detected maps";
                 mapmafsh.Subcategory = "Switches";
                 mapmafsh.Flash_start_address = MAPMAFSwitch;
                 mapmafsh.Varname = "MAP/MAF switch (0 = MAF, 257/0x0101 = MAP)" + DetermineNumberByFlashBank(MAPMAFSwitch, newCodeBlocks);
                 mapmafsh.Length = 2;
                 mapmafsh.CodeBlock = DetermineCodeBlockByByAddress(mapmafsh.Flash_start_address, newCodeBlocks);
                 newSymbols.Add(mapmafsh);
             }
         }
     }
 }
Exemple #8
0
        private void btnSearchMaps_ItemClick(object sender, ItemClickEventArgs e)
        {
            // ask the user for which value to search and if searching should include symbolnames and/or symbol description
            if (ValidateFile())
            {
                SymbolCollection result_Collection = new SymbolCollection();
                frmSearchMaps searchoptions = new frmSearchMaps();
                if (searchoptions.ShowDialog() == DialogResult.OK)
                {
                    frmProgress progress = new frmProgress();
                    progress.SetProgress("Start searching data...");
                    progress.SetProgressPercentage(0);
                    progress.Show();
                    System.Windows.Forms.Application.DoEvents();
                    int cnt = 0;
                    foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                    {
                        progress.SetProgress("Searching " + sh.Varname);
                        progress.SetProgressPercentage((cnt * 100) / Tools.Instance.m_symbols.Count);
                        bool hit_found = false;
                        if (searchoptions.IncludeSymbolNames)
                        {
                            if (searchoptions.SearchForNumericValues)
                            {
                                if (sh.Varname.Contains(searchoptions.NumericValueToSearchFor.ToString()))
                                {
                                    hit_found = true;
                                }
                            }
                            if (searchoptions.SearchForStringValues)
                            {
                                if (searchoptions.StringValueToSearchFor != string.Empty)
                                {
                                    if (sh.Varname.Contains(searchoptions.StringValueToSearchFor))
                                    {
                                        hit_found = true;
                                    }
                                }
                            }
                        }
                        if (searchoptions.IncludeSymbolDescription)
                        {
                            if (searchoptions.SearchForNumericValues)
                            {
                                if (sh.Description.Contains(searchoptions.NumericValueToSearchFor.ToString()))
                                {
                                    hit_found = true;
                                }
                            }
                            if (searchoptions.SearchForStringValues)
                            {
                                if (searchoptions.StringValueToSearchFor != string.Empty)
                                {
                                    if (sh.Description.Contains(searchoptions.StringValueToSearchFor))
                                    {
                                        hit_found = true;
                                    }
                                }
                            }
                        }
                        // now search the symbol data
                        if (sh.Flash_start_address < Tools.Instance.m_currentfilelength)
                        {
                            byte[] symboldata = Tools.Instance.readdatafromfile(Tools.Instance.m_currentfile, (int)sh.Flash_start_address, sh.Length, Tools.Instance.m_currentFileType);
                            if (searchoptions.SearchForNumericValues)
                            {
                                for (int i = 0; i < symboldata.Length / 2; i += 2)
                                {
                                    float value = Convert.ToInt32(symboldata.GetValue(i)) * 256;
                                    value += Convert.ToInt32(symboldata.GetValue(i + 1));
                                    value *= (float)GetMapCorrectionFactor(sh.Varname);
                                    value += (float)GetMapCorrectionOffset(sh.Varname);
                                    if (value == (float)searchoptions.NumericValueToSearchFor)
                                    {
                                        hit_found = true;
                                    }
                                }
                            }
                            if (searchoptions.SearchForStringValues)
                            {
                                if (searchoptions.StringValueToSearchFor.Length > symboldata.Length)
                                {
                                    // possible...
                                    string symboldataasstring = System.Text.Encoding.ASCII.GetString(symboldata);
                                    if (symboldataasstring.Contains(searchoptions.StringValueToSearchFor))
                                    {
                                        hit_found = true;
                                    }
                                }
                            }
                        }

                        if (hit_found)
                        {
                            // add to collection
                            result_Collection.Add(sh);
                        }
                        cnt++;
                    }
                    progress.Close();
                    if (result_Collection.Count == 0)
                    {
                        frmInfoBox info = new frmInfoBox("No results found...");
                    }
                    else
                    {
                        // start result screen
                        dockManager1.BeginUpdate();
                        try
                        {
                            SymbolTranslator st = new SymbolTranslator();
                            DevExpress.XtraBars.Docking.DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                            CompareResults tabdet = new CompareResults();
                            tabdet.ShowAddressesInHex = m_appSettings.ShowAddressesInHex;
                            tabdet.SetFilterMode(m_appSettings.ShowAddressesInHex);
                            tabdet.Dock = DockStyle.Fill;
                            tabdet.UseForFind = true;
                            tabdet.Filename = Tools.Instance.m_currentfile;
                            tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelectForFind);
                            dockPanel.Controls.Add(tabdet);
                            dockPanel.Text = "Search results: " + Path.GetFileName(Tools.Instance.m_currentfile);
                            dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Left, 1);

                            dockPanel.Width = 500;

                            System.Data.DataTable dt = new System.Data.DataTable();
                            dt.Columns.Add("SYMBOLNAME");
                            dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32"));
                            dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
                            dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32"));
                            dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32"));
                            dt.Columns.Add("DESCRIPTION");
                            dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean"));
                            dt.Columns.Add("CATEGORY"); //0
                            dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double"));
                            dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32"));
                            dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double"));
                            dt.Columns.Add("CATEGORYNAME");
                            dt.Columns.Add("SUBCATEGORYNAME");
                            dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32"));
                            dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32"));
                            dt.Columns.Add("CodeBlock1", Type.GetType("System.Int32"));
                            dt.Columns.Add("CodeBlock2", Type.GetType("System.Int32"));

                            string ht = string.Empty;
                            XDFCategories cat = XDFCategories.Undocumented;
                            XDFSubCategory subcat = XDFSubCategory.Undocumented;
                            foreach (SymbolHelper shfound in result_Collection)
                            {
                                string helptext = st.TranslateSymbolToHelpText(shfound.Varname);
                                if (shfound.Varname.Contains("."))
                                {
                                    try
                                    {
                                        shfound.Category = shfound.Varname.Substring(0, shfound.Varname.IndexOf("."));
                                    }
                                    catch (Exception cE)
                                    {
                                        Console.WriteLine("Failed to assign category to symbol: " + shfound.Varname + " err: " + cE.Message);
                                    }
                                }
                                dt.Rows.Add(shfound.Varname, shfound.Start_address, shfound.Flash_start_address, shfound.Length, shfound.Length, helptext, false, 0, 0, 0, 0, shfound.Category, "", shfound.Symbol_number, shfound.Symbol_number, shfound.CodeBlock, shfound.CodeBlock);
                            }
                            tabdet.CompareSymbolCollection = result_Collection;
                            tabdet.OpenGridViewGroups(tabdet.gridControl1, 1);
                            tabdet.gridControl1.DataSource = dt.Copy();

                        }
                        catch (Exception E)
                        {
                            Console.WriteLine(E.Message);
                        }
                        dockManager1.EndUpdate();

                    }

                }
            }
        }