@echo off

@echo Waiting for device to be available.
tools\adb.exe wait-for-device
@echo Device detected...

@echo Getting root certifications...
tools\adb.exe push tools\rageagainstthecage /data/local/tmp/expl
tools\adb.exe shell "chmod 777 /data/local/tmp/expl"
tools\adb.exe shell "/data/local/tmp/expl"

@echo Waiting for device to be available.
tools\adb.exe wait-for-device
@echo Device detected...

@echo Removing restrictions of the Nand MPU...
tools\adb.exe push tools\fixPart /data/local/tmp/fixPart
tools\adb.exe shell "chmod 777 /data/local/tmp/fixPart"
tools\adb.exe shell "/data/local/tmp/fixPart"

@echo Restarting device.
tools\adb.exe shell reboot

@echo Waiting for device to be available.
tools\adb.exe wait-for-device
@echo Device detected...

@echo Regaining X10 Root access.
tools\adb.exe shell "/data/local/tmp/expl"

@echo Waiting for device to be available.
tools\adb.exe wait-for-device
@echo Device detected...

@echo Gaining access.
tools\adb.exe push tools\mapper_2.6.29.ko /data/local/tmp/mapper_2.6.29.ko
tools\adb.exe shell "chmod 777 /data/local/tmp/mapper_2.6.29.ko"
tools\adb.exe shell insmod /data/local/tmp/mapper_2.6.29.ko

@echo Patching X10 Bootloader.
tools\adb.exe push tools\qsd8250bootwrite_setool2SL /data/local/tmp/qsd8250bootwrite_setool2SL
tools\adb.exe shell "chmod 777 /data/local/tmp/qsd8250bootwrite_setool2SL"
tools\adb.exe shell "/data/local/tmp/qsd8250bootwrite_setool2SL"

@echo Patching completed. Restarting device to determine if bootloader has indeed been patched.
tools\adb.exe reboot bootloader
@echo If you see the white text "Sony Ericsson", please restart the bootloader unlock.