Jump to content











Photo
* * * * * 1 votes

Grub4dos Find and boot


  • Please log in to reply
113 replies to this topic

#76 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 26 May 2013 - 07:23 PM

Aren't there various sized NTLDR's?

Various service packs + updates + localized systems?

 

 

 

if %NTS%>=218976 set OS=XP && goto :esnt
if %NTS%>=185208 set OS=2000 && goto :esnt

I believe the same can happen with BOOTMGR

 

:cheers:

Wonko



#77 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 10:11 PM

You're correct.

But I checked a few dozens Windows's from NT to 8, with different SP's, with different localizations and so on...

Here are the results:

 











Version                   length
=================================
NT                        155 984


2000 Pro                  215 584
                          214 432
                          215 456
                          214 416
                          214 976
2000 Server               214 432
                          215 520
2000 Advanced server      214 432

XP SP0                    222 368
                          224 048
XP SP1                    233 632
XP x64 SP1                295 536
XP SP2     EN             250 032
           PT-BR ESP      251 168
           HU             250 624
XP x64 SP2                297 072
XP SP3     EN             250 048
           JA             260 800
           PT-BR          251 696
           FR             252 240
           NL DE          251 712
           VE             252 256
           SV             250 560
                          250 640
                          251 152
                          251 600

Server 2003               297 072
                          298 752
                          296 672
                          295 536
                          277 152

Vista SP0                 438 840
Vista SP1                 333 203
Vista x64 SP1             333 203
                          438 840
Vista SP2                 333 257

Server 2008               383 786

7 SP0                     383 562
7 SP1                     383 786
8                         398 156

 

At bootmgr I didn't see size variations on localized versions (so far).

 

I made the detection to work fine with this values.

Like I said it isn't 100% perfect but it's not that worst and it can be improved.

 

 

 

Later edit: I solved the problem with "pause" by using this:

 



pause --wait=5 || goto :finish
goto :finish

 

This way always it will go to :finish label...



#78 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 27 May 2013 - 12:09 PM

This script I posted here:

http://reboot.pro/to...nd-dll-version/

should work with NTLDR also.

 

:cheers:

Wonko



#79 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 27 May 2013 - 02:28 PM

Yes, very good script.
Thank you.

But I see 2 problems:
1. The main reason for saying that my detection using length is not 100% perfect is that it can't tell for sure that it's from XP x64 or Server 2003; or from Windows 7 or Server 2008.
But I see that the version check detection has the same problem... So the difference in accuracy is not that high...
2. Low speed: on my system is about 14 times slower than checking lengths.
On fast HDD's with very few OS's the drop in speed it will be acceptable. But on slow HDD's and/or with many OS's it will be noticeable.

In conclusion:
Pro: plus few percents accuracy.
Con: noticeable drop in speed on slow systems.

Well, I'm not sure...



#80 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 27 May 2013 - 02:51 PM

I guess that you can speed it up a bit by checking just the three chars that are actually checked as "majmin", i.e. reducing the length of the loops to 6 or so.

Unfortunately the good guys at MS decided that using versioning to distinguish between "workstation" and "server" was a too simple and intelligent approach and introduced a senselessly complex way to distinguish them.

 

:cheers:

Wonko



#81 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 27 May 2013 - 04:21 PM

It seems that I haven't test it accurate enough the first time.
I used the internal HDD (fast) and only 10 cycles for length detection.
Mea culpa :(
This time I used a USB drive at 1.1 speed and 100 cycles for length detection.

Results:

10 cycles with original dll_ver.g4b                                            142 sec
10 cycles with dll_ver.g4b (counter limited from 30 to 6)                      35 sec
100 cycles with length detection                                               41 sec

So now the speed difference dropped from 34.6 to 8.5 ... 4x times faster.
Well, it has potential...



#82 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 27 May 2013 - 06:47 PM

Additionally, once you are set for the just getting major/minor version, you can have a much simplified approach.

Cannot say if the time is used by the cat commands or by the loops, but you can try this:

 

 

 

!BAT
# String is "FileV" in Unicode
if "%1"=="" goto :usage
set file=%~dpnx1
set string=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00

#debug off
cat --hex --locate=%string% %file% > nul
set /a offbase = %?% + 27 > nul
cat --hex --length=6 --skip=%offbase% %file% | set line=
set version=%line:~-5,1%.%line:~-1,1%
set version

:cheers:

Wonko



#83 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 27 May 2013 - 08:55 PM

With this code the time is 16 sec :D which is acceptable.
I hope you don't mind but I moved it into the main script, because it's a little faster this way.
I kept both detections but yours is the default one. If the script is started with /fd parameter it will use length detection.
Thank you very much.

Here is 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
if "%2"=="/fd" set DETTYPE=len
: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%<=74999 goto notgood
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
cat --hex --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (hd%HDN%,%PN%)/ntldr > nul
set /a offbase = %?% + 27 > nul
if "%offbase%"=="28" goto :ntlen
cat --hex --length=6 --skip=%offbase% (hd%HDN%,%PN%)/ntldr | 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%<=199999 goto notgood
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
cat --hex --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (hd%HDN%,%PN%)/bootmgr > nul
set /a offbase = %?% + 27 > nul
if "%offbase%"=="28" goto :mgrlen
cat --hex --length=6 --skip=%offbase% (hd%HDN%,%PN%)/bootmgr | 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


#84 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 28 May 2013 - 09:07 AM

With this code the time is 16 sec :D which is acceptable.
I hope you don't mind but I moved it into the main script, because it's a little faster this way.

Sure :fine:, that's the idea of exchanging ideas ;), JFYI:

http://jaclaz.alterv...s/careware.html

 

 

I kept both detections but yours is the default one. If the script is started with /fd parameter it will use length detection.
Thank you very much.

You are very welcome :).

 

:cheers:

Wonko


 



#85 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 28 May 2013 - 09:03 PM

I think there may be a way to increase the speed of the code who gets the info from the file.
Perhaps copying the file in an (md) would make the search faster.
I wil test...

Later edit:
Well, I tested, with an interesting result.

This code, on an USB 1.1, runs in 14 sec:

 



!BAT
echo ___%@time%___
set I=1
set file=bootmgr
:loop
if "%file%"=="bootmgr" set file=ntldr && goto :ifs
if "%file%"=="ntldr" set file=bootmgr && goto :ifs
:ifs
set majver=0
set minver=0
cat --hex --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 /%file% > nul
set /a offbase = %?% + 28 > nul
cat --hex --length=5 --skip=%offbase% /%file% | set line=
set majver=%line:~-5,1%
set minver=%line:~-1,1%
set OS=
if %majver%<=4 set OS=NT && 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 && goto :esnt
if "%majver%%%minver%"=="60" set OS=Vista or Server 2008 && goto :esnt
if "%majver%%%minver%"=="61" set OS=7 or Server 2008 R2 && goto :esnt
if "%majver%%%minver%"=="62" set OS=8 or Server 2012
:esnt
echo OS is %OS%
set /a I=%I%+1 > nul
if %I%>=11 goto :endloop
goto :loop
:endloop
echo ___%@time%___
pause

 



ntldr hss 244 KB, bootmgr 344 KB. They are read at 800 KB/s in about 0.37 sec but they are processed in 1.4 sec.

I tried to load the files in (md)0x800+1000 with cat, didn't worked. It stops at \0's.
With map and (rd) seems to work, although I'm not sure that I did 100% ok.

This code runs in 9 sec:

 



!BAT
echo ___%@time%___
set I=1
set file=bootmgr
map --ram-drive=0x9f 
map --rd-base=0x600000 
map --rd-size=0x60000
:loop
if "%file%"=="bootmgr" set file=ntldr && goto :ifs
if "%file%"=="ntldr" set file=bootmgr && goto :ifs
:ifs
set majver=0
set minver=0
map --mem /%file% (rd) > nul
cat --hex --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (rd)+1 > nul
set /a offbase = %?% + 28 > nul
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 && 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 && goto :esnt
if "%majver%%%minver%"=="60" set OS=Vista or Server 2008 && goto :esnt
if "%majver%%%minver%"=="61" set OS=7 or Server 2008 R2 && goto :esnt
if "%majver%%%minver%"=="62" set OS=8 or Server 2012
:esnt
echo OS is %OS%
set /a I=%I%+1 > nul
if %I%>=11 goto :endloop
goto :loop
:endloop
echo ___%@time%___
pause

 

So, It works faster...
Still I would prefer using (md)0x800+1000 instead of (rd). Could someone help me with this...?



#86 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 29 May 2013 - 10:47 AM

Well, for now I implemented using rd (maping boot files in it). The code is about 1.4 times faster.
 

!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 
map --rd-base=0x600000 
map --rd-size=0x180000
: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 (hd%HDN%,%PN%)/ntldr (rd) > nul
cat --hex --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 (hd%HDN%,%PN%)/bootmgr (rd) > nul
cat --hex --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


#87 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 29 May 2013 - 11:58 AM

You don't use cat to copy files to memory drive, you use dd! ;)

:cheers:
Wonko

P.S.: since the "FileV" is well towards the end of the NTLDR or BOOTMGR, you may even find a "minimum address" to be skipped when dding the file.



#88 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 29 May 2013 - 01:17 PM

Thanks for the tip.
I usually avoid dd because it's dangerous.
So I never use it in a script and don't have much experience with it...

LE: I will test it...



#89 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 29 May 2013 - 01:45 PM

Thanks for the tip.
I usually avoid dd because it's dangerous.
So I never use it in a script and don't have much experience with it...

I will test it...

250048 bytes or "blocks" (sectors)? :whistling:
you are looking with cat in a device which starts at 0x800 and that extends for around 128 Mb (more exactly 128,024,576 ;)).


Maybe you could reduce the size of the area to look into to 800 sectors or so (800*512=409,600 bytes) OR (advised) use:

 

dd if=(hd0,0)/ntldr of=(md)0x800+%n%
cat --hex --number=1 --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (md)0x800+%n% > nul

which should stop catting after having found first instance of the string to be located.

 

:cheers:

Wonko



#90 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 29 May 2013 - 01:48 PM

Ya, I realized that is too much and reduced the size, that's why I edited my previous post  :whistling:



#91 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 29 May 2013 - 02:16 PM

A problem.

The test code looks like that:

 





!BAT
echo ___%@time%___
set I=1
set file=bootmgr
:loop
if "%file%"=="bootmgr" set file=ntldr && goto :ifs
if "%file%"=="ntldr" set file=bootmgr && goto :ifs
:ifs
set majver=0
set minver=0
dd if=(hd0,0)/%file% of=(md)0x800+800
cat --hex (md)0x800+1
pause
cat --hex --number=1 --locate=\x01\x00\x46\x00\x69\x00\x6C\x00\x65\x00\x56\x00 (md)0x800+800 > nul
set /a offbase = %?% + 28 > nul
echo offbase=%offbase%
cat --hex --length=5 --skip=%offbase% (md)0x800+800 | set line=
set majver=%line:~-5,1%
set minver=%line:~-1,1%
set OS=
if %majver%<=4 set OS=NT && 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 && goto :esnt
if "%majver%%%minver%"=="60" set OS=Vista or Server 2008 && goto :esnt
if "%majver%%%minver%"=="61" set OS=7 or Server 2008 R2 && goto :esnt
if "%majver%%%minver%"=="62" set OS=8 or Server 2012
:esnt
echo %file% is from Windows %OS%
set /a I=%I%+1 > nul
if %I%>=11 goto :endloop
goto :loop
:endloop
echo ___%@time%___
pause

When it reaches at "cat --hex (md)0x800+1" and pauses, it displays the first 512 bytes from each file. But they are different from the real files.

But it finds FileV in ntldr. In bootmgr it doesn't...

 

Is it another funny mistake that I make...? :D

 

Sorry for these but like I said, I don't have any experience with dd :(

 

 

LE: I searched manually some of the hexa strings displayed by cat --hex and, for ntldr, it shows an area positioned at about 80% of the file; for bootmgr couldn't find any match.



#92 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 29 May 2013 - 02:55 PM

if you use

 

dd if=()/ntldr of=(md)0x800+128
cat --hex (md)0x800+1

it works, but if you go higher than 128, you get the wrong bytes

dd if=()/ntldr of=(md)0x800+129
cat --hex (md)0x800+1

very strange!

 

ntldr is 250K = 488 sectors. 

 

dd is reading 4 lots of 0x10000 bytes (or 4 x 128 sectors). It looks like dd is not advancing the buffer pointer to the next 0x10000 bytes!

This looks like a bug to me!



#93 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 29 May 2013 - 03:08 PM

I found a solution:

I changed (md)0x800 to (md)0x6000. Now it displays the first 512 B fine and it finds FileV in both files.

 

But now I am puzzled by another problem: dd seems to be 3x times slower than map --mem.

Investigating...



#94 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15103 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 29 May 2013 - 03:44 PM

Strange. :unsure:

Try adding a bs to dd.

Like:

dd if=()/ntldr of=(md)0x6000+800 bs=1024

or

dd if=()/ntldr of=(md)0x6000+800 bs=2048

 

etc.

 

maybe it changes something (re:speed).

 

Again you can try to pre-calculate a size to be skipped (roughly 80% of size of the smallest NTLDR or calculate it dunamicall yon the size of the file at hand :dubbio:).

Anyway, if you transfer from 20% to (say) 40% of bytes at 1/3 speed the result would be very similar, not a much visible improvement :frusty:,

 

:cheers:

Wonko



#95 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 29 May 2013 - 04:15 PM

After many tests: yes, dd is very slow. At 1.1 USB speed it needs 2..3 sec to copy each of those boot files. Map --mem needs less than a sec, which is normal (300 KB at 800 KB/s).
Using bs 1024 and 2048, no change. Tried a lower memory area (md)0x2000, still no change.
Could be a buggy Bios, but:
1. Why map --mem works?
2. in Windows/VirtualBox I see the same speed difference.

Copying only a part of the file I don't think it's 100% good, I had this idea too but we can't be sure 100% that FileV is found only in that part on all ntldr/bootmgr.

Well, I still have map --mem file (rd) which seems to work fine (and fast).
Is there a better solution?



#96 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 30 May 2013 - 04:34 AM

Probably the final version:

 









!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 
map --rd-base=0x600000 
map --rd-size=0xC00
: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 (hd%HDN%,%PN%)/ntldr (rd) > nul
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 (hd%HDN%,%PN%)/bootmgr (rd) > nul
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

 

 



#97 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 - 10:51 AM

Just found out from chenall that setting --rd-base and --rd-size is pointless when using map --mem /ntldr (rd)  as the map command will set the base address to the top of available memory automatically  (top_of_mem - size of file) and the size will be automatically set to it's file size..

 

To set the file to a specific location in memory (e.g. 0x600000, you would need to use:

map --mem=0x3000 ()/ntldr (rd)

or

map --ram-drive=0x9f
map --rd-base=0x600000
map --rd-size=0x180000
dd if=()/ntldr of=(rd)


#98 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 30 May 2013 - 12:06 PM

Thank you.

When I tried "map --mem=0x300 ()/ntldr (rd)" it showed error "file can't fit into memory" but with 0x2000 worked fine.
I hope that will be ok on most computers...
Btw, why is it better to set "--mem=0x..." and not just "--mem"?

I noticed that it says someting "Autodetect .. failed...". Is there any way to disable the autodetect (I tried setting the values manually, same) and would it be any improvement in speed/stability if I do that...? Or should I just ignore the message?

Oh, and is it wise to erase the ramdrive or at least its content after use? If yes, how? I tried "map --unmap=0x9f" but "map --status" doesn't show any change...



#99 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 - 12:25 PM

I used 0x3000 not 0x300.

This would be in 512 byte sectors, so 0x3000 = 0x600000 in memory.

Not sure why 0x300 does not work  = 384k + 250k for file =  634k  - even 0x20 does not work...??? Maybe the ramdrive needs to be above 1MB as  0x7ff does not work but 0x800 and above does.

 

You can use debug 0 to turn off the Autodetect message but that doesn't stop it trying to do it so just use > nul and ignore it.

 

erasing the ramdrive - it does not matter - it is not a real drive - just memory and pointers which will just be ignored when the system boots...



#100 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 30 May 2013 - 01:12 PM

I used 0x3000 not 0x300.

This would be in 512 byte sectors, so 0x3000 = 0x600000 in memory.

Not sure why 0x300 does not work  = 384k + 250k for file =  634k  - even 0x20 does not work...??? Maybe the ramdrive needs to be above 1MB as  0x7ff does not work but 0x800 and above does.

 

Ok, I will use 3000.

 

You can use debug 0 to turn off the Autodetect message but that doesn't stop it trying to do it so just use > nul and ignore it.

 

I will use > nul.

 

erasing the ramdrive - it does not matter - it is not a real drive - just memory and pointers which will just be ignored when the system boots...

 

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...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users