Jump to content











Photo
- - - - -

auto-scan and boot

grub4dos

  • Please log in to reply
8 replies to this topic

#1 Amr Abdel Aziz

Amr Abdel Aziz
  • Members
  • 9 posts
  •  
    Egypt

Posted 13 December 2011 - 01:54 AM

A dynamic run-time boot menu for Windows NT/2000/XP/Vista/7 detected on internal HDD.


Layout of files on USB


/NTBOOT

/grldr

/menu.lst

/osdetect.lst



This is the menu.lst


#menu.lst

title auto-scan and boot

find --set-root /osdetect.lst

configfile /osdetect.lst



And this is the menu generator for our run-time OS boot menu


#osdetect.lst

color	11 12 13 14

default  0

set	  thismenu=/osdetect.lst

set	  prevmenu=/menu.lst

set	  NTBOOT=/NTBOOT/NTBOOT

set	  usb_hdd?=checkrange 0x80 read 0x8280

set	  xp=Windows NT/2000/XP

set	  w7=Windows Vista/7

set	  help1=n bootmgr and correct bcd are required on hdd.

set	  help2=n ntldr and correct boot.ini are required on hdd.

set	  help3=n Neither bootmgr or correct bcd is required.

set	  help4=n Neither ntldr or correct boot.ini is required.



echo Loading dynamic os boot menu...



map	  --unhook

map	  --unmap=0:0xff

find	 --set-root %thismenu%

map	  --mem %thismenu% (hd60)

map	  --hook

set	  i=(hd60)+1

set	  o=(md)800+50



echo color 11 12 13 14 > %o%



debug 1 && find --devices=h /ntldr > %i%

%usb_hdd?% || cat --locate="(hd0,0)" --replace="(hd0,0)" %i% && echo title %xp% - (hd0,0)/ntldr %help2% >> %o% && echo root (hd0,0) >> %o% && echo chainloader /ntldr >> %o%

%usb_hdd?% || cat --locate="(hd0,1)" --replace="(hd0,1)" %i% && echo title %xp% - (hd0,1)/ntldr %help2% >> %o% && echo root (hd0,1) >> %o% && echo chainloader /ntldr >> %o%

%usb_hdd?% || cat --locate="(hd0,2)" --replace="(hd0,2)" %i% && echo title %xp% - (hd0,2)/ntldr %help2% >> %o% && echo root (hd0,2) >> %o% && echo chainloader /ntldr >> %o%

%usb_hdd?% || cat --locate="(hd0,3)" --replace="(hd0,3)" %i% && echo title %xp% - (hd0,3)/ntldr %help2% >> %o% && echo root (hd0,3) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd1,0)" --replace="(hd1,0)" %i% && echo title %xp% - (hd1,0)/ntldr %help2% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,0) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd1,1)" --replace="(hd1,1)" %i% && echo title %xp% - (hd1,1)/ntldr %help2% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,1) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd1,2)" --replace="(hd1,2)" %i% && echo title %xp% - (hd1,2)/ntldr %help2% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,2) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd1,3)" --replace="(hd1,3)" %i% && echo title %xp% - (hd1,3)/ntldr %help2% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,3) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd2,0)" --replace="(hd2,0)" %i% && echo title %xp% - (hd2,0)/ntldr %help2% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,0) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd2,1)" --replace="(hd2,1)" %i% && echo title %xp% - (hd2,1)/ntldr %help2% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,1) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd2,2)" --replace="(hd2,2)" %i% && echo title %xp% - (hd2,2)/ntldr %help2% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,2) >> %o% && echo chainloader /ntldr >> %o%

cat --locate="(hd2,3)" --replace="(hd2,3)" %i% && echo title %xp% - (hd2,3)/ntldr %help2% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,3) >> %o% && echo chainloader /ntldr >> %o%



debug 1 && find --devices=h /WINDOWS/system32/sysocmgr.exe > %i%

%usb_hdd?% || cat --locate="(hd0,0)" --replace="(hd0,0)" %i% && echo title %xp% - (hd0,0)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd0,0) >> %o%

%usb_hdd?% || cat --locate="(hd0,1)" --replace="(hd0,1)" %i% && echo title %xp% - (hd0,1)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd0,1) >> %o%

%usb_hdd?% || cat --locate="(hd0,2)" --replace="(hd0,2)" %i% && echo title %xp% - (hd0,2)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd0,2) >> %o%

%usb_hdd?% || cat --locate="(hd0,3)" --replace="(hd0,3)" %i% && echo title %xp% - (hd0,3)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd0,3) >> %o%

cat --locate="(hd1,0)" --replace="(hd1,0)" %i% && echo title %xp% - (hd1,0)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd1,0) >> %o%

cat --locate="(hd1,1)" --replace="(hd1,1)" %i% && echo title %xp% - (hd1,1)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd1,1) >> %o%

cat --locate="(hd1,2)" --replace="(hd1,2)" %i% && echo title %xp% - (hd1,2)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd1,2) >> %o%

cat --locate="(hd1,3)" --replace="(hd1,3)" %i% && echo title %xp% - (hd1,3)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd1,3) >> %o%

cat --locate="(hd2,0)" --replace="(hd2,0)" %i% && echo title %xp% - (hd2,0)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd2,0) >> %o%

cat --locate="(hd2,1)" --replace="(hd2,1)" %i% && echo title %xp% - (hd2,1)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd2,1) >> %o%

cat --locate="(hd2,2)" --replace="(hd2,2)" %i% && echo title %xp% - (hd2,2)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd2,2) >> %o%

cat --locate="(hd2,3)" --replace="(hd2,3)" %i% && echo title %xp% - (hd2,3)/Windows %help4% >> %o% && echo command %NTBOOT^% NT5 (hd2,3) >> %o%



debug 1 && find --devices=h /bootmgr > %i%

%usb_hdd?% || cat --locate="(hd0,0)" --replace="(hd0,0)" %i% && echo title %w7% - (hd0,0)/bootmgr %help1% >> %o% && echo root (hd0,0) >> %o% && echo chainloader /bootmgr >> %o%

%usb_hdd?% || cat --locate="(hd0,1)" --replace="(hd0,1)" %i% && echo title %w7% - (hd0,1)/bootmgr %help1% >> %o% && echo root (hd0,1) >> %o% && echo chainloader /bootmgr >> %o%

%usb_hdd?% || cat --locate="(hd0,2)" --replace="(hd0,2)" %i% && echo title %w7% - (hd0,2)/bootmgr %help1% >> %o% && echo root (hd0,2) >> %o% && echo chainloader /bootmgr >> %o%

%usb_hdd?% || cat --locate="(hd0,3)" --replace="(hd0,3)" %i% && echo title %w7% - (hd0,3)/bootmgr %help1% >> %o% && echo root (hd0,3) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd1,0)" --replace="(hd1,0)" %i% && echo title %w7% - (hd1,0)/bootmgr %help1% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,0) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd1,1)" --replace="(hd1,1)" %i% && echo title %w7% - (hd1,1)/bootmgr %help1% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,1) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd1,2)" --replace="(hd1,2)" %i% && echo title %w7% - (hd1,2)/bootmgr %help1% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,2) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd1,3)" --replace="(hd1,3)" %i% && echo title %w7% - (hd1,3)/bootmgr %help1% >> %o% && echo map (hd1) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,3) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd2,0)" --replace="(hd2,0)" %i% && echo title %w7% - (hd2,0)/bootmgr %help1% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,0) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd2,1)" --replace="(hd2,1)" %i% && echo title %w7% - (hd2,1)/bootmgr %help1% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,1) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd2,2)" --replace="(hd2,2)" %i% && echo title %w7% - (hd2,2)/bootmgr %help1% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,2) >> %o% && echo chainloader /bootmgr >> %o%

cat --locate="(hd2,3)" --replace="(hd2,3)" %i% && echo title %w7% - (hd2,3)/bootmgr %help1% >> %o% && echo map (hd2) (hd0) >> %o% && echo map --hook >> %o% && echo root (hd0,3) >> %o% && echo chainloader /bootmgr >> %o%



debug 1 && find --devices=h /Windows/System32/winload.exe > %i%

%usb_hdd?% || cat --locate="(hd0,0)" --replace="(hd0,0)" %i% && echo title %w7% - (hd0,0)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd0,0) >> %o%

%usb_hdd?% || cat --locate="(hd0,1)" --replace="(hd0,1)" %i% && echo title %w7% - (hd0,1)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd0,1) >> %o%

%usb_hdd?% || cat --locate="(hd0,2)" --replace="(hd0,2)" %i% && echo title %w7% - (hd0,2)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd0,2) >> %o%

%usb_hdd?% || cat --locate="(hd0,3)" --replace="(hd0,3)" %i% && echo title %w7% - (hd0,3)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd0,3) >> %o%

cat --locate="(hd1,0)" --replace="(hd1,0)" %i% && echo title %w7% - (hd1,0)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd1,0) >> %o%

cat --locate="(hd1,1)" --replace="(hd1,1)" %i% && echo title %w7% - (hd1,1)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd1,1) >> %o%

cat --locate="(hd1,2)" --replace="(hd1,2)" %i% && echo title %w7% - (hd1,2)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd1,2) >> %o%

cat --locate="(hd1,3)" --replace="(hd1,3)" %i% && echo title %w7% - (hd1,3)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd1,3) >> %o%

cat --locate="(hd2,0)" --replace="(hd2,0)" %i% && echo title %w7% - (hd2,0)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd2,0) >> %o%

cat --locate="(hd2,1)" --replace="(hd2,1)" %i% && echo title %w7% - (hd2,1)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd2,1) >> %o%

cat --locate="(hd2,2)" --replace="(hd2,2)" %i% && echo title %w7% - (hd2,2)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd2,2) >> %o%

cat --locate="(hd2,3)" --replace="(hd2,3)" %i% && echo title %w7% - (hd2,3)/Windows %help3% >> %o% && echo command %NTBOOT^% NT6 (hd2,3) >> %o%



echo title back... >> %o%

echo map --unhook >> %o%

echo map --unmap=hd60 >> %o%

echo set * >> %o%

echo find --set-root %prevmenu% >> %o%

echo configfile %prevmenu% >> %o%



configfile %o%


NTBOOT can be downloaded from http://code.google.c.../downloads/list

I hope this is useful for you and welcome for suggestions and improvements :dubbio:

Edited by Amr Abdel Aziz, 13 December 2011 - 02:14 AM.


#2 chenall

chenall

    Member

  • Members
  • 60 posts
  •  
    China

Posted 14 December 2011 - 12:47 PM

try use g4d_hd_tools
http://chenall.net/post/g4d_hd_tools/

Press F8 to auto-scan and show Windows NT/2000/XP/Vista/7 detected on internal HDD.

#3 chenall

chenall

    Member

  • Members
  • 60 posts
  •  
    China

Posted 14 December 2011 - 01:00 PM

here is a code in g4d_hd_tools
copy and save this code to auto-scan.bat
and run it
eg.
/auto-scan.bat
this code can use configfile to run it eg.
configfile /auto-scan.bat

!BAT

debug off

goto :bat_start

:::Current is call with configfile

::::get the file name.

call Fn.0 0 0x8217 | set menu=

::run it.

%menu%

title

:bat_start

setlocal

write 0x8274 0x2001

debug off

color 11 12 13 14

set menu=(md)0x210+16

echo -e timeout 5ndefault 0 > %menu%

find --set-root --devices=h makeactive --status || echo Not Actived Partition.

find --devices=h call :add_sys ()

configfile (md)0x210+16

exit

:add_sys

call :getver || exit

echo title Microsoft Windows %sys_ver% on %@root%nnttWindows %sys_ver% on %@root% >> %menu%

echo command %NTBOOT% %nt_ver%=%@root% >> %menu%

exit

:getver

map --mem ()/windows/system32/version.dll (rd) || map --mem ()/winnt/system32/version.dll (rd)

calc *0x82d0=*0x82d0+*0x82d8-0x800

calc *0x82d8=0x800

cat --locate=00x44000 --number=1 (rd)+1 | set skip=

set /a skip=0x%skip%-0x30

cat --locate=000 --skip=%skip% --number=1 (rd)+1 | set skip=

calc *0x82d0=*0x82d0+0x%skip%+3

call Fn.67 *0x82d0 0x60000 3

cat (md)0x300+1,1 | set nt_ver=NT

cat (md)0x300+1,3 | goto :_

set sys_ver=Unknown System

exit

:_5.0

set sys_ver=2000

exit

:_5.1

set sys_ver=XP

exit

:_5.2

set sys_ver=2003

exit

:_6.1

set sys_ver=7/2008

exit

:_6.2

set sys_ver=8

exit


  • Amr Abdel Aziz and Szabolcs Raduly-Zorgo like this

#4 Amr Abdel Aziz

Amr Abdel Aziz
  • Members
  • 9 posts
  •  
    Egypt

Posted 16 December 2011 - 11:39 PM

Nice coding chenall :cheerleader:
Now we know how to make loops in g4d


find --devices=h call :add_sys ()



#5 laddanator

laddanator

    Frequent Member

  • Advanced user
  • 337 posts
  • Location:Virginia
  • Interests:Writing code and getting stuff to work when no one else can! Wrote a Windows Vista, 7, and 8 legal activation tool in VBscript and compiled it to exe. First project of this undertaking. Working on an AIO legal activation tool that includes XP.
  •  
    United States

Posted 27 December 2011 - 02:45 PM

Will try

#6 Szabolcs Raduly-Zorgo

Szabolcs Raduly-Zorgo
  • Members
  • 7 posts

Posted 23 January 2012 - 07:53 PM

here is a code in g4d_hd_tools
copy and save this code to auto-scan.bat
and run it
eg.
/auto-scan.bat
this code can use configfile to run it eg.
configfile /auto-scan.bat


!BAT

debug off

goto :bat_start

:::Current is call with configfile

::::get the file name.

call Fn.0 0 0x8217 | set menu=

::run it.

%menu%

title

:bat_start

setlocal

write 0x8274 0x2001

debug off

color 11 12 13 14

set menu=(md)0x210+16

echo -e timeout 5ndefault 0 > %menu%

find --set-root --devices=h makeactive --status || echo Not Actived Partition.

find --devices=h call :add_sys ()

configfile (md)0x210+16

exit

:add_sys

call :getver || exit

echo title Microsoft Windows %sys_ver% on %@root%nnttWindows %sys_ver% on %@root% >> %menu%

echo command %NTBOOT% %nt_ver%=%@root% >> %menu%

exit

:getver

map --mem ()/windows/system32/version.dll (rd) || map --mem ()/winnt/system32/version.dll (rd)

calc *0x82d0=*0x82d0+*0x82d8-0x800

calc *0x82d8=0x800

cat --locate=00x44000 --number=1 (rd)+1 | set skip=

set /a skip=0x%skip%-0x30

cat --locate=000 --skip=%skip% --number=1 (rd)+1 | set skip=

calc *0x82d0=*0x82d0+0x%skip%+3

call Fn.67 *0x82d0 0x60000 3

cat (md)0x300+1,1 | set nt_ver=NT

cat (md)0x300+1,3 | goto :_

set sys_ver=Unknown System

exit

:_5.0

set sys_ver=2000

exit

:_5.1

set sys_ver=XP

exit

:_5.2

set sys_ver=2003

exit

:_6.1

set sys_ver=7/2008

exit

:_6.2

set sys_ver=8

exit


Nice, now I'm trying to get the last real hd[X+1] number... and I'm having difficulty:



I hope some of U will be able to help me with an unusual request / question:
The thing is, that I'm trying to get the next available free hdX (X should be the next free hd device number) so that I can map a new HD disk image.

ex: if I map hd0, then after boot the real hd0 will be invisible (I will see the image instead), ig I map as hd8 or any other higher number then the real existing hdX+1 then it will not be mapped.
If I have 2 HDD's I will have hd0, hd1... if I map the image as hd2 it will be OK, but in different systems I have different number of real HDD's... so I'm trying to find the number X from hdX, where the X is the real existing HDD number (in the second example: 2)

so.. I'm curious and I cannot get around how to obtain a string like "hd3" witch would be the next free hd witch can be mapped...

Thank U anticipated 4 U're help :)

#7 Szabolcs Raduly-Zorgo

Szabolcs Raduly-Zorgo
  • Members
  • 7 posts

Posted 24 January 2012 - 08:38 AM

steve6375 gave me the best solution in the Grub4dos Guide/Tutorial (pg4)

Thank U for the help :)


this was the magic part, that I could not get around: set/a hdn=*0x475&0xff
so now it is ok (and it is workin' as it follows):

title Map as a new HD from test.ima
set /a hdn=*0x475 & 0xff
map --mem (pd)/test.ima (hd%hdn%)
map --hook

Thank U again :)

#8 Amr Abdel Aziz

Amr Abdel Aziz
  • Members
  • 9 posts
  •  
    Egypt

Posted 06 October 2012 - 07:08 PM

Useful indeed!

#9 tinybit

tinybit

    Gold Member

  • Developer
  • 1175 posts
  •  
    China

Posted 07 October 2012 - 01:33 AM

The thing is, that I'm trying to get the next available free hdX (X should be the next free hd device number) so that I can map a new HD disk image.


You may simply use the device (hd) for that. i.e., for hdn=*0x475&0xff

And (hd-1) is for the last available HD, i.e., for hdn=(*0x475-1)&0xff

similarly (hd-2) is corresponding to hdn=(*0x475-2)&0xff

similarly (hd-3) is corresponding to hdn=(*0x475-3)&0xff

and so on.





Also tagged with one or more of these keywords: grub4dos

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users