ma1co / fwtool.py

A tool to unpack Sony camera firmware images
MIT License
159 stars 30 forks source link

FWTool print_backup Error: Wrong Magic #27

Open CyberUSB opened 4 years ago

CyberUSB commented 4 years ago

FWTool fails and gives an error message when trying to decode the Backup.bin taken from a DSC-WX80 camera.

ftool-v1.2-win.exe print_backup -f "Backup.bin"

Traceback (most recent call last):
  File "<string>", line 297, in <module>
  File "<string>", line 289, in main
  File "<string>", line 249, in printBackupCommand
  File "fwtool\sony\backup.py", line 47, in readBackup
Exception: Wrong magic
fwtool returned -1
CyberUSB2 commented 3 years ago

"Magic" refers to the code sequence at the start of files, which is used to identify the file type.

The backup.bin for the WX80 starts with 00 00 EC 92, but firmwaretool.py is looking for 00 00 EC 82

The answer to this problem is to change the code for the file fwtool/sony/backup.py on line 17 from

backupHeaderMagic = [0x82ec0000, 0x832c0000]

to:

backupHeaderMagic = [0x82ec0000, 0x832c0000, 0x92ec0000]

Then fwtool.py will correctly recognise the backup.bin from a WX80.

Alternatively, edit the backup.bin for the WX80 in a hex editor and change the "magic bytes" start sequence from:

00 00 EC 92

to:

00 00 EC 82