Exemple #1
0
        //device list selection was changed
        private void DeviceList_SelectedIndexChanged(System.Object sender, System.EventArgs e)
        {
            DevStruct devstruct = new DevStruct();

            uint[] tag1 = (uint[])MfcList.Tag;
            uint[] tag2 = (uint[])DeviceList.Tag;
            GetIcStru(tag1[MfcList.SelectedIndex], tag2[DeviceList.SelectedIndex], ref devstruct);
            devstruct.chip_id = change_endianess(devstruct.chip_id, devstruct.chip_id_size);
            txt_info.Text     = get_ic_string_ini(devstruct).ToString();
            label_devs.Text   = "Devices:" + DeviceList.Items.Count.ToString();
        }
Exemple #2
0
        private string get_fuse_name(DevStruct devstruct)
        {
            devstruct.type &= 0xff;
            string key = devstruct.name.Split('@')[0].Trim();

            key = key.Split('(')[0].Trim();

            switch (devstruct.protocol_id)
            {
            case 0x2a:
                if (devstruct.type == 1)
                {
                    return("gal1_acw");
                }
                else if (devstruct.type == 2)
                {
                    return("gal2_acw");
                }
                break;

            case 0x2b:
                if (devstruct.type == 4)
                {
                    return("gal3_acw");
                }
                else if (devstruct.type == 5)
                {
                    return("gal4_acw");
                }
                break;

            case 0x2c:
                if (devstruct.type == 8)
                {
                    return("gal5_acw");
                }
                break;
            }
            if (microchip_csv_list.ContainsKey(key))
            {
                return(microchip_csv_list[key].fuses);
            }
            else if (atmel_csv_list.ContainsKey(key))
            {
                return(atmel_csv_list[key].fuses);
            }
            return("NULL");
        }
Exemple #3
0
 bool is_duplicate(List <DevStruct> devices_list, DevStruct device)
 {
     if (device.protocol_id == 0)
     {
         return(false);
     }
     foreach (DevStruct d in devices_list)
     {
         if (compare_devices(d, device) &&
             (((device.package_details & 0X80000000) != 0) &&
              ((device.package_details & 0X7FFFFFFF) == (d.package_details & 0X7FFFFFFF))) ||
             (compare_devices(d, device) &&
              ((device.package_details & 0X00FFFF00) == (d.package_details & 0X00FFFF00)))
             )
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #4
0
        //manufacturers list selection was changed
        private void MfcList_SelectedIndexChanged(System.Object sender, System.EventArgs e)
        {
            MfcStruct mfcstruct = new MfcStruct();

            uint[] tag = (uint[])MfcList.Tag;
            GetMfcStru(tag[MfcList.SelectedIndex], ref mfcstruct);
            LogoImage.Image = GetBitmapFromResources(mfcstruct.logo);
            Label1.Text     = mfcstruct.manufacturer_description;
            uint[]    devices   = new uint[4096];
            DevStruct devstruct = new DevStruct();

            DeviceList.Items.Clear();
            for (int i = 0; i < GetIcList(SearchBox.Text.ToUpper(), devices, (uint)tag[MfcList.SelectedIndex], GetIcType()); i++)
            {
                GetIcStru((uint)tag[MfcList.SelectedIndex], devices[i], ref devstruct);
                DeviceList.Items.Add(devstruct.name);
            }
            DeviceList.Tag = devices;
            if (DeviceList.Items.Count > 0)
            {
                DeviceList.SelectedIndex = 0;
            }
            label_mfc.Text = "Manufacturers:" + MfcList.Items.Count.ToString();
        }
Exemple #5
0
 private static extern void Patch_Device(ref DevStruct devstruct);
Exemple #6
0
 private static extern void GetIcStru(uint Manuf, uint device, ref DevStruct IcName);
Exemple #7
0
        //Perform the infoic.dll dump
        private void dump_database()
        {
            uint[]           manufacturers        = new uint[4096];
            uint[]           devices              = new uint[4096];
            DevStruct        devstruct            = new DevStruct();
            List <DevStruct> devices_list         = new List <DevStruct>();
            List <string>    duplicates           = new List <string>();
            List <device>    device_list_xml      = new List <device>();
            List <string>    device_list_ini      = new List <string>();
            List <string>    device_list_c        = new List <string>();
            SortedDictionary <uint, string> total = new SortedDictionary <uint, string>();

            progressBar.Maximum = (int)GetIcMFC("", manufacturers, 0);

            //Iterate over the entire manufacturers
            for (uint i = 0; i < GetIcMFC("", manufacturers, 0); i++)
            {
                //Iterate over the entire devices in the curent manufacturer
                for (uint k = 0; k < GetIcList("", devices, manufacturers[i], 0); k++)
                {
                    //Get the device struct
                    GetIcStru(manufacturers[i], devices[k], ref devstruct);

                    //Remove spaces
                    devstruct.name    = devstruct.name.Replace(" ", "");
                    devstruct.chip_id = change_endianess(devstruct.chip_id, devstruct.chip_id_bytes_count);

                    //If not duplicate process the chip
                    if (checkBox5.Checked == false || !is_duplicate(devices_list, devstruct))
                    {
                        //Log the device
                        if (total.ContainsKey(devstruct.protocol_id))
                        {
                            total[devstruct.protocol_id] += devstruct.name + Environment.NewLine;
                        }
                        else
                        {
                            total.Add(devstruct.protocol_id, devstruct.name + Environment.NewLine);
                        }

                        /*Rename specific adapter to generic
                         * if (checkBox5.Checked == true)
                         * {
                         *
                         *
                         *  switch (devstruct.package_details & 0xFF)
                         *  {
                         *      case 1:
                         *      case 2:
                         *      case 6:
                         *          devstruct.name = devstruct.name.Split('@')[0] + "@TSOP";
                         *          break;
                         *  }
                         *
                         * }
                         */
                        devices_list.Add(devstruct);
                    }
                    else
                    {
                        duplicates.Add(devstruct.name);
                    }
                }
                progressBar.Value += 1;
                Application.DoEvents();
            }
            progressBar.Value = progressBar.Maximum;

            List <DevStruct> tmp_list = new List <DevStruct>();

            foreach (DevStruct d in devices_list)
            {
                devstruct = d;
                //Patch Microchip and Atmel controllers
                if (devstruct.category == 2)
                {
                    string key = devstruct.name.Split('@')[0];
                    key = key.Split('(')[0];
                    if (microchip_csv_list.ContainsKey(key))
                    {
                        devstruct.chip_id = microchip_csv_list[key].DeviceID;
                        //devstruct.opts3 = microchip_csv_list[key].DeviceIDMask;
                    }
                    else if (atmel_csv_list.ContainsKey(key))
                    {
                        devstruct.chip_id = atmel_csv_list[key].DeviceID;
                    }
                }
                devstruct.name = devstruct.name.Replace("1.8v", "(1.8v)");
                devstruct.name = devstruct.name.Replace("((1.8v))", "(1.8v)");
                devstruct.name = devstruct.name.Replace("1.8V", "(1.8V)");
                devstruct.name = devstruct.name.Replace("((1.8V))", "(1.8V)");
                tmp_list.Add(devstruct);
            }
            devices_list = tmp_list;
            tmp_list     = new List <DevStruct>();



            //Sort the list by category
            if (checkBox6.Checked == true)
            {
                for (uint i = 1; i < 6; i++)
                {
                    foreach (DevStruct d in devices_list)
                    {
                        if (d.category == i)
                        {
                            tmp_list.Add(d);
                        }
                    }
                }
                devices_list = tmp_list;
            }

            //Convert
            for (int i = 0; i < devices_list.Count; i++)
            {
                //Get the element in ini format
                if (checkBox2.Checked)
                {
                    device_list_ini.Add(get_ic_string_ini(devices_list[i]) + Environment.NewLine);
                }

                //Get the element in C header format
                if (checkBox1.Checked)
                {
                    device_list_c.Add(get_ic_string_c(devices_list[i]));
                }

                //Get the element in xml format
                if (checkBox3.Checked)
                {
                    device_list_xml.Add(get_ic_xml(devices_list[i]));
                }
            }
            try
            {
                //Write the devices.h file
                if (checkBox1.Checked)
                {
                    using (StreamWriter stream_writer = new StreamWriter("devices.h"))
                    {
                        foreach (string elem in device_list_c)
                        {
                            stream_writer.WriteLine(elem);
                        }
                    }
                }

                //write the devices.ini file
                if (checkBox2.Checked)
                {
                    using (StreamWriter stream_writer = new StreamWriter("devices.ini"))
                    {
                        foreach (string elem in device_list_ini)
                        {
                            stream_writer.WriteLine(elem);
                        }
                    }
                }

                //write the devices.xml file
                if (checkBox3.Checked)
                {
                    XmlTextWriter xml_text_writer = new XmlTextWriter("Devices.xml", System.Text.Encoding.UTF8);
                    xml_text_writer.Formatting  = Formatting.Indented;
                    xml_text_writer.Indentation = 2;
                    XmlSerializer           serializer           = new XmlSerializer(device_list_xml.GetType(), new XmlRootAttribute("devices"));
                    XmlSerializerNamespaces serializer_namespace = new XmlSerializerNamespaces();
                    serializer_namespace.Add("", "");
                    serializer.Serialize(xml_text_writer, device_list_xml, serializer_namespace);
                    xml_text_writer.Close();
                }

                //write the log.txt file
                if (checkBox4.Checked)
                {
                    using (StreamWriter stream_writer = new StreamWriter("log.txt"))
                    {
                        foreach (KeyValuePair <uint, string> key in total)
                        {
                            stream_writer.WriteLine("Protocol:0x" + key.Key.ToString("X2") + Environment.NewLine + key.Value);
                        }
                        stream_writer.Write(Environment.NewLine +
                                            devices_list.Count.ToString() + " devices in " +
                                            total.Count.ToString() + " protocols.");
                    }

                    using (StreamWriter stream_writer = new StreamWriter("duplicates.txt"))
                    {
                        foreach (string d in duplicates)
                        {
                            stream_writer.WriteLine(d);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Save error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                progressBar.Value = 0;
                return;
            }
            MessageBox.Show(this, "Dump was saved in " + Application.StartupPath, "InfoIc", MessageBoxButtons.OK, MessageBoxIcon.Information);
            progressBar.Value = 0;
        }