├── .gitignore
├── DONATE.md
├── PatchingAPI.md
├── Properties
└── AssemblyInfo.cs
├── README.md
├── SharpTune.exe
├── SharpTune.sln
├── SharpTune.userprefs
├── SharpTune
├── AvailableDevices.cs
├── Core
│ ├── Checksum
│ │ ├── ChecksumSubaruDBW.cs
│ │ └── IChecksumModule.cs
│ ├── ECU.cs
│ ├── ECUIdentifier.cs
│ ├── ECUMetaData.cs
│ ├── ExpressionEvaluator.cs
│ ├── FlashMethod
│ │ └── IFlashMethod.cs
│ ├── MemoryModel
│ │ └── IMemoryModel.cs
│ ├── Plugin.cs
│ ├── ResourceUtil.cs
│ ├── Table
│ │ ├── Axis.cs
│ │ ├── ITableReader.cs
│ │ ├── ITableWriter.cs
│ │ ├── LookupTable.cs
│ │ ├── RamTableReader.cs
│ │ ├── RamTableWriter.cs
│ │ ├── Range.cs
│ │ ├── RomTableReader.cs
│ │ ├── RomTableWriter.cs
│ │ └── Scaling.cs
│ ├── TableMetaData
│ │ ├── Table1DMetaData.cs
│ │ ├── Table2DMetaData.cs
│ │ ├── Table3DMetaData.cs
│ │ └── TableMetaData.cs
│ └── TableTree.cs
├── DumpXML.cs
├── EcuMapTools
│ ├── EcuLoc.cs
│ ├── EcuLocCandidate.cs
│ ├── EcuMap.cs
│ ├── EcuMapTool.cs
│ ├── SSMBase.cs
│ └── XMLtoIDC.cs
├── ExpressionEvaluator.cs
├── GUI
│ ├── AboutWindow.Designer.cs
│ ├── AboutWindow.cs
│ ├── AboutWindow.resx
│ ├── CalidUtility.Designer.cs
│ ├── CalidUtility.cs
│ ├── CalidUtility.resx
│ ├── CustomGrid.cs
│ ├── DefinitionEditor.Designer.cs
│ ├── DefinitionEditor.cs
│ ├── DefinitionEditor.resx
│ ├── IDAtoHEW.Designer.cs
│ ├── IDAtoHEW.cs
│ ├── IDAtoHEW.resx
│ ├── License.Designer.cs
│ ├── License.cs
│ ├── License.resx
│ ├── MainWindow.Designer.cs
│ ├── MainWindow.cs
│ ├── MainWindow.resx
│ ├── MapToDef.Designer.cs
│ ├── MapToDef.cs
│ ├── MapToDef.resx
│ ├── SSMTestApp.Designer.cs
│ ├── SSMTestApp.cs
│ ├── SSMTestApp.resx
│ ├── SimpleCombo.cs
│ ├── SimplePrompt.cs
│ ├── TableView.Designer.cs
│ ├── TableView.cs
│ ├── TableView.resx
│ ├── UndefinedWindow.Designer.cs
│ ├── UndefinedWindow.cs
│ ├── UndefinedWindow.resx
│ ├── XMLtoIDC.Designer.cs
│ ├── XMLtoIDC.cs
│ └── XMLtoIDC.resx
├── GitVersionUpdate.bat
├── ObjectCopier.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfoTemplate.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── PropertyBag.cs
├── RAMDump.cs
├── Resources
│ └── beer1.png
├── RomMod.csproj
├── RomMod
│ ├── Blob.cs
│ ├── BlobList.cs
│ ├── Mod.cs
│ ├── ModDefinition.cs
│ ├── Patch.cs
│ ├── RomMod.cs
│ ├── SRecord.cs
│ ├── SRecordReader.cs
│ ├── SRecordWriter.cs
│ └── Verifier.cs
├── SharpTuner.cs
├── Tables
│ ├── Axis.cs
│ ├── Category.cs
│ ├── PropertyBag.cs
│ ├── Range.cs
│ ├── Table.cs
│ └── Table2D.cs
├── TextBoxStreamWriter.cs
├── Utils.cs
├── app.config
└── dump.xml
├── TODO.md
└── logger.dtd
/.gitignore:
--------------------------------------------------------------------------------
1 | #gitignore
2 | SharpTune/Properties/AssemblyInfo.cs
3 | [Oo]bj
4 | [Bb]in
5 | *.user
6 | *.suo
7 | *.[Cc]ache
8 | *.bak
9 | *.ncb
10 | *.log
11 | *.DS_Store
12 | [Tt]humbs.db
13 | _ReSharper.*
14 | *.resharper
15 | Ankh.NoLoad
16 |
17 | SharpTune/Resources/Defs/*
18 | SharpTune/Resources/Mods/*
19 | .vs/*
20 |
--------------------------------------------------------------------------------
/DONATE.md:
--------------------------------------------------------------------------------
1 | Donations are greatly appreciated! They can be sent to merrillamyersiii@gmail.com using google wallet, dwolla, or paypal.
2 |
3 | Paypal link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2QREF3U5CSFA8
--------------------------------------------------------------------------------
/PatchingAPI.md:
--------------------------------------------------------------------------------
1 | The SharpTune rom patching command line API is defined by SharpTune.RomMod.RomMod.
2 |
3 | The API for mod metadata used in patch creation and application is defined in SharpTune.RomMod.Mod
4 |
5 | The API for mod definition creation is defined in SharpTune.RomMod.ModDefinition
6 |
7 | A working example can be observed in the MerpMod project's Metadata.c and Definition.c files at https://github.com/Merp/MerpMod.
8 |
9 | The SharpTune rom patching API consists of three main functions; Target Rom Selection, Patch file creation, and Patch file application.
10 |
11 | A typical workflow using Renesas HEW:
12 | Target Rom Selection
13 | Compile patch in HEW
14 | Patch File creation
15 | Patch File application
16 | HEW Debugging
17 |
18 |
19 | Target Rom Selection
20 | ====================
21 |
22 | Description:
23 |
24 | Target rom selection is the process of reading definition data from a .map file and normalizing this data for use with the MerpMod source.
25 |
26 | Phases:
27 |
28 | Receive command line arguments from Target Selection phase of HEW build
29 | EcuMapTool updates target rom's header and linker files using .map input file and idatohew.xml
30 |
31 | Details:
32 |
33 | Command line arguments are sent to SharpTune using a custom build phase in HEW. This build phase calls TargetSelection.bat and passes the target rom calibration ID using environment variables.
34 | TargetSelection.bat then calls SharpTune.exe ecumaptool and provides the appropriate input filenames.
35 | The target rom's header and map files are loaded, where all of the defines are unmarshalled to objects.
36 | Definitions from the map file are then translated using idatohew.xml. This process converts nomenclature used to describe definitions in the map file to a nomenclature compatible with MerpMod. Users may alter this to suit their naming conventions by adding their own 'ida name' elements, being careful to observe the example below.
37 | Tools are also provided in the SharpTune GUI to create IDC scripts so users may normalize their naming conventions.
38 | During this process, the HEW output window will display entries of xmltoidc that have not been defined for debugging purposes.
39 | Normalized definition data from map files will override header file defines, but header file defines are otherwise persistent and entries must be removed manually.
40 |
41 | Example idatohew.xml entry:
42 |
43 |
44 |
45 |
46 |
47 | *note: if multiple ida name candidates are provided, priority tags must be set this way! It is a bit crude but it works.
48 |
49 | Idatohew.xml also handles the linker script which creates linker sections.
50 | In this case, multiple candidates are not used. The necessary locations (alias names in the xml) must be defined in the map file as they are named in idatohew.xml.
51 |
52 |
53 | Patch File Creation
54 | ===================
55 |
56 | Patch file creation consists of the following phases:
57 | Input partial-patch.mot s-record file from HEW
58 | Read metadata section of partial patch
59 | Construct individual patches
60 | Add baseline data to individual patches
61 | Check individual patches
62 | Output complete mod patch file
63 | Read definition metadata from patch file
64 | Create definition files
65 |
66 | The metadata API can be easily inferred from the MerpMod project's Metadata.c. Further details are in SharpTune.RomMod.Mod
67 |
68 | The definition data API can be easily inferred from the MerpMod project's Definition.c. Further details are in SharpTune.RomMod.ModDefinition
69 |
70 | Patch File Application
71 | ======================
72 | Check baseline data of patches against device image (ROM)
73 | Apply patches to a copy of the device image
74 | Check patches
75 | Output new device image
76 |
77 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EcuHack")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EcuHack")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("28a4357e-3742-4de4-8044-8c11abc335f3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SharpTune
2 |
3 | SharpTune is an automotive ROM image reader/editor with functionality to apply Mods and patches to the image. It is written in C# using windows forms.
4 |
5 | It is currently in a very alpha state and it is NOT recommended to use the editor until it is thoroughly debugged.
6 |
7 | Embedded resources are specified in RomMod.csproj, not in project properties -> resources GUI.
8 |
9 | # Credits:
10 | -Merp - SharpTune GUI Design, RomModCore upgrades, Subaru mod development
11 | -NSFW - RomModCore (Previously RomPatch), Subaru mod development (Transition to HEW)
12 | -Dschultz - RomRaider Management/Development
13 | -FredCooke & FreeEMS community - Helping me out with all sorts of crap
14 | -RomRaider definition developers and the rest of the community
15 |
16 | # License:
17 | This program is free software: you can redistribute it and/or modify
18 | it under the terms of the GNU General Public License as published by
19 | the Free Software Foundation, either version 3 of the License, or
20 | (at your option) any later version.
21 | This program is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | GNU General Public License for more details.
--------------------------------------------------------------------------------
/SharpTune.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Merp/SharpTune/ecabea89615132dac2de37c05f72adae16d966d1/SharpTune.exe
--------------------------------------------------------------------------------
/SharpTune.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Express 2012 for Windows Desktop
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RomMod", "SharpTune\RomMod.csproj", "{49D56AC9-4956-4C5A-A17D-E64C32CCE693}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Debug|Itanium = Debug|Itanium
10 | Debug|Mixed Platforms = Debug|Mixed Platforms
11 | Debug|x64 = Debug|x64
12 | Debug|x86 = Debug|x86
13 | Release|Any CPU = Release|Any CPU
14 | Release|Itanium = Release|Itanium
15 | Release|Mixed Platforms = Release|Mixed Platforms
16 | Release|x64 = Release|x64
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|Any CPU.ActiveCfg = Debug|x86
21 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|Itanium.ActiveCfg = Debug|x86
22 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
23 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|Mixed Platforms.Build.0 = Debug|x86
24 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|x64.ActiveCfg = Debug|x86
25 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|x86.ActiveCfg = Debug|x86
26 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Debug|x86.Build.0 = Debug|x86
27 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|Any CPU.ActiveCfg = Release|x86
28 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|Itanium.ActiveCfg = Release|x86
29 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|Mixed Platforms.ActiveCfg = Release|x86
30 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|Mixed Platforms.Build.0 = Release|x86
31 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|x64.ActiveCfg = Release|x86
32 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|x86.ActiveCfg = Release|x86
33 | {49D56AC9-4956-4C5A-A17D-E64C32CCE693}.Release|x86.Build.0 = Release|x86
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/SharpTune.userprefs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/SharpTune/Core/Checksum/ChecksumSubaruDBW.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Checksum
7 | {
8 | [Serializable]
9 | public class ChecksumSubaruDBW : IChecksumModule
10 | {
11 | public string Name
12 | {
13 | get { return "subarudbw"; }
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/SharpTune/Core/Checksum/IChecksumModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Checksum
7 | {
8 | public interface IChecksumModule
9 | {
10 | string Name { get; }
11 | }
12 |
13 | public static class ChecksumModules
14 | {
15 | public static IChecksumModule GetChecksumModule(string n)
16 | {
17 | foreach (IChecksumModule csm in checksumModules)
18 | {
19 | if (n.ToLower() == csm.Name.ToLower())
20 | return csm;
21 | }
22 | throw new Exception(String.Format("ChecksumModule {0} not found !!", n));
23 | }
24 |
25 | static ChecksumSubaruDBW _subarudbw = new ChecksumSubaruDBW();
26 |
27 | public static List checksumModules = new List() {
28 | _subarudbw,
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/SharpTune/Core/FlashMethod/IFlashMethod.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.FlashMethod
7 | {
8 | public interface IFlashMethod
9 | {
10 | string name { get; }
11 | }
12 |
13 | [Serializable]
14 | public class FlashMethodWRX02 : IFlashMethod
15 | {
16 | public string name{
17 | get{return "wrx02";}
18 | }
19 | }
20 |
21 | [Serializable]
22 | public class FlashMethodWRX04 : IFlashMethod
23 | {
24 | public string name{
25 | get{return "wrx04";}
26 | }
27 | }
28 |
29 | [Serializable]
30 | public class FlashMethodSTI04 : IFlashMethod
31 | {
32 | public string name{
33 | get{return "sti04";}
34 | }
35 | }
36 |
37 | [Serializable]
38 | public class FlashMethodSTI05 : IFlashMethod
39 | {
40 | public string name{
41 | get{return "sti05";}
42 | }
43 | }
44 |
45 | [Serializable]
46 | public class FlashMethodSubaruCAN : IFlashMethod
47 | {
48 | public string name{
49 | get{return "subarucan";}
50 | }
51 | }
52 |
53 | [Serializable]
54 | public class FlashMethodSubaruBRZ : IFlashMethod
55 | {
56 | public string name{
57 | get{return "subarubrz";}
58 | }
59 | }
60 |
61 | [Serializable]
62 | public static class FlashMethods{
63 |
64 | public static IFlashMethod GetFlashMethod(string n){
65 | foreach(IFlashMethod fm in FlashMethods.flashMethods){
66 | if (n.ToLower() == fm.name.ToLower())
67 | return fm;
68 | }
69 | throw new Exception(String.Format("FlashMethod {0} not found!!"));
70 | }
71 |
72 | static FlashMethodWRX02 _wrx02 = new FlashMethodWRX02();
73 | static FlashMethodWRX04 _wrx04 = new FlashMethodWRX04();
74 | static FlashMethodSTI04 _sti04 = new FlashMethodSTI04();
75 | static FlashMethodSTI05 _sti05 = new FlashMethodSTI05();
76 | static FlashMethodSubaruCAN _subarucan = new FlashMethodSubaruCAN();
77 | static FlashMethodSubaruBRZ _subarubrz = new FlashMethodSubaruBRZ();
78 |
79 | public static List flashMethods = new List() {
80 | _wrx02, _wrx04, _sti04, _sti05, _subarucan, _subarubrz
81 | };
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/SharpTune/Core/MemoryModel/IMemoryModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.MemoryModel
7 | {
8 | public interface IMemoryModel
9 | {
10 | string name { get; }
11 | int cpubits {get; }
12 | int filesizebytes { get; }
13 | System.Text.Encoding encoding { get;}
14 | }
15 |
16 | [Serializable]
17 | public class MemoryModelDefault : IMemoryModel
18 | {
19 | public string name{
20 | get{return "DEFAULT - SH7058";}
21 | }
22 | public int cpubits{
23 | get{return 32;}
24 | }
25 | public int filesizebytes{
26 | get{return 1048576;}
27 | }
28 | public System.Text.Encoding encoding{
29 | get{return System.Text.Encoding.UTF8;}
30 | }
31 | }
32 |
33 | [Serializable]
34 | public class MemoryModelSubaruSH7055 : IMemoryModel
35 | {
36 | public string name{
37 | get{return "SH7055";}
38 | }
39 | public int cpubits{
40 | get{return 32;}
41 | }
42 | public int filesizebytes{
43 | get{return 524288;}
44 | }
45 | public System.Text.Encoding encoding{
46 | get{return System.Text.Encoding.UTF8;}
47 | }
48 | }
49 |
50 | [Serializable]
51 | public class MemoryModelSubaruSH7058 : IMemoryModel
52 | {
53 | public string name{
54 | get{return "SH7058";}
55 | }
56 | public int cpubits{
57 | get{return 32;}
58 | }
59 | public int filesizebytes{
60 | get{return 1048576;}
61 | }
62 | public System.Text.Encoding encoding{
63 | get{return System.Text.Encoding.UTF8;}
64 | }
65 | }
66 |
67 | [Serializable]
68 | public class MemoryModelSubaruSH72531 : IMemoryModel
69 | {
70 | public string name{
71 | get{return "SH72531";}
72 | }
73 | public int cpubits{
74 | get{return 32;}
75 | }
76 | public int filesizebytes{
77 | get{return 1572864;}
78 | }
79 | public System.Text.Encoding encoding{
80 | get{return System.Text.Encoding.UTF8;}
81 | }
82 | }
83 |
84 | [Serializable]
85 | public class MemoryModelSubaruHC16 : IMemoryModel
86 | {
87 | public string name{
88 | get{return "68HC16Y5";}
89 | }
90 | public int cpubits{
91 | get{return 16;}
92 | }
93 | public int filesizebytes{
94 | get{return 196608;}
95 | }
96 | public System.Text.Encoding encoding{
97 | get{return System.Text.Encoding.UTF8;}
98 | }
99 | }
100 |
101 | [Serializable]
102 | public class MemoryModelMitsubishiH8539F : IMemoryModel
103 | {
104 | public string name{
105 | get{return "H8539F";}
106 | }
107 | public int cpubits{
108 | get{return 32;}
109 | }
110 | public int filesizebytes{
111 | get{return 1048576;}
112 | }
113 | public System.Text.Encoding encoding{
114 | get{return System.Text.Encoding.UTF8;}
115 | }
116 | }
117 |
118 | [Serializable]
119 | public class MemoryModelMitsubishiSH7052 : IMemoryModel
120 | {
121 | public string name{
122 | get{return "SH7052";}
123 | }
124 | public int cpubits{
125 | get{return 32;}
126 | }
127 | public int filesizebytes{
128 | get{return 1048576;}
129 | }
130 | public System.Text.Encoding encoding{
131 | get{return System.Text.Encoding.UTF8;}
132 | }
133 | }
134 |
135 | [Serializable]
136 | public class MemoryModelMitsubishiM32186F8 : IMemoryModel
137 | {
138 | public string name{
139 | get{return "M32186F8";}
140 | }
141 | public int cpubits{
142 | get{return 32;}
143 | }
144 | public int filesizebytes{
145 | get{return 1048576;}
146 | }
147 | public System.Text.Encoding encoding{
148 | get{return System.Text.Encoding.UTF8;}
149 | }
150 | }
151 |
152 | public static class MemoryModels{
153 |
154 | public static IMemoryModel GetMemoryModel(string n){
155 | foreach(IMemoryModel fm in MemoryModels.memoryModels){
156 | if (n.ToLower() == fm.name.ToLower())
157 | return fm;
158 | }
159 | throw new Exception(String.Format("MemoryModel {0} not found!!"));
160 | }
161 |
162 | public static MemoryModelDefault _Default = new MemoryModelDefault();
163 |
164 | static MemoryModelSubaruSH7055 _SubaruSH7055 = new MemoryModelSubaruSH7055();
165 | static MemoryModelSubaruSH7058 _SubaruSH7058 = new MemoryModelSubaruSH7058();
166 | static MemoryModelSubaruSH72531 _SubaruSH72531 = new MemoryModelSubaruSH72531();
167 | static MemoryModelSubaruHC16 _Subaru68HC16Y5 = new MemoryModelSubaruHC16();
168 | static MemoryModelMitsubishiH8539F _MitsubishiH8539F = new MemoryModelMitsubishiH8539F();
169 | static MemoryModelMitsubishiM32186F8 _MitsubishiM32186F8 = new MemoryModelMitsubishiM32186F8();
170 | static MemoryModelMitsubishiSH7052 _MitsubishiSH7052 = new MemoryModelMitsubishiSH7052();
171 |
172 | public static List memoryModels = new List() {
173 | _SubaruSH7055, _SubaruSH7058, _SubaruSH72531, _Subaru68HC16Y5,
174 | _MitsubishiH8539F, _MitsubishiM32186F8, _MitsubishiSH7052,
175 | _Default
176 | };
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/SharpTune/Core/Plugin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Windows.Forms;
9 |
10 | namespace SharpTune.Core
11 | {
12 | public interface IPluginHost
13 | {
14 | bool Register(IPlugin ipi);
15 | }
16 |
17 | public interface IPlugin
18 | {
19 | string Name { get; set; }
20 | IPluginHost Host { get; set; }
21 | bool Run(Stream stream);
22 | }
23 |
24 | class PluginContainer : IPluginHost
25 | {
26 |
27 | private IPlugin[] ipis;
28 |
29 | private List SupportedPlugins = new List(){"SharpTune Vin Auth"};
30 |
31 | public bool Register(IPlugin ipi)
32 | {
33 | //MenuItem mn = new MenuItem(ipi.Name, new EventHandler(NewLoad));
34 | Trace.WriteLine("Registered: " + ipi.Name);
35 | //menuItem1.MenuItems.Add(mn);
36 | return true;
37 | }
38 |
39 | //private void NewLoad(object sender, System.EventArgs e)
40 | //{
41 | // //MenuItem mn = (MenuItem)sender;
42 | // for (int i = 0; i < ipis.Length; i++)
43 | // {
44 | // foreach (string strType in SupportedPlugins)
45 | // {
46 | // if (ipis[i] != null)
47 | // {
48 | // if (ipis[i].Name == strType)
49 | // {
50 | // ipis[i].Run();
51 | // break;
52 | // }
53 | // }
54 | // }
55 | // }
56 | //}
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/ITableReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Table
7 | {
8 | public interface ITableReader
9 | {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/ITableWriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Table
7 | {
8 | public interface ITableWriter
9 | {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/RamTableReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Table
7 | {
8 | public class RamTableReader : ITableReader
9 | {
10 | ///OLD CODE EXTRACTED FROM TABLE CLASSES
11 | ///
12 | //public override void Read()
13 | //{
14 | // DeviceImage image = this.parentImage;
15 | // this.elements = 1;
16 | // Scaling sc;
17 | // if (parentDef.ScalingList.TryGetValue(this.properties["scaling"].ToString(), out sc))
18 | // {
19 | // this.defaultScaling = sc;
20 | // }
21 | // else
22 | // throw new Exception(String.Format("Error, scaling {0} not found!", this.properties["scaling"].ToString()));
23 |
24 | ////Check SSM interface ID vs the device ID
25 | //if (SharpTuner.ssmInterface.EcuIdentifier != this.parentImage.CalId)
26 | //{
27 | // throw new System.Exception("Device Image does not match connected device!");
28 | //}
29 |
30 | //SsmInterface ssmInterface = SharpTuner.ssmInterface;
31 |
32 | //May have an issue with this while logging???
33 | //Is it necessary??
34 | //TODO: Find out
35 | //lock (ssmInterface)
36 | //{
37 | // this.byteValues = new List();
38 | // this.displayValues = new List();
39 |
40 | // byte[] b = new byte[this.scaling.storageSize];
41 | // IAsyncResult result = ssmInterface.BeginBlockRead(this.address, this.scaling.storageSize, null, null);
42 | // result.AsyncWaitHandle.WaitOne();
43 | // b = ssmInterface.EndBlockRead(result);
44 | // if (this.scaling.endian == "big")
45 | // {
46 | // b.ReverseBytes();
47 | // }
48 | // this.byteValues.Add(b);
49 | // this.displayValues.Add(this.scaling.toDisplay(b));
50 | //}
51 | //}
52 |
53 | //public override void Read()
54 | //{
55 |
56 |
57 | ////Check SSM interface ID vs the device ID
58 | //if (SharpTuner.ssmInterface.EcuIdentifier != this.parentImage.CalId)
59 | //{
60 | // throw new System.Exception("Device Image does not match connected device!");
61 | //}
62 |
63 | //SsmInterface ssmInterface = SharpTuner.ssmInterface;
64 |
65 | //May have an issue with this while logging???
66 | //Is it necessary??
67 | //TODO: Find out
68 | //lock (ssmInterface)
69 | //{
70 | // this.byteValues = new List();
71 | // this.displayValues = new List();
72 |
73 | // byte[] b = new byte[this.scaling.storageSize];
74 | // IAsyncResult result = ssmInterface.BeginBlockRead(this.address, this.scaling.storageSize, null, null);
75 | // result.AsyncWaitHandle.WaitOne();
76 | // b = ssmInterface.EndBlockRead(result);
77 | // if (this.scaling.endian == "big")
78 | // {
79 | // b.ReverseBytes();
80 | // }
81 | // this.byteValues.Add(b);
82 | // this.displayValues.Add(this.scaling.toDisplay(b));
83 | //}
84 | //}
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/RamTableWriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Table
7 | {
8 | public class RamTableWriter : ITableWriter
9 | {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/Range.cs:
--------------------------------------------------------------------------------
1 | // Range.cs: Simple helper struct.
2 |
3 | /* Copyright (C) 2011 SubaruDieselCrew
4 | *
5 | * This file is part of ScoobyRom.
6 | *
7 | * ScoobyRom is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * ScoobyRom is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with ScoobyRom. If not, see .
19 | */
20 |
21 |
22 | using System;
23 |
24 | namespace SharpTuneCore
25 | {
26 | public struct Range : IEquatable
27 | {
28 | // 2 fields
29 | int pos;
30 | int size;
31 |
32 | ///
33 | /// Position of first byte.
34 | ///
35 | public int Pos
36 | {
37 | get { return pos; }
38 | set { pos = value; }
39 | }
40 |
41 | ///
42 | /// Data size in bytes.
43 | ///
44 | public int Size
45 | {
46 | get { return size; }
47 | set { size = value; }
48 | }
49 |
50 | ///
51 | /// Last used byte position.
52 | /// (= Pos + Size - 1)
53 | ///
54 | public int Last
55 | {
56 | get { return pos + size - 1; }
57 | }
58 |
59 | public Range(int start, int size)
60 | {
61 | this.pos = start;
62 | this.size = size;
63 | }
64 |
65 | public bool Intersects(Range other)
66 | {
67 | if (other.Last < this.pos || other.pos > this.Last)
68 | return false;
69 | else
70 | return true;
71 | }
72 |
73 | public override string ToString()
74 | {
75 | return string.Format("[Pos=0x{0:X}, Size={1}, Last=0x{2:X}]", pos, size.ToString(), Last);
76 | }
77 |
78 | public override int GetHashCode()
79 | {
80 | return this.pos ^ (this.size << 3);
81 | }
82 |
83 |
84 | #region IEquatable implementation
85 |
86 | public bool Equals(Range other)
87 | {
88 | return this.pos == other.pos && this.size == other.size;
89 | }
90 |
91 | #endregion
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/RomTableReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Table
7 | {
8 | public class RomTableReader : ITableReader
9 | {
10 | ///OLD CODE EXTRACTED FROM TABLE CLASSES
11 | ///
12 | ////From table1d:
13 | //public override void Read()
14 | //{
15 | // DeviceImage image = this.parentImage;
16 |
17 | // lock (image.imageStream)
18 | // {
19 | // image.imageStream.Seek(this.address, SeekOrigin.Begin);
20 | // this.byteValues = new List();
21 | // this.displayValues = new List();
22 |
23 | // byte[] b = new byte[this.scaling.storageSize];
24 | // image.imageStream.Read(b, 0, this.scaling.storageSize);
25 | // if (this.scaling.endian == "big")
26 | // {
27 | // b.ReverseBytes();
28 | // }
29 | // this.byteValues.Add(b);
30 | // this.displayValues.Add(this.scaling.toDisplay(b));
31 |
32 | // }
33 | //}
34 |
35 | ////table2d:
36 | //public override void Read()
37 | //{
38 | // DeviceImage image = this.parentImage;
39 | // this.elements = this.yAxis.elements; // * this.yAxis.elements;TODO WTF
40 |
41 | // lock (image.imageStream)
42 | // {
43 | // image.imageStream.Seek(this.address, SeekOrigin.Begin);
44 | // this.byteValues = new List();
45 | // this.floatValues = new List();
46 | // this.displayValues = new List();
47 |
48 | // for (int i = 0; i < this.elements; i++)
49 | // {
50 | // byte[] b = new byte[this.scaling.storageSize];
51 | // image.imageStream.Read(b, 0, this.scaling.storageSize);
52 | // if (this.scaling.endian == "big")
53 | // {
54 | // b.ReverseBytes();
55 | // }
56 | // this.byteValues.Add(b);
57 | // this.displayValues.Add(this.scaling.toDisplay(b));
58 | // }
59 |
60 | // }
61 | //}
62 |
63 | ////table3d
64 | /////
65 | ///// Read table bytes from ROM
66 | ///// And convert to display values
67 | /////
68 | //public override void Read()
69 | //{
70 | // DeviceImage image = this.parentImage;
71 | // this.elements = this.xAxis.elements * this.yAxis.elements;
72 |
73 | // lock (image.imageStream)
74 | // {
75 | // image.imageStream.Seek(this.address, SeekOrigin.Begin);
76 | // this.byteValues = new List();
77 | // this.floatValues = new List();
78 | // this.displayValues = new List();
79 |
80 | // for (int i = 0; i < this.elements; i++)
81 | // {
82 | // byte[] b = new byte[this.scaling.storageSize];
83 | // image.imageStream.Read(b, 0, this.scaling.storageSize);
84 | // if (this.scaling.endian == "big")
85 | // {
86 | // b.ReverseBytes();
87 | // }
88 | // this.byteValues.Add(b);
89 | // this.displayValues.Add(this.scaling.toDisplay(b));
90 | // }
91 |
92 | // }
93 | //}
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/SharpTune/Core/Table/RomTableWriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpTune.Core.Table
7 | {
8 | public class RomTableWriter : ITableWriter
9 | {
10 |
11 | ///OLD CODE EXTRACTED FROM TABLE CLASSES
12 | ///
13 | // //from table1d
14 | // public override void Write()
15 | // {
16 | // DeviceImage image = this.parentImage;
17 | // lock (image.imageStream)
18 | // {
19 | // //No need to write axes, they don't really exist for 1D tables!
20 | // image.imageStream.Seek(this.address, SeekOrigin.Begin);
21 |
22 | // //write this.bytevalues!
23 | // foreach (byte[] bytevalue in this.byteValues)
24 | // {
25 | // if (this.scaling.endian == "big")
26 | // {
27 | // bytevalue.ReverseBytes();
28 | // }
29 | // image.imageStream.Write(bytevalue, 0, bytevalue.Length);
30 | // }
31 | // }
32 |
33 | // }
34 |
35 | // //table2d:
36 |
37 |
38 | // public override void Write()
39 | // {
40 | // DeviceImage image = this.parentImage;
41 | // lock (image.imageStream)
42 | // {
43 | // //2D only has Y axis
44 | // this.yAxis.Write();
45 | // image.imageStream.Seek(this.address, SeekOrigin.Begin);
46 |
47 | // //write this.bytevalues!
48 | // foreach (byte[] bytevalue in this.byteValues)
49 | // {
50 | // if (this.scaling.endian == "big")
51 | // {
52 | // bytevalue.ReverseBytes();
53 | // }
54 | // image.imageStream.Write(bytevalue, 0, bytevalue.Length);
55 | // }
56 | // }
57 |
58 | // }
59 |
60 |
61 | // //table3d
62 |
63 |
64 | // ///
65 | // /// Write the table bytes to ROM
66 | // ///
67 | // public override void Write()
68 | // {
69 | // DeviceImage image = this.parentImage;
70 |
71 | // lock (image.imageStream)
72 | // {
73 | // //2D only has Y axis
74 | // this.yAxis.Write();
75 | // this.xAxis.Write();
76 | // image.imageStream.Seek(this.address, SeekOrigin.Begin);
77 |
78 | // //write this.bytevalues!
79 | // foreach (byte[] bytevalue in this.byteValues)
80 | // {
81 | // if (this.scaling.endian == "big")
82 | // {
83 | // bytevalue.ReverseBytes();
84 | // }
85 | // image.imageStream.Write(bytevalue, 0, bytevalue.Length);
86 | // }
87 | // }
88 |
89 | // }
90 | //}
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/SharpTune/Core/TableMetaData/Table1DMetaData.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Xml.Linq;
18 | using System.Data;
19 | using System.IO;
20 | using SharpTune;
21 | using System.Windows.Forms;
22 | using System.Drawing;
23 | using SharpTune.Core;
24 | using System.Runtime.Serialization;
25 |
26 | namespace SharpTuneCore
27 | {
28 |
29 | public class Table1DMetaData : TableMetaData
30 | {
31 |
32 |
33 | public Table1DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
34 | : base(xel, def, basetable)
35 | { this.type = "1D"; }
36 |
37 | public override TableMetaData CreateChild(LookupTable lut,ECUMetaData d)
38 | {
39 | return base.CreateChild(lut,d);
40 | }
41 | }
42 |
43 |
44 | public class RamTable1DMetaData : Table1DMetaData
45 | {
46 | public RamTable1DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)// DeviceImage image)
47 | : base(xel, def, basetable)
48 | {
49 |
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/SharpTune/Core/TableMetaData/Table2DMetaData.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Xml.Linq;
18 | using System.Data;
19 | using System.IO;
20 | using SharpTune;
21 | using SharpTuneCore;
22 | using SharpTune.Core;
23 | using System.Runtime.Serialization;
24 |
25 | namespace SharpTuneCore
26 | {
27 | public class Table2DMetaData : TableMetaData
28 | {
29 |
30 | public Table2DMetaData(XElement xel,ECUMetaData def, TableMetaData basetable)
31 | : base(xel, def, basetable)
32 | {
33 | this.type = "2D";
34 | }
35 |
36 | public override TableMetaData CreateChild(LookupTable ilut,ECUMetaData d)
37 | {
38 | //TODO: This is a major KLUDGE.
39 | if (ilut.GetType() != typeof(LookupTable2D))
40 | return base.CreateChild(ilut, d);
41 |
42 | XElement xel;
43 | LookupTable2D lut = (LookupTable2D)ilut;
44 | xel = new XElement("table");
45 | xel.SetAttributeValue("name", name);
46 | xel.SetAttributeValue("address", ilut.dataAddress.ToString("X"));
47 | if (this.xAxis != null)
48 | {
49 | XElement tx = new XElement("table");
50 | tx.SetAttributeValue("name", "X");
51 | tx.SetAttributeValue("address", lut.colsAddress.ToString("X"));
52 | tx.SetAttributeValue("elements", lut.cols);
53 | xel.Add(tx);
54 | }
55 | else
56 | {
57 | XElement ty = new XElement("table");
58 | ty.SetAttributeValue("name", "Y");
59 | ty.SetAttributeValue("address", lut.colsAddress.ToString("X"));
60 | ty.SetAttributeValue("elements", lut.cols);
61 | xel.Add(ty);
62 | }
63 | return TableFactory.CreateTable(xel, name, d);
64 | //TODO also set attirbutes and split this up! Copy to table2D!!
65 | //return base.CreateChild(lut,d);
66 | //TODO FIX?? AND CHECK FOR STATIC AXES!!
67 | }
68 | }
69 |
70 | public class RamTable2DMetaData : Table2DMetaData
71 | {
72 |
73 | public RamTable2DMetaData(XElement xel,ECUMetaData def, TableMetaData basetable)
74 | : base(xel,def,basetable)
75 | {
76 |
77 | }
78 |
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/SharpTune/Core/TableMetaData/Table3DMetaData.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Xml.Linq;
18 | using System.Data;
19 | using System.IO;
20 | using SharpTune;
21 | using System.Windows.Forms;
22 | using System.Drawing;
23 | using SharpTune.Core;
24 | using System.Runtime.Serialization;
25 |
26 | namespace SharpTuneCore
27 | {
28 |
29 | public class Table3DMetaData : TableMetaData
30 | {
31 |
32 | public Table3DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
33 | : base(xel, def, basetable)
34 | {
35 | this.type = "3D";
36 | }
37 |
38 | public override TableMetaData CreateChild(LookupTable ilut, ECUMetaData d)
39 | {
40 | XElement xel;
41 | LookupTable3D lut = (LookupTable3D)ilut;
42 | xel = new XElement("table");
43 | xel.SetAttributeValue("name", name);
44 | xel.SetAttributeValue("address", ilut.dataAddress.ToString("X"));
45 | XElement tx = new XElement("table");
46 | tx.SetAttributeValue("name", "X");
47 | tx.SetAttributeValue("address", lut.colsAddress.ToString("X"));
48 | tx.SetAttributeValue("elements", lut.cols);
49 | xel.Add(tx);
50 | XElement ty = new XElement("table");
51 | ty.SetAttributeValue("name", "Y");
52 | ty.SetAttributeValue("address", lut.rowsAddress.ToString("X"));
53 | ty.SetAttributeValue("elements", lut.rows);
54 | xel.Add(ty);
55 | return TableFactory.CreateTable(xel, name, d);
56 | //TODO also set attirbutes and split this up! Copy to table2D!!
57 | }
58 | }
59 |
60 | public class RamTable3DMetaData : Table3DMetaData
61 | {
62 |
63 | public RamTable3DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
64 | : base(xel, def, basetable)
65 | {
66 |
67 | }
68 |
69 | }
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/SharpTune/DumpXML.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Xml;
18 | using System.IO;
19 | using ConsoleRedirection;
20 |
21 | namespace DumpXML
22 | {
23 | class DumpXml
24 | {
25 | StringBuilder output = new StringBuilder();
26 |
27 | public List rangeNameList = new List();
28 |
29 | public List rangeStartList = new List();
30 |
31 | public List rangeLengthList = new List();
32 |
33 | public void readXml()
34 | {
35 |
36 | using (XmlTextReader reader = new XmlTextReader("dump.xml"))
37 | {
38 | reader.ReadToFollowing("range");
39 | while (reader.EOF == false)
40 | {
41 |
42 |
43 | reader.MoveToFirstAttribute();
44 | rangeNameList.Add(reader.Value);
45 | reader.MoveToNextAttribute();
46 | string temp = (reader.Value);
47 | rangeNameList.Add(temp);
48 | rangeStartList.Add(Int32.Parse(reader.Value, System.Globalization.NumberStyles.HexNumber));
49 | reader.MoveToNextAttribute();
50 | temp = (reader.Value);
51 | rangeNameList.Add(temp);
52 | int temp1 = (Int32.Parse(reader.Value, System.Globalization.NumberStyles.HexNumber));
53 | int temp2 = rangeStartList[rangeStartList.Count-1];
54 | rangeLengthList.Add(temp1-temp2);
55 |
56 | reader.ReadToFollowing("range");
57 | }
58 |
59 | }
60 |
61 | }
62 |
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/SharpTune/EcuMapTools/EcuLoc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Xml.Linq;
6 | using SharpTune;
7 | using System.IO;
8 | using System.Diagnostics;
9 |
10 | namespace SharpTune.EcuMapTools
11 | {
12 | ///
13 | /// Represents a location within the ecu
14 | /// Encapsulates the EcuLocCandidates (potential names in .map file)
15 | /// used to identify the locations
16 | ///
17 | public class EcuLoc
18 | {
19 |
20 | public string name { get; private set; }
21 | public string dataType { get; private set; } //TODO: enums???
22 | public Dictionary ecuRefCandidates { get; private set; }
23 | public string offset {get; private set; }
24 | public string bit {get; private set; }
25 |
26 | public EcuLoc(XElement xe)
27 | {
28 | ecuRefCandidates = new Dictionary();
29 | name = xe.Attribute("name").Value.ToString();
30 | if (xe.Attribute("type") != null)
31 | dataType = xe.Attribute("type").Value.ToString();
32 | else
33 | dataType = null;
34 | IEnumerable te = xe.Elements();
35 | ecuRefCandidates.Add(0,new EcuLocCandidate(name));
36 | foreach (var xi in xe.Elements())
37 | {
38 | EcuLocCandidate tid = new EcuLocCandidate(xi);
39 | ecuRefCandidates.Add(tid.priority, tid);
40 | }
41 | }
42 |
43 | public EcuLoc(string n, string hexaddr)
44 | {
45 | name = n;
46 | offset = hexaddr;
47 | }
48 |
49 | public string printType()
50 | {
51 | if (dataType == null)
52 | return null;
53 | return "(" + dataType + ")";
54 | }
55 |
56 | public void print(StreamWriter writer)
57 | {
58 | if (offset == null)
59 | Trace.WriteLine("COULD NOT FIND DEFINE: " + name);
60 | else
61 | writer.WriteLine("#define " + name + " (" + this.printType() + "0x" + offset + ")");
62 | }
63 |
64 | public void findOffset(Dictionary map)
65 | {
66 | foreach (var entry in map)
67 | {
68 | for (int i = 0; i < ecuRefCandidates.Count; i++)
69 | {
70 | if (entry.Key.EqualsCI(ecuRefCandidates[i].name))
71 | {
72 | offset = entry.Value.ToString();
73 | return;
74 | }
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/SharpTune/EcuMapTools/EcuLocCandidate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Xml.Linq;
6 | using SharpTune;
7 |
8 | namespace SharpTune.EcuMapTools
9 | {
10 | public class EcuLocCandidate
11 | {
12 | public string name { get; private set; }
13 | public string type { get; private set; } //TODO: use enum instead??
14 | public int priority { get; private set; }
15 |
16 | public EcuLocCandidate(XElement xi)
17 | {
18 | name = xi.Attribute("name").Value.ToString();
19 | if (xi.Attribute("type") != null)
20 | type = xi.Attribute("type").Value.ToString();
21 | else
22 | type = "default";
23 | if (xi.Attribute("priority") != null)
24 | priority = int.Parse(xi.Attribute("priority").Value.ToString());
25 | else
26 | priority = 1;
27 | }
28 |
29 | public EcuLocCandidate(string n)
30 | {
31 | name = n;
32 | type = "default";
33 | priority = 1;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SharpTune/EcuMapTools/SSMBase.cs:
--------------------------------------------------------------------------------
1 | using SharpTuneCore;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace SharpTune.EcuMapTools
9 | {
10 | public static class SSMBase
11 | {
12 | public static string getSSMBase(Stream imageStream)
13 | {
14 | byte[] byc = new byte[4];
15 | long highlimit = 5000000;
16 | long lowlimit = 100000;
17 | long difflimit = 100000;
18 | if (imageStream.Length < highlimit)
19 | highlimit = imageStream.Length;
20 | for (long i = lowlimit; i < highlimit; i += 4)
21 | {
22 | long start = i;
23 | imageStream.Seek(i, SeekOrigin.Begin);
24 | if (SSMBaseRecursion(imageStream, i, 0, 0, difflimit))
25 | return start.ToString("X");
26 | else
27 | continue;
28 | }
29 | difflimit += 40000;
30 | for (long i = lowlimit; i < highlimit; i += 4)
31 | {
32 | long start = i;
33 | imageStream.Seek(i, SeekOrigin.Begin);
34 | if (SSMBaseRecursion(imageStream, i, 0, 0, difflimit))
35 | return start.ToString("X");
36 | else
37 | continue;
38 | }
39 | return "Enter SSM Base";
40 | }
41 |
42 | private static bool SSMBaseRecursion(Stream imageStream, long currentoffset, int lastaddress, int recursionlevel, long min)
43 | {
44 | int addinc;
45 | if (recursionlevel < 6)
46 | addinc = 17;
47 | else
48 | addinc = 1000;
49 | byte[] byc = new byte[4];
50 | int bc = 0;
51 | imageStream.Read(byc, 0, 4);
52 |
53 | byc.ReverseBytes();
54 | bc = BitConverter.ToInt32(byc, 0);
55 | if (recursionlevel == 0)
56 | lastaddress = bc;
57 | if (bc > 0 && Math.Abs(currentoffset - bc) < min && lastaddress + addinc > bc)
58 | {
59 | if (recursionlevel > 40)
60 | return true;
61 | recursionlevel++;
62 | currentoffset += 4;
63 | return SSMBaseRecursion(imageStream, currentoffset, bc, recursionlevel, min);
64 | }
65 | else
66 | return false;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/SharpTune/GUI/AboutWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SharpTune.GUI
2 | {
3 | partial class AboutWindow
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutWindow));
32 | this.richTextBox1 = new System.Windows.Forms.RichTextBox();
33 | this.SuspendLayout();
34 | //
35 | // richTextBox1
36 | //
37 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
38 | | System.Windows.Forms.AnchorStyles.Left)
39 | | System.Windows.Forms.AnchorStyles.Right)));
40 | this.richTextBox1.BackColor = System.Drawing.Color.White;
41 | this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
42 | this.richTextBox1.Location = new System.Drawing.Point(12, 12);
43 | this.richTextBox1.Name = "richTextBox1";
44 | this.richTextBox1.ReadOnly = true;
45 | this.richTextBox1.Size = new System.Drawing.Size(498, 199);
46 | this.richTextBox1.TabIndex = 0;
47 | this.richTextBox1.Text = resources.GetString("richTextBox1.Text");
48 | //
49 | // AboutWindow
50 | //
51 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
52 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
53 | this.AutoSize = true;
54 | this.ClientSize = new System.Drawing.Size(522, 223);
55 | this.Controls.Add(this.richTextBox1);
56 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
57 | this.Name = "AboutWindow";
58 | this.Text = "About RomMod";
59 | this.Load += new System.EventHandler(this.About_Load);
60 | this.ResumeLayout(false);
61 |
62 | }
63 |
64 | #endregion
65 |
66 | private System.Windows.Forms.RichTextBox richTextBox1;
67 |
68 | }
69 | }
--------------------------------------------------------------------------------
/SharpTune/GUI/AboutWindow.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.ComponentModel;
16 | using System.Data;
17 | using System.Drawing;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Forms;
21 |
22 | namespace SharpTune.GUI
23 | {
24 | public partial class AboutWindow : Form
25 | {
26 | public AboutWindow()
27 | {
28 | InitializeComponent();
29 | }
30 |
31 | private void About_Load(object sender, EventArgs e)
32 | {
33 |
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SharpTune/GUI/CalidUtility.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SharpTune
2 | {
3 | partial class CalidUtility
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.button1 = new System.Windows.Forms.Button();
32 | this.button2 = new System.Windows.Forms.Button();
33 | this.newcalidbox = new System.Windows.Forms.TextBox();
34 | this.oldcalidbox = new System.Windows.Forms.TextBox();
35 | this.label1 = new System.Windows.Forms.Label();
36 | this.label2 = new System.Windows.Forms.Label();
37 | this.SuspendLayout();
38 | //
39 | // button1
40 | //
41 | this.button1.Location = new System.Drawing.Point(12, 41);
42 | this.button1.Name = "button1";
43 | this.button1.Size = new System.Drawing.Size(176, 63);
44 | this.button1.TabIndex = 0;
45 | this.button1.Text = "Generate Random CalID";
46 | this.button1.UseVisualStyleBackColor = true;
47 | this.button1.Click += new System.EventHandler(this.button1_Click);
48 | //
49 | // button2
50 | //
51 | this.button2.Location = new System.Drawing.Point(12, 142);
52 | this.button2.Name = "button2";
53 | this.button2.Size = new System.Drawing.Size(176, 63);
54 | this.button2.TabIndex = 1;
55 | this.button2.Text = "Save";
56 | this.button2.UseVisualStyleBackColor = true;
57 | this.button2.Click += new System.EventHandler(this.button2_Click);
58 | //
59 | // newcalidbox
60 | //
61 | this.newcalidbox.Location = new System.Drawing.Point(62, 116);
62 | this.newcalidbox.Name = "newcalidbox";
63 | this.newcalidbox.Size = new System.Drawing.Size(126, 20);
64 | this.newcalidbox.TabIndex = 2;
65 | //
66 | // oldcalidbox
67 | //
68 | this.oldcalidbox.Location = new System.Drawing.Point(74, 13);
69 | this.oldcalidbox.Name = "oldcalidbox";
70 | this.oldcalidbox.ReadOnly = true;
71 | this.oldcalidbox.Size = new System.Drawing.Size(114, 20);
72 | this.oldcalidbox.TabIndex = 3;
73 | //
74 | // label1
75 | //
76 | this.label1.AutoSize = true;
77 | this.label1.Location = new System.Drawing.Point(13, 16);
78 | this.label1.Name = "label1";
79 | this.label1.Size = new System.Drawing.Size(55, 13);
80 | this.label1.TabIndex = 4;
81 | this.label1.Text = "Current ID";
82 | this.label1.Click += new System.EventHandler(this.label1_Click);
83 | //
84 | // label2
85 | //
86 | this.label2.AutoSize = true;
87 | this.label2.Location = new System.Drawing.Point(13, 119);
88 | this.label2.Name = "label2";
89 | this.label2.Size = new System.Drawing.Size(43, 13);
90 | this.label2.TabIndex = 5;
91 | this.label2.Text = "New ID";
92 | //
93 | // CalidUtility
94 | //
95 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
96 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
97 | this.AutoSize = true;
98 | this.ClientSize = new System.Drawing.Size(199, 214);
99 | this.Controls.Add(this.label2);
100 | this.Controls.Add(this.label1);
101 | this.Controls.Add(this.oldcalidbox);
102 | this.Controls.Add(this.newcalidbox);
103 | this.Controls.Add(this.button2);
104 | this.Controls.Add(this.button1);
105 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
106 | this.Name = "CalidUtility";
107 | this.Text = "CalidUtility";
108 | this.Load += new System.EventHandler(this.CalidUtility_Load);
109 | this.ResumeLayout(false);
110 | this.PerformLayout();
111 |
112 | }
113 |
114 | #endregion
115 |
116 | private System.Windows.Forms.Button button1;
117 | private System.Windows.Forms.Button button2;
118 | private System.Windows.Forms.TextBox newcalidbox;
119 | private System.Windows.Forms.Label label1;
120 | private System.Windows.Forms.Label label2;
121 | protected internal System.Windows.Forms.TextBox oldcalidbox;
122 | }
123 | }
--------------------------------------------------------------------------------
/SharpTune/GUI/CalidUtility.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.ComponentModel;
16 | using System.Data;
17 | using System.Drawing;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Forms;
21 | using System.IO;
22 | using System.Collections;
23 | using SharpTune.RomMod;
24 | using SharpTuneCore;
25 | using System.Diagnostics;
26 |
27 | namespace SharpTune
28 | {
29 | public partial class CalidUtility : Form
30 | {
31 | private ECU currentImage { get; set; }
32 | private readonly SharpTuner sharpTuner;
33 |
34 | public CalidUtility(SharpTuner st, MainWindow mw)
35 | {
36 | this.sharpTuner = st;
37 | this.currentImage = st.activeImage;
38 | InitializeComponent();
39 | }
40 |
41 | private void label1_Click(object sender, EventArgs e)
42 | {
43 |
44 | }
45 |
46 | private void CalidUtility_Load(object sender, EventArgs e)
47 | {
48 | oldcalidbox.Text = currentImage.CalId;
49 | }
50 |
51 | private void button1_Click(object sender, EventArgs e)
52 | {
53 | string randomstring = RandomString(currentImage.CalId.Length);
54 | newcalidbox.Text = randomstring;
55 | }
56 |
57 | private static Random random = new Random((int)DateTime.Now.Ticks);//thanks to McAden
58 | private string RandomString(int size)
59 | {
60 | StringBuilder builder = new StringBuilder();
61 | char ch;
62 | for (int i = 0; i < size; i++)
63 | {
64 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
65 | builder.Append(ch);
66 | }
67 |
68 | return builder.ToString();
69 | }
70 |
71 | public class SADialogState
72 | {
73 |
74 | public DialogResult result;
75 |
76 | public SaveFileDialog dialog;
77 |
78 |
79 | public void ThreadProcShowDialog()
80 | {
81 | result = dialog.ShowDialog();
82 | }
83 |
84 | }
85 |
86 | private DialogResult STAShowSADialog(SaveFileDialog dialog)
87 | {
88 |
89 | SADialogState state = new SADialogState();
90 |
91 | state.dialog = dialog;
92 |
93 | System.Threading.Thread t = new System.Threading.Thread(state.ThreadProcShowDialog);
94 |
95 | t.SetApartmentState(System.Threading.ApartmentState.STA);
96 |
97 | t.Start();
98 |
99 | t.Join();
100 |
101 | return state.result;
102 |
103 | }
104 |
105 | private void button2_Click(object sender, EventArgs e)
106 | {
107 | if (newcalidbox.Text.Length != this.currentImage.CalId.Length)
108 | {
109 | MessageBox.Show("ID is not long enough!", "SharpTune", MessageBoxButtons.OK, MessageBoxIcon.Error);
110 | return;
111 | }
112 | if (sharpTuner.AvailableDevices.IdentList.ContainsCI(newcalidbox.Text.ToString()))
113 | {
114 | MessageBox.Show("ID is already defined!", "SharpTune", MessageBoxButtons.OK, MessageBoxIcon.Error);
115 | return;
116 | }
117 | SaveFileDialog d = new SaveFileDialog();
118 | d.InitialDirectory = this.currentImage.FilePath;
119 | d.Filter = "Binary/Hex files (*.bin; *.hex)|*.bin;*.hex";
120 | DialogResult ret = STAShowSADialog(d);
121 |
122 | if (d.FileName != null)
123 | {
124 | try
125 | {
126 | FileStream romStream = new FileStream(d.FileName, FileMode.OpenOrCreate, FileAccess.Write);
127 |
128 | currentImage.imageStream.Seek(0, SeekOrigin.Begin);
129 | currentImage.imageStream.CopyTo(romStream, 1024);
130 | romStream.Seek(this.currentImage.CalIdOffset, SeekOrigin.Begin);
131 | string newcalid = newcalidbox.Text.ToString();
132 | //byte[] bytes = new byte[newcalid.Length * sizeof(char)];
133 |
134 | byte[] bytes = Encoding.ASCII.GetBytes(newcalid);
135 |
136 |
137 | romStream.Write(bytes, 0, bytes.Length);
138 |
139 | romStream.Close();
140 |
141 | //System.IO.File.Copy(this.currentImage.FilePath, d.FileName, true);
142 | }
143 | catch (System.Exception excpt)
144 | {
145 | MessageBox.Show("Error accessing file! It is locked!", "SharpTune", MessageBoxButtons.OK, MessageBoxIcon.Error);
146 | Trace.WriteLine("Error accessing file! It is locked!");
147 | Trace.WriteLine(excpt.Message);
148 | return;
149 | }
150 | }
151 | else
152 | {
153 | MessageBox.Show("No output file specified! Try again!", "SharpTune", MessageBoxButtons.OK, MessageBoxIcon.Error);
154 | return;
155 | }
156 | this.Close();
157 | }
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/SharpTune/GUI/DefinitionEditor.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SharpTune.GUI
2 | {
3 | partial class DefinitionEditor
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.defTreeView = new System.Windows.Forms.TreeView();
32 | this.textBoxTableInfo = new System.Windows.Forms.TextBox();
33 | this.buttonSave = new System.Windows.Forms.Button();
34 | this.SuspendLayout();
35 | //
36 | // defTreeView
37 | //
38 | this.defTreeView.Location = new System.Drawing.Point(12, 12);
39 | this.defTreeView.Name = "defTreeView";
40 | this.defTreeView.Size = new System.Drawing.Size(422, 666);
41 | this.defTreeView.TabIndex = 0;
42 | this.defTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.defTreeView_AfterSelect);
43 | this.defTreeView.DoubleClick += new System.EventHandler(this.defTreeView_DoubleClick);
44 | //
45 | // textBoxTableInfo
46 | //
47 | this.textBoxTableInfo.Location = new System.Drawing.Point(440, 12);
48 | this.textBoxTableInfo.Multiline = true;
49 | this.textBoxTableInfo.Name = "textBoxTableInfo";
50 | this.textBoxTableInfo.Size = new System.Drawing.Size(406, 601);
51 | this.textBoxTableInfo.TabIndex = 1;
52 | //
53 | // buttonSave
54 | //
55 | this.buttonSave.Location = new System.Drawing.Point(441, 620);
56 | this.buttonSave.Name = "buttonSave";
57 | this.buttonSave.Size = new System.Drawing.Size(405, 58);
58 | this.buttonSave.TabIndex = 2;
59 | this.buttonSave.Text = "SAVE";
60 | this.buttonSave.UseVisualStyleBackColor = true;
61 | this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
62 | //
63 | // DefinitionEditor
64 | //
65 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
66 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
67 | this.ClientSize = new System.Drawing.Size(858, 690);
68 | this.Controls.Add(this.buttonSave);
69 | this.Controls.Add(this.textBoxTableInfo);
70 | this.Controls.Add(this.defTreeView);
71 | this.Name = "DefinitionEditor";
72 | this.Text = "DefinitionEditor";
73 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DefinitionEditor_FormClosing);
74 | this.Load += new System.EventHandler(this.DefinitionEditor_Load);
75 | this.ResumeLayout(false);
76 | this.PerformLayout();
77 |
78 | }
79 |
80 | #endregion
81 |
82 | private System.Windows.Forms.TreeView defTreeView;
83 | private System.Windows.Forms.TextBox textBoxTableInfo;
84 | private System.Windows.Forms.Button buttonSave;
85 | }
86 | }
--------------------------------------------------------------------------------
/SharpTune/GUI/DefinitionEditor.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using SharpTuneCore;
14 | using System;
15 | using System.Collections.Generic;
16 | using System.ComponentModel;
17 | using System.Data;
18 | using System.Drawing;
19 | using System.Linq;
20 | using System.Text;
21 | using System.Windows.Forms;
22 |
23 | namespace SharpTune.GUI
24 | {
25 | public partial class DefinitionEditor : Form
26 | {
27 | private bool Unsaved;
28 | private ECUMetaData Def;
29 | private Dictionary Unexposed;
30 | private Dictionary BaseTables;
31 | private Dictionary Exposed;
32 |
33 | private readonly SharpTuner sharpTuner;
34 |
35 | public DefinitionEditor(SharpTuner st)
36 | {
37 | sharpTuner = st;
38 | InitializeComponent();
39 |
40 | //When this initializes, check for existing device and auto-select
41 | //If no device, default to all definitions
42 |
43 | //TODO: handle ROM VS RAM
44 |
45 | }
46 |
47 | private void DefinitionEditor_Load(object sender, EventArgs e)
48 | {
49 | Def = sharpTuner.activeImage.Definition;
50 | Exposed = Def.AggregateExposedRomTables;
51 | BaseTables = Def.AggregateBaseRomTables;
52 |
53 | TreeNode unexp = new TreeNode("Unexposed Rom Tables");
54 | TreeNode exp = new TreeNode("Exposed Rom Tables"); //TODO SORT BY CATEGORY!! (ROUTINE IN DEFINITION)
55 |
56 | foreach (var t in BaseTables)
57 | {
58 | if (!Exposed.ContainsKey(t.Key))
59 | {
60 | TreeNode tn = new TreeNode(t.Key);//TODO PUT THIS IN DEFINITION!!
61 | tn.Tag = t.Value;
62 | unexp.Nodes.Add(tn);
63 | }
64 | }
65 | foreach (var t in Exposed)
66 | {
67 | TreeNode tn = new TreeNode(t.Key);
68 | tn.Tag = t.Value;
69 | exp.Nodes.Add(tn);
70 | }
71 |
72 | defTreeView.Nodes.Add(exp);
73 | defTreeView.Nodes.Add(unexp);
74 | }
75 |
76 | private void defTreeView_DoubleClick(object sender, EventArgs e)
77 | {
78 | TableMetaData t = (TableMetaData)defTreeView.SelectedNode.Tag;
79 | if (t == null)
80 | return;
81 | DialogResult overWrite;
82 | if(!defTreeView.SelectedNode.FullPath.ToString().ContainsCI("unexposed"))
83 | {
84 | overWrite = MessageBox.Show("Are you sure you want to overwrite " + t.name + "??", "Warning", MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
85 | if (overWrite != DialogResult.Yes)
86 | return;
87 | }
88 | try
89 | {
90 | uint address = uint.Parse(SimplePrompt.ShowDialog("Enter Hex Address of Lookup Table for " + t.name, "Enter Address"), System.Globalization.NumberStyles.AllowHexSpecifier);
91 | Def.ExposeTable(t.name, new Core.LookupTable(t.name, address));
92 | Unsaved = true;
93 | }
94 | catch (Exception E)
95 | {
96 | MessageBox.Show(E.Message);
97 | }
98 | }
99 |
100 | private void DefinitionEditor_FormClosing(object sender, FormClosingEventArgs e)
101 | {
102 | if(Unsaved)
103 | {
104 | DialogResult save;
105 | save = MessageBox.Show("Save changes??", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
106 | if (save == DialogResult.Yes)
107 | Def.ExportEcuFlashXML();
108 | else if (save == DialogResult.Cancel)
109 | e.Cancel = true;
110 | }
111 | }
112 |
113 | private void defTreeView_AfterSelect(object sender, TreeViewEventArgs e)
114 | {
115 | TableMetaData t = (TableMetaData)defTreeView.SelectedNode.Tag;
116 | if (t == null)
117 | {
118 | textBoxTableInfo.Clear();
119 | return;
120 | }
121 | StringBuilder sb = new StringBuilder();
122 | sb.AppendLine("Table XML exposed in " + t.parentDef.calibrationlId.ToString());
123 | sb.AppendLine(t.xml.ToString());
124 | if (!t.isBase)
125 | {
126 | sb.AppendLine();
127 | sb.AppendLine();
128 | sb.AppendLine("Base Table XML inherited from " + t.baseTable.parentDef.calibrationlId.ToString());
129 | sb.AppendLine(t.baseTable.xml.ToString());
130 | }
131 | textBoxTableInfo.Text = sb.ToString();
132 | }
133 |
134 | private void buttonSave_Click(object sender, EventArgs e)
135 | {
136 | Def.ExportEcuFlashXML();
137 | Unsaved = false;
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/SharpTune/GUI/DefinitionEditor.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GUI/IDAtoHEW.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.IO;
10 | using SharpTune;
11 | using SharpTune.EcuMapTools;
12 | using System.Diagnostics;
13 | using SharpTuneCore;
14 |
15 | namespace SharpTune.GUI
16 | {
17 | public partial class IDAtoHEW : Form
18 | {
19 | public IDAtoHEW(AvailableDevices ad)
20 | {
21 | availableDevices = ad;
22 | InitializeComponent();
23 | }
24 |
25 | private readonly AvailableDevices availableDevices;
26 | public List mapoutputs = new List() {"HEW (C header & section file)","IDA (IDC script)"};
27 | public List headeroutputs = new List() {"IDA (IDC script)"};
28 | public string mode = null;
29 | public string output;
30 |
31 |
32 | private void button1_Click(object sender, EventArgs e)
33 | {
34 | OpenFileDialog ofd = new OpenFileDialog();
35 | ofd.Filter = "MAP/HEADER files (*.map; *.h)|*.map;*.h";
36 | DialogResult ret = SharpTune.Utils.STAShowOFDialog(ofd);
37 | if (ret == DialogResult.OK)
38 | {
39 | textBox1.Text = ofd.FileName;
40 | output = Path.GetDirectoryName(ofd.FileName);
41 | }
42 | }
43 |
44 | private void IDAtoHEW_Load(object sender, EventArgs e)
45 | {
46 |
47 | }
48 |
49 | //Trace.WriteLine("Convert .map file to C defines header (.h) and section file (.txt) using .xml translation: IDAtoHEW ");
50 | // Trace.WriteLine("Convert .map file to IDC script: IDAtoHEW ");
51 | // Trace.WriteLine("Convert .h file to IDC script: IDAtoHEW ");
52 |
53 | private void button2_Click(object sender, EventArgs e)
54 | {
55 | switch (mode)
56 | {
57 | case "header":
58 | EcuMapTool.Run(availableDevices, new string[] { textBox1.Text, output + Path.GetFileName(textBox1.Text) + "_converted.idc" });
59 | //call header->idc
60 | break;
61 |
62 | case "map":
63 | if (convertToComboBox.SelectedItem.ToString() == mapoutputs[0])
64 | {
65 | EcuMapTool.Run(availableDevices, new string[] { translationTextBox.Text, textBox1.Text, output + Path.GetFileName(textBox1.Text) + "_converted.h", output + Path.GetFileName(textBox1.Text) + "_converted_sections.txt" } );
66 | break;
67 | //call map->hew
68 | }
69 | else
70 | {
71 | EcuMapTool.Run(availableDevices, new string[] {textBox1.Text, output + Path.GetFileName(textBox1.Text) + "_converted.idc"});
72 | //cal map>idc
73 | break;
74 | }
75 | default:
76 | MessageBox.Show("Error! check your settings & files!!");
77 | Trace.WriteLine("Error! check your settings & files!!");
78 | return;
79 | }
80 | MessageBox.Show("Finished Conversion!");
81 | Trace.WriteLine("Finished Conversion!");
82 | }
83 |
84 | private void textBox1_TextChanged(object sender, EventArgs e)
85 | {
86 | if (textBox1.Text.ContainsCI(".map"))
87 | {
88 | convertToComboBox.DataSource = mapoutputs;
89 | mode = "map";
90 | }
91 | else
92 | {
93 | convertToComboBox.DataSource = headeroutputs;
94 | mode = "header";
95 | }
96 |
97 | }
98 |
99 | private void button3_Click(object sender, EventArgs e)
100 | {
101 | OpenFileDialog ofd = new OpenFileDialog();
102 | ofd.Filter = "XML Files (*.xml)|*xml";
103 | if (ofd.ShowDialog() == DialogResult.OK)
104 | {
105 | translationTextBox.Text = ofd.FileName;
106 | button2.Enabled = true;
107 | }
108 | else
109 | {
110 | translationTextBox.Clear();
111 | button2.Enabled = false;
112 | }
113 | }
114 |
115 | private void convertToComboBox_SelectedIndexChanged(object sender, EventArgs e)
116 | {
117 | if (convertToComboBox.SelectedItem.ToString() == mapoutputs[0])
118 | {
119 | translationButton.Enabled = true;
120 | button2.Enabled = false;
121 | }
122 | else
123 | {
124 | translationButton.Enabled = false;
125 | button2.Enabled = true;
126 | }
127 | }
128 |
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/SharpTune/GUI/IDAtoHEW.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GUI/License.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SharpTune.GUI
2 | {
3 | partial class LicenseWindow
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.richTextBox1 = new System.Windows.Forms.RichTextBox();
32 | this.SuspendLayout();
33 | //
34 | // richTextBox1
35 | //
36 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
37 | | System.Windows.Forms.AnchorStyles.Left)
38 | | System.Windows.Forms.AnchorStyles.Right)));
39 | this.richTextBox1.Location = new System.Drawing.Point(12, 12);
40 | this.richTextBox1.Name = "richTextBox1";
41 | this.richTextBox1.ReadOnly = true;
42 | this.richTextBox1.Size = new System.Drawing.Size(384, 121);
43 | this.richTextBox1.TabIndex = 0;
44 | this.richTextBox1.Text = "SharpTune is released with source under a GPLv3 License.\n";
45 | //
46 | // LicenseWindow
47 | //
48 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
49 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
50 | this.ClientSize = new System.Drawing.Size(408, 145);
51 | this.Controls.Add(this.richTextBox1);
52 | this.Name = "LicenseWindow";
53 | this.Text = "License";
54 | this.Load += new System.EventHandler(this.License_Load);
55 | this.ResumeLayout(false);
56 |
57 | }
58 |
59 | #endregion
60 |
61 | private System.Windows.Forms.RichTextBox richTextBox1;
62 | }
63 | }
--------------------------------------------------------------------------------
/SharpTune/GUI/License.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.ComponentModel;
16 | using System.Data;
17 | using System.Drawing;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Forms;
21 |
22 | namespace SharpTune.GUI
23 | {
24 | public partial class LicenseWindow : Form
25 | {
26 | public LicenseWindow()
27 | {
28 | InitializeComponent();
29 | }
30 |
31 | private void License_Load(object sender, EventArgs e)
32 | {
33 |
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SharpTune/GUI/License.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GUI/MapToDef.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SharpTune.GUI
2 | {
3 | partial class MapToDef
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.buttonText = new System.Windows.Forms.Button();
32 | this.buttonMap = new System.Windows.Forms.Button();
33 | this.textBox1 = new System.Windows.Forms.TextBox();
34 | this.label1 = new System.Windows.Forms.Label();
35 | this.SuspendLayout();
36 | //
37 | // buttonText
38 | //
39 | this.buttonText.Location = new System.Drawing.Point(12, 601);
40 | this.buttonText.Name = "buttonText";
41 | this.buttonText.Size = new System.Drawing.Size(354, 53);
42 | this.buttonText.TabIndex = 0;
43 | this.buttonText.Text = "Parse Text";
44 | this.buttonText.UseVisualStyleBackColor = true;
45 | this.buttonText.Click += new System.EventHandler(this.buttonText_Click);
46 | //
47 | // buttonMap
48 | //
49 | this.buttonMap.Location = new System.Drawing.Point(372, 601);
50 | this.buttonMap.Name = "buttonMap";
51 | this.buttonMap.Size = new System.Drawing.Size(316, 53);
52 | this.buttonMap.TabIndex = 1;
53 | this.buttonMap.Text = "Open .MAP file";
54 | this.buttonMap.UseVisualStyleBackColor = true;
55 | this.buttonMap.Click += new System.EventHandler(this.buttonMap_Click);
56 | //
57 | // textBox1
58 | //
59 | this.textBox1.Location = new System.Drawing.Point(12, 40);
60 | this.textBox1.Multiline = true;
61 | this.textBox1.Name = "textBox1";
62 | this.textBox1.Size = new System.Drawing.Size(676, 555);
63 | this.textBox1.TabIndex = 2;
64 | //
65 | // label1
66 | //
67 | this.label1.AutoSize = true;
68 | this.label1.Location = new System.Drawing.Point(13, 13);
69 | this.label1.Name = "label1";
70 | this.label1.Size = new System.Drawing.Size(199, 13);
71 | this.label1.TabIndex = 3;
72 | this.label1.Text = "Paste from Names List or open .MAP file.";
73 | //
74 | // MapToDef
75 | //
76 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
77 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
78 | this.ClientSize = new System.Drawing.Size(700, 666);
79 | this.Controls.Add(this.label1);
80 | this.Controls.Add(this.textBox1);
81 | this.Controls.Add(this.buttonMap);
82 | this.Controls.Add(this.buttonText);
83 | this.Name = "MapToDef";
84 | this.Text = "MapToDef";
85 | this.Load += new System.EventHandler(this.MapToDef_Load);
86 | this.ResumeLayout(false);
87 | this.PerformLayout();
88 |
89 | }
90 |
91 | #endregion
92 |
93 | private System.Windows.Forms.Button buttonText;
94 | private System.Windows.Forms.Button buttonMap;
95 | private System.Windows.Forms.TextBox textBox1;
96 | private System.Windows.Forms.Label label1;
97 | }
98 | }
--------------------------------------------------------------------------------
/SharpTune/GUI/MapToDef.cs:
--------------------------------------------------------------------------------
1 | using SharpTune.RomMod;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Windows.Forms;
10 |
11 | namespace SharpTune.GUI
12 | {
13 | public partial class MapToDef : Form
14 | {
15 | private readonly SharpTuner sharpTuner;
16 | public OpenFileDialog ofd = new OpenFileDialog();
17 |
18 | public MapToDef(SharpTuner st)
19 | {
20 | sharpTuner = st;
21 | InitializeComponent();
22 | }
23 |
24 | private void buttonMap_Click(object sender, EventArgs e)
25 | {
26 | string ecuid;
27 | if (sharpTuner.activeImage != null && sharpTuner.activeImage.Definition.EcuId != null)
28 | ecuid = sharpTuner.activeImage.Definition.EcuId.ToString();
29 | else
30 | ecuid = SimplePrompt.ShowDialog("Enter ECU Identifier (logger identifier)", "Enter EcuId");
31 | ofd.Filter = "MAP Files (*.map)|*.map";
32 | DialogResult res = Utils.STAShowOFDialog(ofd);
33 | if (res == DialogResult.OK)
34 | {
35 | //try
36 | //{
37 | sharpTuner.activeImage.Definition.ImportMapFile(ofd.FileName, sharpTuner.activeImage);//TODO: clean up creation of XML whitespace sucks ass.
38 | sharpTuner.activeImage.Definition.ExportEcuFlashXML();
39 | ModDefinition md = new ModDefinition(sharpTuner.AvailableDevices, null); //TODO: major KLUDGE
40 | md.DefineRRLogEcuFromMap(ofd.FileName, ecuid);//TODO: import RR stuff to definnition class and deprecate this??
41 | MessageBox.Show("Success!");
42 | this.Close();
43 | return;
44 | //catch (Exception err)
45 | // {
46 | // MessageBox.Show(err.Message);
47 | // }
48 | }
49 | this.Close();
50 | return;
51 | }
52 |
53 | private void MapToDef_Load(object sender, EventArgs e)
54 | {
55 |
56 | }
57 |
58 | private void buttonText_Click(object sender, EventArgs e)
59 | {
60 | string ecuid;
61 | if (sharpTuner.activeImage != null && sharpTuner.activeImage.Definition.EcuId != null)
62 | ecuid = sharpTuner.activeImage.Definition.EcuId;
63 | else
64 | ecuid = SimplePrompt.ShowDialog("Enter ECU Identifier (logger identifier)", "Enter EcuId");
65 | try
66 | {
67 | sharpTuner.activeImage.Definition.ImportMapText(textBox1.Text, sharpTuner.activeImage);//TODO: clean up creation of XML whitespace sucks ass.
68 | sharpTuner.activeImage.Definition.ExportEcuFlashXML();
69 | ModDefinition md = new ModDefinition(sharpTuner.AvailableDevices, null);
70 | md.DefineRRLogEcuFromText(textBox1.Text, ecuid);
71 | MessageBox.Show("Success!");
72 | this.Close();
73 | return;
74 | }
75 | catch (Exception err)
76 | {
77 | MessageBox.Show(err.Message);
78 | }
79 | this.Close();
80 | return;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/SharpTune/GUI/MapToDef.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GUI/SSMTestApp.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GUI/SimpleCombo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Windows.Forms;
18 |
19 | namespace SharpTune
20 | {
21 | public static class SimpleCombo
22 | {
23 | private static Form prompt;
24 | private static Label textLabel;
25 | private static ComboBox comboBox;
26 | private static Button confirmation;
27 |
28 | public static string ShowDialog(string text, string caption, List comboitems)
29 | {
30 | prompt = new Form();
31 | prompt.SizeChanged += new System.EventHandler(SimpleCombo_SizeChanged);
32 | prompt.AutoSizeMode = AutoSizeMode.GrowOnly;
33 | prompt.Padding = new Padding(50);
34 | prompt.Text = caption;
35 | textLabel = new Label() { Text = text, AutoSize = true};
36 | textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5);
37 | textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25);
38 | comboBox = new ComboBox() { DataSource = comboitems, MinimumSize = new System.Drawing.Size(500,20)};
39 | comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5);
40 | comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5);
41 | confirmation = new Button() {Text = "OK" };
42 | confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5);
43 | confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75);
44 | confirmation.Click += (sender, e) => { prompt.Close(); };
45 | prompt.Controls.Add(confirmation);
46 | prompt.Controls.Add(textLabel);
47 | prompt.Controls.Add(comboBox);
48 | prompt.AcceptButton = confirmation;
49 | prompt.AutoSize = true;
50 | prompt.Refresh();
51 | prompt.ShowDialog();
52 | return comboBox.SelectedItem.ToString();
53 | }
54 |
55 | private static void SimpleCombo_SizeChanged(object sender, EventArgs e)
56 | {
57 | textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5);
58 | textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25);
59 | comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5);
60 | comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5);
61 | confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5);
62 | confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75);
63 | }
64 |
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/SharpTune/GUI/SimplePrompt.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Windows.Forms;
18 |
19 | namespace SharpTune.GUI
20 | {
21 | public static class SimplePrompt
22 | {
23 | public static string ShowDialog(string text, string caption)
24 | {
25 | Form prompt = new Form();
26 | prompt.Width = 500;
27 | prompt.Height = 200;
28 | prompt.Text = caption;
29 | Label textLabel = new Label() { Left = 50, Top = 20, Text = text, Width = 300 };
30 | TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
31 | Button confirmation = new Button() { Text = "OK", Left = 350, Width = 100, Top = 70 };
32 | confirmation.Click += (sender, e) => { prompt.Close(); };
33 | prompt.Controls.Add(confirmation);
34 | prompt.Controls.Add(textLabel);
35 | prompt.Controls.Add(textBox);
36 | prompt.AcceptButton = confirmation;
37 | prompt.ShowDialog();
38 | return textBox.Text;
39 | }
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/SharpTune/GUI/TableView.Designer.cs:
--------------------------------------------------------------------------------
1 | //namespace SharpTune
2 | //{
3 | // partial class TableView
4 | // {
5 | // ///
6 | // /// Required designer variable.
7 | // ///
8 | // private System.ComponentModel.IContainer components = null;
9 |
10 | // ///
11 | // /// Clean up any resources being used.
12 | // ///
13 | // /// true if managed resources should be disposed; otherwise, false.
14 | // protected override void Dispose(bool disposing)
15 | // {
16 | // if (disposing && (components != null))
17 | // {
18 | // components.Dispose();
19 | // }
20 | // base.Dispose(disposing);
21 | // }
22 |
23 | // #region Windows Form Designer generated code
24 |
25 | // ///
26 | // /// Required method for Designer support - do not modify
27 | // /// the contents of this method with the code editor.
28 | // ///
29 | // private void InitializeComponent()
30 | // {
31 | // this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
32 | // this.menuStrip1 = new System.Windows.Forms.MenuStrip();
33 | // this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
34 | // this.menuStrip1.SuspendLayout();
35 | // this.SuspendLayout();
36 | // //
37 | // // tableLayoutPanel1
38 | // //
39 | // this.tableLayoutPanel1.AutoSize = true;
40 | // this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
41 | // this.tableLayoutPanel1.ColumnCount = 3;
42 | // this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
43 | // this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
44 | // this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 31F));
45 | // this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 27);
46 | // this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(10);
47 | // this.tableLayoutPanel1.Name = "tableLayoutPanel1";
48 | // this.tableLayoutPanel1.RowCount = 4;
49 | // this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
50 | // this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
51 | // this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
52 | // this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
53 | // this.tableLayoutPanel1.Size = new System.Drawing.Size(81, 80);
54 | // this.tableLayoutPanel1.TabIndex = 5;
55 | // //
56 | // // menuStrip1
57 | // //
58 | // this.menuStrip1.Location = new System.Drawing.Point(0, 0);
59 | // this.menuStrip1.Name = "menuStrip1";
60 | // this.menuStrip1.Size = new System.Drawing.Size(116, 24);
61 | // this.menuStrip1.TabIndex = 6;
62 | // this.menuStrip1.Text = "menuStrip1";
63 | // //
64 | // // fileToolStripMenuItem
65 | // //
66 | // this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
67 | // this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
68 | // this.fileToolStripMenuItem.Text = "File";
69 | // //
70 | // // TableView
71 | // //
72 | // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
73 | // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
74 | // this.AutoSize = true;
75 | // this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
76 | // this.ClientSize = new System.Drawing.Size(116, 123);
77 | // this.Controls.Add(this.tableLayoutPanel1);
78 | // this.Controls.Add(this.menuStrip1);
79 | // this.Name = "TableView";
80 | // this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
81 | // this.Text = "TableView";
82 | // this.Load += new System.EventHandler(this.TableView_Load);
83 | // this.menuStrip1.ResumeLayout(false);
84 | // this.menuStrip1.PerformLayout();
85 | // this.ResumeLayout(false);
86 | // this.PerformLayout();
87 |
88 | // }
89 |
90 | // #endregion
91 |
92 | // public GUI.CustomGrid dataGrid;
93 | // public System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
94 | // public GUI.CustomGrid xAxisGrid;
95 | // public GUI.CustomGrid yAxisGrid;
96 | // private System.Windows.Forms.MenuStrip menuStrip1;
97 | // private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
98 |
99 |
100 | // }
101 | //}
--------------------------------------------------------------------------------
/SharpTune/GUI/TableView.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/SharpTune/GUI/UndefinedWindow.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GUI/XMLtoIDC.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/GitVersionUpdate.bat:
--------------------------------------------------------------------------------
1 | REM Get Git hash and set to gitversion
2 | FOR /F "tokens=* USEBACKQ" %%A IN (`"C:\Program Files\Git\bin\git.exe" describe --tags --long --always`) DO SET gitVersion=%%A
3 | ECHO %gitVersion%
4 | REM Replace text in temp file and rename it
5 | REM %1 = $(ProjectDir)
6 | POWERSHELL -COMMAND "(gc %1Properties\AssemblyInfoTemplate.cs) -replace '\$GITVERSIONPLACEHOLDER\$', '%gitVersion%' | out-file %1Properties\AssemblyInfo.cs" ;
7 |
--------------------------------------------------------------------------------
/SharpTune/ObjectCopier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.Serialization;
4 | using System.Runtime.Serialization.Formatters.Binary;
5 |
6 | ///
7 | /// Reference Article http://www.codeproject.com/KB/tips/SerializedObjectCloner.aspx
8 | /// Provides a method for performing a deep copy of an object.
9 | /// Binary Serialization is used to perform the copy.
10 | ///
11 | public static class ObjectCopier
12 | {
13 | ///
14 | /// Perform a deep Copy of the object.
15 | ///
16 | /// The type of object being copied.
17 | /// The object instance to copy.
18 | /// The copied object.
19 | public static T Clone(this T source)
20 | {
21 | if (!typeof(T).IsSerializable)
22 | {
23 | throw new ArgumentException("The type must be serializable.", "source");
24 | }
25 |
26 | // Don't serialize a null object, simply return the default for that object
27 | if (Object.ReferenceEquals(source, null))
28 | {
29 | return default(T);
30 | }
31 |
32 | IFormatter formatter = new BinaryFormatter();
33 | Stream stream = new MemoryStream();
34 | using (stream)
35 | {
36 | formatter.Serialize(stream, source);
37 | stream.Seek(0, SeekOrigin.Begin);
38 | return (T)formatter.Deserialize(stream);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/SharpTune/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Windows.Forms;
17 | using ConsoleRedirection;
18 | using System.Diagnostics;
19 | using SharpTune.RomMod;
20 | using System.IO;
21 | using SharpTune.EcuMapTools;
22 | using System.Text;
23 | using EcuMapTools;
24 | using SharpTuneCore;
25 |
26 | namespace SharpTune
27 | {
28 | public static class Program
29 | {
30 | private static SharpTuner sharpTuner;
31 | ///
32 | /// Entry point. Runs the utility with or without exception handling, depending on whether a debugger is attached.
33 | ///
34 | [STAThread]
35 | public static int Main(string[] args)
36 | {
37 | bool result = true;
38 | if (Debugger.IsAttached)
39 | {
40 | result = Run(args);
41 | // This gives you time to examine the output before the console window closes.
42 | Debugger.Break();
43 | }
44 | else
45 | {
46 | try
47 | {
48 | result = Run(args);
49 | }
50 | catch (Exception exception)
51 | {
52 | // This makes diagnostics much much easier.
53 | Trace.WriteLine(exception);
54 | }
55 | }
56 | // For parity with "fc /b" return 0 on success, 1 on failure.
57 | return result ? 0 : 1;
58 | }
59 |
60 | ///
61 | /// Determines which command to run.
62 | ///
63 | private static bool Run(string[] args)
64 | {
65 | Application.EnableVisualStyles();
66 | Application.SetCompatibleTextRenderingDefault(false);
67 | sharpTuner = new SharpTuner();
68 | if (args.Length < 1)
69 | {
70 | Application.Run(sharpTuner.mainWindow);
71 | return true;
72 | }
73 | else
74 | {
75 | sharpTuner.InitCMD();
76 | if (args[0] == "ecumaptool")
77 | {
78 | return EcuMapTool.Run(sharpTuner.AvailableDevices, Utils.ShiftLeftTruncate(args));
79 | }
80 | else if (args[0] == "rommod")
81 | {
82 | return SharpTune.RomMod.RomMod.Run(sharpTuner.AvailableDevices, Utils.ShiftLeftTruncate(args));
83 | }
84 | else if (args[0] == "xmlconvertor")
85 | {
86 | ECU di = new ECU(sharpTuner, args[1]);
87 | XMLtoIDC xti = new XMLtoIDC(di);
88 | //TODO clean up this routine: xti.Run(args);
89 | }
90 | else if (args.Length == 2 && args[0] == "help")
91 | {
92 | PrintHelp_RomMod(args[1]);
93 | return true;
94 | }
95 | }
96 | return false;
97 | }
98 |
99 | ///
100 | /// Print generic usage instructions.
101 | ///
102 | private static void PrintHelp_RomMod()
103 | {
104 | Trace.WriteLine("SharpTune RomMod Version " + SharpTune.RomMod.RomMod.Version);
105 | Trace.WriteLine("Commands:");
106 | Trace.WriteLine("");
107 | Trace.WriteLine("test - determine whether a patch is suitable for a ROM");
108 | Trace.WriteLine("apply - apply a patch to a ROM file");
109 | Trace.WriteLine("applied - determine whether a patch has been applied to a ROM");
110 | Trace.WriteLine("remove - remove a patch from a ROM file");
111 | Trace.WriteLine("dump - dump the contents of a patch file");
112 | Trace.WriteLine("baseline - generate baseline data for a ROM and a partial patch");
113 | Trace.WriteLine("");
114 | Trace.WriteLine("Use \"sharptune rommod help \" to show help for that command.");
115 | }
116 |
117 | ///
118 | /// Print usage instructions for a particular command.
119 | ///
120 | private static void PrintHelp_RomMod(string command)
121 | {
122 | switch (command)
123 | {
124 | case "test":
125 | Trace.WriteLine("RomPatch test ");
126 | Trace.WriteLine("Determines whether the given patch file matches the given ROM file.");
127 | break;
128 |
129 | case "help":
130 | Trace.WriteLine("You just had to try that, didn't you?");
131 | break;
132 | }
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/SharpTune/Properties/AssemblyInfoTemplate.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SharpTune")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Merp")]
12 | [assembly: AssemblyProduct("SharpTune")]
13 | [assembly: AssemblyCopyright("Copyright © Merp 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("27ef8cdb-fa03-46bf-84c8-98af985a6cc4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyInformationalVersion("$GITVERSIONPLACEHOLDER$")]
36 |
--------------------------------------------------------------------------------
/SharpTune/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18408
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SharpTune.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpTune.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/SharpTune/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SharpTune/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | All
49 |
50 |
51 |
--------------------------------------------------------------------------------
/SharpTune/PropertyBag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace NateW.Ssm
7 | {
8 | public class PropertyDefinition
9 | {
10 | private string name;
11 |
12 | public PropertyDefinition(string name)
13 | {
14 | this.name = name;
15 | }
16 |
17 | public override string ToString()
18 | {
19 | return this.name;
20 | }
21 | }
22 |
23 | public class PropertyBag : IEnumerable>
24 | {
25 | private Dictionary properties;
26 |
27 | public PropertyBag()
28 | {
29 | this.properties = new Dictionary();
30 | }
31 |
32 | public object this[PropertyDefinition propertyDefinition]
33 | {
34 | get
35 | {
36 | return this.properties[propertyDefinition];
37 | }
38 |
39 | set
40 | {
41 | this.properties[propertyDefinition] = value;
42 | }
43 | }
44 |
45 | public void Add(PropertyBag source)
46 | {
47 | foreach (KeyValuePair pair in source)
48 | {
49 | this.properties.Add(pair.Key, pair.Value);
50 | }
51 | }
52 |
53 | public void Remove(PropertyBag source)
54 | {
55 | foreach (KeyValuePair kvp in source)
56 | {
57 | this.properties.Remove(kvp.Key);
58 | }
59 | }
60 |
61 | public IEnumerator> GetEnumerator()
62 | {
63 | return this.properties.GetEnumerator();
64 | }
65 |
66 | IEnumerator IEnumerable.GetEnumerator()
67 | {
68 | return ((IEnumerable)this.properties).GetEnumerator();
69 | }
70 |
71 | public bool TryGetValue(PropertyDefinition propertyDefinition, out object value)
72 | {
73 | return this.properties.TryGetValue(propertyDefinition, out value);
74 | }
75 |
76 | public override string ToString()
77 | {
78 | StringBuilder builder = new StringBuilder();
79 | foreach (KeyValuePair pair in properties)
80 | {
81 | builder.Append(pair.Key.ToString());
82 | builder.Append("=");
83 | builder.Append(pair.Value.ToString());
84 | builder.Append(", ");
85 | }
86 | return builder.ToString();
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/SharpTune/Resources/beer1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Merp/SharpTune/ecabea89615132dac2de37c05f72adae16d966d1/SharpTune/Resources/beer1.png
--------------------------------------------------------------------------------
/SharpTune/RomMod/Blob.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Text.RegularExpressions;
18 |
19 | namespace SharpTune.RomMod
20 | {
21 | ///
22 | /// Basically a list of bytes plus a start-address.
23 | ///
24 | [Serializable]
25 | public class Blob
26 | {
27 | ///
28 | /// Where to put these bytes.
29 | ///
30 | public uint StartAddress { get; private set; }
31 |
32 | ///
33 | /// The bytes.
34 | ///
35 | public List Content { get; private set; }
36 |
37 | ///
38 | /// Address of the next byte (following this blob).
39 | ///
40 | public uint NextByteAddress { get { return this.StartAddress + (uint) this.Content.Count; } }
41 |
42 | ///
43 | /// Create a new blob using the given start address and content.
44 | ///
45 | public Blob(uint startAddress, IEnumerable content)
46 | {
47 | this.StartAddress = startAddress;
48 | this.Content = new List();
49 | this.Content.AddRange(content);
50 | }
51 |
52 | public Blob CloneWithNewStartAddress(uint newStartAddress)
53 | {
54 | return new Blob(newStartAddress, this.Content);
55 | }
56 |
57 | ///
58 | /// Add the given content to the blob.
59 | ///
60 | ///
61 | public void AddRecord(IEnumerable content)
62 | {
63 |
64 | this.Content.AddRange(content);
65 | }
66 |
67 | ///
68 | /// Describe the blob in human terms.
69 | ///
70 | public override string ToString()
71 | {
72 | return string.Format("Start: {0:X8}, Length: {1:X8}, Data: {2:X}", this.StartAddress, this.Content.Count, BitConverter.ToString(this.Content.ToArray()));
73 | }
74 |
75 | public string GetDataString()
76 | {
77 | return Regex.Replace(BitConverter.ToString(this.Content.ToArray()),"-","");
78 | }
79 |
80 | ///
81 | /// Try to get a byte from the blob at the given offset. If successful, increment the offset.
82 | ///
83 | public bool TryGetByte(ref byte result, ref int offset)
84 | {
85 | if (this.Content.Count > offset)
86 | {
87 | result = this.Content[offset];
88 | offset++;
89 | return true;
90 | }
91 |
92 | return false;
93 | }
94 |
95 | ///
96 | /// Try to get a unsigned short from the blob at the given offset. If successful, incrmenet offset
97 | ///
98 | ///
99 | ///
100 | ///
101 | public bool TryGetUInt16(ref UInt16 result, ref int offset)
102 | {
103 | if (this.Content.Count < offset + 2)
104 | {
105 | return false;
106 | }
107 |
108 | result = 0;
109 | byte temp = 0;
110 | if (!this.TryGetByte(ref temp, ref offset))
111 | {
112 | return false;
113 | }
114 |
115 | result |= temp;
116 | if (!this.TryGetByte(ref temp, ref offset))
117 | {
118 | return false;
119 | }
120 |
121 | result <<= 8;
122 | result |= temp;
123 |
124 | return true;
125 | }
126 |
127 | ///
128 | /// Try to get an unsigned 32-bit integer from the blob at the given offset. If successful, increment the offset.
129 | ///
130 | public bool TryGetUInt32(ref uint result, ref int offset)
131 | {
132 | if (this.Content.Count < offset + 4)
133 | {
134 | return false;
135 | }
136 |
137 | result = 0;
138 | byte temp = 0;
139 | if (!this.TryGetByte(ref temp, ref offset))
140 | {
141 | return false;
142 | }
143 |
144 | result |= temp;
145 | if (!this.TryGetByte(ref temp, ref offset))
146 | {
147 | return false;
148 | }
149 |
150 | result <<= 8;
151 | result |= temp;
152 |
153 | if (!this.TryGetByte(ref temp, ref offset))
154 | {
155 | return false;
156 | }
157 |
158 | result <<= 8;
159 | result |= temp;
160 | if (!this.TryGetByte(ref temp, ref offset))
161 | {
162 | return false;
163 | }
164 |
165 | result <<= 8;
166 | result |= temp;
167 | return true;
168 | }
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/SharpTune/RomMod/BlobList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace SharpTune.RomMod
19 | {
20 | ///
21 | /// Merges the content of contiguous SRecords into a list of Blobs.
22 | ///
23 | public class BlobList
24 | {
25 | ///
26 | /// Congealed blobs.
27 | ///
28 | public readonly List Blobs;
29 |
30 | ///
31 | /// Constructor.
32 | ///
33 | public BlobList()
34 | {
35 | this.Blobs = new List();
36 | }
37 |
38 | ///
39 | /// Add the payload of an SRecord to the appropriate blob, or create a new blob if necessary.
40 | ///
41 | public void ProcessRecord(SRecord record)
42 | {
43 | if (record.Payload == null)
44 | {
45 | return;
46 | }
47 |
48 | foreach (Blob blob in this.Blobs)
49 | {
50 | if (blob.NextByteAddress == record.Address)
51 | {
52 | blob.AddRecord(record.Payload);
53 | return;
54 | }
55 | }
56 |
57 | Blob newBlob = new Blob(record.Address, record.Payload);
58 | this.Blobs.Add(newBlob);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/SharpTune/RomMod/Patch.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace SharpTune.RomMod
19 | {
20 |
21 |
22 | ///
23 | /// Describes the start and end addresses of an ECU patch (but not the content).
24 | ///
25 | ///
26 | /// Corresponds to the metadata in a patch file. See sample HEW project for details.
27 | ///
28 | [Serializable]
29 | public class Patch
30 | {
31 | ///
32 | /// Start address of the patch payload
33 | /// Defined in ecuhacks (HEW) memory addressing (0x0F00XXXX)
34 | ///
35 | public uint CopyStartAddress { get; set; }
36 |
37 | ///
38 | /// Start address of the patch (the first byte to overwrite).
39 | /// Defined in actual rom addressing
40 | ///
41 | public uint StartAddress { get; private set; }
42 |
43 | ///
44 | /// End address of the patch (the last byte to overwrite).
45 | /// Defined in actual rom addressing
46 | ///
47 | public uint EndAddress { get; private set; }
48 |
49 | ///
50 | /// Length of the patch.
51 | ///
52 | public uint Length { get { return (this.EndAddress+1) - this.StartAddress; } }
53 |
54 | public bool IsMetaChecked { get; set; }
55 |
56 | ///
57 | /// Flag for Data/Code patches
58 | /// Used to prevent overwrites of existing data
59 | /// And allow unpatching after map changes
60 | ///
61 | public bool IsNewPatch { get; set; }
62 |
63 | ///
64 | /// Flag for baseline checks while unpatching
65 | ///
66 |
67 | public Blob Baseline { get; set; }
68 |
69 | public Blob Payload { get; set; }
70 |
71 | public String Name { get; set; }
72 |
73 | ///
74 | /// Constructor.
75 | ///
76 | public Patch(string name, uint start, uint end)
77 | {
78 | this.Name = name;
79 | this.StartAddress = start;
80 | this.EndAddress = end;
81 | this.IsNewPatch = false;
82 | this.IsMetaChecked = false;
83 |
84 | }
85 |
86 | ///
87 | /// Describe the patch range in human terms.
88 | ///
89 | public override string ToString()
90 | {
91 | StringBuilder sb = new StringBuilder("Patch name: " + this.Name + Environment.NewLine);
92 | sb.AppendLine(String.Format(" start: {0:X8}, end: {1:X8}, length: {2:X8}", this.StartAddress, this.EndAddress, this.Length));
93 | if(this.Length < 9)
94 | sb.AppendLine(String.Format(" baseline: {0:X}, payload: {1:X}",this.Baseline.GetDataString(),this.Payload.GetDataString()));
95 | return sb.ToString();
96 | }
97 |
98 | ///
99 | /// Check the baseline data for a r4b patch
100 | ///
101 | /// Buffer containing baseline data
102 | ///
103 | public virtual bool MetaCheck(IEnumerable buffer)
104 | {
105 | Blob checkblob = new Blob(this.StartAddress, buffer);
106 |
107 | int count = checkblob.Content.Count;
108 |
109 | for (int i = 0; i < count; i++)
110 | {
111 | if (this.Baseline.Content[i] != checkblob.Content[i])
112 | {
113 | return false;
114 | }
115 |
116 | }
117 | return true;
118 | }
119 |
120 | }
121 |
122 | public class CalidPatch : Patch
123 | {
124 | public CalidPatch(string name, uint start, uint end)
125 | : base(name, start, end)
126 | {
127 | }
128 | }
129 |
130 | public class PullJSRHookPatch : Patch
131 | {
132 | public PullJSRHookPatch(string name, uint start, uint end)
133 | : base(name, start, end)
134 | {
135 | this.IsMetaChecked = true;
136 | }
137 |
138 | public override bool MetaCheck(IEnumerable buffer)
139 | {
140 | Blob checkblob = new Blob(this.StartAddress, buffer);
141 |
142 | int count = checkblob.Content.Count;
143 | byte[] mask = new byte[] { 0xF0, 0xFF, 0x00, 0x00 };
144 | byte[] check = new byte[] { 0x40, 0x0B, 0x00, 0x00 };
145 | byte[] baseline = buffer.ToArray();
146 |
147 | for (int i = 0; i < count; i++)
148 | {
149 | baseline[i] &= (byte)mask[i];
150 | if (check[i] != baseline[i])
151 | {
152 | return false;
153 | }
154 | }
155 | return true;
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/SharpTune/RomMod/SRecordWriter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.IO;
15 | using System.Collections.Generic;
16 | using System.Linq;
17 | using System.Text;
18 |
19 | namespace SharpTune.RomMod
20 | {
21 | public class SRecordWriter
22 | {
23 | private TextWriter writer;
24 |
25 | public SRecordWriter(TextWriter writer)
26 | {
27 | this.writer = writer;
28 | }
29 |
30 | public void Write(uint startAddress, byte[] data)
31 | {
32 | int bytesWritten = 0;
33 | while (bytesWritten < data.Length)
34 | {
35 | byte count = (byte)Math.Min(16, data.Length - bytesWritten);
36 |
37 | // Add 5 to the count since the 4 address bytes and checksum will be written separately
38 | int checksum = count + 5;
39 |
40 | long address = startAddress + bytesWritten;
41 | SRecordWriter.CalculateChecksum(address, ref checksum);
42 |
43 | StringBuilder builder = new StringBuilder();
44 |
45 | for (int index = 0; index < count; index++)
46 | {
47 | byte value = data[index + bytesWritten];
48 | checksum += value;
49 | builder.AppendFormat("{0:X2}", value);
50 | }
51 |
52 | byte lastByte = (byte)(checksum & 0xFF);
53 | byte complement = (byte)(lastByte ^ 0xFF);
54 | builder.Append(complement.ToString("X2"));
55 |
56 | string dataString = builder.ToString();
57 |
58 | // Adding 5 to the count since the 4 address bytes and checksum are written separately
59 | //Trace.WriteLine("S3{0:X2}{1:X8}{2}", count + 5, address, dataString);
60 | writer.WriteLine("S3{0:X2}{1:X8}{2}", count + 5, address, dataString);
61 |
62 | bytesWritten += (int)count;
63 | }
64 | }
65 |
66 | ///
67 | /// Calculate an SRecord checksum for the given 4-byte address;
68 | ///
69 | private static void CalculateChecksum(long address, ref int checksum)
70 | {
71 | byte b;
72 | b = (byte)((address & 0xFF000000) >> 24);
73 | checksum += b;
74 | b = (byte)((address & 0xFF0000) >> 16);
75 | checksum += b;
76 | b = (byte)((address & 0xFF00) >> 8);
77 | checksum += b;
78 | b = (byte)((address & 0xFF));
79 | checksum += b;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/SharpTune/RomMod/Verifier.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Diagnostics;
16 | using System.IO;
17 | using System.Linq;
18 | using System.Text;
19 |
20 | namespace SharpTune.RomMod
21 | {
22 | class Verifier : IDisposable
23 | {
24 | private string patchPath;
25 | private string romPath;
26 | private SRecordReader patchReader;
27 | private Stream romStream;
28 | private bool apply;
29 | private bool dispose;
30 |
31 | public Verifier(string patchPath, string romPath, bool apply)
32 | {
33 | this.patchPath = patchPath;
34 | this.romPath = romPath;
35 | this.apply = apply;
36 | this.patchReader = new SRecordReader(patchPath);
37 | this.romStream = File.OpenRead(romPath);
38 | this.dispose = true;
39 | }
40 |
41 | public Verifier(Stream rs, SRecordReader sr, bool apply)
42 | {
43 | this.romStream = rs;
44 | this.patchReader = sr;
45 | this.apply = apply;
46 | this.dispose = false;
47 | }
48 |
49 | public void Dispose()
50 | {
51 | if (dispose)
52 | {
53 | if (this.patchReader != null)
54 | {
55 | this.patchReader.Dispose();
56 | this.patchReader = null;
57 | }
58 |
59 | if (this.romStream != null)
60 | {
61 | this.romStream.Dispose();
62 | this.romStream = null;
63 | }
64 | }
65 | }
66 |
67 | public bool TryVerify(IList patches)
68 | {
69 | foreach (Patch patch in patches)
70 | {
71 | if (!this.TryVerifyPatch(patch))
72 | {
73 | return false;
74 | }
75 | }
76 |
77 | return true;
78 | }
79 |
80 | private bool TryVerifyPatch(Patch patch)
81 | {
82 | // using (this.patchReader)
83 | //using (this.romStream)
84 | //{
85 | // this.patchReader.Open();
86 | SRecord record;
87 | while (this.patchReader.TryReadNextRecord(out record))
88 | {
89 | if (!this.TryProcessRecord(patch, record))
90 | {
91 | Dispose();
92 | return false;
93 | }
94 | }
95 |
96 | Dispose();
97 | return true;
98 |
99 | }
100 |
101 | private bool TryProcessRecord(Patch patch, SRecord record)
102 | {
103 | if (record.Payload == null)
104 | {
105 | return true;
106 | }
107 |
108 | int startAddress = (int)(this.apply ? patch.StartAddress : patch.StartAddress + Mod.BaselineOffset);
109 | int endAddress = (int)(this.apply ? patch.EndAddress : patch.EndAddress + Mod.BaselineOffset);
110 |
111 | for (uint address = record.Address; address < record.Address + record.Payload.Length; address++)
112 | {
113 | if (address >= startAddress && address <= endAddress)
114 | {
115 | this.romStream.Position = address;
116 | int i = this.romStream.ReadByte();
117 | if (i == -1)
118 | {
119 | Trace.WriteLine(String.Format("Reached end of file while trying to verify address {0:X8}", address));
120 | return false;
121 | }
122 |
123 | int recordAddresss = (int)(this.apply ? record.Address : record.Address - Mod.BaselineOffset);
124 |
125 | uint payloadIndex = address - record.Address;
126 | byte b = record.Payload[payloadIndex];
127 | if (i != b)
128 | {
129 | Trace.WriteLine(String.Format("Address {0:X8} contains {1:X2}, but should contain {2:X2}", address, b, payloadIndex));
130 | return false;
131 | }
132 | }
133 | }
134 |
135 | return true;
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/SharpTune/Tables/Axis.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Xml.Linq;
6 |
7 | namespace ModRom.Tables
8 | {
9 | public class Axis
10 | {
11 | private bool isXAxis { get; set; }
12 |
13 | private bool isStatic { get; set; }
14 |
15 | private List floatList { get; set; }
16 |
17 | private List staticList { get; set; }
18 |
19 | //private Scaling scaling { get; set; }
20 |
21 | ///
22 | /// Constructor from XElement
23 | ///
24 | ///
25 | public Axis(XElement xel)
26 | {
27 |
28 | }
29 | }
30 |
31 | ///
32 | /// Static Axes SubClass
33 | ///
34 | public class StaticAxis : Axis
35 | {
36 |
37 | protected List StaticData { get; set; }
38 |
39 | public StaticAxis(XElement xel)
40 | : base(xel)
41 | {
42 |
43 | }
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/SharpTune/Tables/Category.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ModRom.Tables
7 | {
8 | public class Category
9 | {
10 | public string name { get; private set; }
11 |
12 | public List subcats { get; private set; }
13 |
14 | public Category(string n)
15 | {
16 | this.name = n;
17 | this.subcats = new List();
18 | }
19 |
20 | }
21 |
22 | public class CategoryList : List
23 | {
24 |
25 | public bool Contains(string search)
26 | {
27 | foreach (Category cat in this)
28 | {
29 | if(cat.name.Contains(search)) return true;
30 | }
31 |
32 | return false;
33 | }
34 |
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/SharpTune/Tables/PropertyBag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace NateW.Ssm
7 | {
8 | public class PropertyDefinition
9 | {
10 | private string name;
11 |
12 | public PropertyDefinition(string name)
13 | {
14 | this.name = name;
15 | }
16 |
17 | public override string ToString()
18 | {
19 | return this.name;
20 | }
21 | }
22 |
23 | public class PropertyBag : IEnumerable>
24 | {
25 | private Dictionary properties;
26 |
27 | public PropertyBag()
28 | {
29 | this.properties = new Dictionary();
30 | }
31 |
32 | public object this[PropertyDefinition propertyDefinition]
33 | {
34 | get
35 | {
36 | return this.properties[propertyDefinition];
37 | }
38 |
39 | set
40 | {
41 | this.properties[propertyDefinition] = value;
42 | }
43 | }
44 |
45 | public void Add(PropertyBag source)
46 | {
47 | foreach (KeyValuePair pair in source)
48 | {
49 | this.properties.Add(pair.Key, pair.Value);
50 | }
51 | }
52 |
53 | public void Remove(PropertyBag source)
54 | {
55 | foreach (KeyValuePair kvp in source)
56 | {
57 | this.properties.Remove(kvp.Key);
58 | }
59 | }
60 |
61 | public IEnumerator> GetEnumerator()
62 | {
63 | return this.properties.GetEnumerator();
64 | }
65 |
66 | IEnumerator IEnumerable.GetEnumerator()
67 | {
68 | return ((IEnumerable)this.properties).GetEnumerator();
69 | }
70 |
71 | public bool TryGetValue(PropertyDefinition propertyDefinition, out object value)
72 | {
73 | return this.properties.TryGetValue(propertyDefinition, out value);
74 | }
75 |
76 | public override string ToString()
77 | {
78 | StringBuilder builder = new StringBuilder();
79 | foreach (KeyValuePair pair in properties)
80 | {
81 | builder.Append(pair.Key.ToString());
82 | builder.Append("=");
83 | builder.Append(pair.Value.ToString());
84 | builder.Append(", ");
85 | }
86 | return builder.ToString();
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/SharpTune/Tables/Range.cs:
--------------------------------------------------------------------------------
1 | // Range.cs: Simple helper struct.
2 |
3 | /* Copyright (C) 2011 SubaruDieselCrew
4 | *
5 | * This file is part of ScoobyRom.
6 | *
7 | * ScoobyRom is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * ScoobyRom is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with ScoobyRom. If not, see .
19 | */
20 |
21 |
22 | using System;
23 |
24 | namespace ModRom.Tables
25 | {
26 | public struct Range : IEquatable
27 | {
28 | // 2 fields
29 | int pos;
30 | int size;
31 |
32 | ///
33 | /// Position of first byte.
34 | ///
35 | public int Pos
36 | {
37 | get { return pos; }
38 | set { pos = value; }
39 | }
40 |
41 | ///
42 | /// Data size in bytes.
43 | ///
44 | public int Size
45 | {
46 | get { return size; }
47 | set { size = value; }
48 | }
49 |
50 | ///
51 | /// Last used byte position.
52 | /// (= Pos + Size - 1)
53 | ///
54 | public int Last
55 | {
56 | get { return pos + size - 1; }
57 | }
58 |
59 | public Range(int start, int size)
60 | {
61 | this.pos = start;
62 | this.size = size;
63 | }
64 |
65 | public bool Intersects(Range other)
66 | {
67 | if (other.Last < this.pos || other.pos > this.Last)
68 | return false;
69 | else
70 | return true;
71 | }
72 |
73 | public override string ToString()
74 | {
75 | return string.Format("[Pos=0x{0:X}, Size={1}, Last=0x{2:X}]", pos, size.ToString(), Last);
76 | }
77 |
78 | public override int GetHashCode()
79 | {
80 | return this.pos ^ (this.size << 3);
81 | }
82 |
83 |
84 | #region IEquatable implementation
85 |
86 | public bool Equals(Range other)
87 | {
88 | return this.pos == other.pos && this.size == other.size;
89 | }
90 |
91 | #endregion
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/SharpTune/Tables/Table.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Text;
16 | using System.Xml.XPath;
17 | using System.Xml.Linq;
18 | using ModRom.Tables;
19 |
20 |
21 | namespace ModRom.Tables
22 | {
23 | public enum TableType
24 | {
25 | Float = 0x00,
26 | UInt8 = 0x04,
27 | UInt16 = 0x08,
28 | Int8 = 0x0C,
29 | Int16 = 0x10
30 | }
31 |
32 | public abstract class Table
33 | {
34 |
35 |
36 |
37 | //Every table has a name
38 | public string name { get; set; }
39 |
40 | public string category { get; set; }
41 |
42 | //Every table has a description
43 | private string description { get; set; }
44 |
45 | //Every table has a table type
46 | public string tableTypeString { get; set; }
47 |
48 | public TableType tableTypeHex { get; set; }
49 |
50 | public string scalingName { get; set; }
51 |
52 | public int level { get; set; }
53 |
54 | //Every table is either RAM or ROM
55 | private bool ramTable { get; set; }
56 |
57 | //Every table has a data address
58 | private int dataAddress { get; set; }
59 |
60 | private int dataScaling { get; set; }
61 |
62 | private int colorMin { get; set; }
63 |
64 | private int colorMax { get; set; }
65 |
66 | public Axis xAxis { get; set; }
67 |
68 | public Axis yAxis { get; set; }
69 |
70 |
71 | ///
72 | /// Constructor
73 | ///
74 | public Table(string name)
75 | {
76 | this.name = name;
77 |
78 | }
79 |
80 | public List Attributes { get; set; }
81 |
82 | ///
83 | /// Method to parse XML for adding a table axis
84 | ///
85 | public void AddAxis()
86 | {
87 | }
88 | ///
89 | /// Construct from XML Element
90 | ///
91 | ///
92 | public Table(XElement xel)
93 | {
94 | this.name = xel.Attribute("name").Value.ToString();
95 | if (xel.Attribute("category") != null) this.category = xel.Attribute("category").Value.ToString();
96 | else this.category = "Uncategorized";
97 |
98 | this.tableTypeString = xel.Attribute("type") != null ? xel.Attribute("type").Value.ToString() : null;
99 |
100 | if (xel.Attribute("level") != null) this.level = (int)xel.Attribute("level");
101 | else this.level = 0;
102 |
103 | this.scalingName = xel.Attribute("scaling") != null ? xel.Attribute("scaling").Value.ToString() : null;
104 |
105 |
106 | //TODO USE THIS FORMAT TO PRODUCE ERRORS
107 | if (xel.Attribute("address") != null)
108 | {
109 | string hexaddr = xel.Attribute("address").Value.ToString();
110 | this.dataAddress = System.Int32.Parse(hexaddr, System.Globalization.NumberStyles.AllowHexSpecifier);
111 | }
112 |
113 | foreach (XElement child in xel.Elements())
114 | {
115 | string name = child.Name.ToString();
116 |
117 | switch (name)
118 | {
119 | case "table":
120 | this.AddAxis(child);
121 | break;
122 |
123 | case "description":
124 | this.description = child.Value.ToString();
125 | break;
126 |
127 | default:
128 | break;
129 | }
130 | }
131 |
132 | //Check address for RAM Table
133 | if (this.dataAddress > Convert.ToInt64(0xFFFF0000)) ramTable = true; else ramTable = false;
134 |
135 | }
136 |
137 | public void AddAxis(XElement axis)
138 | {
139 | if (axis.Attribute("type") != null)
140 | {
141 | if (axis.Attribute("type").Value.ToString().Contains("X"))
142 | {
143 | //Adding new X axis
144 | this.xAxis = new Axis(axis);
145 | }
146 | else if (axis.Attribute("type").Value.ToString().Contains("Y"))
147 | {
148 | this.yAxis = new Axis(axis);
149 | }
150 | else
151 | {
152 | }
153 | }
154 |
155 |
156 | }
157 |
158 |
159 |
160 | //public class BlobTable : Table
161 | //{
162 |
163 | // //Blob Table Constructor
164 | // //public BlobTable()
165 | // //: base()
166 | // //{
167 | // // //constructor here
168 | // //}
169 |
170 | //}
171 |
172 |
173 |
174 |
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/SharpTune/Tables/Table2D.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Xml.Linq;
6 |
7 | namespace ModRom.Tables
8 | {
9 | public sealed class Table2D : Table
10 | {
11 |
12 | public Table2D(XElement xel)
13 | : base(xel)
14 | {
15 |
16 | }
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/SharpTune/TextBoxStreamWriter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | This program is free software: you can redistribute it and/or modify
3 | it under the terms of the GNU General Public License as published by
4 | the Free Software Foundation, either version 3 of the License, or
5 | (at your option) any later version.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 | */
12 |
13 | using System;
14 | using System.Text;
15 | using System.IO;
16 | using System.Windows.Forms;
17 | using System.Threading;
18 | using System.ComponentModel;
19 | using System.Collections.Generic;
20 |
21 | namespace ConsoleRedirection
22 | {
23 | public class TextBoxStreamWriter : TextWriter
24 | {
25 | TextBox _output = null;
26 | private readonly object writerLock = new object();
27 | private string stringqueue { get; set; }
28 |
29 |
30 | public TextBoxStreamWriter(TextBox output)
31 | {
32 | this._output = output;
33 | }
34 |
35 |
36 | public override void Write(char value)
37 | {
38 |
39 | //base.Write(value);
40 |
41 | this.stringqueue += value.ToString();
42 |
43 | string newl = this.NewLine;
44 |
45 | if (this.stringqueue != null && this.stringqueue.ToString().Contains(this.NewLine.ToString()) )
46 | {
47 |
48 | BackgroundWorker backgroundwriter = new BackgroundWorker();
49 |
50 | string towrite = this.stringqueue;
51 | this.stringqueue = null;
52 |
53 | backgroundwriter.DoWork += (senderr, ee) =>
54 | {
55 |
56 | if (this._output.InvokeRequired)
57 | {
58 | Action action = new Action((txb, str) =>
59 | {
60 | txb.AppendText(str);
61 | });
62 |
63 |
64 | lock (this._output)
65 | {
66 | this._output.BeginInvoke(action, new object[] { this._output, towrite });
67 | }
68 |
69 | //
70 | }
71 | else
72 | {
73 | try
74 | {
75 | this._output.AppendText(value.ToString()); // When character data is written, append it to the text box.
76 | }
77 | catch
78 | {
79 | //do nothing
80 | }
81 | }
82 |
83 | };
84 |
85 | backgroundwriter.RunWorkerAsync();
86 |
87 | }
88 |
89 |
90 | }
91 |
92 |
93 | public override Encoding Encoding
94 | {
95 | get { return System.Text.Encoding.UTF8; }
96 | }
97 |
98 |
99 |
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/SharpTune/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | All
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/SharpTune/dump.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | Target Selection: Check the handling of linker sections when missing .map file. Also check if/how this outputs to idc.
2 | Docs: add more detail for metadata and definitiondata api.
3 |
--------------------------------------------------------------------------------
/logger.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------