;---------- Parameter ----------
/F:
/VERIFY
/ERASE
/FWVER
/BINVER
/APPVER
/BACKUP
/BACKUP /1KADDR:
/CHECKDEVICE
/FORCEUPDATE
/SILENT
/GENDIGISIGN (need to set SECURITYUPDATE=1 in SHFU.ini file , and ITE USB Token)
/COMPAREVER
/RESET
/NOSKIN
/MULTIPROGRAM
/VERSION
/JUMPTOBOOTDEVICE

;---------- Exit Code ----------
0/100 - Result: Firmware update Success
0/100 - Result: Firmware Verify Success
0/100 - Result: Firmware Erase Success
101 - Result: Check Device OK
102 - Result: Firmware Up to Date
103 - Result: Downgrade not allowed
;104 - Result: Current Ver:
105 - Result: Generate Digital Signature OK
106 - Result: Can't find Main Device after Exit Flash Mode
107 - Result: Jump To Boot Device
201 - Result: Enable Main Device is Error
202 - Result: Fail to Enter Flash Mode203 - Result: Can't find any Device
203 - Result: Can't find any Device
204 - Result: Firmware update Fail (Compare fail)
204 - Result: Firmware Verify Fail
205 - Result: Fail to Exit Flash Mode(Reset the Device)
206 - Result: Can't find Main Device after Remove&Rescan
301 - Result: Can not find the SHFU.ini
302 - Result: Not more than two update files in the same folder
303 - Result: Bin file size is not match
304 - Result: Checksum Error
305 - Result: Can not find the update file by parameter
306 - Result: Can not find update file or wrong file name (*.bin)
;307 - Result: Payload Ver:
;308 - Result: AppVer:
309 - Result: No Digital Signature in Bin file
310 - Result: Verify Digital Signature Fail
311 - Result: Generate Digital Signature Fail
312 - Result: User Abandon Update
313 - Result: Can't find the same ID as FW in multiple BIN files
401 - Result: APP Times Out

;---------- Flash State Value ----------
00: Find Main Device
01: Enter Key to Enable communication
02: Read FW Version via Main Device
03: Enter Flash Mode
04: Find Boot Device
05: Read FW Version via Boot Device
06: Erase fw
07: Program fw
08: Verify fw
09: Exit Flash Mode, Reset and jump to Main Device
10: Check Ready for Main Device
11: Remove&Rescan for MainDevice
12: Check Ready for Main Device
100: Firmware update Success
107: Jump To Boot Device

;---------- ReleaseNote ----------
v4.1.36
The number of scanned files increased from 16 to 128 for CHECK2BYTESFWID function.

v4.1.35
1.Supports multiple language paths
2.The file format of ITESHFUlog.txt has been changed from UTF-16LE to UTF-8

v4.1.34
1.Optimize the behavior of IdThreadComponent1 to avoid the thread no start after it stop.

v4.1.33
1.Add WARNING of [CLOSEAPP] in ini to close app when ExitCode is 10x

v4.1.32
1.Enhanced Check2BytesFWID function
  a.ID compare ok, save the ID to RegistryKey, and clear RegistryKey when Firmware update Success
  b.ID compare fail, read the ID from RegistryKey, and compare it again then continue the process

v4.1.31
1.The function FWVERSIONREGISTRYPATH for v4.1.29, support "Result: Firmware update Success" and "Result: Firmware Up to Date"

v4.1.30
1.Add NOUPDATEBBK in ini to cancel the default action of updating BBK

v4.1.29
1.Add FWVERSIONREGISTRYPATH in ini to save the fw version into RegistryKey, when use /FWVER or /VERSION
ex:FWVERSIONREGISTRYPATH=HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ITE\LedDevice\9457 , and VERSIONISBCDFORMAT=4, and if fw version is v1.2.3.4, then RegistryKey will be FWVersion=01.02.03.04

v4.1.28.1
1.Adjust the sleep location for DELAYMSECAFTERFINDBOOTDEVICE/DELAYMSECAFTERFINDMAINDEVICE

v4.1.28
1.Add DELAYMSECAFTERFINDBOOTDEVICE,DELAYMSECAFTERFINDMAINDEVICE in ini to wait for a ms time after finding the device before sending the HID command.

v4.1.27
1.use the OS built-in pnputil.exe, if the system version is Win11_21H2 or above

v4.1.26
1.modify Check2BytesFWIDFROMBIN to Check2BytesFWIDFromBin
2.if Check2BytesFWIDFromBin=0, then address is used by Check2BytesFWID
3.The above functions support boot device, if main device fw is empty.

v4.1.25
1.Check2BytesFWIDFROMBIN in ini, the value is the address of Bin file.(by Bob)
2.modify IntToStr((_int64)ExitCode)) to IntToStr((long long)ExitCode)).(by Bob)

v4.1.24
1.Add NOCOUNTATSTATE0 in ini to ignore the counting behavior of finding the main device for the first time, it should be set to 1 when factory programming the IC.

v4.1.23
1.Add CHECK2BYTESFWID in ini to compare with FWID of fw and FWID of multiple BINs, the value of CHECK2BYTESFWID is the address.

v4.1.22
1.USB device do not support remove_rescan function on state_3_9
2.using PNPUTIL.exe to do remove_rescan on state_11
3.write FlashFlowState to Registry Key(HKEY_CURRENT_USER\Software\ITE\ITESHFU\FlashFlowState)
4.using ThreadComponent to replace Timer2 for RunFwUpdateFlow
5.add FLASHSTATELOG in ini to record the completed FlashFlowState in the Registry Key
6.optimize ThreadComponent function, such as using Start()/Stop() and setting StopMode's smSuspend
7.change the location where FlashFlowState is written to after RunFwUpdateFlow()
8.using Timer4 to do close APP function, avoid being unable to close app in the ThreadComponent function
9.show system time of finished state
10.add the meaning of each FlashStateValue in the readme file
11.add each state time and total time for state0/state4/state10/state12 when find main device and boot device for message log
12.add OLDREMOVERESCAN in ini to use old remove_rescan function(not PNPUTIL.exe)
13.add /JUMPTOBOOTDEVICE to stop at boot device
14.fix the invalid function and define 107 as return value for /JUMPTOBOOTDEVICE
15.ThreadComponent for normal, Timer for silent. avoid no return value when silent mode
16.Default Memo1->Visible=true, to aviod highlight and lag on the status bar for New C++Builder

v4.1.21
1.show system time of each state and GetLastError value of each HID command for message log

v4.1.20
1.add each state time and total time for state0/state4 when find main device and boot device for message log

v4.1.19
1.Add DOBURSTREADWRITEIFBOOTCODEISV04 in ini to speed up Read/Write time for New boot code v0.4
2.Fixed bug that no get checksum0 for VerifyDoFwCheckSum function

v4.1.18
1.Add NOASSIGNHWID in ini to auto get USB HWID from device attributese when NOCHECKPID=1

v4.1.17.1
1.need to enable device before read chip id at main device state
2.optimize the flow and message for check chip id

v4.1.17
1.Add MAINDEVICECHIPID in ini to make sure that app get the correct main device when NOCHECKPID=1

v4.1.16
1.add "/version" parameter to get fw version and save it to log file

v4.1.15.4
1.move "/subtree" parameter position to fix the issue that main device can not be removed but sub device can be removed

v4.1.15.3
1.add "/subtree" parameter to clear all registry of target device for PNPUTIL.exe

v4.1.15.2
1.using PNPUTIL.exe to do remove_rescan on state_11 by ShellExecuteEx command with SW_HIDE

v4.1.15.1
1.using PNPUTIL.exe to do remove_rescan on state_11 by WinExec command with SW_HIDE

v4.1.15
1.USB device do not support remove_rescan function on state_3_9
2.using PNPUTIL.exe to do remove_rescan on state_11 by std:system command

v4.1.14
1.Fix the issue of remove function that lost the first character of USB

v4.1.13
1.Check the ini and bin file with the path of executable file

v4.1.12
1. Add FIRSTBYTEOFOEMVERSION in ini to compare the first byte of OEM version when find main device.

v4.1.11
1. Add /MULTIPROGRAM function to open multi device with VID/PID/ChipID of ini file setting and open a device with exclusive access

v4.1.10
1. Add FINDMAINBOOTRETRY in ini to re-find main/boot device flow.

v4.1.9
1.Add /1KADDR: function to only backup 1k size with specified starting address, ex: /BACKUP /1KADDR:1f800

v4.1.8
1. Add /NOSKIN function to show default windows skin (no modern skin)
2. Fix AppForm height issue when debug message is enabled

v4.1.7
1. Add WRITERAMADDRESSONEDATA in ini to write a data to ram after update successful.

v4.1.6
1. Add REBOOTFLAG in ini to shutdown(1)/reboot(2) machine after update successful.

v4.1.5
1.Add VERIFYDOFWCHECKSUMIFBOOTCODEISV03 in ini to speed up verification time for New boot code v0.3

v4.1.4
1.Add TIMERRESET in ini to reset timer after read fw version command of bootcode and verify fail
2.add /RESET function to reset device(boot to main)

v4.1.3
1.fix the issue that show devcice infomation when can't find the device with PID 
2.add new PubKey of EvITE2022 for RSA4096

v4.1.2
1.Add ERASEFLASHCOMMANDDELAY in ini to set delay time(ms) for each erase command
2.use the new signature method

v4.1.1
1.Modify the color of the result status, PASS is green, FAIL is red

v4.1.0
1.REPORT_LEN get from the descriptor
2.support new protocol of boot code(v0.2), new API are cmd_set_data_ext/cmd_read_from_flash_ext/cmd_get_protocol_ver

v4.0.17
1.Add ERASEUNITKB in ini to set the unit size of erase 

v4.0.16
1.Add SUPPORTMINIBBK in ini to erase from bottom to top and write the first 1K at the beginning

v4.0.15
1.Add ROMCODESETEMPTY in ini to no verify Rom Code Data

v4.0.14
1.Check BBK and burn it, if it is empty or different with bin for Normal Update Flow

v4.0.13
1.suuport new ITE HSM token(2021) and new PubKey(RSA4096) and new app(SafeNetAuthenticationClient-x64-10.8)

v4.0.12
1.Add NOUPDATETHELAST1KB in ini to by pass the last 1 KB data

v4.0.11
1.Add SENSORHUBINTADDRESS in ini to disable Int before Enter Flash Mode For ASUS IT8353_I2C Project, because sensitivity=0

v4.0.10
1.Add DELAYMSECAFTERENTERFLASHMODE,DELAYMSECAFTEREXITFLASHMODE,DELAYMSECAFTERREMOVE,DELAYMSECAFTERRESCAN in ini for delay

v4.0.9
1.Add POPUPSFORNOTIFICATIONS in ini ,the notification string before update, If it's empty then won't show up

v4.0.8
1.Add FORMUIMODE in ini to change APP's UI

v4.0.7
1.Disable the close APP fuction of SystemMenu during the process
2.Add TITLENAME in ini to change APP's Title

v4.0.6
1.remove IsRunAsAdmin function
2.add 2st PubKey

v4.0.5
1.add /COMPAREVER function (need to set COMPAREVERSIONINDEX/COMPAREVERSIONLENGTH in SHFU.ini file, will return 0 when Firmware needs to be updated)

v4.0.4
1.add NoLogFile function, can set it on and off in the ini file
2.add Version BCD format for Hexadecimal
3.add IsRunAsAdmin function to check whether APP is running under the administrator level

v4.0.3
1.Add DelayMSec parameter in ini

v4.0.2
1.Add new format of fw version

v4.0.1
1.Change the timming of Timer close
2.Built-in a set of RSA2048 public and private keys

v4.0.0
1.New version officially released 