Describes a ROM Image opened by the patching utility.
Exemplo n.º 1
0
        public virtual void Read(ECU image)
        {
            //TODO, pull this ot and make as extension to generic axis
            //remove "scaling" reference -> populate object during construction
            this.scaling = this.defaultScaling;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);
                this.byteValues    = new List <byte[]>();
                this.floatValues   = new List <float>();
                this.displayValues = new List <string>();

                for (int i = 0; i < this.elements; i++)
                {
                    byte[] b = new byte[this.scaling.storageSize];
                    image.imageStream.Read(b, 0, this.scaling.storageSize);
                    if (this.endian == "big")
                    {
                        b.ReverseBytes();
                    }
                    this.byteValues.Add(b);
                    this.displayValues.Add(this.scaling.toDisplay(b));
                    //Must add scaling stuff in here!
                }
            }
        }
Exemplo n.º 2
0
 public void ReadMap(EcuMap idaMap, ECU image)
 {
     //loop through base def and search for table names in map
     foreach (var romtable in AggregateBaseRomTables)
     {
         foreach (var idan in idaMap.CleanLocs)
         {
             if (romtable.Key.EqualsDefineString(idan.Key))
             {
                 ExposeTable(romtable.Key, LookupTableFactory.CreateLookupTable(romtable.Key, uint.Parse(idan.Value.ToString(), NumberStyles.AllowHexSpecifier), image.imageStream));
                 break;
             }
         }
     }
     ////TODO RAMTABLES
     //foreach (var ramtable in baseDef.RamTableList)
     //{
     //    foreach (var idan in idaMap.IdaCleanNames)
     //    {
     //        if (ramtable.Key.EqualsIdaString(idan.Key))
     //        {
     //            break;
     //        }
     //    }
     //}
 }
Exemplo n.º 3
0
        public void ImportMapFile(string filepath, ECU image)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(filepath);
            ReadMap(im, image);
        }
Exemplo n.º 4
0
        public void ImportMapText(string text, ECU image)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(text);
            ReadMap(im, image);
        }
Exemplo n.º 5
0
 public override void Read(ECU image)
 {
     //TODO, pull this ot and make as extension to generic axis
     //remove "scaling" reference -> populate object during construction
     this.scaling       = this.defaultScaling;
     this.displayValues = new List <string>();
     foreach (string value in this.StaticData)
     {
         this.displayValues.Add(value.ToString());
     }
 }
Exemplo n.º 6
0
        public virtual void Write()
        {
            ECU image = this.baseTable.parentImage;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);

                //write this.bytevalues!
                foreach (byte[] bytevalue in this.byteValues)
                {
                    if (this.scaling.endian == "big")
                    {
                        bytevalue.ReverseBytes();
                    }
                    image.imageStream.Write(bytevalue, 0, bytevalue.Length);
                }
            }
        }
Exemplo n.º 7
0
 public override void Read(ECU image)
 {
     //TODO, pull this ot and make as extension to generic axis
     //remove "scaling" reference -> populate object during construction
     this.scaling = this.defaultScaling;
     this.displayValues = new List<string>();
     foreach (string value in this.StaticData)
     {
         this.displayValues.Add(value.ToString());
     }
 }
Exemplo n.º 8
0
        public virtual void Read(ECU image)
        {
            //TODO, pull this ot and make as extension to generic axis
            //remove "scaling" reference -> populate object during construction
            this.scaling = this.defaultScaling;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);
                this.byteValues = new List<byte[]>();
                this.floatValues = new List<float>();
                this.displayValues = new List<string>();

                for (int i = 0; i < this.elements; i++)
                {
                    byte[] b = new byte[this.scaling.storageSize];
                    image.imageStream.Read(b, 0, this.scaling.storageSize);
                    if (this.endian == "big")
                    {
                        b.ReverseBytes();
                    }
                    this.byteValues.Add(b);
                    this.displayValues.Add(this.scaling.toDisplay(b));
                    //Must add scaling stuff in here!
                }
            }
        }
Exemplo n.º 9
0
 public void ReadMap(EcuMap idaMap,ECU image)
 {
     //loop through base def and search for table names in map
     foreach (var romtable in AggregateBaseRomTables)
     {
         foreach (var idan in idaMap.CleanLocs)
         {
             if (romtable.Key.EqualsDefineString(idan.Key))
             {
                 ExposeTable(romtable.Key, LookupTableFactory.CreateLookupTable(romtable.Key, uint.Parse(idan.Value.ToString(), NumberStyles.AllowHexSpecifier), image.imageStream));
                 break;
             }
         }
     }
     ////TODO RAMTABLES
     //foreach (var ramtable in baseDef.RamTableList)
     //{
     //    foreach (var idan in idaMap.IdaCleanNames)
     //    {
     //        if (ramtable.Key.EqualsIdaString(idan.Key))
     //        {
     //            break;
     //        }
     //    }
     //}
 }
Exemplo n.º 10
0
 public void openDeviceImage(string filename)
 {
     //Construct new romimage
     //TODO move this, application logic shouldn't be in GUI class.
     ECU newImage = new ECU(sharpTuner, filename);
     if (newImage.CalId == null)
     {
         Trace.TraceWarning(String.Format("Unable to identify rom at {0}", newImage.FilePath.ToString()));
         MessageBox.Show("Unable to idenfity rom at " + newImage.FilePath.ToString());
         return;
     }
     foreach (ECU image in sharpTuner.ImageList)
     {
         if (image.FilePath == filename)
         {
             Console.Write("Rom is already open!");
             return;
         }
     }
     this.closeDeviceImageToolStripMenuItem.Enabled = true;
     obfuscateCALIDToolStripMenuItem.Enabled = true;
     sharpTuner.AddImage(newImage);
     this.openDeviceListBox.Items.Add(sharpTuner.activeImage.FileName);
     Trace.WriteLine("Successfully opened " + sharpTuner.activeImage.CalId + " filename: " + sharpTuner.activeImage.FileName);
     Refresh();
 }
Exemplo n.º 11
0
 public void ImportMapFile(string filepath, ECU image)
 {
     EcuMap im = new EcuMap();
     im.ImportFromMapFileOrText(filepath);
     ReadMap(im,image);
 }
Exemplo n.º 12
0
 public XMLtoIDCGUI(ECU di)
 {
     deviceImage = di;
     xmlConv = new XMLtoIDC(deviceImage);
     InitializeComponent();
 }
Exemplo n.º 13
0
 public XMLtoIDC(ECU di)
 {
     deviceImage = di;
     workingDir = deviceImage.FileDirectory;
 }
Exemplo n.º 14
0
 public XMLtoIDC(ECU di)
 {
     deviceImage = di;
     workingDir = deviceImage.FilePath;
 }
Exemplo n.º 15
0
 //public static void setSsmInterface(SsmInterface s)
 //{
 //    ssmInterface = s;
 //}
 public void AddImage(ECU d)
 {
     ImageList.Add(d);
     activeImage = d;
 }
Exemplo n.º 16
0
 public void ImportMapText(string text, ECU image)
 {
     EcuMap im = new EcuMap();
     im.ImportFromMapFileOrText(text);
     ReadMap(im,image);
 }
Exemplo n.º 17
0
 public List<Mod> GetValidMods(ECU d)
 {
     List<Mod> tm = new List<Mod>();
     foreach (Mod m in AvailableMods)
     {
         //TODO: When a mod is loaded, detect "FFFFFFF" CALID!!!
         if (m.InitialCalibrationId == d.CalId && m.TryCheckApplyMod(d.FilePath, d.FilePath + ".temp", true, false))
         {
             tm.Add(m);
             Trace.WriteLine("Loaded Mod: " + m.FileName);
         }
         else if (m.ModIdent == d.CalId && m.TryCheckApplyMod(d.FilePath, d.FilePath + ".temp", false, false))
         {
             tm.Add(m);
             Trace.WriteLine("Loaded Mod: " + m.FileName);
         }
     }
     return tm;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Determines which command to run.
 /// </summary>
 private static bool Run(string[] args)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     sharpTuner = new SharpTuner();
     if (args.Length < 1)
     {
         Application.Run(sharpTuner.mainWindow);
         return true;
     }
     else
     {
         sharpTuner.Init();
         if (args[0] == "ecumaptool")
         {
             return EcuMapTool.Run(sharpTuner.AvailableDevices, Utils.ShiftLeftTruncate(args));
         }
         else if (args[0] == "rommod")
         {
             return SharpTune.RomMod.RomMod.Run(sharpTuner.AvailableDevices, Utils.ShiftLeftTruncate(args));
         }
         else if (args[0] == "xmlconvertor")
         {
             ECU di = new ECU(sharpTuner, args[1]);
             XMLtoIDC xti = new XMLtoIDC(di);
             //TODO clean up this routine: xti.Run(args);
         }
         else if (args.Length == 2 && args[0] == "help")
         {
             PrintHelp_RomMod(args[1]);
             return true;
         }
     }
     return false;
 }