Jump to content











Photo
- - - - -

[RELEASE] mbrview.g4b a BAT! tool for grub4dos


  • Please log in to reply
61 replies to this topic

#26 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:36 PM

Not a hundred.

Just one more.

The grub4dos I have in the floppy image on which I tested/developed the batch is grub4dos-0.4.5c-2012-06-19.7z

 

See the result yourself.

 

mbrview.png

 

BTW, the version of wenv I am using is what attached to this post.



#27 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:43 PM

wenv  21/02/2011

 

I can find wenv-2011-01-21. Please provide the link.



#28 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 03:44 PM

I can find wenv-2011-01-21. Please provide the link.

sorry - typo!



#29 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 03:48 PM

I tested using QEMU and Oracle VM Virtual Box  (booting direct from USB flash drive - not using Plop) and both work.



#30 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 03:54 PM

I tested using QEMU and Oracle VM Virtual Box  (booting direct from USB flash drive - not using Plop) and both work.

 

Something weird is happening with me. Please check G4D version and MD5 of wenv (F452C90244261B9B5C4F78D941AF7094) from the screenshot.

 

mbrview.png



#31 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 03:56 PM

my wenv ends in QC0.   2011-01-21 22,784 bytes



#32 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 11 March 2013 - 03:59 PM

What else could it be? :unsure:

 

I am attaching a floppy that works here.

 

OT :ph34r: but not much ;), WHAT THE HECK do you think md5crypt does? :w00t:

 

:cheers:

Wonko

Attached Files



#33 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 11 March 2013 - 04:02 PM

@Wonko - BTW - Where did you get wenv from 2011-06-27 ?? What is difference from 2011-01-21 ??



#34 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 04:03 PM

my wenv ends in QC0.   2011-01-21 22,784 bytes

 

Did you download from here?

 

SHA-1 checksum matches with the download page. But MD5 of wenv is F452C90244261B9B5C4F78D941AF7094 and size is 22,784 bytes.

 

Can you please recheck?



#35 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 11 March 2013 - 04:28 PM

I am attaching a floppy that works here.

 

BLOODY HELLTry using the same floppy image in Oracle VirtualBox with 32MB memory. You'll get the answer why numerous attempts of mine were failing.

 

 

 

OT  :ph34r: but not much  ;), WHAT THE HECK do you think md5crypt does?  :w00t:

 

I though that it calculates MD5 of the file. Later I understood my mistake and that's why I have posted the hash in text calculated by other tools.



#36 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 11 March 2013 - 05:45 PM

@Wonko - BTW - Where did you get wenv from 2011-06-27 ?? What is difference from 2011-01-21 ??

Should be this one:

http://code.google.c.../downloads/list

grubutils-2011-06-27.zip  Featured

http://code.google.c...27.zip&can=2&q=

 

:cheers:

Wonko


  • steve6375 likes this

#37 Holmes.Sherlock

Holmes.Sherlock

    Gold Member

  • Team Reboot
  • 1444 posts
  • Location:Santa Barbara, California
  •  
    United States

Posted 12 March 2013 - 01:02 AM

BLOODY HELLTry using the same floppy image in Oracle VirtualBox with 32MB memory. You'll get the answer why numerous attempts of mine were failing.

 

steve6375 and Wonko, thanks to both of you. I never imagined Grub4DOS is so memory hungry.



#38 nando4

nando4

    Frequent Member

  • Advanced user
  • 112 posts
  •  
    Australia

Posted 30 October 2013 - 09:16 AM

I was above to get rid of several wenv calls and instead use the grub4dos enhanced string/set functions.

Only one I haven't been able to fix is the lines that set a substring with an embedded variable for start/length. Example below. How can this be done without using wenv?
 

set bchsf=%bchsf:~0,%bbefl%%%bchs% 


#39 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 10:31 AM

Try

set d=bchsf:~0,%bbefl% ;; call echo %%%d%%%%%bchs%

There should be a better way using  call and %^ but I can't seem to get it to work...



#40 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 10:43 AM

found it! - try 

call echo %^bchsf:~0,%bbefl%%%%%^bchs%

a ^ inside a variable  %xxxxx% means 'don't translate' - so when call is run, %^bchs% is converted to %bchs%, then when echo is run it comes out right.

So bbefl is converted to a number and %^bchsf% and %^bchs% are converted to %bchsf% and %bchs% after the call so that the echo works.

 

so the echo command becomes, e.g.

echo %bchsf:~0,4%%%bchs%

To set a variable use

call set bchsf=%^bchsf:~0,%bbefl%%%%%^bchs%


#41 nando4

nando4

    Frequent Member

  • Advanced user
  • 112 posts
  •  
    Australia

Posted 30 October 2013 - 01:52 PM

 

found it! - try 

call echo %^bchsf:~0,%bbefl%%%%%^bchs%

a ^ inside a variable  %xxxxx% means 'don't translate' - so when call is run, %^bchs% is converted to %bchs%, then when echo is run it comes out right.

So bbefl is converted to a number and %^bchsf% and %^bchs% are converted to %bchsf% and %bchs% after the call so that the echo works.

 

so the echo command becomes, e.g.

echo %bchsf:~0,4%%%bchs%

To set a variable use

call set bchsf=%^bchsf:~0,%bbefl%%%%%^bchs%

 

Is there a couple too many %% in there? I had a go at changing the wenv string concats using this but unfortunately still haven't quite got it. Could you apply your expertise so we could have a new mbrview.g4b for use with newer grub4dos that has no wenv calls?



#42 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 01:56 PM

no, the number of % is correct. The 'call' will remove some of them so %%%%% becomes %%%.

If you use it exactly as I posted it should work. I did test it.

 

If you want leading spaces then use Fn.1 to print the string instead of echo and it will remove the quotes

!BAT
set bchsf=
set bchsf=x                                x
set bbefl=4
set bchs=99
call set bchfs="%^bchsf:~1,%bbefl%%%%%^bchs%" && call Fn.1 %bchfs%

This produces four spaces and then 99

 

    99

 

 



#43 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 02:21 PM

!BAT
set bchsf=
set bchsf=³               ³
set bbefl=4
set bchs=99
call set bchfs="%^bchsf:~0,%bbefl%%%%%^bchs%" ;; call Fn.1 %bchfs% | set bchfs=

echo %bchfs%

try this?



#44 nando4

nando4

    Frequent Member

  • Advanced user
  • 112 posts
  •  
    Australia

Posted 30 October 2013 - 03:53 PM

!BAT
set bchsf=
set bchsf=³               ³
set bbefl=4
set bchs=99
call set bchfs="%^bchsf:~0,%bbefl%%%%%^bchs%" ;; call Fn.1 %bchfs% | set bchfs=

echo %bchfs%

try this?

 

 

Have integrated the extra % and that part of the code is now OK. Though I've hit a wall replacing the get_length subroutine with gets a string length.

:get_length
wenv get %1
set %1l=%?_GET%

I tried Fn.12 but it just doesn't get the right string length. Any clues as to what is wrong here?

:get_length
::wenv get %1
:: set %1l=%?_GET%
call Fn.12 %%^%1%%
set %1l=%@retval%


#45 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 04:25 PM

call Fn.12 "%1" ;; set L=%@retval%


#46 nando4

nando4

    Frequent Member

  • Advanced user
  • 112 posts
  •  
    Australia

Posted 30 October 2013 - 04:55 PM

call Fn.12 "%1" ;; set L=%@retval%

 

Thanks. I tried it finding it doesn't work for me.  Appears that Fn.12 interpreting the variable but rather getting the length of the string passed.



#47 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 05:00 PM

works for me?

!BAT
set cc=wwwwww
call :LL %cc%
exit

:LL
call Fn.12 "%1"
set %1l=%@retval%
set

goto :eof

returns 

wwwwww1=6



#48 nando4

nando4

    Frequent Member

  • Advanced user
  • 112 posts
  •  
    Australia

Posted 30 October 2013 - 05:09 PM

call Fn.12 "%1" ;; set L=%@retval%

 

Can you see if this works for variables like "%1"?  It works fine for a literal string like 'call Fn.12 "mystring"' but fails when I pass a variable to operate on. (least did when I last booted to FreeDOS).



#49 steve6375

steve6375

    Platinum Member

  • Developer
  • 6709 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 October 2013 - 05:12 PM

but the example I gave uses %1 ????



#50 nando4

nando4

    Frequent Member

  • Advanced user
  • 112 posts
  •  
    Australia

Posted 30 October 2013 - 06:24 PM



but the example I gave uses %1 ????

 

Got it. Here's the fully working mbrview.g4b that no longer uses wenv. I also commented out the seperator lines between the partition listing giving a shorter, and in my eyes, nicer output. They can easily be uncommented back out if desired.

!BAT
debug 0
if "%1"=="" goto :error1
setlocal
set target=%1
if "%target%"=="/?" goto :syntax
if "%target%"=="-help" goto :syntax
::validate target
set cdev=%target:~0,1%%%target:~2,1%%%target:~-1,1%
if "%cdev%"=="(d)" set target=%target%+1
if "%cdev%"=="(x)" set target=%target%+1

cat --hex --skip=510 --length=2 %target% | set magic=
set magic=0x%magic:~10,2%%%magic:~13,2%
if "%magic%"=="0x55AA" goto :mbOK
echo No valid Magic Bytes: %magic% instead of 0x55AA
:mbOK
cat --hex --skip=440 --length=4 %target% | set disksig=
set disksig=%disksig:~10,2%%%disksig:~13,2%%%disksig:~16,2%%%disksig:~19,2%
echo Drive=%target:~0,5%, Signature=%disksig%
echo ÚÄÄÄÄÂÄÄÄÄÂÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³Part³Type³Boot³  Begin   CHS  ³   End   CHS   ³ LBA Start ³ LBA Sectors ³
echo ÃÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
call :part_entry 0 446
::echo ÃÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
call :part_entry 1 462
::echo ÃÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
call :part_entry 2 478
::echo ÃÄÄÄÄÅÄÄÄÄÅÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
call :part_entry 3 494
echo ÀÄÄÄÄÁÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
goto :EOF

:part_entry
cat --hex --skip=%2 --length=16 %target% | set part=
echo %part:~10,2%%%part:~13,2%%%part:~16,2%%%part:~19,2%%%part:~23,2%%%part:~26,2%%%part:~29,2%%%part:~32,2%%%part:~36,2%%%part:~39,2%%%part:~42,2%%%part:~45,2%%%part:~49,2%%%part:~52,2%%%part:~55,2%%%part:~58,2% | set pe=
echo %part:~10,2% | set as=

echo %part:~19,2%%%part:~16,2% | set bcs=0x
echo %part:~19,2% | set bc=0x
echo %part:~16,2% | set bs=0x
echo %part:~13,2% | set bh=0x

set /a bc2b=%bs%>>6<<6
set /a bs=%bs%-%bc2b%
set /a bc=%bc2b%<<2+%bc%
set /a bh=%bh%

echo %part:~23,2% | set pt=

echo %part:~32,2%%%part:~29,2% | set ecs=0x
echo %part:~32,2% | set ec=0x
echo %part:~29,2% | set es=0x
echo %part:~26,2% | set eh=0x

set /a ec2b=%es%>>6<<6
set /a es=%es%-%ec2b%
set /a ec=%ec2b%<<2+%ec%
set /a eh=%eh%

echo %part:~45,2%%%part:~42,2%%%part:~39,2%%%part:~36,2% | set slb=0x
set /a slb=%slb%

echo %part:~58,2%%%part:~55,2%%%part:~52,2%%%part:~49,2% | set ns=0x
set /a ns=%ns%

set bchs=%bc%/%bh%/%bs%
call :get_length bchs
set /a bbefl=15-%bchsl%
set bchsf=³               ³
call set bchsf=%^bchsf:~0,%bbefl%%%%%^bchs%

set echs=%ec%/%eh%/%es%
call :get_length echs
set /a ebefl=15-%echsl%

set echsf=³               ³
call set echsf=%^echsf:~0,%ebefl%%%%%^echs%

call :get_length slb
set /a sbefl=12-%slbl%

set slbf=³           ³
call set slbf=%^slbf:~0,%sbefl%%%%%^slb%

call :get_length ns
set /a nbefl=14-%nsl%

set nsf=³             ³
call set nsf=%^nsf:~0,%nbefl%%%%%n^s%³

set line=³ #%1 ³ %pt% ³ %as% %bchsf% %echsf% %slbf%%%nsf%

echo %line%
goto :EOF

:get_length
call call Fn.12 "%^%1%%"
set %1l=%@retval%
goto :EOF


:error1
echo Missing parameter
echo you must provide a target hard disk device
echo such as (hd0), (hd1), etc.
echo
goto :syntax
goto :EOF

:syntax
echo *mbrview.g4b* - grub4dos BAT! file by jaclaz
echo released under the jaclaz's CAREWARE license
echo Version 0.02 Alpha, updated nando4 without WENV
echo
echo syntax:
echo mbrview.g4b <device or file>
echo to make sense the device must have a MBR (be partitioned)
echo for isohybrid .iso's or CD/DVD's (cd) is also acceptable
echo as well as mapped drives like (0xFF)
echo or, if a file is used, it's first sector should be a MBR
echo examples:
echo mbrview.g4b (hd0)
echo mbrview.g4b (hd0,0)/myimg.img
goto :EOF

:end





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users