Saturday 28 March 2015

Add HitManPro to your Easy2Boot USB drive

A previous blog post here described how you can add and run HitManPro from an E2B USB Removable Flash drive (NTFS or FAT32). The E2B USB drive must be of the 'Removable' type - it won't work if your E2B  flash drive is of the Fixed-disk type (a USB HDD will not work either - Hitman will not auto-run when you boot to Windows).

HitmanPro needs to see a Removable USB drive which has some special code in the sectors at the very end of the USB drive (currently they use the very last 55 sectors).

I have written a grub4dos batch file HitManXfer.g4b (included in Easy2boot) which will transfer these sectors from a valid HitManPro USB Flash drive to the end of your E2B USB flash drive.




To run the batch file, just exit from the E2B menu to the grub4dos console (press SHIFT+P enter the password 'easy2boot', and then type SHIFT+C) and then type: HitmanXfer in the grub4dos console.

The batch file makes a BIOS call to obtain the exact physical size (and thus the last sector) of each USB drive using the grub4dos executable 'bios' which is already present in E2B.

I had some problems when accessing sectors near the end of an NTFS E2B drive and have reported the problem to chenall. That is why some of the code may seem rather 'obtuse' and uses BIOS calls instead of dd to copy sectors.

The batch file is shown below for your interest:

!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 you 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..
# set available buffer space before BIOS call is made

write 0x60000 0x42 > nul
write 0x60010 0 > nul
# get size of disk from INT 13h AH=48 into memory at DS:DI+10h
/%grub%/bios int=0x13 eax=0x4800 edx=0x8%DISK% ds=0x6000 edi=0x0 > nul
#cat --hex --length=0x20 (md)0x300+1
read 0x60010 > nul
set /A END=%@retval%-1 > nul
# 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!

# set available buffer space before BIOS call is made

write 0x60000 0x42 > nul
write 0x60010 0 > nul
# get size of disk from INT 13h AH=48 into memory at DS:DI+10h
/%grub%/bios int=0x13 eax=0x4800 edx=0x8%EDISK% ds=0x6000 edi=0x0 > nul
read 0x60010 > nul
set /A EEND=%@retval%-1 > nul
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

Note: If you run this and it shows errors or doesn't seem to work correctly, try loading the grub4dos USB 2.0 driver from the E2B Utilities menu first, before you run the batch file from the console.

Don't bother to try it on a large E2B USB hard disk, HitManPro will not work when you boot to Windows because it only auto-runs if the special 'HitManPro' sectors are detected at the end of a removable drive!

Tip: If you get write errors from grub4dos, reboot E2B and press the 'S' key just as it boots (for 'safe mode') - you should see a 5-second wait message. Then run the script again.

Using a Virtual Machine

Note: Due to what seems like a bug in VirtualBox SATA\SAS\SCSI handlers, this batch file may not work due to VBox returning invalid sector data for the last 60 or so sectors at the end of the USB drive (but it does work if the VM Mass Storage controller is an IDE controller with the USB drives attached under it)! This may be fixed in later versions of VBox.
Note that booting E2B or a HitManPro USB flash drive using a VM (e.g. VBox) will not work if the USB drive appears as a virtual hard disk in the VM - it must appear as a Removable drive!

No comments:

Post a Comment