Defines and Applies a Mod (series of patches) to a ROM.
コード例 #1
0
ファイル: ModDefinition.cs プロジェクト: nosajton/SharpTune
 public ModDefinition(AvailableDevices ad, Mod parent)
 {
     availableDevices = ad;
     parentMod = parent;
     RomLutList = new List<LookupTable>();
     RamTableList = new Dictionary<string, TableMetaData>();
     definition = new ECUMetaData(availableDevices);
 }
コード例 #2
0
ファイル: ECUMetaData.cs プロジェクト: nosajton/SharpTune
        /// <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;
            }
        }
コード例 #3
0
ファイル: RomMod.cs プロジェクト: Merp/SharpTune
 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);
     }
 }
コード例 #4
0
ファイル: Definition.cs プロジェクト: segapsh2/SharpTune
        /// <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 Definition(string filepath, Mod mod)
            : this()
        {
            this.include = mod.InitialCalibrationId;
            defPath = filepath;

            CloneRomIdFrom(include,true);

            CarInfo["internalidaddress"] = mod.ModIdentAddress.ToString("X");
            CarInfo["internalidstring"] = mod.ModIdent.ToString();
            CarInfo["ecuid"] = mod.FinalEcuId.ToString();
            CarInfo["xmlid"] = mod.ModIdent.ToString();
            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?
            }
        }
コード例 #5
0
ファイル: RomMod.cs プロジェクト: Merp/SharpTune
        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);
            }
        }
コード例 #6
0
ファイル: RomMod.cs プロジェクト: Merp/SharpTune
        /// <summary>
        /// Extract data from an unpatched ROM file, for inclusion in a patch file.
        /// </summary>
        private static bool TryGenerateBaseline(string patchPath, string romPath, string build)
        {
            using (Stream romStream = File.OpenRead(romPath))
            {
                Mod patcher = new Mod(patchPath, build);

                if (!patcher.TryReadPatches())
                    return false;
                return patcher.TryPrintBaselines(patchPath, romStream);
            }
        }
コード例 #7
0
ファイル: RomMod.cs プロジェクト: Merp/SharpTune
 private static bool TryApply(string patchPath, string romPath, bool apply, bool commit)
 {
     Mod currentMod = new Mod(patchPath);//TODO: KING KLUDGE!
     return currentMod.TryCheckApplyMod(romPath, romPath, apply, commit);
 }
コード例 #8
0
ファイル: RomMod.cs プロジェクト: Merp/SharpTune
 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;
 }
コード例 #9
0
ファイル: MainWindow.cs プロジェクト: Merp/SharpTune
        private bool TryUpgradeMod(Mod m, string outfile)
        {
            foreach (KeyValuePair<Mod,ModDirection> mkvp in sharpTuner.activeImage.ModList)
            {
                if (mkvp.Value == ModDirection.Remove)
                {
                    if (m.TryCheckApplyMod(sharpTuner.activeImage.FilePath, outfile, false, true))
                    {
                        if (m.TryCheckApplyMod(outfile, outfile, true, true))
                        {
                            MessageBox.Show("MOD SUCCESSFULLY UPGRADED!", "SharpTune", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            sharpTuner.fileQueued = true;
                            sharpTuner.QueuedFilePath = outfile;
                            return true;
                        }
                    }
                }
            }
            return false;
        }
コード例 #10
0
ファイル: MainWindow.cs プロジェクト: Merp/SharpTune
        private bool TryRemoveMod(Mod m, string infile, string outfile)
        {
            if (m.TryCheckApplyMod(infile, outfile, false, true))
            {
                MessageBox.Show("MOD SUCCESSFULLY REMOVED!", "SharpTune", MessageBoxButtons.OK, MessageBoxIcon.Information);

                sharpTuner.fileQueued = true;
                sharpTuner.QueuedFilePath = outfile;
                return true;
            }
            return false;
        }
コード例 #11
0
ファイル: ModDefinition.cs プロジェクト: segapsh2/SharpTune
 public ModDefinition(Mod parent)
 {
     this.parentMod = parent;
     RomLutList = new List<Lut>();
     RamTableList = new Dictionary<string, Table>();
 }