Latest Canon Cams refuses to boot our stuff. Naughty naughty naughty!
I'm running now the 860is firmware in qemu.
Handling the diskboot.bin starts at 0xff82bb44
At 0xff8650cc it becomes interesting:
Problems dumping the SD1100IS/IXUS80ISThe first byte must be 0x00 and it must not contain "gaonisoy". Next, it shifts the file 1 byte down.
At 0xff865008 we have the following situation: r0=r1=*file and r2=length.
What's happening there? Let's find out. First we make a macro in gdb:
define dekkode
x $r0=$r1=0x3000
x $r2=$arg0
j *0xff865008
x/16x 0x3000
end
and set a breakpoint at the end of this stuff:
b *0xff8650c8
On fresh bootup, 0x3000 is free:
(gdb) x/8x 0x3000
0x3000: 0x00000000 0x00000000 0x00000000 0x00000000
0x3010: 0x00000000 0x00000000 0x00000000 0x00000000
Let's run the decoder on these zeros:
(gdb) dekkode 64
0x3000: 0x00000000
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x00ffffa0 0xffa0ffff 0xffff00ff 0x00ffffa0
0x3010: 0xffa0ffff 0xffff00ff 0x00ffffa0 0xffa0ffff
0x3020: 0xffff00ff 0x00ffffa0 0xffa0ffff 0xffff00ff
0x3030: 0x00ffffa0 0xffa0ffff 0xffff00ff 0x00ffffa0
Hu? Looks like tic tac toe, 96bits.
Press Return to rerun another round:
(gdb)
0x3000: 0x00ffffa0
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x0a005f5f 0xff5f0000 0x00ffff5f 0xff0000a0
0x3010: 0x005f0000 0x00ff0a00 0x0a005f5f 0xff5f0000
0x3020: 0x00ffff5f 0xff0000a0 0x005f0000 0x00ff0a00
0x3030: 0x0a005f5f 0xff5f0000 0x00ffff5f 0xff0000a0
another:
(gdb)
0x3000: 0x0a005f5f
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xf5a0a0a0 0xf5a0ff00 0xa000005f 0x00ff005f
0x3010: 0xffa000ff 0xfff5f5ff 0xf5a0a0a0 0xf5a0ff00
0x3020: 0xa000005f 0x00ff005f 0xffa000ff 0xfff5f5ff
0x3030: 0xf5a0a0a0 0xf5a0ff00 0xa000005f 0x00ff005f
and another:
(gdb)
0x3000: 0xf5a0a0a0
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x0a5f5fa0 0x0a5f5f0a 0xa0ffffa0 0x0affffa0
0x3010: 0x00a00a00 0x000a0a00 0x0a5f5fa0 0x0a5f5f0a
0x3020: 0xa0ffffa0 0x0affffa0 0x00a00a00 0x000a0a00
0x3030: 0x0a5f5fa0 0x0a5f5f0a 0xa0ffffa0 0x0affffa0
Hey, it's free, so take another trip:
(gdb)
0x3000: 0x0a5f5fa0
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x0aa0a0aa 0xf5ffa0f5 0x5f00ff5f 0x0a0000aa
0x3010: 0xffaaf5ff 0xfff50aff 0x0aa0a0aa 0xf5ffa0f5
0x3020: 0x5f00ff5f 0x0a0000aa 0xffaaf5ff 0xfff50aff
0x3030: 0x0aa0a0aa 0xf5ffa0f5 0x5f00ff5f 0x0a0000aa
(gdb)
0x3000: 0x0aa0a0aa
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xaa5f0055 0xf5005f0a 0xa0000055 0xf5ffffaa
0x3010: 0x00550a00 0x00f5aa00 0xaa5f0055 0xf5005f0a
0x3020: 0xa0000055 0xf5ffffaa 0x00550a00 0x00f5aa00
0x3030: 0xaa5f0055 0xf5005f0a 0xa0000055 0xf5ffffaa
(gdb)
0x3000: 0xaa5f0055
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x55ffffaa 0x55ffa00a 0xaaffff55 0x0a00ff55
0x3010: 0xffaa0aff 0xff5555ff 0x55ffffaa 0x55ffa00a
0x3020: 0xaaffff55 0x0a00ff55 0xffaa0aff 0xff5555ff
0x3030: 0x55ffffaa 0x55ffa00a 0xaaffff55 0x0a00ff55
(gdb)
0x3000: 0x55ffffaa
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xaa0000aa 0xaa0000aa 0xaa0000aa 0xaa0000aa
0x3010: 0x00aaaa00 0x00aaaa00 0xaa0000aa 0xaa0000aa
0x3020: 0xaa0000aa 0xaa0000aa 0x00aaaa00 0x00aaaa00
0x3030: 0xaa0000aa 0xaa0000aa 0xaa0000aa 0xaa0000aa
(gdb)
0x3000: 0xaa0000aa
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xaaffff0a 0x55a0ff55 0x55ff0055 0xaaffff0a
0x3010: 0xff0a55ff 0xff55aaff 0xaaffff0a 0x55a0ff55
0x3020: 0x55ff0055 0xaaffff0a 0xff0a55ff 0xff55aaff
0x3030: 0xaaffff0a 0x55a0ff55 0x55ff0055 0xaaffff0a
(gdb)
0x3000: 0xaaffff0a
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xa0005ff5 0x555f00aa 0xaafffff5 0x5500000a
0x3010: 0x00f5aa00 0x0055a000 0xa0005ff5 0x555f00aa
0x3020: 0xaafffff5 0x5500000a 0x00f5aa00 0x0055a000
0x3030: 0xa0005ff5 0x555f00aa 0xaafffff5 0x5500000a
(gdb)
0x3000: 0xa0005ff5
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x5fa0a00a 0x5fa0ffaa 0x0a0000f5 0xaaff00f5
0x3010: 0xff0aaaff 0xff5f5fff 0x5fa0a00a 0x5fa0ffaa
0x3020: 0x0a0000f5 0xaaff00f5 0xff0aaaff 0xff5f5fff
0x3030: 0x5fa0a00a 0x5fa0ffaa 0x0a0000f5 0xaaff00f5
(gdb)
0x3000: 0x5fa0a00a
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xa05f5f0a 0xa05f5fa0 0x0affff0a 0xa0ffff0a
0x3010: 0x000aa000 0x00a0a000 0xa05f5f0a 0xa05f5fa0
0x3020: 0x0affff0a 0xa0ffff0a 0x000aa000 0x00a0a000
0x3030: 0xa05f5f0a 0xa05f5fa0 0x0affff0a 0xa0ffff0a
(gdb)
0x3000: 0xa05f5f0a
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xa0a0a000 0x5fffa05f 0xf500fff5 0xa0000000
0x3010: 0xff005fff 0xff5fa0ff 0xa0a0a000 0x5fffa05f
0x3020: 0xf500fff5 0xa0000000 0xff005fff 0xff5fa0ff
0x3030: 0xa0a0a000 0x5fffa05f 0xf500fff5 0xa0000000
(gdb)
0x3000: 0xa0a0a000
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x005f00ff 0x5f005fa0 0x0a0000ff 0x5fffff00
0x3010: 0x00ffa000 0x005f0000 0x005f00ff 0x5f005fa0
0x3020: 0x0a0000ff 0x5fffff00 0x00ffa000 0x005f0000
0x3030: 0x005f00ff 0x5f005fa0 0x0a0000ff 0x5fffff00
(gdb)
0x3000: 0x005f00ff
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0xffffff00 0xffffa0a0 0x00ffffff 0xa000ffff
0x3010: 0xff00a0ff 0xffffffff 0xffffff00 0xffffa0a0
0x3020: 0x00ffffff 0xa000ffff 0xff00a0ff 0xffffffff
0x3030: 0xffffff00 0xffffa0a0 0x00ffffff 0xa000ffff
(gdb)
0x3000: 0xffffff00
0x40: 0x00000000
Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()
0x3000: 0x00000000 0x00000000 0x00000000 0x00000000
0x3010: 0x00000000 0x00000000 0x00000000 0x00000000
0x3020: 0x00000000 0x00000000 0x00000000 0x00000000
0x3030: 0x00000000 0x00000000 0x00000000 0x00000000
So here we go. Encoding a diskboot.bin is simply decoding it 15 times:
(gdb) restore led/diskboot.bin binary 0x3000
Restoring binary file led/diskboot.bin into memory (0x3000 to 0x3088)
(gdb) dekkode 0x100
repeat 15 times
(gdb) dump memory outfile.bin 0x3000-1 0x3000+0x19000
The last commands writes out from 0x2fff, which is hopefully still 0x00 and we write out more so we have the necessary padding.
Pressing return 15 times is a matter of practise. So run the last round and you should see the unencoded binary again:
(gdb) dekkode 0x100