!BAT
clear
setlocal
echo
echo HitManPro Transfer Batch File
echo -e =============================
echo
echo This transfers the HitManPro sectors at the end of a HitManPro USB Flash drive
echo to the Easy2Boot USB drive (NTFS or FAT32).
echo The Easy2Boot USB flash drive must be of the Removable type.
echo
echo 1. Make your HitManPro USB Flash drive using the Windows tool provided
echo 2. Connect the E2B drive and the HitManPro drive to a REAL System (not a VM)
echo 3. Boot from the E2B drive and run this batch file
echo 4. Add the HitManPro files to the root of the E2B drive
echo 5. Add the HitManPro .mnu file to the E2B \_ISO\MAINMENU folder.
echo
# get size of disk
debug 1
find /HitManPro.exe > (md)0x300+1
cat --locate=(hd1 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 1
cat --locate=(hd2 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 2
cat --locate=(hd3 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 3
cat --locate=(hd4 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 4
cat --locate=(hd5 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 5
cat --locate=(hd6 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 6
cat --locate=(hd7 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 7
cat --locate=(hd8 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 8
cat --locate=(hd9 (md)0x300+1 > nul && echo $[0xe]HitManPro.exe found on Drive 9
echo
set ask=
set /p ask=Please enter Disk Number of HitManPro USB Drive : 
set DISK=%ask% > nul
if "%DISK%"=="" exit
set /a DISK=%DISK%+0 > nul
if not exist (hd%DISK%,0)/HitManPro.exe echo $[0xc]ERROR: HitManPro.exe not found on hd%DISK%! && pause && exit
echo
echo
echo Please wait..
write 0x60010 0 > nul
# set available buffer space before BIOS call is made
write 0x60000 0x42 > nul
# get size of disk from INT 13h AH=48 into memory at DS:SI+10h
/%grub%/bios int=0x13 eax=0x4800 edx=0x8%DISK% ds=0x6000 esi=0x0 > nul
#cat --hex --length=0x20 (md)0x300+1
read 0x60010 > nul
set /A END=%@retval%-1 > nul
if %END%<=0 echo Drive too big! && exit
# go back 2 tracks sectors
set /A END1=%END%-63 > nul
# find hitman sectors at end of disk
cat --locate=\x53\x4e\x00\x00 --number=1 --locate-align=0x200 (hd%DISK%)%END1%+63 > nul || echo -e \n$[0xc]ERROR: HitMan code not found after sector (hd%DISK%)%END1%\nPlease use a REAL system, not a VM! && pause && exit
set /A START=%?%/0x200+%END1% > nul
set /A LENGTH=%END%-%START%+1 > nul
echo
echo $[0xe]HitMan code found at end of Disk %DISK%
echo HD%DISK% Start=%START%  Length=%LENGTH% sectors
echo

# Now get size of E2B drive
set EDISK=0
if not exist (hd%EDISK%,0)/_ISO/e2b/grub/E2B.cfg if not exist (hd%EDISK%,1)/_ISO/e2b/grub/E2B.cfg echo $[0xc]WARNING: E2B not on Disk 0!

write 0x60010 0 > nul
# set available buffer space before BIOS call is made
write 0x60000 0x42 > nul
# get size of disk from INT 13h AH=48 into memory at DS:SI+10h
/%grub%/bios int=0x13 eax=0x4800 edx=0x8%EDISK% ds=0x6000 esi=0x0 > nul
read 0x60010 > nul
set /A EEND=%@retval%-1 > nul
if %EEND%<=0 echo Drive too big! && exit
set /A ESTART=%EEND%-%LENGTH%+1 > nul
echo E2B drive ends at Sector %EEND%
# Now copy from Hitman Pro drive to E2B drive
echo Copying Disk %DISK%: Start sector=%START%  Length=%LENGTH% sectors to Disk %EDISK% Sector %ESTART%
#echo dd if=(hd%DISK%)%START%+%LENGTH% of=(hd%EDISK%)%ESTART%+%LENGTH%
echo
set ask=
set /p ask=OK to transfer sectors from hd%DISK% to hd%EDISK% (Y/[N]) : 
echo
if /i "%ask%"=="Y" dd if=(hd%DISK%)%START%+%LENGTH% of=(hd%EDISK%)%ESTART%+%LENGTH%  > nul || echo ERROR: Copy failed! && exit
# Check if it worked
cat --locate=\x53\x4e\x00\x00 --number=1 --locate-align=0x200 (hd%EDISK%)%ESTART%+63 > nul || echo -e \n$[0xc]ERROR: HitMan code not found after (hd%EDISK%)%END1% - copy failed!  && pause && exit
# check last sector

dd if=(hd%DISK%)%END%+1 of=(md)0x300+1 > nul
read 0x60000 > nul
set /A A=%@retval% > nul
dd if=(hd%EDISK%)%EEND%+1 of=(md)0x301+1 > nul
read 0x60200 > nul
set /A B=%@retval% > nul
if not "%A%"=="%B%" echo -e \n$[0xc]ERROR: Hitman code not correctly copied! && pause && exit
echo
echo $[0xf]HitManPro sectors copied OK


