예제 #1
0
파일: CCFTools.cs 프로젝트: demonzhq/JLR
        private void ImportVBF(string FileName)
        {
            try
            {
                bool Result = false;
                CJLRVBF.VBFFile VBFFile = new CJLRVBF.VBFFile();
                Result = VBFFile.Import(FileName);

                
                if (!Result)
                    throw new Exception("VBF Import Error");

                Result = CCFBin.Import(VBFFile.DataBlocks[0].Data);
                if (!Result)
                    throw new Exception("Not a CCF Binary");
                Result = MastPayLoad.ReadValue(ref CCFBin);
                if (!Result)
                    throw new Exception("Data Translation Not Complete");
                FillData(MastPayLoad.CCFParameters);
                DoSearch();

                MessageBox.Show("Read Finished", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: demonzhq/JLR
        private void button4_Click(object sender, EventArgs e)
        {
            CJLRVBF.VBFFile File = new VBFFile();
            File.ForceImport("D:\\a.vbf");
            ushort Poly = 0;
            Poly = 0xF617;

            MessageBox.Show("Finished");
            
        }
예제 #3
0
파일: CCFTools.cs 프로젝트: demonzhq/JLR
        private void btnSaveVBF_Click(object sender, EventArgs e)
        {
            try
            {
                List<VBFCreationData> VBFData = GetVBFCreationData(cbxCarType.Text);
                if (VBFData == null || VBFData.Count == 0)
                    throw new Exception("Car Type Not Supportted");



                if (sfdSaveVBF.ShowDialog() == DialogResult.OK)
                {
                    string OutputPath = Path.GetDirectoryName(sfdSaveVBF.FileName);
                    string FileName = Path.GetFileNameWithoutExtension(sfdSaveVBF.FileName);
                    if (!OutputPath.EndsWith("\\"))
                        OutputPath = OutputPath + "\\";







                    foreach(VBFCreationData t in VBFData)
                    {
                        VBFFile p = new VBFFile();
                        p.setHeaderPrarm("vbf_version = 2.2;\r\nheader{\r\n\tsw_part_number = \"\";\r\n"
                            + "\tsw_part_type =" + t.sw_part_type + ";\r\n"
                            + "\tnetwork = " + t.network + " ;\r\n"
                            + "\tecu_address = " + "0x" + Convert.ToString(t.ecu_address, 16) + ";\r\n"
                            + "\tframe_format = CAN_STANDARD;}\r\n");
                        CCFBin.CCFBinaryLength = Convert.ToInt32(t.parameter_erase_length);
                        VBFBlock q = new VBFBlock(t.parameter_start_address, CCFBin.ExportBytes());
                        p.DataBlocks.Add(q);
                        string OutputFile = OutputPath + FileName + "_" + t.NodeName + ".VBF";
                        bool Result = p.Export(OutputFile);
                        if (!Result)
                            throw new Exception("VBF Generate Failed");
                        if (cbx_Setting_ExportSBL.Checked)
                        {
                            try
                            {
                                string sourceSBL = new DirectoryInfo(tbx_Setting_SBLFoler.Text).FullName + "\\" + t.SBL + ".vbf";
                                string TargetSBL = OutputPath + t.SBL + ".vbf";
                                File.Copy(sourceSBL, TargetSBL);
                            }
                            catch
                            {

                            }
                        }
                    }








                    string SDSfile = OutputPath + FileName + ".sds";
                    if (File.Exists(SDSfile))
                        File.Delete(SDSfile);
                    StreamWriter SDSStream = new StreamWriter(SDSfile);
                    SDSStream.Write(Library.GetSDSString(cbxCarType.Text, FileName, VBFData));
                    SDSStream.Close();



                    MessageBox.Show("File Creation Finished", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }

               
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: demonzhq/JLR
        private void button2_Click(object sender, EventArgs e)
        {
            //AESCryptoService a = new AESCryptoService();

            //MessageBox.Show((b.ToUniversalTime() - a.ToUniversalTime()).TotalMilliseconds.ToString());

            CJLRVBF.VBFFile a = new VBFFile();
            a.ForceImport("D:\\a.vbf");

            StreamWriter SW = new StreamWriter("D:\\CheckSum.txt");




            a.UnCompressData();
            for (int i = 0; i < a.DataBlocks.Count; i++)
            {
                a.DataBlocks[i].UpdateChecksum();

                SW.Write(Convert.ToString(a.DataBlocks[i].Length, 16).ToUpper());
                SW.Write(" ");
                SW.Write(Convert.ToString(a.DataBlocks[i].CheckSum, 16).ToUpper());

                SW.Write("\r\n");
            }
            a.CompressData();

            a.UnCompressData();
            for (int i = 0; i < a.DataBlocks.Count; i++)
            {
                a.DataBlocks[i].UpdateChecksum();

                SW.Write(Convert.ToString(a.DataBlocks[i].Length, 16).ToUpper());
                SW.Write(" ");
                SW.Write(Convert.ToString(a.DataBlocks[i].CheckSum, 16).ToUpper());

                SW.Write("\r\n");
            }

           

            SW.Close();


            MessageBox.Show("Finished");
        }