Example #1
0
 /// <summary>
 /// Constructor
 /// TODO: Change to a factory to share already-opened definitions
 /// TODO: Include more information about inheritance in the class for def-editing
 /// </summary>
 /// <param name="calID"></param>
 public ECUMetaData(AvailableDevices ad, string filepath)
     : this(ad)
 {
     filePath = filepath;
     //TODO: switch based on current definition schema
     ParseMetaData_ECUFlash();
 }
Example #2
0
 public EcuMapTool(AvailableDevices ad)
 {
     availableDevices = ad;
     Defines = new Dictionary<string, List<EcuLoc>>();
     Sections = new Dictionary<KeyValuePair<string,List<string>>, List<string>>();
     ecuMap = new EcuMap();
 }
Example #3
0
 public ModDefinition(AvailableDevices ad, Mod parent)
 {
     availableDevices = ad;
     parentMod = parent;
     RomLutList = new List<LookupTable>();
     RamTableList = new Dictionary<string, TableMetaData>();
     definition = new ECUMetaData(availableDevices);
 }
Example #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ECUMetaData(AvailableDevices ad)
 {
     availableDevices = ad;
     isBase = false;
     ident = new ECUIdentifier();
     ExposedRomTables = new Dictionary<string, TableMetaData>();
     ExposedRamTables = new Dictionary<string, TableMetaData>();
     BaseRomTables = new Dictionary<string, TableMetaData>();
     BaseRamTables = new Dictionary<string, TableMetaData>();
     ScalingList = new Dictionary<string,Scaling>();
     inheritList = new List<ECUMetaData>();
 }
Example #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ECUMetaData(AvailableDevices ad)
 {
     availableDevices = ad;
     isBase           = false;
     ident            = new ECUIdentifier();
     ExposedRomTables = new Dictionary <string, TableMetaData>();
     ExposedRamTables = new Dictionary <string, TableMetaData>();
     BaseRomTables    = new Dictionary <string, TableMetaData>();
     BaseRamTables    = new Dictionary <string, TableMetaData>();
     ScalingList      = new Dictionary <string, Scaling>();
     inheritList      = new List <ECUMetaData>();
 }
Example #6
0
        public static bool Run(AvailableDevices ad, string[] args)
        {
            try
            {

                EcuMapTool prog = new EcuMapTool(ad);//TODO: get rid of static?

                if (args.Length < 1 || args[0].EqualsCI("-h") || args[0].EqualsCI("-help"))
                {
                    WriteHelp();
                }
                else if (args[0].ContainsCI(".h"))
                {
                    prog.ReadHeader(args[0]);
                    if (args.Length < 2) //no idc filename specified, use header name
                        prog.WriteIDC(Regex.Split(args[0], ".h")[0] + ".idc");
                    else if (args[1].ContainsCI(".idc"))
                        prog.WriteIDC(args[1]);
                    else
                        WriteHelp();
                }
                else if (args[0].ContainsCI(".map"))
                {
                    prog.MapToDefines(args[0]);
                    if (args.Length < 2) //no filename specified
                        prog.WriteIDC(Regex.Split(args[0], ".map")[0] + ".idc");
                    else if (args[1].ContainsCI(".idc"))
                        prog.WriteIDC(args[1]);
                    else
                        WriteHelp();
                }
                else if (args[0].ContainsCI(".xml") && args[1].ContainsCI(".map") && args[2].ContainsCI(".h") && args[3].ContainsCI(".txt") && args.Length == 6)
                {
                    prog.UpdateTargetHeader(args[0], args[1], args[2], args[3], args[4], args[5], null);
                }
                else if (args[0].ContainsCI(".xml") && args[1].ContainsCI(".map") && args[2].ContainsCI(".h") && args[3].ContainsCI(".txt") && args.Length == 7)
                {
                    prog.UpdateTargetHeader(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
                }
                else
                    WriteHelp();
                return true; //TODO FIX!!
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                return false;
            }
        }
Example #7
0
 /// <summary>
 /// Determines which command to run.
 /// </summary>
 public static bool Run(AvailableDevices availableDevices, string[] args)
 {
     if (args.Length == 2 && args[0] == "help")
     {
         PrintHelp(args[1]);
         return true;
     }
     else if (args.Length == 2 && args[0] == "dump")
     {
         return RomMod.TryDumpSRecordFile(args[1]);
     }
     else if (args.Length == 3 && args[0] == "test")
     {
         return RomMod.TryApply(args[1], args[2], true, false) || RomMod.TryApply(args[1], args[2], false, false);
     }
     else if (args.Length == 3 && args[0] == "apply")
     {
         return RomMod.TryApply(args[1], args[2], true, true);
     }
     else if (args.Length == 3 && args[0] == "applied")
     {
         return RomMod.TryApply(args[1], args[2], false, false);//TODO is this deprecated?
     }
     else if (args.Length == 3 && args[0] == "remove")
     {
         return RomMod.TryApply(args[1], args[2], false, true);
     }
     else if (args.Length == 4 && args[0] == "baseline")
     {
         return RomMod.TryGenerateBaseline(args[1], args[2], args[3]);
     }
     else if (args.Length == 4 && args[0] == "baselinedefine")
     {
         return RomMod.TryBaselineAndDefine(availableDevices, args[1], args[2], args[3],Settings.Default.EcuFlashDefRepoPath);
     }
     else if (args.Length == 4 && args[0] == "define")
     {
         return RomMod.TryDefine(availableDevices, args[1], args[2], args[3], Settings.Default.EcuFlashDefRepoPath);
     }
     else if (args.Length == 4 && args[0] == "hewbuild")
     {
         return RomMod.TryHewBuild(availableDevices, args[1], args[2], args[3], Settings.Default.EcuFlashDefRepoPath);
     }
     PrintHelp();
     return false;
 }
Example #8
0
 public IDAtoHEW(AvailableDevices ad)
 {
     availableDevices = ad;
     InitializeComponent();
 }
Example #9
0
 public void PopulateAvailableDevices()
 {
     AvailableDevices = new AvailableDevices();
     if (Directory.Exists(Settings.Default.EcuFlashDefRepoPath) && (Directory.GetDirectories(Settings.Default.EcuFlashDefRepoPath).Length > 0 || Directory.GetFiles(Settings.Default.EcuFlashDefRepoPath).Length < 1 ))
     {
         Trace.WriteLine("Loading definitions from: " + Settings.Default.EcuFlashDefRepoPath);
         AvailableDevices.Populate(Settings.Default.EcuFlashDefRepoPath);
     }
     else
     {
         if (!Directory.Exists(Settings.Default.EmbeddedDefRepoPath))
             Directory.CreateDirectory(Settings.Default.EmbeddedDefRepoPath);
         if (Directory.GetFiles(Settings.Default.EmbeddedDefRepoPath).Length < 1)
             CopyEmbeddedDefs();
         Trace.WriteLine("Loading definitions from: " + Settings.Default.EmbeddedDefRepoPath);
         AvailableDevices.Populate(Settings.Default.EmbeddedDefRepoPath);
     }
 }
Example #10
0
 public static bool TryHewBuild(AvailableDevices ad, string patchPath, string romPath, string bc, string defPath)
 {
     Mod mod = new Mod(patchPath, bc);
     using (Stream romStream = File.OpenRead(romPath))
     {
         Trace.WriteLine("Attempting to read patches");
         if (!mod.TryReadPatches())
         {
             PrintError("READING PATCH");
             return false;
         }
         Trace.WriteLine("Attempting to baseline patches");
         if (!mod.TryPrintBaselines(patchPath, romStream))
         {
             PrintError("GENERATING BASELINES");
             return false;
         }
     }
     File.Copy(romPath, "oem.bin", true);
     Trace.WriteLine("Attempting to test patches");
     if (!mod.TryCheckApplyMod(romPath, romPath, true, false)) //&& !mod.TryCheckApplyMod(romPath, romPath, false, false)) ;
     {
         PrintError("TESTING PATCH");
         return false;
     }
     Trace.WriteLine("Attempting to apply patches");
     if (!mod.TryCheckApplyMod(romPath, romPath, true, true))
     {
         PrintError("APPLYING PATCH");
         return false;
     }
     Trace.WriteLine("Attempting to remove patches");
     File.Copy(romPath, "reverted.bin", true);
     if (!mod.TryCheckApplyMod("reverted.bin", "reverted.bin", false, true))
     {
         PrintError("REMOVING PATCH");
         return false;
     }
     Trace.WriteLine("Attempting to verify patch removal");
     if (!Utils.FileCompare("reverted.bin", "oem.bin"))
     {
         PrintError("VERIFYING REMOVED PATCH");
         return false;
     }
     Trace.WriteLine("Attempting to define patch");
     if (!mod.TryDefinition(ad, defPath))
     {
         PrintError("WRITING DEFINITIONS");
         return false;
     }
     Trace.WriteLine("Attempting to copy patch to: "+ bc + "\\" + mod.InitialCalibrationId + "\\" + mod.FileName);
     string d = bc + "\\" + mod.InitialCalibrationId + "\\";
     Directory.CreateDirectory(d);
     string c = d + mod.FileName;
     File.Copy(mod.FilePath,c,true);
     Trace.WriteLine("HEW BUILD SUCCESS!!");
     return true;
 }
Example #11
0
        public bool TryDefinition(AvailableDevices ad, string defPath)
        {
            //Read metadata
            try
            {
                Trace.WriteLine("Attempting to read definition metadata");
                this.modDef = new ModDefinition(ad, this);
                if (!modDef.TryReadDefs(defPath)) return false;
                Trace.WriteLine("Success reading definition meatdata");
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error reading definition metadata");
                Trace.WriteLine(e.Message);
                return false;
            }

            //Create RR logger def
            try
            {
                Trace.WriteLine("Attempting to create RR logger definition");
                //TODO: move RR stuff into definition?
                //prompt to select logger type
                modDef.NewRRLogDefInheritWithTemplate(this.modDef.RamTableList, Settings.Default.RomRaiderLoggerDefPath + @"\MerpMod\" + this.ModBuild + @"\" + this.ModIdent + ".xml", Settings.Default.RomRaiderLoggerDefPath + @"\MerpMod\base.xml", this.InitialEcuId.ToString(), this.FinalEcuId.ToString());
                Trace.WriteLine("Success creating RR logger definition");
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error creating RR logger definition");
                Trace.WriteLine(e.Message);
                return false;
            }

            //Create RR ecu def
            try
            {
                Trace.WriteLine("Attempting to create RR ecu definition");
                //TODO: move RR stuff into definition?
                //prompt to select logger type
                string path = Settings.Default.RomRaiderEcuDefPath + @"\MerpMod\" + this.ModBuild + @"\"; //TODO: use settings???
                Directory.CreateDirectory(path);
                path += this.ModIdent + ".xml";
                modDef.PopulateRREcuDefStub(path);

                Trace.WriteLine("Success creating RR ecu definition");
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error creating RR ecu definition");
                Trace.WriteLine(e.Message);
                return false;
            }

            //Create ECUFlash definition
            try {
                if (ModBuild != null)
                    defPath = defPath + "/MerpMod/" + ModBuild + "/";
                Directory.CreateDirectory(defPath);
                defPath += ModIdent.ToString() + ".xml";
                Trace.WriteLine("Attempting to export ECUFlash definition to: " + defPath);
                modDef.definition.ExportEcuFlashXML(defPath);
                Trace.WriteLine("Success exporting ECUFlash definition");
                return true;
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error exporting ECUFlash definition");
                Trace.WriteLine(e.Message);
                return false;
            }
        }
Example #12
0
        /// <summary>
        /// Constructor used to create new definitions using existing data
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="carinfo"></param>
        /// <param name="include"></param>
        /// <param name="xromt"></param>
        /// <param name="xramt"></param>
        public ECUMetaData(AvailableDevices ad, string fp, Mod mod)
            : this(ad)
        {
            try
            {
                this.filePath = fp;

                ident = availableDevices.DefDictionary[mod.InitialCalibrationId].ident.Clone();
                ident.UpdateFromMod(mod);

                Inherit();

                //TODO: ADD THE TABLES FROM MOD
                //mod.modDef.
                foreach (var rt in mod.modDef.RomLutList)
                {
                    //do something with each lut.
                    ExposeTable(rt.Name, rt); //TODO: Fix this redundancy?
                }
                //TODO: Add RAM tables!
            }
            catch (Exception crap)
            {
                Trace.Write("Error creating definition OBJECT at " + fp);
                throw;
            }
        }
Example #13
0
 public ECUMetaData(AvailableDevices ad, string respath, bool isres)
     : this(ad)
 {
     filePath = respath;
     ParseMetaData_ECUFlash();
 }
Example #14
0
        private static bool TryBaselineAndDefine(AvailableDevices ad, string patchPath, string romPath, string build, string defPath)
        {
            using (Stream romStream = File.OpenRead(romPath))
            {
                Mod patcher = new Mod(patchPath, build);

                if (!patcher.TryReadPatches())
                    return false;
                if (!patcher.TryDefinition(ad, defPath))
                    return false;
                return patcher.TryPrintBaselines(patchPath,romStream);
            }
        }
Example #15
0
 public static void PopulateAvailableDevices()
 {
     AvailableDevices = new AvailableDevices(EcuFlashDefRepoPath.ToString());
 }
Example #16
0
 public ECUMetaData(AvailableDevices ad, string respath, bool isres)
     : this(ad)
 {
     filePath = respath;
     ParseMetaData_ECUFlash();
 }
Example #17
0
 public static bool TryDefine(AvailableDevices ad, string patchPath, string romPath, string bc, string defPath)
 {
     using (Stream romStream = File.OpenRead(romPath))
     {
         Mod mod = new Mod(patchPath, bc);
         return mod.TryDefinition(ad, defPath);
     }
 }