2022-04-13 23:39:25 -07:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Diagnostics ;
using System.Drawing ;
using System.Globalization ;
using System.IO ;
using System.Linq ;
using System.Runtime.CompilerServices ;
using System.Text ;
using System.Windows.Forms ;
using DarkUI.Controls ;
using DarkUI.Forms ;
using SAE.J2534 ;
public class GForm_Main : DarkForm
{
2022-04-14 02:46:36 -07:00
bool ECU_Unlocked = false ;
private DarkButton darkButton_Unlock01 ;
2022-04-18 01:06:03 -07:00
private DarkButton darkButton2 ;
private OpenFileDialog openFileDialog1 ;
2022-04-14 02:46:36 -07:00
byte Unlocking_Mode = 0x41 ;
2022-05-07 17:39:50 -07:00
bool WritingBinaryMode = true ; //if false we are in writing firmware mode, this is set later anyway
2022-04-19 02:07:30 -07:00
private DarkButton darkButton_FlashFW ;
2022-04-24 16:05:27 -07:00
private GForm_Main GForm_Main_0 ;
2022-04-20 22:32:03 -07:00
private DarkGroupBox DarkgroupBox1 ;
private DarkButton darkButton4 ;
private DarkButton darkButton5 ;
2022-04-24 16:05:27 -07:00
private DarkButton darkButton6 ;
2022-04-19 02:07:30 -07:00
private DarkButton darkButton3 ;
2022-04-24 16:05:27 -07:00
public Editortable Editortable_0 ;
2022-05-07 17:39:50 -07:00
public string Version = "v1.1.2" ;
private DarkTextBox darkTextBoxJ2534Command ;
private DarkLabel darkLabel1 ;
private DarkButton darkButtonJ2534Command ;
public Class_DefinitionMaker Class_DefinitionMaker_0 ;
private bool BadResponceReceived = false ;
2022-04-14 02:46:36 -07:00
2022-04-13 23:39:25 -07:00
public GForm_Main ( )
{
this . InitializeComponent ( ) ;
this . darkTextBox_0 . Text = this . darkTextBox_0 . Text + Environment . NewLine ;
this . darkTextBox_0 . Text = this . darkTextBox_0 . Text + Environment . NewLine ;
this . darkTextBox_0 . Text = this . darkTextBox_0 . Text + Environment . NewLine ;
2022-04-18 01:06:03 -07:00
GForm_Main_0 = this ;
2022-04-24 16:05:27 -07:00
Editortable_0 = new Editortable ( ref GForm_Main_0 ) ;
2022-04-18 01:06:03 -07:00
Class_RWD . Load ( ref GForm_Main_0 ) ;
2022-04-27 04:52:09 -07:00
this . Text = this . Text + " (" + Version + ")" ;
2022-05-01 16:07:45 -07:00
2022-05-07 17:39:50 -07:00
Class_DefinitionMaker_0 = new Class_DefinitionMaker ( ref GForm_Main_0 ) ;
2022-04-13 23:39:25 -07:00
}
private void method_0 ( string string_3 )
{
if ( this . darkTextBox_0 . InvokeRequired )
{
GForm_Main . Delegate0 delegate_ = new GForm_Main . Delegate0 ( this . method_0 ) ;
this . method_22 ( delegate_ , new object [ ]
{
string_3
} ) ;
return ;
}
this . darkTextBox_0 . Text = string_3 ;
//Console.Write(string_3);
}
2022-04-18 01:06:03 -07:00
public void method_Log ( string string_3 )
{
this . darkTextBox_0 . Text + = string_3 ;
//Console.Write(string_3);
2022-05-07 17:39:50 -07:00
//Send to ROM Editor logs
Editortable_0 . method_Log ( string_3 ) ;
2022-04-18 01:06:03 -07:00
}
2022-04-13 23:39:25 -07:00
2022-04-18 01:06:03 -07:00
public void method_1 ( string string_3 )
2022-04-13 23:39:25 -07:00
{
2022-04-30 09:08:54 -07:00
try
{
//With newline automaticly added
Console . WriteLine ( string_3 ) ;
GForm_Main . Class5 @class = new GForm_Main . Class5 ( ) ;
@class . gform0_0 = this ;
@class . string_0 = string_3 ;
this . darkTextBox_0 . BeginInvoke ( new MethodInvoker ( @class . method_0 ) ) ;
2022-05-07 17:39:50 -07:00
//Send to ROM Editor logs
Editortable_0 . method_1 ( string_3 ) ;
2022-04-30 09:08:54 -07:00
}
catch { }
2022-04-13 23:39:25 -07:00
}
private void method_2 ( object sender , EventArgs e )
{
APIInfo [ ] apilist = APIFactory . GetAPIList ( ) ;
APIInfo apiinfo = apilist [ 0 ] ;
DarkTextBox darkTextBox = this . darkTextBox_0 ;
2022-04-20 22:32:03 -07:00
Console . WriteLine ( apiinfo . Name ) ;
Console . WriteLine ( "Filename:" + apiinfo . Filename ) ;
Console . WriteLine ( apiinfo . Details ) ;
2022-04-13 23:39:25 -07:00
darkTextBox . Text = darkTextBox . Text + apiinfo . Name + Environment . NewLine ;
darkTextBox . Text = darkTextBox . Text + "Filename:" + apiinfo . Filename + Environment . NewLine ;
darkTextBox . Text = darkTextBox . Text + apiinfo . Details + Environment . NewLine ;
}
private void method_3 ( object sender , EventArgs e )
{
GForm_J2534Select gform = new GForm_J2534Select ( ) ;
if ( gform . ShowDialog ( ) = = DialogResult . OK )
{
GForm_Main . string_0 = gform . APIInfo_0 . Filename ;
gform . Dispose ( ) ;
darkButton1 . Enabled = true ;
darkButton_4 . Enabled = true ;
darkButton_0 . Enabled = true ;
}
}
2022-05-07 17:39:50 -07:00
private void SetCommandText ( byte [ ] CommandArray )
{
try
{
darkTextBoxJ2534Command . Text = "" ;
for ( int i = 0 ; i < CommandArray . Length ; i + + )
{
darkTextBoxJ2534Command . Text = darkTextBoxJ2534Command . Text + CommandArray [ i ] . ToString ( "X2" ) ;
if ( i < CommandArray . Length - 1 ) darkTextBoxJ2534Command . Text = darkTextBoxJ2534Command . Text + "," ;
}
}
catch { }
}
2022-04-13 23:39:25 -07:00
private void darkButton1_Click ( object sender , EventArgs e )
{
2022-04-14 02:46:36 -07:00
ECU_Unlocked = false ;
this . darkButton_DownloadROM . Enabled = false ;
this . darkButton_Unlock41 . Enabled = false ;
this . darkButton_Unlock01 . Enabled = false ;
2022-04-19 02:07:30 -07:00
this . darkButton_FlashRom . Enabled = false ;
this . darkButton_FlashFW . Enabled = false ;
2022-05-07 17:39:50 -07:00
this . darkButtonJ2534Command . Enabled = false ;
2022-04-14 02:46:36 -07:00
2022-04-13 23:39:25 -07:00
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
{
try
{
2022-05-07 17:39:50 -07:00
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . CAN_29BIT_ID , false ) )
{
LoadJ2534Channel ( channel ) ;
2022-04-18 01:06:03 -07:00
int num2 = 0 ;
byte [ ] arraySend1 = new byte [ ]
2022-04-13 23:39:25 -07:00
{
34 , //0x22 -> Read Data by ID (F190)
241 , //0xF1
144 //0x90
} ;
2022-05-07 17:39:50 -07:00
byte [ ] Received = SendJ2534Message ( channel , arraySend1 , 5 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
int num4 = GForm_Main . smethod_0 ( Received , byte_1 ) ;
if ( num4 ! = - 1 )
2022-04-13 23:39:25 -07:00
{
2022-04-18 01:06:03 -07:00
byte [ ] bytes = new byte [ 0x10 ] ;
Array . Copy ( Received , 8 , bytes , 0 , 0x10 ) ;
this . darkTextBox_1 . Text = Encoding . ASCII . GetString ( bytes ) ; //Display VIN number
2022-04-20 22:32:03 -07:00
this . method_1 ( "VIN:" + Encoding . ASCII . GetString ( bytes ) ) ;
2022-04-18 01:06:03 -07:00
num2 = 1 ;
}
//#############################################################
//#############################################################
arraySend1 = new byte [ ]
{
34 , //0x22 -> Read Data by ID (F181)
241 , //0xF1
129 //0x81
2022-04-13 23:39:25 -07:00
} ;
2022-05-07 17:39:50 -07:00
Received = SendJ2534Message ( channel , arraySend1 , 5 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
int num6 = GForm_Main . smethod_0 ( Received , byte_0 ) ;
if ( num6 ! = - 1 )
{
byte [ ] bytes = new byte [ 0x10 ] ;
Array . Copy ( Received , 7 , bytes , 0 , 0x10 ) ;
this . darkTextBox_2 . Text = Encoding . ASCII . GetString ( bytes ) ; //Display CAL_ID Number
2022-04-20 22:32:03 -07:00
this . method_1 ( "ID:" + Encoding . ASCII . GetString ( bytes ) ) ;
this . method_1 ( "Vehicle is Online" ) ;
2022-04-18 01:06:03 -07:00
num2 = 2 ;
}
2022-04-13 23:39:25 -07:00
//#############################################################
2022-04-18 01:06:03 -07:00
if ( num2 = = 1 )
2022-04-13 23:39:25 -07:00
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Vehicle is in recovery mode?" ) ;
2022-04-18 01:06:03 -07:00
DarkMessageBox . Show ( this , "Failed to retrieve vin number, assuming recovery mode, read disabled" , "RECOVERY MODE" , MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
}
else if ( num2 ! = 2 )
{
DarkMessageBox . Show ( this , "ECU was not detected.\n\rMake sure you have selected the correct platform and the vehicle is on and your device is plugged in.\n\rProvided you have checked these things. Please send a message to the discord group or the page with your vehicle \n\rDomestic Market, Make, Model,Year,Transmission, and Device you are using to Connect." , "Failed to detect Ecu" , MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
}
else
{
this . darkButton_Unlock41 . Enabled = true ;
this . darkButton_Unlock01 . Enabled = true ;
2022-05-07 17:39:50 -07:00
this . darkButtonJ2534Command . Enabled = true ;
2022-04-13 23:39:25 -07:00
}
2022-05-07 17:39:50 -07:00
}
}
2022-04-13 23:39:25 -07:00
}
catch ( Exception ex )
{
DarkMessageBox . Show ( this , ex . Message ) ;
}
}
return ;
}
public void method_4 ( int int_0 )
{
this . darkProgressBar_0 . Value = int_0 ;
this . darkLabel_7 . Text = "Reading: " + int_0 . ToString ( ) + "%" ;
2022-04-18 12:39:55 -07:00
Application . DoEvents ( ) ;
2022-04-13 23:39:25 -07:00
}
public void method_5 ( int int_0 )
{
this . darkProgressBar_0 . Value = int_0 ;
this . darkLabel_7 . Text = "Writing: " + int_0 . ToString ( ) + "%" ;
2022-04-18 12:39:55 -07:00
Application . DoEvents ( ) ;
2022-04-13 23:39:25 -07:00
}
2022-04-19 02:07:30 -07:00
public void ResetProgressBar ( )
{
this . darkProgressBar_0 . Value = 0 ;
this . darkLabel_7 . Text = "Status" ;
Application . DoEvents ( ) ;
}
2022-04-13 23:39:25 -07:00
private void method_6 ( object sender , ProgressChangedEventArgs e )
{
string text = e . UserState as string ;
this . darkLabel_8 . Text = text ;
this . method_4 ( e . ProgressPercentage ) ;
}
2022-04-14 02:46:36 -07:00
private void method_7_Nothing ( object sender , RunWorkerCompletedEventArgs e )
{
2022-05-07 17:39:50 -07:00
if ( ! ECU_Unlocked )
{
2022-04-14 02:46:36 -07:00
2022-05-07 17:39:50 -07:00
ECU_Unlocked = false ;
this . darkButton_DownloadROM . Enabled = false ;
this . darkButton_FlashRom . Enabled = false ;
this . darkButton_FlashFW . Enabled = false ;
DarkMessageBox . Show ( "Failed to Unlock ECU, Check Log" ) ;
}
if ( ECU_Unlocked )
{
if ( Unlocking_Mode = = 0x41 )
{
//Unlock ALL buttons (Read&Writes) for 0x27,0x41 Unlock
this . darkButton_DownloadROM . Enabled = true ;
this . darkButton_FlashRom . Enabled = true ;
this . darkButton_FlashFW . Enabled = true ;
}
else
{
//Unlock FlashFW button (Write FW ONLY) for 0x27,0x01 Unlock
this . darkButton_FlashFW . Enabled = true ;
}
}
2022-04-14 02:46:36 -07:00
}
2022-04-13 23:39:25 -07:00
private void method_7 ( object sender , RunWorkerCompletedEventArgs e )
{
if ( this . byte_7 ! = null )
{
this . method_8 ( this . byte_7 ) ;
}
}
private void method_8 ( byte [ ] byte_12 )
{
SaveFileDialog saveFileDialog = new SaveFileDialog ( ) ;
saveFileDialog . RestoreDirectory = true ;
saveFileDialog . Filter = "Honda Rom Dump|*.Bin" ;
saveFileDialog . FileName = this . darkTextBox_2 . Text ;
if ( saveFileDialog . ShowDialog ( ) ! = DialogResult . OK )
{
return ;
}
File . WriteAllBytes ( saveFileDialog . FileName , byte_12 ) ;
2022-04-20 22:32:03 -07:00
this . method_1 ( "File saved: " + saveFileDialog . FileName ) ;
2022-04-13 23:39:25 -07:00
DarkMessageBox . Show ( this , "Successfully Saved File!" , "Success" , MessageBoxButtons . OK , MessageBoxIcon . Asterisk ) ;
2022-04-14 02:46:36 -07:00
this . darkButton_DownloadROM . Enabled = false ;
this . darkButton_Unlock41 . Enabled = false ;
this . darkButton_Unlock01 . Enabled = false ;
2022-04-19 02:07:30 -07:00
this . darkButton_FlashRom . Enabled = false ;
this . darkButton_FlashFW . Enabled = false ;
2022-04-13 23:39:25 -07:00
}
private void darkButton2_Click ( object sender , EventArgs e )
{
2022-04-14 02:46:36 -07:00
if ( GForm_Main . string_0 . Length = = 0 )
{
GForm_J2534Select gform = new GForm_J2534Select ( ) ;
if ( gform . ShowDialog ( ) ! = DialogResult . OK )
{
this . darkTextBox_0 . Text = "Couldn't open device selection form" ;
return ;
}
GForm_Main . string_0 = gform . APIInfo_0 . Filename ;
gform . Dispose ( ) ;
}
2022-04-13 23:39:25 -07:00
2022-04-14 02:46:36 -07:00
this . Unlocking_Mode = 0x41 ;
this . backgroundWorker_1 = new BackgroundWorker ( ) ;
this . backgroundWorker_1 . WorkerReportsProgress = true ;
this . backgroundWorker_1 . DoWork + = this . method_UnlockECU ;
this . backgroundWorker_1 . ProgressChanged + = this . method_6 ;
this . backgroundWorker_1 . RunWorkerCompleted + = this . method_7_Nothing ;
this . backgroundWorker_1 . RunWorkerAsync ( ) ;
2022-04-13 23:39:25 -07:00
}
2022-04-14 02:46:36 -07:00
private void darkButton_Unlock01_Click ( object sender , EventArgs e )
2022-04-13 23:39:25 -07:00
{
2022-04-14 02:46:36 -07:00
if ( GForm_Main . string_0 . Length = = 0 )
{
GForm_J2534Select gform = new GForm_J2534Select ( ) ;
if ( gform . ShowDialog ( ) ! = DialogResult . OK )
{
this . darkTextBox_0 . Text = "Couldn't open device selection form" ;
return ;
}
GForm_Main . string_0 = gform . APIInfo_0 . Filename ;
gform . Dispose ( ) ;
}
this . Unlocking_Mode = 0x01 ;
this . backgroundWorker_1 = new BackgroundWorker ( ) ;
this . backgroundWorker_1 . WorkerReportsProgress = true ;
this . backgroundWorker_1 . DoWork + = this . method_UnlockECU ;
this . backgroundWorker_1 . ProgressChanged + = this . method_6 ;
this . backgroundWorker_1 . RunWorkerCompleted + = this . method_7_Nothing ;
this . backgroundWorker_1 . RunWorkerAsync ( ) ;
}
public void method_UnlockECU ( object sender , DoWorkEventArgs e )
{
ECU_Unlocked = false ;
2022-05-07 17:39:50 -07:00
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
{
try
{
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . CAN_29BIT_ID , false ) )
2022-04-13 23:39:25 -07:00
{
2022-05-07 17:39:50 -07:00
LoadJ2534Channel ( channel ) ;
2022-04-18 01:06:03 -07:00
2022-05-07 17:39:50 -07:00
device . SetProgrammingVoltage ( Pin . PIN_12 , 5000 ) ;
2022-04-18 01:06:03 -07:00
2022-05-07 17:39:50 -07:00
byte [ ] arraySend1 = new byte [ ]
2022-04-13 23:39:25 -07:00
{
2022-05-07 17:39:50 -07:00
16 , //0x10
3 //0x03 Not supposed to be 02 or FB?? ##########################################
} ;
byte [ ] Received = SendJ2534Message ( channel , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
2022-05-07 17:39:50 -07:00
if ( Received ! = null )
{
this . method_1 ( "Diag Mode Set" ) ;
2022-04-13 23:39:25 -07:00
}
2022-05-07 17:39:50 -07:00
//################################################################
2022-04-18 01:06:03 -07:00
arraySend1 = new byte [ ]
2022-04-13 23:39:25 -07:00
{
39 , //0x27
2022-05-07 17:39:50 -07:00
65 //0x41 Not supposed to be 05?? -> could be 0x01 0x03 0x05 0x07 or 0x41
2022-04-13 23:39:25 -07:00
} ;
2022-05-07 17:39:50 -07:00
byte SeedSendByte = this . Unlocking_Mode ;
arraySend1 [ 1 ] = SeedSendByte ;
this . method_1 ( "Requesting Seed" ) ;
Received = SendJ2534Message ( channel , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
byte [ ] byte_ = new byte [ ]
2022-04-13 23:39:25 -07:00
{
103 , //0x67
2022-05-07 17:39:50 -07:00
65 //0x41
2022-04-13 23:39:25 -07:00
} ;
2022-05-07 17:39:50 -07:00
byte_ [ 1 ] = SeedSendByte ;
byte [ ] array6 = new byte [ 4 ] ;
bool TwoBytesMode = false ;
byte b = 1 ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
2022-04-13 23:39:25 -07:00
{
2022-05-07 17:39:50 -07:00
int num = GForm_Main . smethod_2 ( Received , byte_ , 0 ) ;
2022-04-18 01:06:03 -07:00
if ( num > 0 )
2022-04-13 23:39:25 -07:00
{
2022-05-07 17:39:50 -07:00
if ( Received . Length < 10 )
2022-04-19 02:07:30 -07:00
{
2022-05-07 17:39:50 -07:00
array6 = new byte [ 2 ] ;
TwoBytesMode = true ;
2022-04-19 02:07:30 -07:00
}
2022-05-07 17:39:50 -07:00
int index = 0 ;
while ( true )
2022-04-19 02:07:30 -07:00
{
2022-05-07 17:39:50 -07:00
if ( ( ! TwoBytesMode & & index > = 4 ) | | ( TwoBytesMode & & index > = 2 ) )
{
if ( ! TwoBytesMode )
{
b = Received [ ( index + num ) + 2 ] ;
Array . Reverse ( array6 ) ;
}
this . method_1 ( "Security Request - Seed Bytes:" + GForm_Main . smethod_1 ( array6 ) ) ;
if ( ! TwoBytesMode ) this . method_1 ( "Security Request - Algorithm:" + b . ToString ( "X2" ) ) ;
break ;
}
array6 [ index ] = Received [ ( index + num ) + 2 ] ;
index + + ;
2022-04-19 02:07:30 -07:00
}
2022-04-13 23:39:25 -07:00
}
2022-05-07 17:39:50 -07:00
}
if ( array6 [ 0 ] ! = 0 )
{
uint value = 0 ;
if ( ! TwoBytesMode ) value = Class_Cypher . GetKey41 ( BitConverter . ToUInt32 ( array6 , 0 ) , b ) ;
else value = Class_Cypher . GetKey01 ( array6 , darkTextBox_2 . Text ) ;
byte [ ] bytes = BitConverter . GetBytes ( value ) ;
this . method_1 ( "Security Request - Key to Send:" + GForm_Main . smethod_1 ( bytes ) ) ;
arraySend1 = new byte [ ]
{
39 , //0x27
66 //0x42
} ;
arraySend1 [ 1 ] = ( byte ) ( SeedSendByte + 1 ) ;
byte [ ] array8 = new byte [ arraySend1 . Length + 5 ] ;
if ( TwoBytesMode ) array8 = new byte [ arraySend1 . Length + 2 ] ;
for ( int i = 0 ; i < arraySend1 . Length ; i + + ) array8 [ i ] = arraySend1 [ i ] ;
array8 [ 2 ] = bytes [ 0 ] ; //SecurityKey Byte1
array8 [ 3 ] = bytes [ 1 ] ; //SecurityKey Byte2
if ( ! TwoBytesMode )
{
array8 [ 2 ] = bytes [ 2 ] ; //SecurityKey Byte3
array8 [ 3 ] = bytes [ 3 ] ; //SecurityKey Byte4
array8 [ 4 ] = b ; //Algorithm Byte
}
byte [ ] byte_2 = new byte [ ]
2022-04-13 23:39:25 -07:00
{
2022-05-07 17:39:50 -07:00
103 , //0x67
66 //0x42
} ;
byte_2 [ 1 ] = ( byte ) ( SeedSendByte + 1 ) ;
Received = SendJ2534Message ( channel , array8 , 3 ) ;
if ( BadResponceReceived ) return ;
if ( Received ! = null )
{
int num = GForm_Main . smethod_2 ( Received , byte_2 , 0 ) ; //looking for 0x67, 0x42
if ( num > 0 )
{
this . method_1 ( "Security Authorized: ECU Unlocked" ) ;
ECU_Unlocked = true ;
}
else
{
this . method_1 ( "Recv:" + GForm_Main . smethod_1 ( Received ) ) ;
ECU_Unlocked = false ;
}
2022-04-13 23:39:25 -07:00
}
2022-04-14 02:46:36 -07:00
}
2022-05-07 17:39:50 -07:00
else
{
this . method_1 ( "Result NOT OK!!" ) ;
}
2022-04-14 02:46:36 -07:00
}
2022-05-07 17:39:50 -07:00
}
}
catch ( Exception ex )
{
DarkMessageBox . Show ( ex . Message ) ;
}
}
2022-04-14 02:46:36 -07:00
}
2022-05-07 17:39:50 -07:00
public byte [ ] SendJ2534Message ( Channel channel , byte [ ] MessageBytes , int receivelenght )
2022-04-18 01:06:03 -07:00
{
2022-05-07 17:39:50 -07:00
BadResponceReceived = false ;
2022-04-18 01:06:03 -07:00
byte [ ] arrayCommand = new byte [ ]
{
24 , //0x18
218 , //0xDA
GForm_Main . byte_3 , //0x00 -> 0x10|0x11
241 //0xF1
} ;
2022-05-07 17:39:50 -07:00
SetCommandText ( MessageBytes ) ;
2022-04-18 01:06:03 -07:00
//Add the rest of the messages bytes to the final array
byte [ ] arrayCommandFinal = new byte [ arrayCommand . Length + MessageBytes . Length ] ;
int MessageIndex = 0 ;
for ( int i = 0 ; i < arrayCommand . Length ; i + + )
{
arrayCommandFinal [ MessageIndex ] = arrayCommand [ i ] ;
MessageIndex + + ;
}
for ( int i = 0 ; i < MessageBytes . Length ; i + + )
{
arrayCommandFinal [ MessageIndex ] = MessageBytes [ i ] ;
MessageIndex + + ;
}
//Send message
2022-05-07 17:39:50 -07:00
SAE . J2534 . Message messageCommands = new SAE . J2534 . Message ( arrayCommandFinal , TxFlag . CAN_29BIT_ID | TxFlag . ISO15765_FRAME_PAD ) ;
2022-04-18 01:06:03 -07:00
channel . SendMessage ( messageCommands ) ;
2022-04-20 22:32:03 -07:00
this . method_1 ( "Send:" + GForm_Main . smethod_1 ( messageCommands . Data ) ) ;
2022-04-18 01:06:03 -07:00
//Receive message
2022-05-07 17:39:50 -07:00
GetMessageResults messagesReceived = channel . GetMessages ( receivelenght , 1000 ) ;
2022-04-18 01:06:03 -07:00
if ( messagesReceived . Result . IsOK ( ) )
{
2022-04-20 22:32:03 -07:00
//this.method_1("Programming Mode Set!");
2022-04-18 01:06:03 -07:00
int IndexReceived = 1 ;
foreach ( SAE . J2534 . Message message3 in messagesReceived . Messages )
{
//Gather Negative Responce
int num2 = GForm_Main . smethod_2 ( message3 . Data , this . byte_5 , 0 ) ; //looking for 0x11, 0x7F
if ( num2 > 0 )
{
for ( int k = 0 ; k < 2 ; k + + )
{
this . byte_6 [ k ] = message3 . Data [ k + num2 + 2 ] ; //0x27, 0x35
}
Class_ODB . Mode mode = ( Class_ODB . Mode ) this . byte_6 [ 0 ] ;
string str2 = mode . ToString ( ) ;
Class_ODB . NegativeResponse negativeResponse = ( Class_ODB . NegativeResponse ) this . byte_6 [ 1 ] ;
2022-04-20 22:32:03 -07:00
this . method_1 ( "BAD Response: " + str2 + "|" + negativeResponse . ToString ( ) ) ;
2022-05-07 17:39:50 -07:00
BadResponceReceived = true ;
2022-04-18 01:06:03 -07:00
}
2022-05-07 17:39:50 -07:00
if ( IndexReceived > = receivelenght )
2022-04-18 01:06:03 -07:00
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Recv:" + GForm_Main . smethod_1 ( message3 . Data ) ) ;
2022-04-18 01:06:03 -07:00
return message3 . Data ; //after 3messages received, return the last messages bytes
}
IndexReceived + + ;
}
}
else
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Result NOT OK!!" ) ;
2022-05-07 17:39:50 -07:00
BadResponceReceived = true ;
2022-04-18 01:06:03 -07:00
}
return null ;
}
2022-04-14 02:46:36 -07:00
public void method_ReadROM ( object sender , DoWorkEventArgs e )
{
2022-05-07 17:39:50 -07:00
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
{
2022-04-14 02:46:36 -07:00
try
{
2022-05-07 17:39:50 -07:00
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . CAN_29BIT_ID , false ) )
{
LoadJ2534Channel ( channel ) ;
2022-04-14 02:46:36 -07:00
device . SetProgrammingVoltage ( Pin . PIN_12 , 5000 ) ;
2022-04-13 23:39:25 -07:00
2022-04-14 02:46:36 -07:00
if ( ! ECU_Unlocked )
{
MessageBox . Show ( "ECU is NOT Unlocked!" ) ;
}
else
{
2022-04-13 23:39:25 -07:00
Stopwatch stopwatch = new Stopwatch ( ) ;
stopwatch . Start ( ) ;
2022-04-14 02:46:36 -07:00
this . byte_7 = this . method_10 ( channel , this . backgroundWorker_1 ) ;
2022-04-13 23:39:25 -07:00
stopwatch . Stop ( ) ;
TimeSpan timeSpan = TimeSpan . FromMilliseconds ( ( double ) stopwatch . ElapsedMilliseconds ) ;
2022-04-14 02:46:36 -07:00
this . backgroundWorker_1 . ReportProgress ( 0 , "Successfully read " + this . byte_7 . Length + "bytes of flash memory in " + timeSpan . Minutes + ":" + timeSpan . Seconds ) ;
2022-04-13 23:39:25 -07:00
device . SetProgrammingVoltage ( Pin . PIN_12 , - 1 ) ;
}
2022-05-07 17:39:50 -07:00
}
}
2022-04-13 23:39:25 -07:00
}
2022-04-14 02:46:36 -07:00
catch ( Exception ex )
{
2022-05-07 17:39:50 -07:00
DarkMessageBox . Show ( ex . Message ) ;
2022-04-14 02:46:36 -07:00
}
2022-05-07 17:39:50 -07:00
}
2022-04-13 23:39:25 -07:00
}
public static int smethod_0 ( byte [ ] byte_12 , byte [ ] byte_13 )
{
2022-05-07 17:39:50 -07:00
if ( byte_12 = = null ) return - 1 ;
2022-04-13 23:39:25 -07:00
if ( byte_13 . Length > byte_12 . Length )
{
return - 1 ;
}
for ( int i = 0 ; i < byte_12 . Length - byte_13 . Length ; i + + )
{
bool flag = true ;
for ( int j = 0 ; j < byte_13 . Length ; j + + )
{
if ( byte_12 [ i + j ] ! = byte_13 [ j ] )
{
flag = false ;
break ;
}
}
if ( flag )
{
return i ;
}
}
return - 1 ;
}
public static string smethod_1 ( byte [ ] byte_12 )
{
StringBuilder stringBuilder = new StringBuilder ( byte_12 . Length * 2 ) ;
foreach ( byte b in byte_12 )
{
stringBuilder . Append ( "0x" ) ;
stringBuilder . AppendFormat ( "{0:X2} " , b ) ;
}
return stringBuilder . ToString ( ) ;
}
private static int smethod_2 ( byte [ ] byte_12 , byte [ ] byte_13 , int int_0 = 0 )
{
int num = byte_12 . Length - byte_13 . Length ;
byte b = byte_13 [ 0 ] ; //0x67 || 0x11
while ( int_0 < = num )
{
if ( byte_12 [ int_0 ] = = b )
{
for ( int num2 = 1 ; num2 ! = byte_13 . Length ; num2 + + )
{
if ( byte_12 [ int_0 + num2 ] ! = byte_13 [ num2 ] ) //0x42 || 0x7F
{
goto IL_32 ;
}
}
return int_0 ;
}
IL_32 :
int_0 + + ;
}
return - 1 ;
}
public byte [ ] method_10 ( Channel channel_0 , BackgroundWorker backgroundWorker_1 = null )
{
GForm_Main . Class6 @class = new GForm_Main . Class6 ( ) ;
@class . gform0_0 = this ;
@class . byte_0 = new byte [ 1 ] ;
DateTime now = DateTime . Now ;
@class . uint_0 = 4 U ;
this . darkTextBox_0 . BeginInvoke ( new MethodInvoker ( @class . method_0 ) ) ;
GForm_Main . Class7 class2 = new GForm_Main . Class7 ( ) ;
class2 . class6_0 = @class ;
class2 . uint_0 = 0 U ;
while ( ( ulong ) class2 . uint_0 < = ( ulong ) ( ( long ) GForm_Main . class9_0 . ReadingSize ) )
{
Application . DoEvents ( ) ;
TimeSpan timeSpan = TimeSpan . FromTicks ( DateTime . Now . Subtract ( now ) . Ticks * ( ( long ) GForm_Main . class9_0 . ReadingSize - ( long ) ( ( ulong ) ( class2 . uint_0 + 1 U ) ) ) / ( long ) ( ( ulong ) ( class2 . uint_0 + 1 U ) ) ) ;
this . method_12 ( class2 . uint_0 , class2 . class6_0 . uint_0 , out class2 . class6_0 . byte_0 , channel_0 ) ;
//string userState = "Time Remaining:" + string.Format("{0:mm:ss}", timeSpan);
string userState = "Time Remaining:" + string . Format ( "{0:mm\\:ss}" , timeSpan ) ;
this . method_11 ( ( long ) ( ( ulong ) class2 . uint_0 ) ) ;
if ( ( long ) class2 . class6_0 . byte_0 . Length ! = ( long ) ( ( ulong ) class2 . class6_0 . uint_0 ) )
{
Control control = this . darkTextBox_0 ;
MethodInvoker method ;
if ( ( method = class2 . class6_0 . methodInvoker_0 ) = = null )
{
method = ( class2 . class6_0 . methodInvoker_0 = new MethodInvoker ( class2 . class6_0 . method_1 ) ) ;
}
control . BeginInvoke ( method ) ;
}
try
{
Buffer . BlockCopy ( class2 . class6_0 . byte_0 , 0 , this . byte_7 , ( int ) class2 . uint_0 , class2 . class6_0 . byte_0 . Length ) ;
goto IL_213 ;
}
catch
{
this . darkTextBox_0 . BeginInvoke ( new MethodInvoker ( class2 . method_0 ) ) ;
goto IL_213 ;
}
goto IL_1B4 ;
IL_1CD :
if ( backgroundWorker_1 ! = null )
{
backgroundWorker_1 . ReportProgress ( ( int ) ( class2 . uint_0 / ( float ) GForm_Main . class9_0 . ReadingSize * 100f ) , userState ) ;
}
class2 . uint_0 + = class2 . class6_0 . uint_0 ;
continue ;
IL_1B4 :
this . darkTextBox_0 . BeginInvoke ( new MethodInvoker ( class2 . method_1 ) ) ;
goto IL_1CD ;
IL_213 :
if ( class2 . uint_0 % 256 U = = 0 U )
{
goto IL_1B4 ;
}
goto IL_1CD ;
}
return this . byte_7 ;
}
private void method_11 ( long long_1 )
{
GForm_Main . Class8 @class = new GForm_Main . Class8 ( ) ;
@class . gform0_0 = this ;
if ( this . long_0 ! = 0L )
{
DateTime now = DateTime . Now ;
TimeSpan timeSpan = now - this . dateTime_0 ;
long num = long_1 - this . long_0 ;
@class . double_0 = ( double ) num / timeSpan . TotalSeconds ;
this . long_0 = long_1 ;
this . dateTime_0 = now ;
this . darkLabel_5 . BeginInvoke ( new MethodInvoker ( @class . method_0 ) ) ;
return ;
}
this . dateTime_0 = DateTime . Now ;
this . long_0 = long_1 ;
}
public void method_12 ( uint uint_0 , uint uint_1 , out byte [ ] byte_12 , Channel channel_0 )
{
byte_12 = new byte [ 1 ] ;
2022-04-18 01:06:03 -07:00
byte [ ] arraySend1 = new byte [ ]
2022-04-13 23:39:25 -07:00
{
35 , //0x23 -> Read_data_by_address
20 , //0x14
( byte ) ( ( uint_0 > > 0x18 ) & 0xff ) ,
( byte ) ( ( uint_0 > > 0x10 ) & 0xff ) ,
( byte ) ( ( uint_0 > > 8 ) & 0xff ) ,
( byte ) ( uint_0 & 0xff ) ,
4
2022-04-18 01:06:03 -07:00
} ;
2022-04-13 23:39:25 -07:00
byte [ ] byte_13 = new byte [ ]
{
GForm_Main . byte_3 ,
99
} ;
2022-04-18 01:06:03 -07:00
2022-05-07 17:39:50 -07:00
byte [ ] Received = SendJ2534Message ( channel_0 , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
2022-04-13 23:39:25 -07:00
{
2022-04-18 01:06:03 -07:00
//if (messages.Result != ResultCode.DEVICE_NOT_CONNECTED)
//{
int num = GForm_Main . smethod_2 ( Received , byte_13 , 0 ) ;
if ( num > 0 )
2022-04-13 23:39:25 -07:00
{
2022-04-18 01:06:03 -07:00
num + = 2 ;
Array . Resize < byte > ( ref byte_12 , Received . Length - num ) ;
Array . Copy ( Received , num , byte_12 , 0 , Received . Length - num ) ;
2022-04-13 23:39:25 -07:00
}
}
}
private void method_13 ( object sender , EventArgs e )
{
if ( GForm_Main . string_0 . Length = = 0 )
{
GForm_J2534Select gform = new GForm_J2534Select ( ) ;
if ( gform . ShowDialog ( ) ! = DialogResult . OK )
{
this . darkTextBox_0 . Text = "Couldn't open device selection form" ;
return ;
}
GForm_Main . string_0 = gform . APIInfo_0 . Filename ;
gform . Dispose ( ) ;
}
this . backgroundWorker_0 = new BackgroundWorker ( ) ;
this . backgroundWorker_0 . WorkerReportsProgress = true ;
2022-04-14 02:46:36 -07:00
this . backgroundWorker_0 . DoWork + = this . method_ReadROM ;
2022-04-13 23:39:25 -07:00
this . backgroundWorker_0 . ProgressChanged + = this . method_6 ;
this . backgroundWorker_0 . RunWorkerCompleted + = this . method_7 ;
this . backgroundWorker_0 . RunWorkerAsync ( ) ;
}
private void method_14 ( object sender , EventArgs e )
{
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
{
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . CAN_29BIT_ID , false ) )
{
MessageFilter messageFilter = new MessageFilter ( ) ;
messageFilter . FilterType = Filter . FLOW_CONTROL_FILTER ;
messageFilter . Mask = new byte [ ]
{
byte . MaxValue ,
byte . MaxValue ,
byte . MaxValue ,
byte . MaxValue
} ;
messageFilter . Pattern = new byte [ ]
{
0 ,
0 ,
126 ,
8
} ;
MessageFilter messageFilter2 = messageFilter ;
byte [ ] array = new byte [ 4 ] ;
array [ 2 ] = 126 ;
messageFilter2 . FlowControl = array ;
MessageFilter filter = messageFilter ;
channel . StartMsgFilter ( filter ) ;
SConfig [ ] config = new SConfig [ ]
{
new SConfig ( Parameter . LOOP_BACK , 1 ) ,
new SConfig ( Parameter . DATA_RATE , 500000 )
} ;
channel . SetConfig ( config ) ;
Stopwatch stopwatch = new Stopwatch ( ) ;
stopwatch . Start ( ) ;
2022-04-14 02:46:36 -07:00
this . byte_7 = this . method_15 ( channel , this . backgroundWorker_1 ) ;
2022-04-13 23:39:25 -07:00
stopwatch . Stop ( ) ;
TimeSpan . FromMilliseconds ( ( double ) stopwatch . ElapsedMilliseconds ) ;
DarkTextBox darkTextBox = this . darkTextBox_0 ;
darkTextBox . Text = darkTextBox . Text + GForm_Main . smethod_1 ( this . byte_7 ) + Environment . NewLine ;
}
}
}
}
public byte [ ] method_15 ( Channel channel_0 , BackgroundWorker backgroundWorker_1 = null )
{
byte [ ] array = new byte [ 4 ] ;
byte [ ] array2 = new byte [ 1 ] ;
uint num = uint . Parse ( this . darkTextBox_4 . Text ) ;
uint uint_ = uint . Parse ( this . darkTextBox_3 . Text , NumberStyles . HexNumber ) ;
this . method_12 ( uint_ , num , out array2 , channel_0 ) ;
if ( ( long ) array2 . Length = = ( long ) ( ( ulong ) num ) )
{
Buffer . BlockCopy ( array2 , 0 , array , 0 , array2 . Length ) ;
}
return array ;
}
private void method_16 ( object sender , EventArgs e )
{
if ( GForm_Main . string_0 = = string . Empty )
{
GForm_J2534Select gform = new GForm_J2534Select ( ) ;
if ( gform . ShowDialog ( ) ! = DialogResult . OK )
{
this . darkTextBox_0 . Text = "Couldn't open device selection form" ;
return ;
}
GForm_Main . string_0 = gform . APIInfo_0 . Filename ;
gform . Dispose ( ) ;
}
try
{
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
{
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . SNIFF_MODE , false ) )
{
List < byte [ ] > list = new List < byte [ ] > ( ) ;
GetMessageResults messages = channel . GetMessages ( 10000 ) ;
if ( messages . Result ! = ResultCode . DEVICE_NOT_CONNECTED )
{
foreach ( SAE . J2534 . Message message in messages . Messages )
{
list . Add ( message . Data ) ;
}
}
if ( list . Count < byte [ ] > ( ) > 0 )
{
for ( int j = 0 ; j < list . Count < byte [ ] > ( ) ; j + + )
{
this . darkTextBox_0 . AppendText ( string . Format ( "message[{0}]: " , j ) + GForm_Main . smethod_1 ( list [ j ] ) + Environment . NewLine ) ;
}
}
}
}
}
}
catch
{
}
}
2022-04-20 22:32:03 -07:00
public byte GetNegativeChecksumFullBin ( byte [ ] byte_1 )
2022-04-14 02:46:36 -07:00
{
byte b = 0 ;
for ( int i = 0 ; i < byte_1 . Length ; i + + )
{
2022-04-20 22:32:03 -07:00
if ( i ! = 0x8400 )
2022-04-14 02:46:36 -07:00
{
b - = byte_1 [ i ] ;
}
}
2022-04-20 22:32:03 -07:00
return b ;
2022-04-14 02:46:36 -07:00
}
2022-04-20 22:32:03 -07:00
public byte GetNegativeChecksumArea ( byte [ ] byte_1 , int Start , int ChecksumLocation )
2022-04-18 01:06:03 -07:00
{
byte b = 0 ;
2022-04-20 22:32:03 -07:00
for ( int i = Start ; i < byte_1 . Length ; i + + )
2022-04-18 01:06:03 -07:00
{
2022-04-20 22:32:03 -07:00
if ( i ! = ChecksumLocation )
2022-04-18 01:06:03 -07:00
{
b - = byte_1 [ i ] ;
}
}
2022-04-20 22:32:03 -07:00
return b ;
}
public byte [ ] VerifyChecksumFullBin ( byte [ ] BinFileBytes )
{
//###############################
//Get Checksum and Fix it for 0x8400
byte [ ] BufferBytes = BinFileBytes ;
int CheckLocation = 0x8400 ;
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
2022-05-03 09:25:40 -07:00
/ * CheckLocation = 0x10400 ;
2022-04-20 22:32:03 -07:00
num = BufferBytes [ CheckLocation ] ;
num2 = GetNegativeChecksumArea ( BufferBytes , 0x8000 , 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" ) ) ;
2022-05-03 09:25:40 -07:00
} * /
2022-04-20 22:32:03 -07:00
//########################################################
//########################################################
return BufferBytes ;
}
public byte [ ] VerifyChecksumFWBin ( byte [ ] FWFileBytes )
{
//###############################
//Get Checksum and Fix it at 0x400 (0x8400 in full bin)
byte [ ] BufferBytes = FWFileBytes ;
byte num = Class_RWD . BootloaderSum ;
byte num2 = Class_RWD . GetNegativeChecksumFWBin ( BufferBytes ) ;
byte ThisSum = num ;
ThisSum - = num2 ;
int CheckLocation = 0x400 ;
byte chk = BufferBytes [ CheckLocation ] ;
if ( chk ! = ThisSum )
{
this . method_1 ( "Checksum miss match." ) ;
BufferBytes [ 0x400 ] = 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)
2022-05-03 09:25:40 -07:00
/ * CheckLocation = 0x8400 ;
2022-04-20 22:32:03 -07:00
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" ) ) ;
2022-05-03 09:25:40 -07:00
} * /
2022-04-20 22:32:03 -07:00
//########################################################
//########################################################
return BufferBytes ;
2022-04-18 01:06:03 -07:00
}
2022-04-13 23:39:25 -07:00
private void method_17 ( object sender , EventArgs e )
{
2022-04-14 02:46:36 -07:00
using ( OpenFileDialog dialog = new OpenFileDialog ( ) )
{
2022-04-18 01:06:03 -07:00
dialog . Filter = "Honda Binary ROM File|*.bin" ;
2022-04-14 02:46:36 -07:00
dialog . FilterIndex = 1 ;
dialog . RestoreDirectory = true ;
if ( dialog . ShowDialog ( ) = = DialogResult . OK )
{
string string_Filename = dialog . FileName ;
2022-04-18 01:06:03 -07:00
byte_ToWrite = File . ReadAllBytes ( string_Filename ) ;
WritingBinaryMode = true ;
//###############################
2022-04-20 22:32:03 -07:00
//Get/Fix Checksums
byte_ToWrite = VerifyChecksumFullBin ( byte_ToWrite ) ;
2022-04-18 01:06:03 -07:00
if ( MessageBox . Show ( "Are you sure you want to write this file to ECU?" , "Flash Tool" , MessageBoxButtons . YesNo ) = = DialogResult . Yes )
2022-04-14 02:46:36 -07:00
{
2022-04-18 01:06:03 -07:00
this . backgroundWorker_0 = new BackgroundWorker ( ) ;
this . backgroundWorker_0 . WorkerReportsProgress = true ;
this . backgroundWorker_0 . DoWork + = new DoWorkEventHandler ( this . backgroundWorker_0_DoWork_1 ) ;
this . backgroundWorker_0 . ProgressChanged + = new ProgressChangedEventHandler ( this . method_18 ) ;
this . backgroundWorker_0 . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( this . method_19 ) ;
this . backgroundWorker_0 . RunWorkerAsync ( ) ;
}
}
}
}
private void darkButton3_Click ( object sender , EventArgs e )
{
using ( OpenFileDialog dialog = new OpenFileDialog ( ) )
{
dialog . Filter = "Honda Compressed Firmware RWD File|*.gz|Honda Firmware RWD File|*.rwd" ;
dialog . FilterIndex = 1 ;
dialog . RestoreDirectory = true ;
if ( dialog . ShowDialog ( ) = = DialogResult . OK )
{
string string_Filename = dialog . FileName ;
if ( Path . GetExtension ( string_Filename ) . ToLower ( ) . Contains ( "gz" ) ) byte_ToWrite = Class_RWD . Decompress ( string_Filename ) ;
else byte_ToWrite = File . ReadAllBytes ( string_Filename ) ;
WritingBinaryMode = false ;
//Decrypt firmware file and get needed variable (Decryption byte)
2022-05-07 17:39:50 -07:00
Class_RWD . LoadRWD ( dialog . FileName , false , false ) ;
2022-04-18 01:06:03 -07:00
//###############################
//Get Checksum and Fix it
/ * int num = ( int ) byte_ToWrite [ 33792 ] ;
int num2 = this . GetChecksum ( byte_ToWrite ) ;
if ( num ! = num2 )
{
DialogResult dialogResult = MessageBox . Show ( "Checksum miss match." + Environment . NewLine + "Do you want to correct it?" , "Checksum Error." , MessageBoxButtons . YesNo , MessageBoxIcon . Hand ) ;
if ( dialogResult = = DialogResult . Yes )
2022-04-14 02:46:36 -07:00
{
2022-04-18 01:06:03 -07:00
byte_ToWrite [ 33792 ] = ( byte ) num2 ;
2022-04-14 02:46:36 -07:00
}
2022-04-18 01:06:03 -07:00
} * /
//###############################
2022-04-14 02:46:36 -07:00
if ( MessageBox . Show ( "Are you sure you want to write this file to ECU?" , "Flash Tool" , MessageBoxButtons . YesNo ) = = DialogResult . Yes )
{
this . backgroundWorker_0 = new BackgroundWorker ( ) ;
this . backgroundWorker_0 . WorkerReportsProgress = true ;
this . backgroundWorker_0 . DoWork + = new DoWorkEventHandler ( this . backgroundWorker_0_DoWork_1 ) ;
this . backgroundWorker_0 . ProgressChanged + = new ProgressChangedEventHandler ( this . method_18 ) ;
this . backgroundWorker_0 . RunWorkerCompleted + = new RunWorkerCompletedEventHandler ( this . method_19 ) ;
this . backgroundWorker_0 . RunWorkerAsync ( ) ;
}
}
}
}
2022-04-30 09:08:54 -07:00
private Channel LoadJ2534Channel ( Channel channel )
2022-04-18 01:06:03 -07:00
{
MessageFilter messageFilter = new MessageFilter ( ) ;
messageFilter . FilterType = Filter . FLOW_CONTROL_FILTER ;
messageFilter . Mask = new byte [ ]
{
byte . MaxValue ,
byte . MaxValue ,
byte . MaxValue ,
byte . MaxValue
} ;
messageFilter . Pattern = new byte [ ]
{
24 , //0x18
218 , //0xDA
241 , //0xF1
GForm_Main . byte_3 //0x00
} ;
messageFilter . FlowControl = new byte [ ]
{
24 , //0x18
218 , //0xDA
GForm_Main . byte_3 , //0x00 -> 0x10|0x11
241 //0xF1
} ;
MessageFilter filter = messageFilter ;
channel . StartMsgFilter ( filter ) ;
SConfig [ ] config = new SConfig [ ]
{
new SConfig ( Parameter . LOOP_BACK , 1 ) ,
new SConfig ( Parameter . DATA_RATE , 500000 )
} ;
channel . SetConfig ( config ) ;
2022-04-30 09:08:54 -07:00
return channel ;
2022-04-18 01:06:03 -07:00
}
2022-04-24 16:05:27 -07:00
private void backgroundWorker_0_DoWork_1 ( object sender , DoWorkEventArgs e )
2022-04-14 02:46:36 -07:00
{
2022-05-07 17:39:50 -07:00
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
2022-04-14 02:46:36 -07:00
{
2022-05-07 17:39:50 -07:00
try
{
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . CAN_29BIT_ID , false ) )
2022-04-30 09:08:54 -07:00
{
2022-05-07 17:39:50 -07:00
LoadJ2534Channel ( channel ) ;
2022-04-14 02:46:36 -07:00
2022-05-07 17:39:50 -07:00
if ( ! ECU_Unlocked )
2022-04-14 02:46:36 -07:00
{
MessageBox . Show ( "ECU is NOT Unlocked!" ) ;
}
else
{
2022-04-18 01:06:03 -07:00
device . SetProgrammingVoltage ( Pin . PIN_12 , 5000 ) ;
2022-04-18 12:39:55 -07:00
Stopwatch stopwatch = new Stopwatch ( ) ;
2022-04-18 01:06:03 -07:00
//Send WRITE_DATA_BY_IDENTIFIER for firmware (.rwd) writing mode
if ( ! WritingBinaryMode )
{
//Set Programming Mode
byte [ ] arraySend1 = new byte [ ]
{
16 , //0x10
2 //0x02
} ;
2022-05-07 17:39:50 -07:00
byte [ ] Received = SendJ2534Message ( channel , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Programming Mode Set!" ) ;
2022-04-18 01:06:03 -07:00
}
//###################
//Erase Memory
//31-01-FF-00
arraySend1 = new byte [ ]
{
0x31 , //0x31
0x01 , //0x01
2022-05-07 17:39:50 -07:00
0x00 , //0xFF ###################################
0xFF //0x00 ###################################
2022-04-18 01:06:03 -07:00
} ;
2022-05-07 17:39:50 -07:00
Received = SendJ2534Message ( channel , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Memory Erased!" ) ;
2022-04-18 01:06:03 -07:00
}
//###################
//Set WRITE_DATA_BY_IDENTIFIER
arraySend1 = new byte [ ]
{
2022-05-07 17:39:50 -07:00
0x2E , //0x2E -> Write Data by ID (F101)
0x01 , //0xF1 ###################################
0xF1 , //0x01 ###################################
2022-04-18 01:06:03 -07:00
Class_RWD . _keys [ 0 ] , //Key1
Class_RWD . _keys [ 1 ] , //Key2
Class_RWD . _keys [ 2 ] //Key3
} ;
2022-05-07 17:39:50 -07:00
Received = SendJ2534Message ( channel , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "WRITE_DATA_BY_IDENTIFIER Set!" ) ;
2022-04-18 01:06:03 -07:00
}
//###################
//Request Download
2022-05-07 17:39:50 -07:00
byte memory_address_bytes = 0x04 ;
byte memory_size_bytes = 0x04 ;
2022-04-18 01:06:03 -07:00
uint memory_address = Class_RWD . start ;
uint memory_size = Class_RWD . size ;
arraySend1 = new byte [ ]
{
0x34 , //0x34
2022-05-07 17:39:50 -07:00
0x00 , //0x00 data_format=0x00
memory_address_bytes , //0x04
2022-04-18 01:06:03 -07:00
0x00 , //0x00 -> Set later
0x00 , //0x00 -> Set later
0x00 , //0x00 -> Set later
0x00 , //0x00 -> Set later
0x00 , //0x00 -> Set later
0x00 , //0x00 -> Set later
0x00 , //0x00 -> Set later
0x00 //0x00 -> Set later
} ;
2022-05-07 17:39:50 -07:00
arraySend1 [ 2 ] = ( byte ) ( ( memory_size_bytes < < 4 ) | memory_address_bytes ) ;
if ( memory_address > = Math . Pow ( 2 , memory_address_bytes * 8 ) ) throw new Exception ( string . Format ( "invalid memory_address: 0x{0}" , memory_address . ToString ( "X4" ) ) ) ;
for ( int i = 0 ; i < memory_address_bytes ; i + + )
2022-04-18 01:06:03 -07:00
{
2022-05-07 17:39:50 -07:00
uint b = ( memory_address > > ( ( memory_address_bytes - i - 1 ) * 8 ) ) & 0xFF ;
2022-04-18 01:06:03 -07:00
arraySend1 [ 3 + i ] = ( byte ) b ;
}
2022-05-07 17:39:50 -07:00
if ( memory_size > = Math . Pow ( 2 , memory_size_bytes * 8 ) ) throw new Exception ( string . Format ( "invalid memory_size: 0x{0}" , memory_size . ToString ( "X4" ) ) ) ;
for ( int i = 0 ; i < memory_size_bytes ; i + + )
2022-04-18 01:06:03 -07:00
{
2022-05-07 17:39:50 -07:00
uint b = ( memory_size > > ( ( memory_size_bytes - i - 1 ) * 8 ) ) & 0xFF ;
arraySend1 [ 3 + memory_size_bytes + i ] = ( byte ) b ;
2022-04-18 01:06:03 -07:00
}
2022-05-07 17:39:50 -07:00
Received = SendJ2534Message ( channel , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Request download started" ) ;
2022-04-18 12:39:55 -07:00
stopwatch . Start ( ) ;
2022-05-07 17:39:50 -07:00
//if (max_num_bytes_len >= 1 && max_num_bytes_len <= 4)
//{
var max_num_bytes = 0 ;
for ( int i = 0 ; i < 4 ; i + + )
{
max_num_bytes = ( max_num_bytes < < 8 ) | Received [ Received . Length - 5 + i ] ;
}
//}
// account for service id and block sequence count (one byte each)
//var block_size = (Received[Received.Length - 2] + Received[Received.Length - 1]); //Get the two last bytes
var block_size = max_num_bytes ;
2022-04-18 12:39:55 -07:00
var chunk_size = block_size - 2 ;
var cnt = 0 ;
2022-05-07 17:39:50 -07:00
//Perform Write firmware to ECU
2022-04-18 12:39:55 -07:00
for ( int i = 0 ; i < Class_RWD . _firmware_encrypted . Length ; i + = chunk_size )
{
cnt + = 1 ;
byte [ ] chunk = Class_RWD . Slice ( Class_RWD . _firmware_encrypted , i , i + chunk_size ) ;
byte bsct = ( byte ) ( cnt & 0xFF ) ;
arraySend1 = new byte [ ]
{
0x36 , //0x36 -> TRANSFER_DATA
bsct //0x00 -> block_sequence_count
} ;
//Add the rest of the messages bytes to the final array
byte [ ] arrayCommandFinal = new byte [ arraySend1 . Length + chunk . Length ] ;
int MessageIndex = 0 ;
for ( int i2 = 0 ; i2 < arraySend1 . Length ; i2 + + )
{
arrayCommandFinal [ MessageIndex ] = arraySend1 [ i2 ] ;
MessageIndex + + ;
}
for ( int i2 = 0 ; i2 < chunk . Length ; i2 + + )
{
arrayCommandFinal [ MessageIndex ] = chunk [ i2 ] ;
MessageIndex + + ;
}
2022-05-07 17:39:50 -07:00
Received = SendJ2534Message ( channel , arrayCommandFinal , 3 ) ;
2022-04-18 12:39:55 -07:00
int Percent = ( ( i * 100 ) / Class_RWD . _firmware_encrypted . Length ) ;
this . method_5 ( Percent ) ;
/ * if ( Received ! = null )
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "WRITE CHUNK CORRECT!" ) ;
2022-04-18 12:39:55 -07:00
} * /
}
stopwatch . Stop ( ) ;
2022-04-18 01:06:03 -07:00
}
}
2022-04-18 12:39:55 -07:00
if ( WritingBinaryMode )
{
stopwatch . Start ( ) ;
this . WriteROMtoECU ( channel , byte_ToWrite , this . backgroundWorker_0 ) ;
stopwatch . Stop ( ) ;
}
2022-04-14 02:46:36 -07:00
2022-04-18 01:06:03 -07:00
if ( ! WritingBinaryMode )
{
//Request transfer exit && routine control: check dependencies
this . method_13_Close ( channel ) ;
}
2022-04-14 02:46:36 -07:00
TimeSpan timeSpan = TimeSpan . FromMilliseconds ( ( double ) stopwatch . ElapsedMilliseconds ) ;
2022-04-18 01:06:03 -07:00
this . backgroundWorker_0 . ReportProgress ( 0 , "Successfully write " + this . byte_7 . Length + "bytes of flash memory in " + timeSpan . Minutes + ":" + timeSpan . Seconds ) ;
2022-04-14 02:46:36 -07:00
device . SetProgrammingVoltage ( Pin . PIN_12 , - 1 ) ; //Set 0V on Pin12
}
2022-05-07 17:39:50 -07:00
}
}
2022-04-14 02:46:36 -07:00
}
catch ( Exception ex )
{
2022-05-07 17:39:50 -07:00
DarkMessageBox . Show ( ex . Message ) ;
2022-04-14 02:46:36 -07:00
}
2022-05-07 17:39:50 -07:00
}
2022-04-14 02:46:36 -07:00
}
public void WriteROMtoECU ( Channel channel_0 , byte [ ] byte_5 , BackgroundWorker backgroundWorker_X = null )
{
2022-04-18 01:06:03 -07:00
//Get valid addresses for Firmware writing (get Start address)
if ( byte_5 . Length < 1015808 & & WritingBinaryMode )
2022-04-14 02:46:36 -07:00
{
return ;
}
byte b = 1 ;
int num = 256 ;
for ( int i = 0 ; i < 1015808 ; i + = num )
{
2022-05-07 17:39:50 -07:00
this . method_14_Write ( channel_0 , byte_5 , i , b , num , - 1 ) ;
2022-04-14 02:46:36 -07:00
if ( b = = 255 )
{
b = 0 ;
}
else
{
b + = 1 ;
}
if ( backgroundWorker_X ! = null )
{
backgroundWorker_X . ReportProgress ( ( int ) ( ( float ) i / 1015808f * 100f ) ) ;
}
}
2022-04-18 01:06:03 -07:00
this . method_13_Close ( channel_0 ) ;
2022-04-14 02:46:36 -07:00
}
2022-04-18 01:06:03 -07:00
public void method_13_Close ( Channel channel_0 )
2022-04-14 02:46:36 -07:00
{
2022-04-18 01:06:03 -07:00
byte [ ] arraySend1 = new byte [ ]
2022-04-14 02:46:36 -07:00
{
0x37 //0x37
2022-04-18 01:06:03 -07:00
} ;
2022-04-14 02:46:36 -07:00
byte [ ] buffer2 = new byte [ ] { GForm_Main . byte_3 , 0x77 } ;
2022-04-18 01:06:03 -07:00
2022-05-07 17:39:50 -07:00
byte [ ] Received = SendJ2534Message ( channel_0 , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
2022-04-14 02:46:36 -07:00
{
2022-04-18 01:06:03 -07:00
int num3 = GForm_Main . smethod_2 ( Received , buffer2 , 0 ) ;
if ( num3 > 0 )
2022-04-14 02:46:36 -07:00
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Transfer Exited" ) ;
2022-04-14 02:46:36 -07:00
}
2022-04-18 01:06:03 -07:00
arraySend1 = new byte [ ]
2022-04-14 02:46:36 -07:00
{
2022-04-18 01:06:03 -07:00
0x31 , //0x31
1 , //0x01
0xff , //0xff
1 //0x01
} ;
2022-05-07 17:39:50 -07:00
Received = SendJ2534Message ( channel_0 , arraySend1 , 3 ) ;
if ( BadResponceReceived ) return ;
2022-04-18 01:06:03 -07:00
if ( Received ! = null )
{
2022-04-20 22:32:03 -07:00
this . method_1 ( "Routine control check dependencies" ) ;
2022-04-14 02:46:36 -07:00
}
}
2022-04-13 23:39:25 -07:00
}
2022-05-07 17:39:50 -07:00
public void method_14_Write ( Channel channel_0 , byte [ ] byte_5X , int int_23 , byte byte_6X , int int_24 , int int_25 = - 1 )
2022-04-14 02:46:36 -07:00
{
if ( int_25 = = - 1 )
{
int_25 = int_24 ;
}
2022-04-18 01:06:03 -07:00
//Transfer Data (0x36)
byte [ ] data = new byte [ ]
{
0x18 ,
0xDA ,
GForm_Main . byte_3 ,
0xF1 ,
0x36 ,
byte_6X
} ;
2022-04-14 02:46:36 -07:00
Buffer . BlockCopy ( byte_5X , int_23 , data , 6 , int_25 ) ;
SAE . J2534 . Message message = new SAE . J2534 . Message ( data , TxFlag . CAN_29BIT_ID | TxFlag . ISO15765_FRAME_PAD ) ;
channel_0 . SendMessage ( message ) ;
bool flag = false ;
byte [ ] buffer2 = new byte [ ] { GForm_Main . byte_3 , 0x76 , byte_6X } ;
while ( ! flag )
{
GetMessageResults messages = channel_0 . GetMessages ( 5 ) ;
int num = - 1 ;
if ( messages . Result ! = ResultCode . DEVICE_NOT_CONNECTED )
{
foreach ( SAE . J2534 . Message message2 in messages . Messages )
{
num = GForm_Main . smethod_2 ( message2 . Data , buffer2 , 0 ) ;
if ( num > 0 )
{
flag = true ;
return ;
}
}
}
}
}
2022-04-13 23:39:25 -07:00
private void method_18 ( object sender , ProgressChangedEventArgs e )
{
string text = e . UserState as string ;
this . darkLabel_8 . Text = text ;
this . method_5 ( e . ProgressPercentage ) ;
}
private void method_19 ( object sender , RunWorkerCompletedEventArgs e )
{
DarkMessageBox . Show ( this , "Flash Finished writing!" ) ;
}
private void method_20 ( object sender , EventArgs e )
{
GForm_PlatformSelect gform = new GForm_PlatformSelect ( ) ;
if ( gform . ShowDialog ( ) = = DialogResult . OK )
{
try
{
GForm_Main . class9_0 = gform . Class9_0 ;
}
catch
{
return ;
}
gform . Dispose ( ) ;
GForm_Main . byte_3 = GForm_Main . class9_0 . ECU_Byte ;
GForm_Main . byte_0 [ 3 ] = GForm_Main . class9_0 . ECU_Byte ;
GForm_Main . byte_1 [ 3 ] = GForm_Main . class9_0 . ECU_Byte ;
GForm_Main . byte_2 [ 3 ] = GForm_Main . class9_0 . ECU_Byte ;
this . byte_5 [ 0 ] = GForm_Main . class9_0 . ECU_Byte ;
Array . Resize < byte > ( ref GForm_Main . byte_4 , GForm_Main . class9_0 . FirmwareSize ) ;
Array . Resize < byte > ( ref this . byte_7 , GForm_Main . class9_0 . RomSize ) ;
this . byte_7 = Enumerable . Repeat < byte > ( byte . MaxValue , GForm_Main . class9_0 . RomSize ) . ToArray < byte > ( ) ;
this . darkButton_2 . Enabled = true ;
return ;
}
}
protected virtual void Dispose ( bool disposing )
{
if ( disposing & & this . icontainer_0 ! = null )
{
this . icontainer_0 . Dispose ( ) ;
}
base . Dispose ( disposing ) ;
}
private void InitializeComponent ( )
{
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( GForm_Main ) ) ;
this . darkTextBox_0 = new DarkUI . Controls . DarkTextBox ( ) ;
this . darkButton_3 = new DarkUI . Controls . DarkButton ( ) ;
this . darkButton_2 = new DarkUI . Controls . DarkButton ( ) ;
2022-04-14 02:46:36 -07:00
this . darkButton_DownloadROM = new DarkUI . Controls . DarkButton ( ) ;
2022-04-13 23:39:25 -07:00
this . darkButton_0 = new DarkUI . Controls . DarkButton ( ) ;
this . darkGroupBox_0 = new DarkUI . Controls . DarkGroupBox ( ) ;
2022-04-24 02:49:42 -07:00
this . darkButton5 = new DarkUI . Controls . DarkButton ( ) ;
2022-04-19 02:07:30 -07:00
this . darkButton_FlashFW = new DarkUI . Controls . DarkButton ( ) ;
2022-04-18 01:06:03 -07:00
this . darkButton_Unlock01 = new DarkUI . Controls . DarkButton ( ) ;
2022-04-14 02:46:36 -07:00
this . darkButton_Unlock41 = new DarkUI . Controls . DarkButton ( ) ;
2022-04-13 23:39:25 -07:00
this . darkButton1 = new DarkUI . Controls . DarkButton ( ) ;
this . darkButton_6 = new DarkUI . Controls . DarkButton ( ) ;
2022-04-19 02:07:30 -07:00
this . darkButton_FlashRom = new DarkUI . Controls . DarkButton ( ) ;
2022-04-20 22:32:03 -07:00
this . darkButton3 = new DarkUI . Controls . DarkButton ( ) ;
this . darkButton2 = new DarkUI . Controls . DarkButton ( ) ;
this . darkTextBox_4 = new DarkUI . Controls . DarkTextBox ( ) ;
this . darkTextBox_3 = new DarkUI . Controls . DarkTextBox ( ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_3 = new DarkUI . Controls . DarkLabel ( ) ;
2022-04-13 23:39:25 -07:00
this . darkButton_4 = new DarkUI . Controls . DarkButton ( ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_2 = new DarkUI . Controls . DarkLabel ( ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_0 = new DarkUI . Controls . DarkLabel ( ) ;
this . darkLabel_1 = new DarkUI . Controls . DarkLabel ( ) ;
this . darkLabel_4 = new DarkUI . Controls . DarkLabel ( ) ;
this . darkLabel_5 = new DarkUI . Controls . DarkLabel ( ) ;
this . darkTextBox_1 = new DarkUI . Controls . DarkTextBox ( ) ;
this . darkTextBox_2 = new DarkUI . Controls . DarkTextBox ( ) ;
this . darkProgressBar_0 = new DarkUI . Controls . DarkProgressBar ( ) ;
this . darkLabel_7 = new DarkUI . Controls . DarkLabel ( ) ;
this . darkLabel_8 = new DarkUI . Controls . DarkLabel ( ) ;
2022-04-18 01:06:03 -07:00
this . openFileDialog1 = new System . Windows . Forms . OpenFileDialog ( ) ;
2022-04-20 22:32:03 -07:00
this . DarkgroupBox1 = new DarkUI . Controls . DarkGroupBox ( ) ;
2022-04-24 16:05:27 -07:00
this . darkButton6 = new DarkUI . Controls . DarkButton ( ) ;
2022-05-01 16:07:45 -07:00
this . darkButton4 = new DarkUI . Controls . DarkButton ( ) ;
2022-05-07 17:39:50 -07:00
this . darkTextBoxJ2534Command = new DarkUI . Controls . DarkTextBox ( ) ;
this . darkLabel1 = new DarkUI . Controls . DarkLabel ( ) ;
this . darkButtonJ2534Command = new DarkUI . Controls . DarkButton ( ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . SuspendLayout ( ) ;
2022-04-20 22:32:03 -07:00
this . DarkgroupBox1 . SuspendLayout ( ) ;
2022-04-13 23:39:25 -07:00
this . SuspendLayout ( ) ;
//
// darkTextBox_0
//
2022-04-18 12:39:55 -07:00
this . darkTextBox_0 . Location = new System . Drawing . Point ( 218 , 63 ) ;
2022-04-13 23:39:25 -07:00
this . darkTextBox_0 . Multiline = true ;
this . darkTextBox_0 . Name = "darkTextBox_0" ;
2022-05-07 17:39:50 -07:00
this . darkTextBox_0 . Size = new System . Drawing . Size ( 399 , 408 ) ;
2022-04-13 23:39:25 -07:00
this . darkTextBox_0 . TabIndex = 55 ;
this . darkTextBox_0 . Text = "Honda CANBUS Tools" ;
//
// darkButton_3
//
this . darkButton_3 . Checked = false ;
this . darkButton_3 . Location = new System . Drawing . Point ( 6 , 19 ) ;
this . darkButton_3 . Name = "darkButton_3" ;
this . darkButton_3 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_3 . TabIndex = 47 ;
this . darkButton_3 . Text = "Scan for J2534 Devices" ;
this . darkButton_3 . Click + = new System . EventHandler ( this . method_2 ) ;
//
// darkButton_2
//
this . darkButton_2 . Checked = false ;
this . darkButton_2 . Enabled = false ;
2022-04-18 12:39:55 -07:00
this . darkButton_2 . Location = new System . Drawing . Point ( 6 , 77 ) ;
2022-04-13 23:39:25 -07:00
this . darkButton_2 . Name = "darkButton_2" ;
this . darkButton_2 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_2 . TabIndex = 48 ;
this . darkButton_2 . Text = "Select Adapter" ;
this . darkButton_2 . Click + = new System . EventHandler ( this . method_3 ) ;
//
2022-04-14 02:46:36 -07:00
// darkButton_DownloadROM
2022-04-13 23:39:25 -07:00
//
2022-04-14 02:46:36 -07:00
this . darkButton_DownloadROM . Checked = false ;
this . darkButton_DownloadROM . Enabled = false ;
2022-04-18 12:39:55 -07:00
this . darkButton_DownloadROM . Location = new System . Drawing . Point ( 6 , 193 ) ;
2022-04-14 02:46:36 -07:00
this . darkButton_DownloadROM . Name = "darkButton_DownloadROM" ;
this . darkButton_DownloadROM . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_DownloadROM . TabIndex = 49 ;
this . darkButton_DownloadROM . Text = "Download Rom" ;
this . darkButton_DownloadROM . Click + = new System . EventHandler ( this . method_13 ) ;
2022-04-13 23:39:25 -07:00
//
// darkButton_0
//
this . darkButton_0 . Checked = false ;
this . darkButton_0 . Enabled = false ;
2022-04-20 22:32:03 -07:00
this . darkButton_0 . Location = new System . Drawing . Point ( 695 , 24 ) ;
2022-04-13 23:39:25 -07:00
this . darkButton_0 . Name = "darkButton_0" ;
this . darkButton_0 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_0 . TabIndex = 50 ;
this . darkButton_0 . Text = "Read Ram Address" ;
this . darkButton_0 . Visible = false ;
this . darkButton_0 . Click + = new System . EventHandler ( this . method_14 ) ;
//
// darkGroupBox_0
//
this . darkGroupBox_0 . BorderColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 51 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 51 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 51 ) ) ) ) ) ;
2022-04-20 22:32:03 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton5 ) ;
2022-04-19 02:07:30 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton_FlashFW ) ;
2022-04-14 02:46:36 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton_Unlock01 ) ;
this . darkGroupBox_0 . Controls . Add ( this . darkButton_Unlock41 ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton1 ) ;
this . darkGroupBox_0 . Controls . Add ( this . darkButton_6 ) ;
2022-04-19 02:07:30 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton_FlashRom ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton_3 ) ;
2022-04-14 02:46:36 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton_DownloadROM ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . Controls . Add ( this . darkButton_2 ) ;
2022-04-18 12:39:55 -07:00
this . darkGroupBox_0 . Location = new System . Drawing . Point ( 7 , 6 ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . Name = "darkGroupBox_0" ;
2022-04-20 22:32:03 -07:00
this . darkGroupBox_0 . Size = new System . Drawing . Size ( 204 , 314 ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . TabIndex = 56 ;
this . darkGroupBox_0 . TabStop = false ;
this . darkGroupBox_0 . Text = "J2534 Controls" ;
//
2022-04-24 02:49:42 -07:00
// 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 ) ;
//
2022-04-19 02:07:30 -07:00
// darkButton_FlashFW
//
this . darkButton_FlashFW . Checked = false ;
this . darkButton_FlashFW . Enabled = false ;
this . darkButton_FlashFW . Location = new System . Drawing . Point ( 6 , 251 ) ;
this . darkButton_FlashFW . Name = "darkButton_FlashFW" ;
this . darkButton_FlashFW . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_FlashFW . TabIndex = 60 ;
this . darkButton_FlashFW . Text = "Flash Firmware (.rwd)" ;
this . darkButton_FlashFW . Click + = new System . EventHandler ( this . darkButton3_Click ) ;
//
2022-04-18 01:06:03 -07:00
// darkButton_Unlock01
//
this . darkButton_Unlock01 . Checked = false ;
this . darkButton_Unlock01 . Enabled = false ;
2022-04-18 12:39:55 -07:00
this . darkButton_Unlock01 . Location = new System . Drawing . Point ( 6 , 135 ) ;
2022-04-18 01:06:03 -07:00
this . darkButton_Unlock01 . Name = "darkButton_Unlock01" ;
this . darkButton_Unlock01 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_Unlock01 . TabIndex = 58 ;
this . darkButton_Unlock01 . Text = "UNLOCK ECU (0x27,0x01)" ;
this . darkButton_Unlock01 . Click + = new System . EventHandler ( this . darkButton_Unlock01_Click ) ;
//
2022-04-14 02:46:36 -07:00
// darkButton_Unlock41
2022-04-13 23:39:25 -07:00
//
2022-04-14 02:46:36 -07:00
this . darkButton_Unlock41 . Checked = false ;
this . darkButton_Unlock41 . Enabled = false ;
2022-04-18 12:39:55 -07:00
this . darkButton_Unlock41 . Location = new System . Drawing . Point ( 6 , 164 ) ;
2022-04-14 02:46:36 -07:00
this . darkButton_Unlock41 . Name = "darkButton_Unlock41" ;
this . darkButton_Unlock41 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_Unlock41 . TabIndex = 57 ;
this . darkButton_Unlock41 . Text = "UNLOCK ECU (0x27,0x41)" ;
this . darkButton_Unlock41 . Click + = new System . EventHandler ( this . darkButton2_Click ) ;
2022-04-13 23:39:25 -07:00
//
// darkButton1
//
this . darkButton1 . Checked = false ;
this . darkButton1 . Enabled = false ;
2022-04-18 12:39:55 -07:00
this . darkButton1 . Location = new System . Drawing . Point ( 6 , 106 ) ;
2022-04-13 23:39:25 -07:00
this . darkButton1 . Name = "darkButton1" ;
this . darkButton1 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton1 . TabIndex = 56 ;
this . darkButton1 . Text = "Connect ECU" ;
this . darkButton1 . Click + = new System . EventHandler ( this . darkButton1_Click ) ;
//
// darkButton_6
//
this . darkButton_6 . Checked = false ;
2022-04-18 12:39:55 -07:00
this . darkButton_6 . Location = new System . Drawing . Point ( 6 , 48 ) ;
2022-04-13 23:39:25 -07:00
this . darkButton_6 . Name = "darkButton_6" ;
this . darkButton_6 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_6 . TabIndex = 55 ;
this . darkButton_6 . Text = "Select ECU" ;
this . darkButton_6 . Click + = new System . EventHandler ( this . method_20 ) ;
//
2022-04-19 02:07:30 -07:00
// darkButton_FlashRom
//
this . darkButton_FlashRom . Checked = false ;
this . darkButton_FlashRom . Enabled = false ;
this . darkButton_FlashRom . Location = new System . Drawing . Point ( 6 , 222 ) ;
this . darkButton_FlashRom . Name = "darkButton_FlashRom" ;
this . darkButton_FlashRom . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_FlashRom . TabIndex = 54 ;
this . darkButton_FlashRom . Text = "Flash Rom (.bin)" ;
this . darkButton_FlashRom . Click + = new System . EventHandler ( this . method_17 ) ;
//
2022-04-20 22:32:03 -07:00
// darkButton3
//
this . darkButton3 . Checked = false ;
this . darkButton3 . Location = new System . Drawing . Point ( 6 , 48 ) ;
this . darkButton3 . Name = "darkButton3" ;
this . darkButton3 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton3 . TabIndex = 67 ;
this . darkButton3 . Text = "Convert Firmware .bin to .rwd" ;
this . darkButton3 . Click + = new System . EventHandler ( this . darkButton3_Click_1 ) ;
//
// darkButton2
//
this . darkButton2 . Checked = false ;
this . darkButton2 . Location = new System . Drawing . Point ( 6 , 19 ) ;
this . darkButton2 . Name = "darkButton2" ;
this . darkButton2 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton2 . TabIndex = 59 ;
this . darkButton2 . Text = "Convert Firmware .rwd to .bin" ;
this . darkButton2 . Click + = new System . EventHandler ( this . darkButton2_Click_1 ) ;
//
// darkTextBox_4
//
this . darkTextBox_4 . Location = new System . Drawing . Point ( 774 , 104 ) ;
this . darkTextBox_4 . Name = "darkTextBox_4" ;
this . darkTextBox_4 . Size = new System . Drawing . Size ( 113 , 20 ) ;
this . darkTextBox_4 . TabIndex = 66 ;
this . darkTextBox_4 . Visible = false ;
//
// darkTextBox_3
//
this . darkTextBox_3 . Location = new System . Drawing . Point ( 774 , 80 ) ;
this . darkTextBox_3 . Name = "darkTextBox_3" ;
this . darkTextBox_3 . Size = new System . Drawing . Size ( 113 , 20 ) ;
this . darkTextBox_3 . TabIndex = 65 ;
this . darkTextBox_3 . Visible = false ;
//
2022-04-19 02:07:30 -07:00
// darkLabel_3
2022-04-13 23:39:25 -07:00
//
2022-04-19 02:07:30 -07:00
this . darkLabel_3 . AutoSize = true ;
this . darkLabel_3 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-04-20 22:32:03 -07:00
this . darkLabel_3 . Location = new System . Drawing . Point ( 713 , 106 ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_3 . Name = "darkLabel_3" ;
this . darkLabel_3 . Size = new System . Drawing . Size ( 56 , 13 ) ;
this . darkLabel_3 . TabIndex = 60 ;
this . darkLabel_3 . Text = "Read Size" ;
this . darkLabel_3 . Visible = false ;
2022-04-13 23:39:25 -07:00
//
// darkButton_4
//
this . darkButton_4 . Checked = false ;
this . darkButton_4 . Enabled = false ;
2022-04-20 22:32:03 -07:00
this . darkButton_4 . Location = new System . Drawing . Point ( 695 , 53 ) ;
2022-04-13 23:39:25 -07:00
this . darkButton_4 . Name = "darkButton_4" ;
this . darkButton_4 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton_4 . TabIndex = 51 ;
this . darkButton_4 . Text = "Sniff All Traffic" ;
this . darkButton_4 . Visible = false ;
this . darkButton_4 . Click + = new System . EventHandler ( this . method_16 ) ;
//
2022-04-19 02:07:30 -07:00
// darkLabel_2
//
this . darkLabel_2 . AutoSize = true ;
this . darkLabel_2 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-04-20 22:32:03 -07:00
this . darkLabel_2 . Location = new System . Drawing . Point ( 696 , 83 ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_2 . Name = "darkLabel_2" ;
this . darkLabel_2 . Size = new System . Drawing . Size ( 73 , 13 ) ;
this . darkLabel_2 . TabIndex = 59 ;
this . darkLabel_2 . Text = "Read address" ;
this . darkLabel_2 . Visible = false ;
//
2022-04-13 23:39:25 -07:00
// darkLabel_0
//
this . darkLabel_0 . AutoSize = true ;
this . darkLabel_0 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_0 . Location = new System . Drawing . Point ( 218 , 14 ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_0 . Name = "darkLabel_0" ;
this . darkLabel_0 . Size = new System . Drawing . Size ( 62 , 13 ) ;
this . darkLabel_0 . TabIndex = 57 ;
this . darkLabel_0 . Text = "Vin Number" ;
//
// darkLabel_1
//
this . darkLabel_1 . AutoSize = true ;
this . darkLabel_1 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_1 . Location = new System . Drawing . Point ( 218 , 40 ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_1 . Name = "darkLabel_1" ;
this . darkLabel_1 . Size = new System . Drawing . Size ( 70 , 13 ) ;
this . darkLabel_1 . TabIndex = 58 ;
this . darkLabel_1 . Text = "Calibration ID" ;
//
// darkLabel_4
//
this . darkLabel_4 . AutoSize = true ;
2022-04-24 02:49:42 -07:00
this . darkLabel_4 . Font = new System . Drawing . Font ( "Microsoft Sans Serif" , 15.75F , System . Drawing . FontStyle . Underline , System . Drawing . GraphicsUnit . Point , ( ( byte ) ( 0 ) ) ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_4 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-05-01 16:07:45 -07:00
this . darkLabel_4 . Location = new System . Drawing . Point ( 536 , 509 ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_4 . Name = "darkLabel_4" ;
2022-04-24 02:49:42 -07:00
this . darkLabel_4 . Size = new System . Drawing . Size ( 80 , 25 ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_4 . TabIndex = 61 ;
2022-04-24 02:49:42 -07:00
this . darkLabel_4 . Text = "Credits" ;
this . darkLabel_4 . Click + = new System . EventHandler ( this . darkLabel_4_Click ) ;
2022-04-13 23:39:25 -07:00
//
// darkLabel_5
//
this . darkLabel_5 . AutoSize = true ;
this . darkLabel_5 . Font = new System . Drawing . Font ( "Microsoft Sans Serif" , 12F ) ;
this . darkLabel_5 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_5 . Location = new System . Drawing . Point ( 12 , 512 ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_5 . Name = "darkLabel_5" ;
this . darkLabel_5 . Size = new System . Drawing . Size ( 0 , 20 ) ;
this . darkLabel_5 . TabIndex = 51 ;
//
// darkTextBox_1
//
2022-04-19 02:07:30 -07:00
this . darkTextBox_1 . Location = new System . Drawing . Point ( 294 , 11 ) ;
2022-04-13 23:39:25 -07:00
this . darkTextBox_1 . Name = "darkTextBox_1" ;
this . darkTextBox_1 . ReadOnly = true ;
2022-05-01 16:07:45 -07:00
this . darkTextBox_1 . Size = new System . Drawing . Size ( 323 , 20 ) ;
2022-04-13 23:39:25 -07:00
this . darkTextBox_1 . TabIndex = 63 ;
//
// darkTextBox_2
//
2022-04-19 02:07:30 -07:00
this . darkTextBox_2 . Location = new System . Drawing . Point ( 294 , 37 ) ;
2022-04-13 23:39:25 -07:00
this . darkTextBox_2 . Name = "darkTextBox_2" ;
this . darkTextBox_2 . ReadOnly = true ;
2022-05-01 16:07:45 -07:00
this . darkTextBox_2 . Size = new System . Drawing . Size ( 323 , 20 ) ;
2022-04-13 23:39:25 -07:00
this . darkTextBox_2 . TabIndex = 64 ;
//
// darkProgressBar_0
//
this . darkProgressBar_0 . Location = new System . Drawing . Point ( 98 , 537 ) ;
this . darkProgressBar_0 . Name = "darkProgressBar_0" ;
2022-05-01 16:07:45 -07:00
this . darkProgressBar_0 . Size = new System . Drawing . Size ( 519 , 23 ) ;
2022-04-13 23:39:25 -07:00
this . darkProgressBar_0 . TabIndex = 67 ;
//
// darkLabel_7
//
this . darkLabel_7 . AutoSize = true ;
this . darkLabel_7 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
this . darkLabel_7 . Location = new System . Drawing . Point ( 14 , 542 ) ;
this . darkLabel_7 . Name = "darkLabel_7" ;
this . darkLabel_7 . Size = new System . Drawing . Size ( 37 , 13 ) ;
this . darkLabel_7 . TabIndex = 68 ;
this . darkLabel_7 . Text = "Status" ;
//
// darkLabel_8
//
this . darkLabel_8 . AutoSize = true ;
this . darkLabel_8 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
2022-04-19 02:07:30 -07:00
this . darkLabel_8 . Location = new System . Drawing . Point ( 228 , 516 ) ;
2022-04-13 23:39:25 -07:00
this . darkLabel_8 . Name = "darkLabel_8" ;
this . darkLabel_8 . Size = new System . Drawing . Size ( 0 , 13 ) ;
this . darkLabel_8 . TabIndex = 69 ;
//
2022-04-18 01:06:03 -07:00
// openFileDialog1
2022-04-14 02:46:36 -07:00
//
2022-04-18 01:06:03 -07:00
this . openFileDialog1 . DefaultExt = "*.gz" ;
2022-04-19 02:07:30 -07:00
this . openFileDialog1 . Filter = "Honda Compressed RWD Firmware|*.gz;*.rwd" ;
2022-04-20 22:32:03 -07:00
this . openFileDialog1 . Title = "Open Honda/Acura File" ;
//
// DarkgroupBox1
//
this . DarkgroupBox1 . BorderColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 51 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 51 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 51 ) ) ) ) ) ;
2022-04-24 16:05:27 -07:00
this . DarkgroupBox1 . Controls . Add ( this . darkButton6 ) ;
2022-04-20 22:32:03 -07:00
this . DarkgroupBox1 . Controls . Add ( this . darkButton4 ) ;
this . DarkgroupBox1 . Controls . Add ( this . darkButton3 ) ;
this . DarkgroupBox1 . Controls . Add ( this . darkButton2 ) ;
this . DarkgroupBox1 . Location = new System . Drawing . Point ( 7 , 326 ) ;
this . DarkgroupBox1 . Name = "DarkgroupBox1" ;
this . DarkgroupBox1 . Size = new System . Drawing . Size ( 204 , 180 ) ;
this . DarkgroupBox1 . TabIndex = 70 ;
this . DarkgroupBox1 . TabStop = false ;
this . DarkgroupBox1 . Text = "File Controls" ;
//
2022-04-24 16:05:27 -07:00
// darkButton6
//
this . darkButton6 . Checked = false ;
this . darkButton6 . Location = new System . Drawing . Point ( 6 , 106 ) ;
this . darkButton6 . Name = "darkButton6" ;
this . darkButton6 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton6 . TabIndex = 69 ;
this . darkButton6 . Text = "Open ROM Editor" ;
this . darkButton6 . Click + = new System . EventHandler ( this . darkButton6_Click ) ;
//
2022-05-01 16:07:45 -07:00
// darkButton4
//
this . darkButton4 . Checked = false ;
this . darkButton4 . Location = new System . Drawing . Point ( 6 , 77 ) ;
this . darkButton4 . Name = "darkButton4" ;
this . darkButton4 . Size = new System . Drawing . Size ( 192 , 23 ) ;
this . darkButton4 . TabIndex = 68 ;
this . darkButton4 . Text = "Fix Checksums" ;
this . darkButton4 . Click + = new System . EventHandler ( this . darkButton4_Click ) ;
//
2022-05-07 17:39:50 -07:00
// darkTextBoxJ2534Command
//
this . darkTextBoxJ2534Command . Location = new System . Drawing . Point ( 313 , 477 ) ;
this . darkTextBoxJ2534Command . Name = "darkTextBoxJ2534Command" ;
this . darkTextBoxJ2534Command . Size = new System . Drawing . Size ( 230 , 20 ) ;
this . darkTextBoxJ2534Command . TabIndex = 72 ;
//
// darkLabel1
//
this . darkLabel1 . AutoSize = true ;
this . darkLabel1 . ForeColor = System . Drawing . Color . FromArgb ( ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) , ( ( int ) ( ( ( byte ) ( 220 ) ) ) ) ) ;
this . darkLabel1 . Location = new System . Drawing . Point ( 218 , 480 ) ;
this . darkLabel1 . Name = "darkLabel1" ;
this . darkLabel1 . Size = new System . Drawing . Size ( 89 , 13 ) ;
this . darkLabel1 . TabIndex = 71 ;
this . darkLabel1 . Text = "J2534 Command:" ;
//
// darkButtonJ2534Command
//
this . darkButtonJ2534Command . Checked = false ;
this . darkButtonJ2534Command . Enabled = false ;
this . darkButtonJ2534Command . Location = new System . Drawing . Point ( 549 , 475 ) ;
this . darkButtonJ2534Command . Name = "darkButtonJ2534Command" ;
this . darkButtonJ2534Command . Size = new System . Drawing . Size ( 53 , 23 ) ;
this . darkButtonJ2534Command . TabIndex = 70 ;
this . darkButtonJ2534Command . Text = "Send" ;
this . darkButtonJ2534Command . Click + = new System . EventHandler ( this . darkButtonJ2534Command_Click ) ;
//
2022-04-13 23:39:25 -07:00
// GForm_Main
//
this . AutoScaleDimensions = new System . Drawing . SizeF ( 6F , 13F ) ;
this . AutoScaleMode = System . Windows . Forms . AutoScaleMode . Font ;
2022-05-01 16:07:45 -07:00
this . ClientSize = new System . Drawing . Size ( 629 , 571 ) ;
2022-05-07 17:39:50 -07:00
this . Controls . Add ( this . darkButtonJ2534Command ) ;
this . Controls . Add ( this . darkTextBoxJ2534Command ) ;
this . Controls . Add ( this . darkLabel1 ) ;
2022-04-20 22:32:03 -07:00
this . Controls . Add ( this . DarkgroupBox1 ) ;
2022-04-13 23:39:25 -07:00
this . Controls . Add ( this . darkLabel_8 ) ;
this . Controls . Add ( this . darkLabel_7 ) ;
this . Controls . Add ( this . darkProgressBar_0 ) ;
this . Controls . Add ( this . darkTextBox_2 ) ;
2022-04-20 22:32:03 -07:00
this . Controls . Add ( this . darkTextBox_4 ) ;
2022-04-13 23:39:25 -07:00
this . Controls . Add ( this . darkTextBox_1 ) ;
this . Controls . Add ( this . darkLabel_5 ) ;
2022-04-20 22:32:03 -07:00
this . Controls . Add ( this . darkTextBox_3 ) ;
2022-04-13 23:39:25 -07:00
this . Controls . Add ( this . darkLabel_4 ) ;
this . Controls . Add ( this . darkLabel_1 ) ;
this . Controls . Add ( this . darkLabel_0 ) ;
this . Controls . Add ( this . darkGroupBox_0 ) ;
2022-04-20 22:32:03 -07:00
this . Controls . Add ( this . darkLabel_3 ) ;
2022-04-13 23:39:25 -07:00
this . Controls . Add ( this . darkTextBox_0 ) ;
2022-04-20 22:32:03 -07:00
this . Controls . Add ( this . darkButton_4 ) ;
this . Controls . Add ( this . darkLabel_2 ) ;
this . Controls . Add ( this . darkButton_0 ) ;
2022-04-13 23:39:25 -07:00
this . Icon = ( ( System . Drawing . Icon ) ( resources . GetObject ( "$this.Icon" ) ) ) ;
2022-05-01 16:07:45 -07:00
this . MaximizeBox = false ;
this . MinimumSize = new System . Drawing . Size ( 645 , 610 ) ;
2022-04-13 23:39:25 -07:00
this . Name = "GForm_Main" ;
this . Text = "Honda CANBUS Tools" ;
2022-04-19 02:07:30 -07:00
this . Load + = new System . EventHandler ( this . GForm_Main_Load ) ;
2022-04-13 23:39:25 -07:00
this . darkGroupBox_0 . ResumeLayout ( false ) ;
2022-04-20 22:32:03 -07:00
this . DarkgroupBox1 . ResumeLayout ( false ) ;
2022-04-13 23:39:25 -07:00
this . ResumeLayout ( false ) ;
this . PerformLayout ( ) ;
}
// Note: this type is marked as 'beforefieldinit'.
static GForm_Main ( )
{
}
IAsyncResult method_22 ( Delegate delegate_0 , object [ ] object_0 )
{
return base . BeginInvoke ( delegate_0 , object_0 ) ;
}
public static string string_0 = string . Empty ;
public static string string_1 = "" ;
private Dictionary < string , byte [ ] > dictionary_0 = new Dictionary < string , byte [ ] > ( ) ;
private List < string > list_0 = new List < string > ( ) ;
public static byte [ ] byte_0 = new byte [ ]
{
24 ,
218 ,
241 ,
16 ,
98 ,
241 ,
129
} ;
public static byte [ ] byte_1 = new byte [ ]
{
24 ,
218 ,
241 ,
16 ,
98 ,
241 ,
144
} ;
public static byte [ ] byte_2 = new byte [ ]
{
24 ,
218 ,
241 ,
16 ,
127
} ;
public static byte byte_3 = 16 ;
2022-04-14 02:46:36 -07:00
public static byte [ ] byte_ToWrite = new byte [ ] { } ;
2022-04-13 23:39:25 -07:00
public static byte [ ] byte_4 = new byte [ 2097152 ] ;
private byte [ ] byte_5 = new byte [ ]
{
GForm_Main . byte_3 ,
127
} ;
private byte [ ] byte_6 = new byte [ 2 ] ;
private byte [ ] byte_7 ;
private static byte [ ] byte_8 = new byte [ ]
{
GForm_Main . byte_3 ,
20
} ;
private string string_2 = string . Empty ;
internal static Class_ECUS class9_0 ;
public static byte [ ] byte_9 = new byte [ ]
{
48 ,
6
} ;
public static byte [ ] byte_10 = new byte [ ]
{
16 ,
8
} ;
public static byte [ ] byte_11 = new byte [ ]
{
18 ,
7
} ;
private BackgroundWorker backgroundWorker_0 ;
2022-04-14 02:46:36 -07:00
private BackgroundWorker backgroundWorker_1 ;
2022-04-13 23:39:25 -07:00
private DateTime dateTime_0 ;
private long long_0 ;
private IContainer icontainer_0 ;
private DarkButton darkButton_0 ;
2022-04-14 02:46:36 -07:00
private DarkButton darkButton_DownloadROM ;
2022-04-13 23:39:25 -07:00
private DarkButton darkButton_2 ;
private DarkButton darkButton_3 ;
private DarkTextBox darkTextBox_0 ;
private DarkGroupBox darkGroupBox_0 ;
private DarkLabel darkLabel_0 ;
private DarkLabel darkLabel_1 ;
private DarkLabel darkLabel_2 ;
private DarkLabel darkLabel_3 ;
private DarkLabel darkLabel_4 ;
private DarkLabel darkLabel_5 ;
private DarkTextBox darkTextBox_1 ;
private DarkTextBox darkTextBox_2 ;
private DarkTextBox darkTextBox_3 ;
private DarkTextBox darkTextBox_4 ;
private DarkButton darkButton_4 ;
2022-04-19 02:07:30 -07:00
private DarkButton darkButton_FlashRom ;
2022-04-13 23:39:25 -07:00
private DarkButton darkButton_6 ;
private DarkProgressBar darkProgressBar_0 ;
private DarkLabel darkLabel_7 ;
private DarkLabel darkLabel_8 ;
private DarkButton darkButton1 ;
2022-04-14 02:46:36 -07:00
private DarkButton darkButton_Unlock41 ;
2022-04-13 23:39:25 -07:00
private delegate void Delegate0 ( string text ) ;
[CompilerGenerated]
private sealed class Class5
{
public Class5 ( )
{
}
internal void method_0 ( )
{
this . gform0_0 . darkTextBox_0 . AppendText ( this . string_0 + Environment . NewLine ) ;
}
public GForm_Main gform0_0 ;
public string string_0 ;
}
[CompilerGenerated]
private sealed class Class6
{
public Class6 ( )
{
}
internal void method_0 ( )
{
this . gform0_0 . darkTextBox_0 . AppendText ( "Read Memory Starts" + Environment . NewLine ) ;
}
internal void method_1 ( )
{
this . gform0_0 . darkTextBox_0 . AppendText ( "Invalid Block size detected" + Environment . NewLine + string . Format ( "Buffer :{0} != blockSize {1} " , this . byte_0 . Length , this . uint_0 ) + Environment . NewLine ) ;
}
public GForm_Main gform0_0 ;
public byte [ ] byte_0 ;
public uint uint_0 ;
public MethodInvoker methodInvoker_0 ;
}
[CompilerGenerated]
private sealed class Class7
{
public Class7 ( )
{
}
internal void method_0 ( )
{
this . class6_0 . gform0_0 . darkTextBox_0 . AppendText ( string . Format ( "Failed block read at: {0}" , this . uint_0 ) + Environment . NewLine ) ;
}
internal void method_1 ( )
{
this . class6_0 . gform0_0 . darkTextBox_0 . AppendText ( string . Format ( "block read at: {0}" , this . uint_0 ) + Environment . NewLine ) ;
}
public uint uint_0 ;
public GForm_Main . Class6 class6_0 ;
}
[CompilerGenerated]
private sealed class Class8
{
public Class8 ( )
{
}
internal void method_0 ( )
{
this . gform0_0 . darkLabel_5 . Text = "Download Rate: " + this . double_0 . ToString ( ) ;
}
public GForm_Main gform0_0 ;
public double double_0 ;
}
2022-04-18 01:06:03 -07:00
private void darkButton2_Click_1 ( object sender , EventArgs e )
{
2022-04-20 22:32:03 -07:00
this . openFileDialog1 . Filter = "Honda Compressed RWD Firmware|*.gz;*.rwd" ;
this . openFileDialog1 . DefaultExt = "*.gz" ;
2022-04-18 01:06:03 -07:00
DialogResult result = openFileDialog1 . ShowDialog ( ) ;
if ( result = = DialogResult . OK )
{
2022-04-19 02:07:30 -07:00
Class_RWD . LoadRWD ( openFileDialog1 . FileName , true , true ) ;
}
}
private void GForm_Main_Load ( object sender , EventArgs e )
{
}
private void darkButton3_Click_1 ( object sender , EventArgs e )
{
GForm_ConvertBIN gform = new GForm_ConvertBIN ( ) ;
if ( gform . ShowDialog ( ) = = DialogResult . OK )
{
string ThisB = gform . FileBIN ;
string ThisR = gform . FileRWD ;
gform . Dispose ( ) ;
2022-04-20 22:32:03 -07:00
2022-04-19 02:07:30 -07:00
Class_RWD . LoadBIN ( ThisB , ThisR ) ;
2022-04-18 01:06:03 -07:00
}
2022-04-20 22:32:03 -07:00
}
private void darkButton4_Click ( object sender , EventArgs e )
{
//this.openFileDialog1.Filter = "Honda Compressed RWD Firmware|*.gz;*.rwd";
this . openFileDialog1 . Filter = "Honda full binary rom file|*.bin|Honda decompressed firmware binary|*.bin" ;
this . openFileDialog1 . DefaultExt = "*.bin" ;
DialogResult result = openFileDialog1 . ShowDialog ( ) ;
if ( result = = DialogResult . OK )
{
if ( openFileDialog1 . FilterIndex = = 1 )
{
byte [ ] FilesBytes = File . ReadAllBytes ( openFileDialog1 . FileName ) ;
2022-04-24 16:05:27 -07:00
if ( ( FilesBytes . Length - 1 ) = = 0xFFFFF )
2022-04-20 22:32:03 -07:00
{
byte [ ] NewFilesBytes = VerifyChecksumFullBin ( FilesBytes ) ;
if ( NewFilesBytes ! = FilesBytes )
{
string NewPath = Path . GetDirectoryName ( openFileDialog1 . FileName ) + @"\" + Path . GetFileNameWithoutExtension ( openFileDialog1 . FileName ) + "_FixedChkSum.bin" ;
File . Create ( NewPath ) . Dispose ( ) ;
File . WriteAllBytes ( NewPath , NewFilesBytes ) ;
this . method_1 ( "File saved: " + NewPath ) ;
}
}
else
{
this . method_1 ( "This file is not compatible!" ) ;
2022-05-07 17:39:50 -07:00
if ( ( FilesBytes . Length - 1 ) = = 0xF7FFF ) this . method_1 ( "Try changing the file extention filter in the 'OpenFileDialog' box" ) ;
2022-04-20 22:32:03 -07:00
}
}
if ( openFileDialog1 . FilterIndex = = 2 )
{
2022-05-07 17:39:50 -07:00
/ * byte [ ] FilesBytes = File . ReadAllBytes ( openFileDialog1 . FileName ) ;
int BtSumInt = this . Editortable_0 . CheckForBootLoaderSum ( this . Editortable_0 . ExtractECUNameFromThisFile ( FilesBytes ) ) ;
if ( BtSumInt = = - 1 )
{
DarkMessageBox . Show ( this , "Since this decompressed firmware .bin file is missing the bootloader section\nSelect the firmware .rwd file from which is as been decompressed from" , "MISSING BOOTLOADER SECTION FOR CHECKSUMS VERIFICATIONS" , MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
//Open RWD firmware
openFileDialog1 . Filter = "Honda Compressed RWD Firmware|*.gz;*.rwd" ;
openFileDialog1 . DefaultExt = "*.gz" ;
DialogResult result = openFileDialog1 . ShowDialog ( ) ;
if ( result = = DialogResult . OK )
{
Class_RWD . LoadRWD ( openFileDialog1 . FileName , true , false ) ;
}
}
else
{
Class_RWD . BootloaderSum = ( byte ) BtSumInt ;
} * /
2022-04-20 22:32:03 -07:00
GForm_FWChkSum gform = new GForm_FWChkSum ( ) ;
gform . FileBIN = openFileDialog1 . FileName ;
if ( gform . ShowDialog ( ) = = DialogResult . OK )
{
string ThisB = gform . FileBIN ;
string ThisR = gform . FileRWD ;
gform . Dispose ( ) ;
byte [ ] FilesBytes = File . ReadAllBytes ( ThisB ) ;
2022-04-24 16:05:27 -07:00
if ( ( FilesBytes . Length - 1 ) = = 0xF7FFF )
2022-04-20 22:32:03 -07:00
{
Class_RWD . LoadRWD ( ThisR , true , false ) ;
byte [ ] NewFilesBytes = VerifyChecksumFWBin ( FilesBytes ) ;
if ( NewFilesBytes ! = FilesBytes )
{
string NewPath = Path . GetDirectoryName ( ThisB ) + @"\" + Path . GetFileNameWithoutExtension ( ThisB ) + "_FixedChkSum.bin" ;
File . Create ( NewPath ) . Dispose ( ) ;
File . WriteAllBytes ( NewPath , NewFilesBytes ) ;
this . method_1 ( "File saved: " + NewPath ) ;
}
}
else
{
this . method_1 ( "This file is not compatible!" ) ;
2022-05-07 17:39:50 -07:00
if ( ( FilesBytes . Length - 1 ) = = 0xFFFFF ) this . method_1 ( "Try changing the file extention filter in the 'OpenFileDialog' box" ) ;
2022-04-20 22:32:03 -07:00
}
}
}
}
}
private void darkButton5_Click ( object sender , EventArgs e )
{
frmOBD2Scan frmOBD2Scan_0 = new frmOBD2Scan ( ) ;
frmOBD2Scan_0 . Show ( ) ;
2022-04-18 01:06:03 -07:00
}
2022-04-24 02:49:42 -07:00
private void darkLabel_4_Click ( object sender , EventArgs e )
{
GForm_Credits GForm_Credits_0 = new GForm_Credits ( ) ;
GForm_Credits_0 . ShowDialog ( ) ;
}
2022-04-24 16:05:27 -07:00
private void darkButton6_Click ( object sender , EventArgs e )
{
try
{
this . Editortable_0 . Show ( ) ;
2022-05-07 17:39:50 -07:00
this . Editortable_0 . Loadingg ( ) ;
2022-04-24 16:05:27 -07:00
}
catch ( Exception ex )
{
try
{
this . Editortable_0 = null ;
this . Editortable_0 = new Editortable ( ref GForm_Main_0 ) ;
this . Editortable_0 . Show ( ) ;
2022-05-07 17:39:50 -07:00
this . Editortable_0 . Loadingg ( ) ;
2022-04-24 16:05:27 -07:00
}
catch
{
}
}
}
2022-05-07 17:39:50 -07:00
private byte [ ] GetBytesArrayFromCommandText ( )
{
string CMDText = darkTextBoxJ2534Command . Text ;
byte [ ] ReturnArray = new byte [ 0 ] ;
if ( CMDText ! = "" )
{
if ( CMDText . Contains ( "," ) )
{
string [ ] SplittedBytes = CMDText . Split ( ',' ) ;
ReturnArray = new byte [ SplittedBytes . Length ] ;
for ( int i = 0 ; i < SplittedBytes . Length ; i + + )
{
ReturnArray [ i ] = ( byte ) int . Parse ( SplittedBytes [ i ] , System . Globalization . NumberStyles . HexNumber ) ;
}
}
}
return ReturnArray ;
}
private void darkButtonJ2534Command_Click ( object sender , EventArgs e )
{
using ( API api = APIFactory . GetAPI ( GForm_Main . string_0 ) )
{
try
{
using ( Device device = api . GetDevice ( "" ) )
{
using ( Channel channel = device . GetChannel ( Protocol . ISO15765 , Baud . CAN , ConnectFlag . CAN_29BIT_ID , false ) )
{
LoadJ2534Channel ( channel ) ;
SendJ2534Message ( channel , GetBytesArrayFromCommandText ( ) , 3 ) ;
}
}
}
catch ( Exception ex )
{
DarkMessageBox . Show ( ex . Message ) ;
}
}
}
2022-04-13 23:39:25 -07:00
}