jack23912 / grub4dos-chenall

Automatically exported from code.google.com/p/grub4dos-chenall
0 stars 0 forks source link

usb --init causes sector access issues near end of disk #165

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create 32GB NTFS USB Flash drive or FAT16 512MB flash drive
2. Try to access near end of disk using batch file (see below)

cat --length=16 --hex (hd0)963965+1

works OK on 0.4.6a  2014-01-17

BUT If add 
usb --init
to start of menu.lst, the same batch file fails.

usb --init
cat --length=16 --hex (hd0)963965+1  -> FAILS
cat --length=16 --hex (hd0)963700+1  -> FAILS
cat --length=16 --hex (hd0)963600+1  -> OK

BATCH FILE IS:

!BAT

# check can access last sector - warn if problem (allow for >1TB drives)
if not "%?_BOOT:~1,1%"=="h" goto :EOF
setlocal
set result=0
echo -n %?_BOOT% > (md)0x3000+1
cat --locate=, --replace=)\x00 (md)0x3000+1
cat (md)0x3000+1 | set driv=
if "%driv%"=="" goto :skipca
dd if=%driv%+1 of=(md)0x3000+1 > nul

:: in case number is > 0x80000000 divide by 4
set /a s1=*0x6001c6 & 0xffffffff >>2 > nul
set /a l1=*0x6001ca & 0xffffffff >>2 > nul
set /a s2=*0x6001d6 & 0xffffffff >>2 > nul
set /a l2=*0x6001da & 0xffffffff >>2 > nul
set /a s3=*0x6001e6 & 0xffffffff >>2 > nul
set /a l3=*0x6001ea & 0xffffffff >>2 > nul
set /a s4=*0x6001f6 & 0xffffffff >>2 > nul
set /a l4=*0x6001fa & 0xffffffff >>2 > nul

set s=%s1% && set l=%l1%
if %s2%>=%s% set s=%s2% && set l=%l2%
if %s3%>=%s% set s=%s3% && set l=%l3%
if %s4%>=%s% set s=%s4% && set l=%l4%
set /a lba=%s%+%l%-1  > nul
set /a lba=%lba%<<2 > nul
echo Last Sector of last partition of %driv% is %lba%   %redir%
echo -n Checking last sector is accessible...   %redir%
cat --length=16 --hex %driv%%%lba%+1 > nul && set result=1

if "%result%"=="1" echo BIOS OK %redir% || echo $[0114]BIOS BAD! && pause 
--wait=2 WARNING: THIS BIOS MAY HAVE PROBLEMS ACCESSING FILES ON THIS DRIVE!
:skipca

endlocal

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
0.4.6a 2014-01-17

Please provide any additional information below.

Original issue reported on code.google.com by Steve6375 on 6 Feb 2014 at 11:52

GoogleCodeExporter commented 8 years ago
On 32GB USB Flash drive (NTFS)

after using usb --init

block 62603125+1  OK
block 62603126+1  FAILS

without usb --init
block 62605296+1  OK

Original comment by Steve6375 on 6 Feb 2014 at 12:10

GoogleCodeExporter commented 8 years ago
Please try this.

Original comment by yaya2007_7777@126.com on 17 Feb 2014 at 7:15

Attachments:

GoogleCodeExporter commented 8 years ago
Can now access sectors up to and past the end of the drive.

e.g. without using usb --init and access past end of 32GB flash drive:
cat --length=16 --hex (hd0)64627460+1  takes a few minutes and then shows
00000000: 55 53 42 53  D3 25 00 00 00 02 00 00  01 41 44 3f : USBS......AD?

Is this a USB packet data?

If I add  usb --init, then it hangs on same cat command.

Original comment by Steve6375 on 17 Feb 2014 at 10:43

GoogleCodeExporter commented 8 years ago
Don't know, You can use the WINHEX to look.

Original comment by yaya2007_7777@126.com on 18 Feb 2014 at 1:20

GoogleCodeExporter commented 8 years ago
WinHEx (or any Windows program) will not allow access past the last sector of 
the reported size of the disk.

Original comment by Steve6375 on 24 Feb 2014 at 9:18