Jump to content











Photo
* * * * * 1 votes

Grub4dos Find and boot


  • Please log in to reply
113 replies to this topic

#101 steve6375

steve6375

    Platinum Member

  • Developer
  • 7107 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 30 May 2013 - 01:26 PM

You're right, after boot will be ignored but I'm thinking at the situation when the user doesn't choose an OS (or the boot fails) and returns to the main menu. Maybe other script will try to use that memory area...

Maybe I'm worrying too much for this :D, after all it's a very small chance for this to happen...

 

It is just bytes in memory - if rd is re-used, then all that happens is that rd-base may be set to a different value (or the same) and bytes are loaded into memory in a different place (or the same place). The 'ram drive' is not a real drive, it is just a set of memory pointers + values, which point to a particular area in memory.



#102 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 30 May 2013 - 01:41 PM

Ok :)

 

The script:

 







!BAT
setlocal
clear
echo Please wait, searching...
find --devices=h > (md)0x220+8
set SKIPPED=0
set N=0
set TMSZ=0
set BDN=-1
set DETTYPE=ver
#########   if the batch file was started with /abd as parameter it will not search
#########   on boot device (if it's seen as a HDD). Usually is the USB drive (hd0)
if "%1"=="/abd" if "%?_BOOT:~1,2%"=="hd" set BDN=%?_BOOT:~3,1%
if "%2"=="/abd" if "%?_BOOT:~1,2%"=="hd" set BDN=%?_BOOT:~3,1%
#########   if the batch file was started with /fd as parameter it will use
#########   a faster OS type detection but with slightly less accuracy
if "%1"=="/fd" set DETTYPE=len && goto :skrd
if "%2"=="/fd" set DETTYPE=len && goto :skrd
map --ram-drive=0x9f 
:skrd
:loop
cat --skip=%SKIPPED% --number=1 --locate=" (hd" (md)0x220+8  | set PPOSB=
if "%PPOSB%"=="" goto endloop
set /a SKIPPED=0x%PPOSB%+7 > nul
cat --skip=%SKIPPED% --number=1 --locate=")" (md)0x220+8  | set PPOSE=
if "%PPOSE%"=="" goto endloop
set /a PPOSL=0x%PPOSE%-0x%PPOSB% > nul
set /a SKIPPED=0x%PPOSB%+1 > nul
cat --skip=%SKIPPED% --length=%PPOSL% --locate=" " (md)0x220+8 && set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
cat --skip=%SKIPPED% --length=%PPOSL% --locate="," --number=1 (md)0x220+8 | set CPOS=
if "%CPOS%"=="" set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
set /a PNL=0x%PPOSE%-0x%CPOS%-1 > nul
set /a SKIPPED=0x%CPOS%+1 > nul
cat --skip=%SKIPPED% --length=%PNL% (md)0x220+8 | set PN=
set /a HDNL=0x%CPOS%-0x%PPOSB%-4 > nul
set /a SKIPPED=0x%PPOSB%+4 > nul
cat --skip=%SKIPPED% --length=%HDNL% (md)0x220+8 | set HDN=

if %PN%>=4 goto :notgood
if %BDN%==%HDN% goto notgood
checkrange 0x06:0x0e parttype (hd%HDN%,%PN%) > nul || goto :notgood

ls (hd%HDN%,%PN%)/ > (md)0x300+8
cat --locate=\0 --number=1 (md)0x300+8 | set ENDFILE=
set /a ENDFILE=0x%ENDFILE% > nul
if not "%ENDFILE%"=="0" write --offset=%ENDFILE% (md)0x300+8 \ \0 > nul

cat --locate=" ntldr " --number=1 (md)0x300+8 > nul || goto :nont
cat --length=0 (hd%HDN%,%PN%)/ntldr | set NTS=
set /a NTS=0x%NTS:~14% > nul
if %NTS%<=76799 goto :nont
if %NTS%>=1048577 goto :nont
set /a N=%N%+1 > nul
set CLCMD=chainloader
if "%DETTYPE%"=="ver" goto :ntver
:ntlen
if %NTS%>=268976 set OS=\ XP\ 64-bit\ or\ Server\ 2003 && goto :esnt
if %NTS%>=218976 set OS=\ XP && goto :esnt
if %NTS%>=185208 set OS=\ 2000 && goto :esnt
set OS=\ NT
set CLCMD=chainloader --force --load-segment=0x2000
goto :esnt
:ntver
set majver=0
set minver=0
map --mem=0x11000 (hd%HDN%,%PN%)/ntldr (rd) > nul || goto :ntlen
cat --hex --number=1 --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (rd)+1 > nul
set /a offbase = %?% + 28 > nul
if "%offbase%"=="29" goto :ntlen
cat --hex --length=5 --skip=%offbase% (rd)+1 | set line=
set majver=%line:~-5,1%
set minver=%line:~-1,1%
set OS=
if %majver%<=4 set OS=\ NT && set CLCMD=chainloader\ --force\ --load-segment=0x2000 && goto :esnt
if "%majver%%%minver%"=="50" set OS=\ 2000 && goto :esnt
if "%majver%%%minver%"=="51" set OS=\ XP && goto :esnt
if "%majver%%%minver%"=="52" set OS=\ XP 64-bit or Server 2003
:esnt

if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\n%CLCMD% (hd%HDN%,%PN%)/ntldr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth
set STATUS=
set HIDST=
hiddenflag (hd%HDN%,%PN%) > nul && set HIDST=\ (hidden) && set UNHCOM=\r\nunhide (hd%HDN%,%PN%) \> nul

set BWINM%N%=title Boot to Windows%OS% on %HDNT% HDD, %PNT% partition%HIDST%\\nUsually the %HDNTR%... %UNHCOM%%%REMAP%\r\nroot (hd0,%PN%) \> nul\r\%CLCMD% /ntldr%AFTERR%\r\n
call call Fn.12 "%^BWINM%N%%%"
set /a TMSZ=%TMSZ%+%@retval% > nul
:nont

cat --locate=" bootmgr " --number=1 (md)0x300+8 > nul || goto :nomgr
cat --length=0 (hd%HDN%,%PN%)/bootmgr | set MGRS=
set /a MGRS=0x%MGRS:~14% > nul
if %MGRS%<=204799 goto :nomgr
if %MGRS%>=1572865 goto :nomgr
if "%DETTYPE%"=="ver" goto :mgrver
if %MGRS%==438840 set OS=\ Vista && goto :esmgr
:mgrlen
if %MGRS%>=390971 set OS=\ 8 or Server 2012 && goto :esmgr
if %MGRS%>=358410 set OS=\ 7 or Server 2008 && goto :esmgr
set OS=\ Vista or Server 2008
:mgrver
set majver=0
set minver=0
map --mem=0x11000 (hd%HDN%,%PN%)/bootmgr (rd) > nul || goto :mgrlen
cat --hex --number=1 --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (rd)+1 > nul
set /a offbase = %?% + 28 > nul
if "%offbase%"=="29" goto :mgrlen
cat --hex --length=5 --skip=%offbase% (rd)+1 | set line=
set majver=%line:~-5,1%
set minver=%line:~-1,1%
set OS=
if "%majver%%%minver%"=="60" set OS=\ Vista or Server 2008 && goto :esmgr
if "%majver%%%minver%"=="61" set OS=\ 7 or Server 2008 R2 && goto :esmgr
if "%majver%%%minver%"=="62" set OS=\ 8 or Server 2012
:esmgr
set /a N=%N%+1 > nul
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\nchainloader (hd%HDN%,%PN%)/bootmgr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth
set HIDST=
set UNHCOM=
hiddenflag (hd%HDN%,%PN%) > nul && set HIDST=\ (hidden) && set UNHCOM=\r\nunhide (hd%HDN%,%PN%) \> nul

set BWINM%N%=title Boot to Windows%OS% on %HDNT% HDD, %PNT% partition%HIDST%\\nUsually the %HDNTR%...%UNHCOM%%%REMAP%\r\nroot (hd0,%PN%) \> nul\r\nchainloader /bootmgr%AFTERR%\r\n
call call Fn.12 "%^BWINM%N%%%"
set /a TMSZ=%TMSZ%+%@retval% > nul
:nomgr

:notgood

set /a SKIPPED=0x%PPOSE%+2 > nul
goto :loop
:endloop

if not %N%==0 goto :not0
endlocal
clear
echo No bootable Windows NT/2000/XP/Vista/7/8 partitions found, returning to main menu...
pause --wait=5 || goto :finish
goto :finish
:not0

set I=0
set OFFSET=0
set /a N=%N%+1 > nul
call Fn.12 "\r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0"
set /a MBSZ=%TMSZ%+%@retval%/512+1 > nul
:wloop
set /a I=%I%+1 > nul
if %I%>=%N% goto :endwloop
call write --offset=%OFFSET% (md)0x300+%MBSZ% %^BWINM%I%%% > nul
call call Fn.12 "%^BWINM%I%%%"
set /a OFFSET=%OFFSET%+%@retval% > nul
goto :wloop
:endwloop
write --offset=%OFFSET% (md)0x300+%MBSZ% \r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0 > nul

endlocal && set MBSZ=%MBSZ%
configfile (md)0x300+%MBSZ%
:finish

 

 



#103 steve6375

steve6375

    Platinum Member

  • Developer
  • 7107 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 30 May 2013 - 02:41 PM

Interesting comment from tinybit with regard to (md)  (and presumably (rd))!!!

 

physical address range from 1M to 32M is reserved for grub4dos internal code and data. Users should not use this range.

32MB = 0x2000000  or (md)0x10000

 

If we shouldn't use it then why no warning!!!



#104 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 30 May 2013 - 03:45 PM

Interesting comment from tinybit with regard to (md)  (and presumably (rd))!!!

 

32MB = 0x2000000  or (md)0x10000

 

If we shouldn't use it then why no warning!!!

 

Yes, that's interesting, if not even a little strange...

 

Anyway, to be on the safe side, I changed 0x3000 in 0x11000 in the script.



#105 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 May 2013 - 05:43 AM

I tested dd speed again with (md)0x11000, no change.
But I found other way to increase its speed: using buflen=1MB as parameter.
Without it it's 3.55 times slower than map --mem. With it it's only 1.39 times slower. It's good but obviously I will still use map --mem.
Increasing to 10MB or 100MB doesn't help (because the boot files are 300 KB in size).



#106 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 02 June 2013 - 06:22 AM

I've made some small improvements:
- searching on boot device is off by default; if you use /sbd as parameter it will also search on boot device;
- if /ab parameter is used, it will automatically boot into Windows if only one bootable partition is found.

The script:

!BAT
setlocal
clear
echo Please wait, searching...

set SKIPPED=0
set N=0
set TMSZ=0
set BDN=-1
if "%?_BOOT:~1,2%"=="hd" set BDN=%?_BOOT:~3,1%
set DETTYPE=ver
set AB=0

:loopb
if "%1"=="" goto :endloopb
#########   if the batch file was started with /sbd as parameter it will also search
#########   on the boot device (if it's seen as a HDD). Usually is the USB drive (hd0)
if "%1"=="/sbd" set BDN=-1
#########   if the batch file was started with /fd as parameter it will use
#########   a faster OS type detection but with slightly less accuracy
if "%1"=="/fd" set DETTYPE=len
#########   if the batch file was started with /ab as parameter
#########   it will automatically boot Windows if only one is found
if "%1"=="/ab" set AB=1
shift
goto :loopb
:endloopb

debug on > nul
find --devices=h > (md)0x220+8

:loop
cat --skip=%SKIPPED% --number=1 --locate=" (hd" (md)0x220+8  | set PPOSB=
if "%PPOSB%"=="" goto endloop
set /a SKIPPED=0x%PPOSB%+7 > nul
cat --skip=%SKIPPED% --number=1 --locate=")" (md)0x220+8  | set PPOSE=
if "%PPOSE%"=="" goto endloop
set /a PPOSL=0x%PPOSE%-0x%PPOSB% > nul
set /a SKIPPED=0x%PPOSB%+1 > nul
cat --skip=%SKIPPED% --length=%PPOSL% --locate=" " (md)0x220+8 && set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
cat --skip=%SKIPPED% --length=%PPOSL% --locate="," --number=1 (md)0x220+8 | set CPOS=
if "%CPOS%"=="" set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
set /a PNL=0x%PPOSE%-0x%CPOS%-1 > nul
set /a SKIPPED=0x%CPOS%+1 > nul
cat --skip=%SKIPPED% --length=%PNL% (md)0x220+8 | set PN=
set /a HDNL=0x%CPOS%-0x%PPOSB%-4 > nul
set /a SKIPPED=0x%PPOSB%+4 > nul
cat --skip=%SKIPPED% --length=%HDNL% (md)0x220+8 | set HDN=

if %PN%>=4 goto :notgood
if %BDN%==%HDN% goto :notgood
checkrange 0x06:0x0e parttype (hd%HDN%,%PN%) > nul || goto :notgood

ls (hd%HDN%,%PN%)/ > (md)0x300+8
cat --locate=\0 --number=1 (md)0x300+8 | set ENDFILE=
set /a ENDFILE=0x%ENDFILE% > nul
if not "%ENDFILE%"=="0" write --offset=%ENDFILE% (md)0x300+8 \ \0 > nul

cat --locate=" ntldr " --number=1 (md)0x300+8 > nul || goto :nont
cat --length=0 (hd%HDN%,%PN%)/ntldr | set NTS=
set /a NTS=0x%NTS:~14% > nul
if %NTS%<=76799 goto :nont
if %NTS%>=1048577 goto :nont
set /a N=%N%+1 > nul
set CLCMD=chainloader
if "%DETTYPE%"=="ver" goto :ntver
:ntlen
if %NTS%>=268976 set OS=\ XP\ 64-bit\ or\ Server\ 2003 && goto :esnt
if %NTS%>=218976 set OS=\ XP && goto :esnt
if %NTS%>=185208 set OS=\ 2000 && goto :esnt
set OS=\ NT
set CLCMD=chainloader --force --load-segment=0x2000
goto :esnt
:ntver
set majver=0
set minver=0
map --mem=0x11000 (hd%HDN%,%PN%)/ntldr (rd) > nul || goto :ntlen
cat --hex --number=1 --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (rd)+1 > nul
set /a offbase = %?% + 28 > nul
if "%offbase%"=="29" goto :ntlen
cat --hex --length=5 --skip=%offbase% (rd)+1 | set line=
set majver=%line:~-5,1%
set minver=%line:~-1,1%
set OS=
if %majver%<=4 set OS=\ NT && set CLCMD=chainloader\ --force\ --load-segment=0x2000 && goto :esnt
if "%majver%%%minver%"=="50" set OS=\ 2000 && goto :esnt
if "%majver%%%minver%"=="51" set OS=\ XP && goto :esnt
if "%majver%%%minver%"=="52" set OS=\ XP 64-bit or Server 2003
:esnt

if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\n%CLCMD% (hd%HDN%,%PN%)/ntldr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth
set STATUS=
set HIDST=
hiddenflag (hd%HDN%,%PN%) > nul && set HIDST=\ (hidden) && set UNHCOM=\r\nunhide (hd%HDN%,%PN%) \> nul

set BWINM%N%=title Boot to Windows%OS% on %HDNT% HDD, %PNT% partition%HIDST%\\nUsually the %HDNTR%... %UNHCOM%%%REMAP%\r\nroot (hd0,%PN%) \> nul\r\%CLCMD% /ntldr%AFTERR%\r\n
call call Fn.12 "%^BWINM%N%%%"
set /a TMSZ=%TMSZ%+%@retval% > nul
:nont

cat --locate=" bootmgr " --number=1 (md)0x300+8 > nul || goto :nomgr
cat --length=0 (hd%HDN%,%PN%)/bootmgr | set MGRS=
set /a MGRS=0x%MGRS:~14% > nul
if %MGRS%<=204799 goto :nomgr
if %MGRS%>=1572865 goto :nomgr
if "%DETTYPE%"=="ver" goto :mgrver
if %MGRS%==438840 set OS=\ Vista && goto :esmgr
:mgrlen
if %MGRS%>=390971 set OS=\ 8, 8.1 or Server 2012 && goto :esmgr
if %MGRS%>=358410 set OS=\ 7 or Server 2008 && goto :esmgr
set OS=\ Vista or Server 2008
:mgrver
set majver=0
set minver=0
map --mem=0x11000 (hd%HDN%,%PN%)/bootmgr (rd) > nul || goto :mgrlen
cat --hex --number=1 --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (rd)+1 > nul
set /a offbase = %?% + 28 > nul
if "%offbase%"=="29" goto :mgrlen
cat --hex --length=5 --skip=%offbase% (rd)+1 | set line=
set majver=%line:~-5,1%
set minver=%line:~-1,1%
set OS=
if "%majver%%%minver%"=="60" set OS=\ Vista or Server 2008 && goto :esmgr
if "%majver%%%minver%"=="61" set OS=\ 7 or Server 2008 R2 && goto :esmgr
if "%majver%%%minver%"=="62" set OS=\ 8 or Server 2012
if "%majver%%%minver%"=="63" set OS=\ 8.1
:esmgr
set /a N=%N%+1 > nul
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\nchainloader (hd%HDN%,%PN%)/bootmgr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth
set HIDST=
set UNHCOM=
hiddenflag (hd%HDN%,%PN%) > nul && set HIDST=\ (hidden) && set UNHCOM=\r\nunhide (hd%HDN%,%PN%) \> nul

set BWINM%N%=title Boot to Windows%OS% on %HDNT% HDD, %PNT% partition%HIDST%\\nUsually the %HDNTR%...%UNHCOM%%%REMAP%\r\nroot (hd0,%PN%) \> nul\r\nchainloader /bootmgr%AFTERR%\r\n
call call Fn.12 "%^BWINM%N%%%"
set /a TMSZ=%TMSZ%+%@retval% > nul
:nomgr

:notgood

set /a SKIPPED=0x%PPOSE%+2 > nul
goto :loop
:endloop

if not %N%==0 goto :not0
endlocal
clear
echo No bootable Windows NT/2000/XP/Vista/7/8/8.1 partitions found, returning to main menu...
pause --wait=5 || goto :finish
goto :finish
:not0

clear
set I=0
set OFFSET=0
if "%N%"=="1" if "%AB%"=="1" set OFFSET=13 && set /a TMSZ=%TMSZ%+13 > nul
call Fn.12 "\r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0"
set /a MBSZ=%TMSZ%+%@retval%/512+1 > nul
if "%N%"=="1" if "%AB%"=="1" write (md)0x300+%MBSZ% timeout 0\r\n\r\n > nul
set /a N=%N%+1 > nul
:wloop
set /a I=%I%+1 > nul
if %I%>=%N% goto :endwloop
call write --offset=%OFFSET% (md)0x300+%MBSZ% %^BWINM%I%%% > nul
call call Fn.12 "%^BWINM%I%%%"
set /a OFFSET=%OFFSET%+%@retval% > nul
goto :wloop
:endwloop
write --offset=%OFFSET% (md)0x300+%MBSZ% \r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0 > nul

endlocal && set MBSZ=%MBSZ%
configfile (md)0x300+%MBSZ%
:finish

Attached File  findbwin.g4b.gz   2.03KB   302 downloads

 

 

LE 3 dec 2014: updates the script to detect Windows 8.1 also.



#107 tinybit

tinybit

    Gold Member

  • Developer
  • 1158 posts
  •  
    China

Posted 02 June 2013 - 07:00 AM

I don't quite understand why you need map --ram-drive=(0x9f) ?

perhaps you needn't change the ramdrive number.

usually you only want to change rd base and rd size. the drive number needn't touch.

the default ram drive number is 0x7f, which is a floppy. For version 0.4.5c and later, floppies can also have partition table. So if your image has a partition table, you needn't change the ramdrive number to be greater than  0x80. you may access floppy partitions by using (fdX,Y), just as that for harddrives.



#108 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 02 June 2013 - 08:19 AM

Actually I'm loading a normal file (not image) to ramdrive using "map --mem=0x11000 file (rd)". I use that instead of dd because is faster.

But you're right. I changed in script. Thank you.

Regarding rd base and rd size steve said that chenall said that aren't necessary...

 

Oh, another thing: is there any way to find the number of batch parameters? I mean when you start "test.g4b param1 param2 .. paramn" - find the "n"



#109 steve6375

steve6375

    Platinum Member

  • Developer
  • 7107 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 02 June 2013 - 08:54 AM

When you use map file (rd)  - then grub4dos ignores what rd-size and rd-base was set. grub4dos will  set rd-base to  (top-of-available memory - length of file) and rd-size to the size of the file  (if the file is compressed then it will uncompress it first).

I don't know of an 'argc' type parameter. To enumerate them you will need to make a loop with 'shift' if you expect more that 9 parameters...



#110 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 02 June 2013 - 09:04 AM

Ok.

The parameters are %1, %2, .. , %n

If you define a counter I (from 1 to n), how can you get the value for each one like you showed with BWINM:

call ... %^BWINM%I%%% ...

I guess, with all the %'s, it's a little trickier here   :D



#111 steve6375

steve6375

    Platinum Member

  • Developer
  • 7107 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 02 June 2013 - 09:07 AM

The parameters are %0 - %9   not %n!  You need to use shift to get at the ones past %9 so it is even trickier!

if "%1"=="" set argc=0

if "%2"=="" set argc=1

etc. up to %9



#112 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 02 June 2013 - 09:14 AM

Ok I understand, but how can I get the value of each of the %0..%9 using a counter from 0 to 9?



#113 steve6375

steve6375

    Platinum Member

  • Developer
  • 7107 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 02 June 2013 - 09:44 AM

!BAT
set argc=0
:LOOP
if "%1"=="" goto :fin
set /a argc=%argc%+1 > nul
set arg%argc%=%1
shift
goto :LOOP
:fin
# display variables
set arg


#114 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 02 June 2013 - 10:11 AM

Thank you very much :)

 

I implemented in the script:

 

:loopb
if "%1"=="" goto :endloopb
#########   if the batch file was started with /sbd as parameter it will also search
#########   on the boot device (if it's seen as a HDD). Usually is the USB drive (hd0)
if "%1"=="/sbd" set BDN=-1
#########   if the batch file was started with /fd as parameter it will use
#########   a faster OS type detection but with slightly less accuracy
if "%1"=="/fd" set DETTYPE=len
#########   if the batch file was started with /ab as parameter
#########   it will automatically boot Windows if only one is found
if "%1"=="/ab" set AB=1
shift
goto :loopb
:endloopb





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users