v1.1.4 - More compatibilities
This commit is contained in:
parent
17cdb1763b
commit
b7e90b4a6a
|
@ -49,7 +49,7 @@ internal class ClassEditor
|
|||
public List<bool> DefinitionsIsUntested = new List<bool>();
|
||||
public List<bool> DefinitionsIsNotDefined = new List<bool>();
|
||||
|
||||
public int SelectedROMLocation;
|
||||
public long SelectedROMLocation;
|
||||
public int SelectedTableSize;
|
||||
public int SelectedTableIndexInDefinitions;
|
||||
public bool IsTableLoadedCorrectly = false;
|
||||
|
@ -67,6 +67,7 @@ internal class ClassEditor
|
|||
public int[] BufferTableSize = new int[2];
|
||||
public string BufferMath = "";
|
||||
private string LastMathDoneCheck = "";
|
||||
public string FileFormat = ""; //-> 1mb-fw, 1mb-full,
|
||||
|
||||
private Editortable Editortable_0;
|
||||
|
||||
|
@ -109,6 +110,18 @@ internal class ClassEditor
|
|||
return (float.Parse(text) - num).ToString(format);
|
||||
}
|
||||
|
||||
public void SetFileFormat(byte[] FilesBytes)
|
||||
{
|
||||
//SH7055 512Kb, SH7058 1Mb, SH72543 2Mb, SH7059 1.5Mb, MPC5554 2Mb, Bosch MED17.9.3 ECU 4Mb, TC179X 4Mb
|
||||
if ((FilesBytes.Length - 1) == 0xF7FFF) FileFormat = "1mb-fw";
|
||||
if ((FilesBytes.Length - 1) == 0xFFFFF) FileFormat = "1mb-full";
|
||||
if ((FilesBytes.Length - 1) == 0x1EFFFF) FileFormat = "2mb-fw";
|
||||
if ((FilesBytes.Length - 1) == 0x1FFFFF) FileFormat = "2mb-full";
|
||||
if ((FilesBytes.Length - 1) == 0x26FFFF) FileFormat = "4mb-fw";
|
||||
if ((FilesBytes.Length - 1) == 0x27FFFF) FileFormat = "4mb-full";
|
||||
//if ((FilesBytes.Length - 1) == 0x3FFFFF) FileFormat = "4mb-full";
|
||||
}
|
||||
|
||||
public void IncDecreaseSelection(bool Decreasing, bool HoldShift)
|
||||
{
|
||||
if (!Decreasing)
|
||||
|
@ -215,7 +228,7 @@ internal class ClassEditor
|
|||
|
||||
public void GetChanges()
|
||||
{
|
||||
int num = this.SelectedROMLocation;
|
||||
long num = this.SelectedROMLocation;
|
||||
int multiplier = 2;
|
||||
if (this.IsSingleByteX || this.IsSingleByteY || this.IsSingleByteTable) multiplier = 1; //###############################
|
||||
|
||||
|
@ -309,10 +322,18 @@ internal class ClassEditor
|
|||
//Remove fake bootloader section if it's a partial firmware .bin file
|
||||
if (!this.Editortable_0.IsFullBinary)
|
||||
{
|
||||
byte[] BufferBytes = new byte[SavingBytes.Length - 0x8000];
|
||||
for (int i = 0; i < SavingBytes.Length; i++) BufferBytes[i] = SavingBytes[i + 0x8000];
|
||||
|
||||
SavingBytes = BufferBytes;
|
||||
if (FileFormat == "1mb-fw")
|
||||
{
|
||||
byte[] BufferBytes = new byte[SavingBytes.Length - 0x8000];
|
||||
for (int i = 0; i < SavingBytes.Length; i++) BufferBytes[i] = SavingBytes[i + 0x8000];
|
||||
SavingBytes = BufferBytes;
|
||||
}
|
||||
if (FileFormat == "2mb-fw" || FileFormat == "4mb-fw")
|
||||
{
|
||||
byte[] BufferBytes = new byte[SavingBytes.Length - 0x10000];
|
||||
for (int i = 0; i < SavingBytes.Length; i++) BufferBytes[i] = SavingBytes[i + 0x10000];
|
||||
SavingBytes = BufferBytes;
|
||||
}
|
||||
}
|
||||
|
||||
//Fix Checksums
|
||||
|
@ -361,7 +382,7 @@ internal class ClassEditor
|
|||
|
||||
}
|
||||
|
||||
public void SetTableValues(int[] TableSize, int ROMLocationX, string TopLeftString, string RowHeaderString, string[] HeaderStringList, string ThisMathX, string ThisFormatX, bool IsXYInverted, int ROMLocationTable, string ThisMathTable, string ThisTableFormat, bool IsTableInverted, bool IsReadOnly)
|
||||
public void SetTableValues(int[] TableSize, long ROMLocationX, string TopLeftString, string RowHeaderString, string[] HeaderStringList, string ThisMathX, string ThisFormatX, bool IsXYInverted, long ROMLocationTable, string ThisMathTable, string ThisTableFormat, bool IsTableInverted, bool IsReadOnly)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -853,7 +874,7 @@ internal class ClassEditor
|
|||
return ReturnVal;
|
||||
}
|
||||
|
||||
public string[] GetAdvancedHeader(int ValuesCount, int ThisLocation, string ThisMath, string HeaderFormat)
|
||||
public string[] GetAdvancedHeader(int ValuesCount, long ThisLocation, string ThisMath, string HeaderFormat)
|
||||
{
|
||||
string[] strArray = new string[ValuesCount];
|
||||
for (int i = 0; i < ValuesCount; i++)
|
||||
|
@ -890,7 +911,7 @@ internal class ClassEditor
|
|||
return k1;
|
||||
}*/
|
||||
|
||||
public int HexStringToInt(string hex)
|
||||
public long HexStringToInt(string hex)
|
||||
{
|
||||
string ThisStr = hex.Replace("0x", "");
|
||||
if (ThisStr.Length == 1 || ThisStr.Length == 3 || ThisStr.Length == 5 || ThisStr.Length == 7)
|
||||
|
@ -908,10 +929,34 @@ internal class ClassEditor
|
|||
for (int i = 0; i < ThisBytes.Length; i++) buffArray[i] = ThisBytes[i];
|
||||
ThisBytes = buffArray;
|
||||
}
|
||||
if (ThisBytes.Length == 5)
|
||||
{
|
||||
byte[] buffArray = new byte[8];
|
||||
buffArray[5] = 0;
|
||||
buffArray[6] = 0;
|
||||
buffArray[7] = 0;
|
||||
for (int i = 0; i < ThisBytes.Length; i++) buffArray[i] = ThisBytes[i];
|
||||
ThisBytes = buffArray;
|
||||
}
|
||||
if (ThisBytes.Length == 6)
|
||||
{
|
||||
byte[] buffArray = new byte[8];
|
||||
buffArray[6] = 0;
|
||||
buffArray[7] = 0;
|
||||
for (int i = 0; i < ThisBytes.Length; i++) buffArray[i] = ThisBytes[i];
|
||||
ThisBytes = buffArray;
|
||||
}
|
||||
if (ThisBytes.Length == 7)
|
||||
{
|
||||
byte[] buffArray = new byte[8];
|
||||
buffArray[7] = 0;
|
||||
for (int i = 0; i < ThisBytes.Length; i++) buffArray[i] = ThisBytes[i];
|
||||
ThisBytes = buffArray;
|
||||
}
|
||||
|
||||
if (ThisBytes.Length == 2) return BitConverter.ToUInt16(ThisBytes, 0);
|
||||
if (ThisBytes.Length == 4) return BitConverter.ToInt32(ThisBytes, 0);
|
||||
//if (ThisBytes.Length == 8) return BitConverter.ToUInt64(ThisBytes, 0);
|
||||
if (ThisBytes.Length == 4) return BitConverter.ToUInt32(ThisBytes, 0);
|
||||
if (ThisBytes.Length == 8) return BitConverter.ToInt64(ThisBytes, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -923,14 +968,27 @@ internal class ClassEditor
|
|||
{
|
||||
this.ROM_Bytes = File.ReadAllBytes(string_4);
|
||||
|
||||
//Console.WriteLine(Editortable_0.IsFullBinary);
|
||||
//Console.WriteLine(FileFormat);
|
||||
|
||||
//Create a fake bootloader section
|
||||
if (!Editortable_0.IsFullBinary)
|
||||
{
|
||||
byte[] BufferBytes = new byte[0x8000 + this.ROM_Bytes.Length];
|
||||
for (int i = 0; i < 0x8000; i++) BufferBytes[i] = 0xff;
|
||||
for (int i = 0; i < this.ROM_Bytes.Length; i++) BufferBytes[0x8000 + i] = this.ROM_Bytes[i];
|
||||
|
||||
this.ROM_Bytes = BufferBytes;
|
||||
if (FileFormat == "1mb-fw")
|
||||
{
|
||||
byte[] BufferBytes = new byte[0x8000 + this.ROM_Bytes.Length];
|
||||
for (int i = 0; i < 0x8000; i++) BufferBytes[i] = 0xff;
|
||||
for (int i = 0; i < this.ROM_Bytes.Length; i++) BufferBytes[0x8000 + i] = this.ROM_Bytes[i];
|
||||
this.ROM_Bytes = BufferBytes;
|
||||
}
|
||||
if (FileFormat == "2mb-fw" || FileFormat == "4mb-fw")
|
||||
{
|
||||
long ThisSize = (long)0x10000 + (long)this.ROM_Bytes.Length;
|
||||
byte[] BufferBytes = new byte[ThisSize];
|
||||
for (long i = 0; i < 0x10000; i++) BufferBytes[i] = 0xff;
|
||||
for (long i = 0; i < this.ROM_Bytes.Length; i++) BufferBytes[0x10000 + i] = this.ROM_Bytes[i];
|
||||
this.ROM_Bytes = BufferBytes;
|
||||
}
|
||||
}
|
||||
|
||||
//Get ECU filename (33 37 38 30 35 2D -> 37805- 'in ASCII chars') (37805-RRB-A140)
|
||||
|
@ -1012,12 +1070,12 @@ internal class ClassEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
public int GetIntValue(int int_232)
|
||||
public int GetIntValue(long int_232)
|
||||
{
|
||||
return (int)((short)((int)this.ROM_Bytes[int_232] << 8 | (int)this.ROM_Bytes[int_232 + 1]));
|
||||
}
|
||||
|
||||
public int GetSingleByteValue(int int_232)
|
||||
public int GetSingleByteValue(long int_232)
|
||||
{
|
||||
return (int)this.ROM_Bytes[int_232];
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public class Class_DefinitionMaker
|
|||
{
|
||||
if (BufECUName != "") CreateFile(AllStringFile, BufECUName);
|
||||
BufECUName = AllECUS[i];
|
||||
AllStringFile = GenerateNewHeader(BufECUName);
|
||||
AllStringFile = GenerateNewHeader(BufECUName, new List<string>());
|
||||
//Console.WriteLine(AllECUS[i] + " | 0x" + AllFoundAddress[i].ToString("X") + " | " + AllFoundFunctions[i]);
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ public class Class_DefinitionMaker
|
|||
GForm_Main_0.method_1("File saved:" + DirectoryPath + @"\" + ThisFile + ".txt");
|
||||
}
|
||||
|
||||
private string GenerateNewHeader(string ThisEECU)
|
||||
private string GenerateNewHeader(string ThisEECU, List<string> AllEcuCompatible)
|
||||
{
|
||||
string ReturnStr = "";
|
||||
ReturnStr = ReturnStr + "#######################################################################" + Environment.NewLine;
|
||||
|
@ -359,7 +359,11 @@ public class Class_DefinitionMaker
|
|||
ReturnStr = ReturnStr + "#######################################################################" + Environment.NewLine;
|
||||
ReturnStr = ReturnStr + "# Supported ECU:" + Environment.NewLine;
|
||||
ReturnStr = ReturnStr + "#######################################################################" + Environment.NewLine;
|
||||
ReturnStr = ReturnStr + ThisEECU + Environment.NewLine;
|
||||
if (ThisEECU != "") ReturnStr = ReturnStr + ThisEECU + Environment.NewLine;
|
||||
if (AllEcuCompatible.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < AllEcuCompatible.Count; i++) ReturnStr = ReturnStr + AllEcuCompatible[i] + Environment.NewLine;
|
||||
}
|
||||
ReturnStr = ReturnStr + "#######################################################################" + Environment.NewLine;
|
||||
ReturnStr = ReturnStr + "#######################################################################" + Environment.NewLine;
|
||||
ReturnStr = ReturnStr + "#######################################################################" + Environment.NewLine;
|
||||
|
@ -527,49 +531,191 @@ public class Class_DefinitionMaker
|
|||
List<bool> AllTableUntested = new List<bool>();
|
||||
|
||||
string CurrentParam = "";
|
||||
//string ThisECUName = "";
|
||||
int ParamCount = 0;
|
||||
int TableCount = 0;
|
||||
List<string> AllEcuCompatible = new List<string>();
|
||||
int NumberOfEcus = 0;
|
||||
|
||||
//#########################################
|
||||
//FileName=RDX-RWC-A620 NumBinaries
|
||||
if (AllLines[2].Contains("NumBinaries="))
|
||||
{
|
||||
NumberOfEcus = int.Parse(AllLines[2].Split('=')[1]);
|
||||
|
||||
for (int i2 = 0; i2 < NumberOfEcus; i2++)
|
||||
{
|
||||
AllEcuCompatible.Add(AllLines[3 + (i2 * 3) + 1].Split('=')[1]);
|
||||
}
|
||||
|
||||
SavingPath = ThisEndPath + AllEcuCompatible[0] + ".txt";
|
||||
}
|
||||
|
||||
if (AllLines[1].Contains("FileName=") && !AllLines[2].Contains("NumBinaries="))
|
||||
{
|
||||
string ThisECUName = AllLines[1].Split('=')[1];
|
||||
if (ThisECUName.Contains(".")) ThisECUName = ThisECUName.Split('.')[0];
|
||||
ThisECUName = "37805-" + ThisECUName.Substring(ThisECUName.Length - 8);
|
||||
|
||||
SavingPath = ThisEndPath + ThisECUName + ".txt";
|
||||
AllEcuCompatible.Add(ThisECUName);
|
||||
}
|
||||
//#########################################
|
||||
|
||||
for (int i = 0; i < AllLines.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
//#########################################
|
||||
/*ParameterCount=40
|
||||
IndexCount=53
|
||||
TableCount=49
|
||||
ChecksumAddress=0x001FFFFA
|
||||
ChecksumAddress=0x00008400*/
|
||||
if (AllLines[i].Contains("ParameterCount=")) ParamCount = int.Parse(AllLines[i].Split('=')[1]);
|
||||
if (AllLines[i].Contains("TableCount=") && !AllLines[i].Contains("DevTableCount")) TableCount = int.Parse(AllLines[i].Split('=')[1]);
|
||||
|
||||
//#########################################
|
||||
if (AllLines[i].Contains("[Parameter"))
|
||||
{
|
||||
if (AllLines[i] != CurrentParam)
|
||||
{
|
||||
CurrentParam = AllLines[i];
|
||||
|
||||
AllParamName.Add(AllLines[i + 2].Split('=')[1]);
|
||||
AllParamLocations.Add(AllLines[i + 7].Split('=')[1]);
|
||||
if (AllLines[i + 17].Split('=')[1] == "0") AllParamReadOnly.Add(false);
|
||||
if (AllLines[i + 17].Split('=')[1] == "1") AllParamReadOnly.Add(true);
|
||||
if (AllLines[i + 18].Split('=')[1] == "0") AllParamUntested.Add(false);
|
||||
if (AllLines[i + 18].Split('=')[1] == "1") AllParamUntested.Add(true);
|
||||
bool DoneThisParameter = false;
|
||||
try
|
||||
{
|
||||
string ParamNamee = AllLines[i + 2].Split('=')[1];
|
||||
|
||||
for (int i2 = 0; i2 < AllParamName.Count; i2++) if (AllParamName[i2] == ParamNamee) DoneThisParameter = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
DoneThisParameter = true;
|
||||
}
|
||||
|
||||
if (!DoneThisParameter)
|
||||
{
|
||||
//############################
|
||||
AllParamName.Add("");
|
||||
AllParamLocations.Add("");
|
||||
AllParamReadOnly.Add(false);
|
||||
AllParamUntested.Add(false);
|
||||
//############################
|
||||
|
||||
try
|
||||
{
|
||||
AllParamName[AllParamName.Count - 1] = AllLines[i + 2].Split('=')[1];
|
||||
AllParamLocations[AllParamLocations.Count - 1] = AllLines[i + 7].Split('=')[1];
|
||||
if (AllLines[i + 17].Split('=')[1] == "0") AllParamReadOnly[AllParamReadOnly.Count - 1] = false;
|
||||
if (AllLines[i + 17].Split('=')[1] == "1") AllParamReadOnly[AllParamReadOnly.Count - 1] = true;
|
||||
if (AllLines[i + 18].Split('=')[1] == "0") AllParamUntested[AllParamUntested.Count - 1] = false;
|
||||
if (AllLines[i + 18].Split('=')[1] == "1") AllParamUntested[AllParamUntested.Count - 1] = true;
|
||||
|
||||
//Check for issues
|
||||
bool IssueEncountered = false;
|
||||
if (!AllParamLocations[AllParamLocations.Count - 1].Contains("0x")) IssueEncountered = true;
|
||||
if (AllParamLocations[AllParamLocations.Count - 1] == "0") IssueEncountered = true;
|
||||
if (AllParamName[AllParamName.Count - 1].Contains("0x")) IssueEncountered = true;
|
||||
|
||||
if (IssueEncountered)
|
||||
{
|
||||
AllParamName.RemoveAt(AllParamName.Count - 1);
|
||||
AllParamLocations.RemoveAt(AllParamLocations.Count - 1);
|
||||
AllParamReadOnly.RemoveAt(AllParamReadOnly.Count - 1);
|
||||
AllParamUntested.RemoveAt(AllParamUntested.Count - 1);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//issue extracing parameters, remove from list to avoid issue creating definition
|
||||
AllParamName.RemoveAt(AllParamName.Count - 1);
|
||||
AllParamLocations.RemoveAt(AllParamLocations.Count - 1);
|
||||
AllParamReadOnly.RemoveAt(AllParamReadOnly.Count - 1);
|
||||
AllParamUntested.RemoveAt(AllParamUntested.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#########################################
|
||||
if (AllLines[i].Contains("[Table"))
|
||||
{
|
||||
if (AllLines[i] != CurrentParam)
|
||||
{
|
||||
CurrentParam = AllLines[i];
|
||||
|
||||
AllTableName.Add(AllLines[i + 2].Split('=')[1]);
|
||||
AllTableLocations.Add(AllLines[i + 5].Split('=')[1]);
|
||||
AllColCount.Add(int.Parse(AllLines[i + 10].Split('=')[1]));
|
||||
bool DoneThisParameter = false;
|
||||
try
|
||||
{
|
||||
string ParamNamee = AllLines[i + 2].Split('=')[1];
|
||||
for (int i2 = 0; i2 < AllTableName.Count; i2++) if (AllTableName[i2] == ParamNamee) DoneThisParameter = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
DoneThisParameter = true;
|
||||
}
|
||||
|
||||
if (AllLines[i + 18].Split('=')[1] == "1") AllRowCount.Add(1);
|
||||
if (AllLines[i + 18].Split('=')[1] == "0") AllRowCount.Add(20); //#####
|
||||
if (!DoneThisParameter)
|
||||
{
|
||||
//############################
|
||||
AllTableName.Add("");
|
||||
AllTableLocations.Add("");
|
||||
AllColCount.Add(0);
|
||||
AllRowCount.Add(0);
|
||||
AllTableLocationsX.Add("");
|
||||
AllTableLocationsY.Add("");
|
||||
AllTableReadOnly.Add(false);
|
||||
AllTableUntested.Add(false);
|
||||
//############################
|
||||
|
||||
if (AllLines[i + 6].Split('=')[1] != "0x00000") AllTableLocationsX.Add(AllLines[i + 6].Split('=')[1]);
|
||||
if (AllLines[i + 6].Split('=')[1] == "0x00000") AllTableLocationsX.Add("");
|
||||
try
|
||||
{
|
||||
AllTableName[AllTableName.Count - 1] = AllLines[i + 2].Split('=')[1];
|
||||
AllTableLocations[AllTableLocations.Count - 1] = AllLines[i + 5].Split('=')[1];
|
||||
AllColCount[AllColCount.Count - 1] = int.Parse(AllLines[i + 10].Split('=')[1]);
|
||||
|
||||
if (AllLines[i + 7].Split('=')[1] != "0x00000") AllTableLocationsY.Add(AllLines[i + 7].Split('=')[1]);
|
||||
if (AllLines[i + 7].Split('=')[1] == "0x00000") AllTableLocationsY.Add("");
|
||||
if (AllLines[i + 18].Split('=')[1] == "1") AllRowCount[AllRowCount.Count - 1] = 1;
|
||||
if (AllLines[i + 18].Split('=')[1] == "0") AllRowCount[AllRowCount.Count - 1] = 20; //#####
|
||||
|
||||
if (AllLines[i + 15].Split('=')[1] == "0") AllTableReadOnly.Add(false);
|
||||
if (AllLines[i + 15].Split('=')[1] == "1") AllTableReadOnly.Add(true);
|
||||
if (AllLines[i + 6].Split('=')[1] != "0x00000") AllTableLocationsX[AllTableLocationsX.Count - 1] = AllLines[i + 6].Split('=')[1];
|
||||
if (AllLines[i + 6].Split('=')[1] == "0x00000") AllTableLocationsX[AllTableLocationsX.Count - 1] = "";
|
||||
|
||||
if (AllLines[i + 16].Split('=')[1] == "0") AllTableUntested.Add(false);
|
||||
if (AllLines[i + 16].Split('=')[1] == "1") AllTableUntested.Add(true);
|
||||
if (AllLines[i + 7].Split('=')[1] != "0x00000") AllTableLocationsY[AllTableLocationsY.Count - 1] = AllLines[i + 7].Split('=')[1];
|
||||
if (AllLines[i + 7].Split('=')[1] == "0x00000") AllTableLocationsY[AllTableLocationsY.Count - 1] = "";
|
||||
|
||||
if (AllLines[i + 15].Split('=')[1] == "0") AllTableReadOnly[AllTableReadOnly.Count - 1] = false;
|
||||
if (AllLines[i + 15].Split('=')[1] == "1") AllTableReadOnly[AllTableReadOnly.Count - 1] = true;
|
||||
|
||||
if (AllLines[i + 16].Split('=')[1] == "0") AllTableUntested[AllTableUntested.Count - 1] = false;
|
||||
if (AllLines[i + 16].Split('=')[1] == "1") AllTableUntested[AllTableUntested.Count - 1] = true;
|
||||
|
||||
//Check for issues
|
||||
bool IssueEncountered = false;
|
||||
if (!AllTableLocations[AllTableLocations.Count - 1].Contains("0x")) IssueEncountered = true;
|
||||
if (AllTableLocations[AllTableLocations.Count - 1] == "0") IssueEncountered = true;
|
||||
if (AllTableName[AllTableName.Count - 1].Contains("0x")) IssueEncountered = true;
|
||||
|
||||
if (IssueEncountered)
|
||||
{
|
||||
AllParamName.RemoveAt(AllParamName.Count - 1);
|
||||
AllParamLocations.RemoveAt(AllParamLocations.Count - 1);
|
||||
AllParamReadOnly.RemoveAt(AllParamReadOnly.Count - 1);
|
||||
AllParamUntested.RemoveAt(AllParamUntested.Count - 1);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//issue extracing parameters, remove from list to avoid issue creating definition
|
||||
AllTableName.RemoveAt(AllTableName.Count - 1);
|
||||
AllTableLocations.RemoveAt(AllTableLocations.Count - 1);
|
||||
AllColCount.RemoveAt(AllColCount.Count - 1);
|
||||
AllRowCount.RemoveAt(AllRowCount.Count - 1);
|
||||
AllTableLocationsX.RemoveAt(AllTableLocationsX.Count - 1);
|
||||
AllTableLocationsY.RemoveAt(AllTableLocationsY.Count - 1);
|
||||
AllTableReadOnly.RemoveAt(AllTableReadOnly.Count - 1);
|
||||
AllTableUntested.RemoveAt(AllTableUntested.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +725,15 @@ public class Class_DefinitionMaker
|
|||
}
|
||||
}
|
||||
|
||||
string SavingStr = "";
|
||||
//Check Counts
|
||||
GForm_Main_0.method_1("Parameters existing in FPM: " + ParamCount);
|
||||
GForm_Main_0.method_1("Parameters extracted: " + AllParamName.Count);
|
||||
GForm_Main_0.method_1("Tables existing in FPM: " + TableCount);
|
||||
GForm_Main_0.method_1("Tables extracted: " + AllTableName.Count);
|
||||
|
||||
|
||||
//string SavingStr = GenerateNewHeader(ThisECUName);
|
||||
string SavingStr = GenerateNewHeader("", AllEcuCompatible);
|
||||
for (int i = 0; i < AllParamName.Count; i++)
|
||||
{
|
||||
SavingStr = SavingStr + "ROMLocationTable:" + AllParamLocations[i] + Environment.NewLine;
|
||||
|
@ -589,7 +743,7 @@ public class Class_DefinitionMaker
|
|||
SavingStr = SavingStr + "IsNotDefined:true" + Environment.NewLine;
|
||||
if (AllParamReadOnly[i]) SavingStr = SavingStr + "IsReadOnly:true" + Environment.NewLine;
|
||||
if (AllParamUntested[i]) SavingStr = SavingStr + "IsUntested:true" + Environment.NewLine;
|
||||
if (i < AllParamName.Count - 2) SavingStr = SavingStr + "#############################" + Environment.NewLine;
|
||||
if (i < AllParamName.Count - 1) SavingStr = SavingStr + "#############################" + Environment.NewLine;
|
||||
}
|
||||
|
||||
SavingStr = SavingStr + "#############################################################" + Environment.NewLine;
|
||||
|
@ -623,9 +777,21 @@ public class Class_DefinitionMaker
|
|||
// REQUIRED CONSTS
|
||||
const int PROCESS_QUERY_INFORMATION = 0x0400;
|
||||
const int MEM_COMMIT = 0x00001000;
|
||||
const int PAGE_READWRITE = 0x04;
|
||||
//const int PAGE_READWRITE = 0x04;
|
||||
const int PROCESS_WM_READ = 0x0010;
|
||||
|
||||
const int PAGE_EXECUTE = 0x10;
|
||||
const int PAGE_EXECUTE_READ = 0x20;
|
||||
const int PAGE_EXECUTE_READWRITE = 0x40;
|
||||
const int PAGE_EXECUTE_WRITECOPY = 0x80;
|
||||
const int PAGE_NOACCESS = 0x01;
|
||||
const int PAGE_READONLY = 0x02;
|
||||
const int PAGE_READWRITE = 0x04;
|
||||
const int PAGE_WRITECOPY = 0x08;
|
||||
const int PAGE_GUARD = 0x100;
|
||||
const int PAGE_NOCACHE = 0x200;
|
||||
const int PAGE_WRITECOMBINE = 0x400;
|
||||
|
||||
// REQUIRED METHODS
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
|
||||
|
@ -740,13 +906,17 @@ public class Class_DefinitionMaker
|
|||
//RemovePastDump();
|
||||
string ReloadDump = "";
|
||||
|
||||
Console.WriteLine("memsize: " + sys_info.maximumApplicationAddress.ToString("X"));
|
||||
|
||||
while (!Done)
|
||||
{
|
||||
int Percent = (int)(((CurrentIndex - 4000000) * 100) / (Int64.Parse(sys_info.maximumApplicationAddress.ToString()) - 1));
|
||||
//int Percent = (int)(((CurrentIndex - 4000000) * 100) / (Int64.Parse(sys_info.maximumApplicationAddress.ToString()) - 1));
|
||||
int Percent = (int)(((CurrentIndex) * 100) / (Int64.Parse(sys_info.maximumApplicationAddress.ToString()) - 1));
|
||||
//Console.Write("\nSEARCH #" + SearchID + " " + Percent + "%");
|
||||
GForm_Main_0.method_4(Percent);
|
||||
|
||||
if ((CurrentIndex + BlockSizeExtracted) > Int64.Parse(sys_info.maximumApplicationAddress.ToString()))
|
||||
//if ((CurrentIndex + BlockSizeExtracted) > 0xFEFFFFFF)
|
||||
{
|
||||
Done = true;
|
||||
}
|
||||
|
@ -783,6 +953,16 @@ public class Class_DefinitionMaker
|
|||
GForm_Main_0.method_1("Extracted Definitions file created: " + SaveDefPath);
|
||||
File.Create(SaveDefPath).Dispose();
|
||||
File.WriteAllText(SaveDefPath, DumpedDefinition);
|
||||
|
||||
//< 0x20 > 0x7E
|
||||
/*byte[] AllFileBytes = File.ReadAllBytes(SaveDefPath);
|
||||
string SavingString = "";
|
||||
for (int i = 0; i < AllFileBytes.Length; i++)
|
||||
{
|
||||
if (AllFileBytes[i] >= 0x20 && AllFileBytes[i] <= 0x7E) SavingString += ((char)AllFileBytes[i]).ToString();
|
||||
if (AllFileBytes[i] == 0x0D && AllFileBytes[i + 1] == 0x0A) SavingString += Environment.NewLine;
|
||||
}
|
||||
File.WriteAllText(SaveDefPath, SavingString);*/
|
||||
}
|
||||
}
|
||||
if (ExtractMode == "Bin")
|
||||
|
@ -862,12 +1042,15 @@ public class Class_DefinitionMaker
|
|||
{
|
||||
VirtualQueryEx(processHandle, proc_min_address, out mem_basic_info, 28);
|
||||
|
||||
if (mem_basic_info.Protect == PAGE_READWRITE && mem_basic_info.State == MEM_COMMIT)
|
||||
if ((mem_basic_info.Protect == PAGE_READWRITE && mem_basic_info.State == MEM_COMMIT) || mem_basic_info.Protect == PAGE_WRITECOPY)
|
||||
{
|
||||
byte[] buffer = new byte[mem_basic_info.RegionSize];
|
||||
|
||||
ReadProcessMemory((int)processHandle, mem_basic_info.BaseAddress, buffer, mem_basic_info.RegionSize, ref bytesRead);
|
||||
|
||||
//Console.WriteLine("adrr: " + mem_basic_info.BaseAddress.ToString("X"));
|
||||
//Console.WriteLine("size: " + mem_basic_info.RegionSize.ToString("X"));
|
||||
|
||||
for (int i = 0; i < mem_basic_info.RegionSize; i++)
|
||||
{
|
||||
if (ExtractMode == "Bin") sw2.Write(buffer[i].ToString("X2") + " ");
|
||||
|
@ -882,6 +1065,21 @@ public class Class_DefinitionMaker
|
|||
//sw.Close();
|
||||
sw2.Close();
|
||||
|
||||
if (ExtractMode == "Definition")
|
||||
{
|
||||
byte[] AllBytes = File.ReadAllBytes(ThisEndPath + "DumpHex" + ExtractedBlockDone);
|
||||
List<byte> AllBytesList = new List<byte>();
|
||||
for (int i = 0; i < AllBytes.Length; i++)
|
||||
{
|
||||
if (AllBytes[i] >= 0x20 && AllBytes[i] <= 0x7E) AllBytesList.Add(AllBytes[i]);
|
||||
if (AllBytes[i] == 0x0D || AllBytes[i] == 0x0A) AllBytesList.Add(AllBytes[i]);
|
||||
}
|
||||
AllBytes = new byte[AllBytesList.Count];
|
||||
for (int i = 0; i < AllBytesList.Count; i++) AllBytes[i] = AllBytesList[i];
|
||||
|
||||
File.WriteAllBytes(ThisEndPath + "DumpHex" + ExtractedBlockDone, AllBytes);
|
||||
}
|
||||
|
||||
if (ExtractMode == "Bin")
|
||||
{
|
||||
byte[] AllBytesChar = File.ReadAllBytes(ThisEndPath + "DumpHex" + ExtractedBlockDone);
|
||||
|
|
110
Class_RWD.cs
110
Class_RWD.cs
|
@ -164,36 +164,98 @@ static class Class_RWD
|
|||
|
||||
string indicatorBytes = data[0].ToString("x2") + data[1].ToString("x2") + data[2].ToString("x2");
|
||||
if (indicatorBytes != "5a0d0a")
|
||||
//if (indicatorBytes != "5a0d0a" && indicatorBytes != "310d0a")
|
||||
{
|
||||
GForm_Main_0.method_1("Not Compatible file!");
|
||||
return;
|
||||
}
|
||||
|
||||
byte Mode = 0x5a;
|
||||
if (indicatorBytes == "310d0a") Mode = 0x31;
|
||||
|
||||
byte[] headers0 = { };
|
||||
byte[] headers1 = { };
|
||||
byte[] headers2 = { };
|
||||
byte[] headers3 = { };
|
||||
byte[] headers4 = { };
|
||||
byte[] headers5 = { };
|
||||
int idx = 0;
|
||||
idx += 3;
|
||||
int idx = 3;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
// first byte is number of values
|
||||
var count = data[idx];
|
||||
idx += 1;
|
||||
|
||||
byte[] header = { };
|
||||
for (int j = 0; j < count; j++)
|
||||
|
||||
if (Mode == 0x5a)
|
||||
{
|
||||
// first byte is length of value
|
||||
int length = data[idx];
|
||||
byte count = data[idx];
|
||||
idx += 1;
|
||||
|
||||
byte[] v = Slice(data, idx, idx + length);
|
||||
idx += length;
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
// first byte is length of value
|
||||
int length = data[idx];
|
||||
idx += 1;
|
||||
|
||||
header = Push(header, v);
|
||||
byte[] v = Slice(data, idx, idx + length);
|
||||
idx += length;
|
||||
|
||||
header = Push(header, v);
|
||||
}
|
||||
}
|
||||
|
||||
if (Mode == 0x31)
|
||||
{
|
||||
byte[] h_prefix = new byte[2];
|
||||
idx += 4;
|
||||
h_prefix[0] = data[idx];
|
||||
h_prefix[1] = data[idx + 1];
|
||||
//h_prefix[2] = data[idx + 2];
|
||||
idx += 2;
|
||||
|
||||
if (h_prefix[0] != 0x0d && h_prefix[1] != 0x0a)
|
||||
{
|
||||
GForm_Main_0.method_1("header delimiter not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
//while (data[idx] != h_prefix[0] && data[idx + 1] != h_prefix[1] && data[idx + 2] != h_prefix[2])
|
||||
while (data[idx] != h_prefix[0] && data[idx + 1] != h_prefix[1])
|
||||
{
|
||||
int end_idx = -1;
|
||||
for (int j = idx; j < data.Length - 1; j++)
|
||||
{
|
||||
if (data[j] == 0x0d && data[j + 1] == 0x0a)
|
||||
{
|
||||
end_idx = j;
|
||||
j = data.Length;
|
||||
}
|
||||
}
|
||||
if (end_idx == -1)
|
||||
{
|
||||
GForm_Main_0.method_1("field delimiter not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] v_data = Slice(data, idx, end_idx);
|
||||
idx += v_data.Length;
|
||||
|
||||
//skip past field delimiter
|
||||
//byte[] v_suffix = Slice(data, idx, idx + 2);
|
||||
idx += 2;
|
||||
|
||||
header = Push(header, v_data);
|
||||
}
|
||||
|
||||
//skip past delimiter
|
||||
byte[] h_suffix = Slice(data, idx, idx + 2);
|
||||
idx += 3;
|
||||
if (h_prefix != h_suffix)
|
||||
//if (h_prefix[0] != h_suffix[0] && h_prefix[1] != h_suffix[1])
|
||||
{
|
||||
Console.WriteLine(h_prefix[0].ToString("X2") + h_prefix[1].ToString("X2"));
|
||||
Console.WriteLine(h_suffix[0].ToString("X2") + h_suffix[1].ToString("X2"));
|
||||
GForm_Main_0.method_1("header prefix and suffix do not match");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) headers0 = header;
|
||||
|
@ -328,13 +390,17 @@ static class Class_RWD
|
|||
//Since we are missing the bootloader section of the full binary we have to remove the section 0x0000 to 0x8000(Start_Address)
|
||||
//we can calculate what was the 'sum' of the bootloader by subtracting the 'sum' of the decrypted firmware!
|
||||
|
||||
if (start == 0x8000) //Only SH7058 1mb file
|
||||
if (fc.Length - 1 == 0xF7FFF || fc.Length - 1 == 0x1EFFFF || fc.Length - 1 == 0x26FFFF)
|
||||
{
|
||||
byte num = GetBootloaderSum(fc);
|
||||
byte num2 = GetNegativeChecksumFWBin(fc);
|
||||
int CheckLocation = 0;
|
||||
if (fc.Length - 1 == 0xF7FFF) CheckLocation = 0x400;
|
||||
if (fc.Length - 1 == 0x1EFFFF) CheckLocation = 0x12; //0x10012
|
||||
if (fc.Length - 1 == 0x26FFFF) CheckLocation = 0x1F03E6; //0x2003E6
|
||||
byte num = GetBootloaderSum(fc, CheckLocation);
|
||||
byte num2 = GetNegativeChecksumFWBin(fc, CheckLocation);
|
||||
byte ThisSum = num;
|
||||
ThisSum -= num2;
|
||||
byte chk = fc[0x400];
|
||||
byte chk = fc[CheckLocation];
|
||||
if (chk == ThisSum)
|
||||
{
|
||||
GForm_Main_0.method_1("checksums good!");
|
||||
|
@ -418,26 +484,24 @@ static class Class_RWD
|
|||
}
|
||||
}
|
||||
|
||||
public static byte GetBootloaderSum(byte[] FWFileBytes)
|
||||
public static byte GetBootloaderSum(byte[] FWFileBytes, int CheckLocation)
|
||||
{
|
||||
//###############################
|
||||
//Get Checksum (sum)
|
||||
byte[] BufferBytes = FWFileBytes;
|
||||
byte num = BufferBytes[0x400];
|
||||
byte num2 = GetNegativeChecksumFWBin(BufferBytes);
|
||||
byte num = BufferBytes[CheckLocation];
|
||||
byte num2 = GetNegativeChecksumFWBin(BufferBytes, CheckLocation);
|
||||
byte BTSum = num;
|
||||
BTSum += num2;
|
||||
return BTSum;
|
||||
//BootloaderSum = BTSum;
|
||||
//GForm_Main_0.method_1("Bootloader Sum are 0x" + BootloaderSum.ToString("X"));
|
||||
}
|
||||
|
||||
public static byte GetNegativeChecksumFWBin(byte[] byte_1)
|
||||
public static byte GetNegativeChecksumFWBin(byte[] byte_1, int CheckLocation)
|
||||
{
|
||||
byte b = 0;
|
||||
for (int i = 0; i < byte_1.Length; i++)
|
||||
{
|
||||
if (i != 0x400) b -= byte_1[i];
|
||||
if (i != CheckLocation) b -= byte_1[i];
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -955,8 +955,12 @@ public class Editortable : DarkForm
|
|||
string[] TableSizeStrSplit = TableSizeStr.Split('x');
|
||||
int[] TableSizze = new int[] { int.Parse(TableSizeStrSplit[0]), int.Parse(TableSizeStrSplit[1]) };
|
||||
|
||||
if (ClassEditor_0.DefinitionsLocationsX[NodeIndex].Length >= 10) ClassEditor_0.DefinitionsLocationsX[NodeIndex] = ClassEditor_0.DefinitionsLocationsX[NodeIndex].Replace("0x80", "0x");
|
||||
if (ClassEditor_0.DefinitionsLocationsY[NodeIndex].Length >= 10) ClassEditor_0.DefinitionsLocationsY[NodeIndex] = ClassEditor_0.DefinitionsLocationsY[NodeIndex].Replace("0x80", "0x");
|
||||
if (ClassEditor_0.DefinitionsLocationsTable[NodeIndex].Length >= 10) ClassEditor_0.DefinitionsLocationsTable[NodeIndex] = ClassEditor_0.DefinitionsLocationsTable[NodeIndex].Replace("0x80", "0x");
|
||||
|
||||
//Set X rom location
|
||||
int ParamLocation = ClassEditor_0.HexStringToInt(ClassEditor_0.DefinitionsLocationsX[NodeIndex]);
|
||||
long ParamLocation = ClassEditor_0.HexStringToInt(ClassEditor_0.DefinitionsLocationsX[NodeIndex]);
|
||||
|
||||
//Set Y Headers (normal header mode)
|
||||
int DoingThisSize = TableSizze[0];
|
||||
|
@ -980,7 +984,7 @@ public class Editortable : DarkForm
|
|||
string NewHeaderLocation = ClassEditor_0.DefinitionsLocationsY[NodeIndex];
|
||||
if (NewHeaderLocation != "")
|
||||
{
|
||||
int ParamHeaderLocation = ClassEditor_0.HexStringToInt(NewHeaderLocation);
|
||||
long ParamHeaderLocation = ClassEditor_0.HexStringToInt(NewHeaderLocation);
|
||||
textArray1 = ClassEditor_0.GetAdvancedHeader(TableSizze[0], ParamHeaderLocation, ClassEditor_0.DefinitionsMathY[NodeIndex], ClassEditor_0.DefinitionsFormatY[NodeIndex]);
|
||||
}
|
||||
|
||||
|
@ -1063,6 +1067,7 @@ public class Editortable : DarkForm
|
|||
return ECUName;
|
||||
}
|
||||
|
||||
|
||||
public void LoadThisFile(string ThisFilePath)
|
||||
{
|
||||
this.Text = "Honda Rom Tables Editor (" + this.GForm_Main_0.Version + ") | " + Path.GetFileName(ThisFilePath);
|
||||
|
@ -1070,16 +1075,23 @@ public class Editortable : DarkForm
|
|||
string LastOpenFilePath = Application.StartupPath + @"\LastFileOpened.txt";
|
||||
File.Create(LastOpenFilePath).Dispose();
|
||||
File.WriteAllText(LastOpenFilePath, ThisFilePath);
|
||||
this.IsFullBinary = false;
|
||||
|
||||
byte[] FilesBytes = File.ReadAllBytes(ThisFilePath);
|
||||
this.Editortable_0.LoadedFilename = ThisFilePath;
|
||||
if ((FilesBytes.Length - 1) == 0xFFFFF) this.IsFullBinary = true;
|
||||
if ((FilesBytes.Length - 1) == 0x1FFFFF) this.IsFullBinary = true;
|
||||
if ((FilesBytes.Length - 1) == 0x27FFFF) this.IsFullBinary = true;
|
||||
//if ((FilesBytes.Length - 1) == 0x3FFFFF) this.IsFullBinary = true;
|
||||
|
||||
ClassEditor_0.SetFileFormat(FilesBytes);
|
||||
|
||||
//Console.WriteLine("calib: " + (FilesBytes.Length - 1).ToString("X"));
|
||||
//Console.WriteLine("full: " + (FilesBytes.Length - 1 + 0xA0010000).ToString("X"));
|
||||
|
||||
//Load BootLoader Sum byte for decrypted firmware (not a full binary rom)
|
||||
if ((FilesBytes.Length - 1) == 0xF7FFF)
|
||||
if ((FilesBytes.Length - 1) == 0xF7FFF || (FilesBytes.Length - 1) == 0x1EFFFF || (FilesBytes.Length - 1) == 0x26FFFF)
|
||||
{
|
||||
this.IsFullBinary = false;
|
||||
|
||||
int BtSumInt = CheckForBootLoaderSum(ExtractECUNameFromThisFile(FilesBytes));
|
||||
if (BtSumInt == -1)
|
||||
{
|
||||
|
@ -1101,14 +1113,19 @@ public class Editortable : DarkForm
|
|||
}
|
||||
|
||||
//Load File
|
||||
if ((FilesBytes.Length - 1) == 0xF7FFF || (FilesBytes.Length - 1) == 0xFFFFF)
|
||||
if ((FilesBytes.Length - 1) == 0xF7FFF
|
||||
|| (FilesBytes.Length - 1) == 0xFFFFF
|
||||
|| (FilesBytes.Length - 1) == 0x1EFFFF
|
||||
|| (FilesBytes.Length - 1) == 0x1FFFFF
|
||||
|| (FilesBytes.Length - 1) == 0x26FFFF
|
||||
|| (FilesBytes.Length - 1) == 0x27FFFF) //0x3FFFFF
|
||||
{
|
||||
//Load Binary into ROM Table Editor
|
||||
this.Editortable_0.method_1();
|
||||
this.method_1();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine((FilesBytes.Length - 1).ToString("X"));
|
||||
//Console.WriteLine((FilesBytes.Length - 1).ToString("X"));
|
||||
DarkMessageBox.Show(this, "This file is not compatible!");
|
||||
}
|
||||
}
|
||||
|
@ -1343,13 +1360,20 @@ public class Editortable : DarkForm
|
|||
if (result == DialogResult.OK)
|
||||
{
|
||||
byte[] FilesBytes = File.ReadAllBytes(openFileDialog1.FileName);
|
||||
if ((FilesBytes.Length - 1) == 0xFFFFF)
|
||||
ClassEditor_0.SetFileFormat(FilesBytes);
|
||||
|
||||
if (ClassEditor_0.FileFormat == "1mb-full" || ClassEditor_0.FileFormat == "2mb-full" || ClassEditor_0.FileFormat == "4mb-full")
|
||||
{
|
||||
//remove 0x0000 to 0x8000
|
||||
byte[] FilesBytesRWD = new byte[FilesBytes.Length - 0x8000];
|
||||
for (int i = 0; i < FilesBytesRWD.Length; i++)
|
||||
byte[] FilesBytesRWD = new byte[] { };
|
||||
if (ClassEditor_0.FileFormat == "1mb-full")
|
||||
{
|
||||
FilesBytesRWD[i] = FilesBytes[i + 0x8000];
|
||||
FilesBytesRWD = new byte[FilesBytes.Length - 0x8000];
|
||||
for (int i = 0; i < FilesBytesRWD.Length; i++) FilesBytesRWD[i] = FilesBytes[i + 0x8000];
|
||||
}
|
||||
if (ClassEditor_0.FileFormat == "2mb-full" || ClassEditor_0.FileFormat == "4mb-full")
|
||||
{
|
||||
FilesBytesRWD = new byte[FilesBytes.Length - 0x10000];
|
||||
for (int i = 0; i < FilesBytesRWD.Length; i++) FilesBytesRWD[i] = FilesBytes[i + 0x10000];
|
||||
}
|
||||
|
||||
string SaveeePath = Path.GetDirectoryName(openFileDialog1.FileName) + @"\" + Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "_NoBootloader.bin";
|
||||
|
@ -1374,6 +1398,7 @@ public class Editortable : DarkForm
|
|||
|
||||
private void extractbinFileFromFPMToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//THIS FUNCTION DOES NOT WORK YET
|
||||
GForm_Main_0.Class_DefinitionMaker_0.Extract("Bin");
|
||||
}
|
||||
|
||||
|
|
|
@ -1055,19 +1055,6 @@ public class GForm_Main : DarkForm
|
|||
}
|
||||
}
|
||||
|
||||
public byte GetNegativeChecksumFullBin(byte[] byte_1)
|
||||
{
|
||||
byte b = 0;
|
||||
for (int i = 0; i < byte_1.Length; i++)
|
||||
{
|
||||
if (i != 0x8400)
|
||||
{
|
||||
b -= byte_1[i];
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public byte GetNegativeChecksumArea(byte[] byte_1, int Start, int ChecksumLocation)
|
||||
{
|
||||
byte b = 0;
|
||||
|
@ -1084,28 +1071,15 @@ public class GForm_Main : DarkForm
|
|||
public byte[] VerifyChecksumFullBin(byte[] BinFileBytes)
|
||||
{
|
||||
//###############################
|
||||
//Get Checksum and Fix it for 0x8400
|
||||
//Get Checksum and Fix it
|
||||
byte[] BufferBytes = BinFileBytes;
|
||||
int CheckLocation = 0x8400;
|
||||
int CheckLocation = 0;
|
||||
if (BufferBytes.Length - 1 == 0xFFFFF) CheckLocation = 0x8400; //1mb-full
|
||||
if (BufferBytes.Length - 1 == 0x1FFFFF) CheckLocation = 0x10012; //2mb-full
|
||||
if (BufferBytes.Length - 1 == 0x27FFFF) CheckLocation = 0x2003E6; //4mb-full //0x3FFFFF
|
||||
|
||||
byte num = BufferBytes[CheckLocation];
|
||||
byte num2 = GetNegativeChecksumArea(BufferBytes, 0, CheckLocation);
|
||||
//byte num2 = this.GetNegativeChecksumFullBin(BufferBytes);
|
||||
if (num != num2)
|
||||
{
|
||||
this.method_1("Checksum miss match.");
|
||||
BufferBytes[0x8400] = num2;
|
||||
this.method_1("Checksum fixed at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.method_1("Checksum are good at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}
|
||||
//########################################################
|
||||
//########################################################
|
||||
//Verify for 0x10400
|
||||
/*CheckLocation = 0x10400;
|
||||
num = BufferBytes[CheckLocation];
|
||||
num2 = GetNegativeChecksumArea(BufferBytes, 0x8000, CheckLocation);
|
||||
if (num != num2)
|
||||
{
|
||||
this.method_1("Checksum miss match.");
|
||||
|
@ -1115,52 +1089,35 @@ public class GForm_Main : DarkForm
|
|||
else
|
||||
{
|
||||
this.method_1("Checksum are good at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}*/
|
||||
//########################################################
|
||||
//########################################################
|
||||
}
|
||||
return BufferBytes;
|
||||
}
|
||||
|
||||
public byte[] VerifyChecksumFWBin(byte[] FWFileBytes)
|
||||
{
|
||||
//###############################
|
||||
//Get Checksum and Fix it at 0x400 (0x8400 in full bin)
|
||||
//Get Checksum and Fix it
|
||||
byte[] BufferBytes = FWFileBytes;
|
||||
int CheckLocation = 0;
|
||||
if (BufferBytes.Length - 1 == 0xF7FFF) CheckLocation = 0x400; //1mb-fw -> 0x8400 in full bin but we dont have the bootloader 0x0000 to 0x8000
|
||||
if (BufferBytes.Length - 1 == 0x1EFFFF) CheckLocation = 0x12; //2mb-fw
|
||||
if (BufferBytes.Length - 1 == 0x26FFFF) CheckLocation = 0x1F03E6; //4mb-fw
|
||||
|
||||
byte num = Class_RWD.BootloaderSum;
|
||||
byte num2 = Class_RWD.GetNegativeChecksumFWBin(BufferBytes);
|
||||
byte num2 = Class_RWD.GetNegativeChecksumFWBin(BufferBytes, CheckLocation);
|
||||
byte ThisSum = num;
|
||||
ThisSum -= num2;
|
||||
int CheckLocation = 0x400;
|
||||
byte chk = BufferBytes[CheckLocation];
|
||||
if (chk != ThisSum)
|
||||
{
|
||||
this.method_1("Checksum miss match.");
|
||||
BufferBytes[0x400] = ThisSum;
|
||||
BufferBytes[CheckLocation] = ThisSum;
|
||||
this.method_1("Checksum fixed at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
GForm_Main_0.method_1("checksum good at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}
|
||||
//########################################################
|
||||
//########################################################
|
||||
//Verify for 0x8400 (0x10400 in full bin)
|
||||
/*CheckLocation = 0x8400;
|
||||
num = BufferBytes[CheckLocation];
|
||||
num2 = GetNegativeChecksumArea(BufferBytes, 0, CheckLocation);
|
||||
if (num != num2)
|
||||
{
|
||||
this.method_1("Checksum miss match.");
|
||||
BufferBytes[CheckLocation] = num2;
|
||||
this.method_1("Checksum fixed at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.method_1("Checksum are good at 0x" + CheckLocation.ToString("X") + " | Checksum: 0x" + num2.ToString("X2"));
|
||||
}*/
|
||||
//########################################################
|
||||
//########################################################
|
||||
return BufferBytes;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,12 +44,21 @@ public class GForm_PlatformSelect : DarkForm
|
|||
|
||||
private void method_1()
|
||||
{
|
||||
//this.list_0.Add(new Class_ECUS("512k", "SH7055", 16, "0x10", 0x7FFFF, 1015808, "Manual"));
|
||||
//this.list_0.Add(new Class_ECUS("512k", "SH7055", 17, "0x11", 0x7FFFF, 1015808, "Automatic"));
|
||||
//this.list_0.Add(new Class_ECUS("512k", "SH7055", 14, "0x0E", 0x7FFFF, 1015808, "CVT(maybe?)"));
|
||||
this.list_0.Add(new Class_ECUS("1MB", "SH7058", 16, "0x10", 1048576, 1015808, "Manual"));
|
||||
this.list_0.Add(new Class_ECUS("1MB", "SH7058", 17, "0x11", 1048576, 1015808, "Automatic"));
|
||||
this.list_0.Add(new Class_ECUS("1MB", "SH7058", 14, "0x0E", 1048576, 1015808, "CVT(maybe?)"));
|
||||
this.list_0.Add(new Class_ECUS("2MB", "SH72531", 16, "0x10", 2097152, 2031616, "Manual"));
|
||||
this.list_0.Add(new Class_ECUS("2MB", "SH72531", 17, "0x11", 2097152, 2031616, "Automatic"));
|
||||
this.list_0.Add(new Class_ECUS("2MB", "SH72531", 14, "0x0E", 2097152, 2031616, "CVT(maybe?)"));
|
||||
//this.list_0.Add(new Class_ECUS("1.5MB", "SH7059", 16, "0x10", 1048576, 1015808, "Manual"));
|
||||
//this.list_0.Add(new Class_ECUS("1.5MB", "SH7059", 17, "0x11", 1048576, 1015808, "Automatic"));
|
||||
//this.list_0.Add(new Class_ECUS("1.5MB", "SH7059", 14, "0x0E", 1048576, 1015808, "CVT(maybe?)"));
|
||||
this.list_0.Add(new Class_ECUS("2MB", "SH72531/MPC5554", 16, "0x10", 2097152, 2031616, "Manual"));
|
||||
this.list_0.Add(new Class_ECUS("2MB", "SH72531/MPC5554", 17, "0x11", 2097152, 2031616, "Automatic"));
|
||||
this.list_0.Add(new Class_ECUS("2MB", "SH72531/MPC5554", 14, "0x0E", 2097152, 2031616, "CVT(maybe?)"));
|
||||
this.list_0.Add(new Class_ECUS("4MB", "MED17.9.3/TC179X", 16, "0x10", 0x400000, 0x270000, "Manual"));
|
||||
this.list_0.Add(new Class_ECUS("4MB", "MED17.9.3/TC179X", 17, "0x11", 0x400000, 0x270000, "Automatic"));
|
||||
this.list_0.Add(new Class_ECUS("4MB", "MED17.9.3/TC179X", 14, "0x0E", 0x400000, 0x270000, "CVT(maybe?)"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue