diff --git a/Class_RWD.cs b/Class_RWD.cs
index 5318332..b2dc946 100644
--- a/Class_RWD.cs
+++ b/Class_RWD.cs
@@ -55,7 +55,14 @@ static class Class_RWD
return k1;
}
- public static UInt16 checksum_by_sum(byte[] fw, uint start, uint end)
+ public static UInt32 ToUInt32BE(byte[] FourBytes)
+ {
+ int k0 = BitConverter.ToInt32(FourBytes, 0);
+ int k1 = BitConverter.ToInt32(BitConverter.GetBytes(k0).Reverse().ToArray(), 0);
+ return (UInt32) k1;
+ }
+
+ /*public static UInt16 checksum_by_sum(byte[] fw, uint start, uint end)
{
int s = 0;
uint valuescount = (end - start) / 2;
@@ -81,6 +88,21 @@ static class Class_RWD
if (s < 0) s += 0xFFFF;
}
return (UInt16) s;
+ }*/
+
+ private static UInt32 Get_rwd_checksum(byte[] data, uint start, uint end)
+ {
+ uint s = 0;
+ uint valuescount = (end - start);
+ for (int i = 0; i < valuescount; i++)
+ {
+ byte ThisValuee = data[start + i];
+ s += ThisValuee;
+
+ if (s > 0xFFFFFFFF) s -= 0xFFFFFFFF;
+ }
+ s = ToUInt32BE(BitConverter.GetBytes(s));
+ return (UInt32)s;
}
//######################################################################################################
@@ -93,8 +115,8 @@ static class Class_RWD
//Load .rwd file for obtaining 'encryption' method and then encrypt the .bin using the same method.
LoadRWD(f_nameFW, true, false);
- //Copy Start file bytes from the selected rwd file
- byte[] dataEncrypted = new byte[RWD_encrypted_StartFile.Length + data.Length];
+ //Copy Start file bytes from the selected rwd file, then add the dat aand checksum bytes
+ byte[] dataEncrypted = new byte[RWD_encrypted_StartFile.Length + data.Length + 4];
for (int i = 0; i < RWD_encrypted_StartFile.Length; i++) dataEncrypted[i] = RWD_encrypted_StartFile[i];
//Encrypt .bin data bytes to .rwd format
@@ -105,9 +127,21 @@ static class Class_RWD
}
//Fix Checksums
- //TODO HERE #######################################
- //UInt16 thisnn = Class_RWD.checksum_by_sum(dataEncrypted, (uint)RWD_encrypted_StartFile.Length, (uint)dataEncrypted.Length);
- //Console.WriteLine(thisnn.ToString("X4"));
+ UInt32 ChecksumValue = Get_rwd_checksum(dataEncrypted, 0, (uint)dataEncrypted.Length);
+ byte[] ChecksumBytes = BitConverter.GetBytes(ChecksumValue);
+ if (ChecksumBytes.Length == 4)
+ {
+ for (int i = 0; i < ChecksumBytes.Length; i++)
+ {
+ dataEncrypted[((dataEncrypted.Length - 1) - 4) + i] = ChecksumBytes[i];
+ }
+ GForm_Main_0.method_1("Checksum bytes fixed!");
+ }
+ else
+ {
+ GForm_Main_0.method_1("Checksum is not 4bytes long!");
+ }
+ //Console.WriteLine(Get_rwd_checksum(dataEncrypted, 0, (uint)dataEncrypted.Length).ToString("X8"));
//Save Encrypted rwd firmware
string ThisPath = Path.GetDirectoryName(f_name) + @"\" + Path.GetFileNameWithoutExtension(f_name) + ".rwd";
diff --git a/FlashToolTest.csproj b/FlashToolTest.csproj
index 7a2e1b0..03be4c5 100644
--- a/FlashToolTest.csproj
+++ b/FlashToolTest.csproj
@@ -76,6 +76,9 @@
+
+ Form
+
Form
@@ -100,6 +103,9 @@
+
+ GForm_Credits.cs
+
GForm_FWChkSum.cs
diff --git a/GForm_Credits.cs b/GForm_Credits.cs
new file mode 100644
index 0000000..2397813
--- /dev/null
+++ b/GForm_Credits.cs
@@ -0,0 +1,115 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using System.Windows.Forms;
+using DarkUI.Controls;
+using DarkUI.Forms;
+
+
+public class GForm_Credits : DarkForm
+{
+
+ public GForm_Credits()
+ {
+ this.InitializeComponent();
+ }
+
+ private void method_0(object sender, EventArgs e)
+ {
+ base.Close();
+ }
+
+ private void method_1(object sender, EventArgs e)
+ {
+
+ }
+
+ private void method_2(object sender, EventArgs e)
+ {
+ base.DialogResult = DialogResult.Abort;
+ base.Close();
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing && this.icontainer_0 != null)
+ {
+ this.icontainer_0.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ private void InitializeComponent()
+ {
+ this.darkButton_0 = new DarkUI.Controls.DarkButton();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+ this.SuspendLayout();
+ //
+ // darkButton_0
+ //
+ this.darkButton_0.Checked = false;
+ this.darkButton_0.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.darkButton_0.Location = new System.Drawing.Point(86, 139);
+ this.darkButton_0.Name = "darkButton_0";
+ this.darkButton_0.Size = new System.Drawing.Size(75, 23);
+ this.darkButton_0.TabIndex = 4;
+ this.darkButton_0.Text = "Accept";
+ this.darkButton_0.Click += new System.EventHandler(this.method_0);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.ForeColor = System.Drawing.SystemColors.ControlLight;
+ this.label1.Location = new System.Drawing.Point(59, 41);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(110, 65);
+ this.label1.TabIndex = 6;
+ this.label1.Text = "BMDevs (Bouletmarc)\r\nNii-Saan (Romraider)\r\nGreg Hogan\r\nKalisto2002\r\nDmitry";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label3.ForeColor = System.Drawing.SystemColors.ControlLight;
+ this.label3.Location = new System.Drawing.Point(6, 10);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(231, 20);
+ this.label3.TabIndex = 10;
+ this.label3.Text = "Credits from Honda community:";
+ this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+ //
+ // openFileDialog1
+ //
+ this.openFileDialog1.Title = "Select File";
+ //
+ // GForm_Credits
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(244, 172);
+ this.ControlBox = false;
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.darkButton_0);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "GForm_Credits";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Credits";
+ this.Load += new System.EventHandler(this.method_1);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ [CompilerGenerated]
+ private IContainer icontainer_0;
+ private DarkButton darkButton_0;
+ private Label label1;
+ private Label label3;
+ private OpenFileDialog openFileDialog1;
+}
diff --git a/GForm_Credits.resx b/GForm_Credits.resx
new file mode 100644
index 0000000..3a7d671
--- /dev/null
+++ b/GForm_Credits.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/GForm_Main.cs b/GForm_Main.cs
index a1fb2ca..76e84a2 100644
--- a/GForm_Main.cs
+++ b/GForm_Main.cs
@@ -1304,7 +1304,6 @@ public class GForm_Main : DarkForm
0x00 //0x00 -> Set later
};
arraySend1[2] = (byte) ((Addrr << 4) | Addrr);
- //if (memory_address >= Math.Pow(2 ^ Addrr * 8)) throw new Exception(string.Format("invalid memory_address: 0x{0}", memory_address.ToString("X4")));
if (memory_address >= Math.Pow(2, Addrr * 8)) throw new Exception(string.Format("invalid memory_address: 0x{0}", memory_address.ToString("X4")));
for (int i = 0; i < Addrr; i++)
{
@@ -1332,10 +1331,6 @@ public class GForm_Main : DarkForm
{
cnt += 1;
byte[] chunk = Class_RWD.Slice(Class_RWD._firmware_encrypted, i, i + chunk_size);
- //console.log(`${ cnt}: 0x${ i.toString(16)} -0x${ (i + chunk_size).toString(16)}`);
- //await this.client.transfer_data(cnt & 0xFF, chunk);
- // bitwise | converts float to int
- //postMessage({ command: 'flash-progress', result: (i / this.rwd.firmware.data.byteLength * 100) | 0 })
byte bsct = (byte) (cnt & 0xFF);
arraySend1 = new byte[]
@@ -1561,6 +1556,7 @@ public class GForm_Main : DarkForm
this.darkButton_DownloadROM = new DarkUI.Controls.DarkButton();
this.darkButton_0 = new DarkUI.Controls.DarkButton();
this.darkGroupBox_0 = new DarkUI.Controls.DarkGroupBox();
+ this.darkButton5 = new DarkUI.Controls.DarkButton();
this.darkButton_FlashFW = new DarkUI.Controls.DarkButton();
this.darkButton_Unlock01 = new DarkUI.Controls.DarkButton();
this.darkButton_Unlock41 = new DarkUI.Controls.DarkButton();
@@ -1586,7 +1582,6 @@ public class GForm_Main : DarkForm
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.DarkgroupBox1 = new DarkUI.Controls.DarkGroupBox();
this.darkButton4 = new DarkUI.Controls.DarkButton();
- this.darkButton5 = new DarkUI.Controls.DarkButton();
this.darkGroupBox_0.SuspendLayout();
this.DarkgroupBox1.SuspendLayout();
this.SuspendLayout();
@@ -1664,6 +1659,16 @@ public class GForm_Main : DarkForm
this.darkGroupBox_0.TabStop = false;
this.darkGroupBox_0.Text = "J2534 Controls";
//
+ // darkButton5
+ //
+ this.darkButton5.Checked = false;
+ this.darkButton5.Location = new System.Drawing.Point(6, 280);
+ this.darkButton5.Name = "darkButton5";
+ this.darkButton5.Size = new System.Drawing.Size(192, 23);
+ this.darkButton5.TabIndex = 69;
+ this.darkButton5.Text = "Open OBD2 Scan Tools";
+ this.darkButton5.Click += new System.EventHandler(this.darkButton5_Click);
+ //
// darkButton_FlashFW
//
this.darkButton_FlashFW.Checked = false;
@@ -1822,13 +1827,14 @@ public class GForm_Main : DarkForm
// darkLabel_4
//
this.darkLabel_4.AutoSize = true;
- this.darkLabel_4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F);
+ this.darkLabel_4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.darkLabel_4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
- this.darkLabel_4.Location = new System.Drawing.Point(404, 509);
+ this.darkLabel_4.Location = new System.Drawing.Point(596, 509);
this.darkLabel_4.Name = "darkLabel_4";
- this.darkLabel_4.Size = new System.Drawing.Size(272, 25);
+ this.darkLabel_4.Size = new System.Drawing.Size(80, 25);
this.darkLabel_4.TabIndex = 61;
- this.darkLabel_4.Text = "Copyright 2022 @ BMDevs";
+ this.darkLabel_4.Text = "Credits";
+ this.darkLabel_4.Click += new System.EventHandler(this.darkLabel_4_Click);
//
// darkLabel_5
//
@@ -1911,16 +1917,6 @@ public class GForm_Main : DarkForm
this.darkButton4.Text = "Fix Checksums";
this.darkButton4.Click += new System.EventHandler(this.darkButton4_Click);
//
- // darkButton5
- //
- this.darkButton5.Checked = false;
- this.darkButton5.Location = new System.Drawing.Point(6, 280);
- this.darkButton5.Name = "darkButton5";
- this.darkButton5.Size = new System.Drawing.Size(192, 23);
- this.darkButton5.TabIndex = 69;
- this.darkButton5.Text = "Open OBD2 Scan Tools";
- this.darkButton5.Click += new System.EventHandler(this.darkButton5_Click);
- //
// GForm_Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2355,4 +2351,10 @@ public class GForm_Main : DarkForm
frmOBD2Scan frmOBD2Scan_0 = new frmOBD2Scan();
frmOBD2Scan_0.Show();
}
+
+ private void darkLabel_4_Click(object sender, EventArgs e)
+ {
+ GForm_Credits GForm_Credits_0 = new GForm_Credits();
+ GForm_Credits_0.ShowDialog();
+ }
}
diff --git a/bin/Debug/FlashToolTest.exe b/bin/Debug/FlashToolTest.exe
index e9888f0..c438ccf 100644
Binary files a/bin/Debug/FlashToolTest.exe and b/bin/Debug/FlashToolTest.exe differ
diff --git a/bin/Debug/FlashToolTest.pdb b/bin/Debug/FlashToolTest.pdb
index 6c67151..3c755e1 100644
Binary files a/bin/Debug/FlashToolTest.pdb and b/bin/Debug/FlashToolTest.pdb differ
diff --git a/bin/Debug/FlashToolTest.zip b/bin/Debug/FlashToolTest.zip
index a644075..4bc8052 100644
Binary files a/bin/Debug/FlashToolTest.zip and b/bin/Debug/FlashToolTest.zip differ