A bit of voodoo, black magic, pizza, some beer, and a hex editor ;)
Luckily the chinese didn't do half of what I had expected them to do, else we'd have been taking months to work it out - as it was it probably took us 3 or 4 evenings of combined efforts.