Jump to content











Photo
* * - - - 1 votes

improving grubinst and grubinst_gui in Windows and Linux


  • Please log in to reply
329 replies to this topic

#301 steve6375

steve6375

    Platinum Member

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

Posted 30 March 2015 - 01:05 PM

Its on Technet

http://download.micr...ec_10_18_06.doc



#302 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 30 March 2015 - 01:19 PM

Thanks, Wonko, but, unfortunately, most of what you're saying I already know for years :(.

Thanks my sock! :ranting2:  

WHY then you asked for it? :dubbio:

 

 

 

Does anybody know where I can find info about vhds internal structure? I'm talking about both vhd types: dynamically allocated and fixed size.
 

 

You would have already known that the fixed has a footer (and not a header) and that it was a RAW image, and that there was no need whatsoever for knowing it's format, since there is none, and certainly no need to add support for it in grubinst as fixed vhd's are ALREADY supported in it, or, to be more exact, as supported as RAW images.

Anyway, no prob :), I should know better than going around and try to help people.  :angry7:

:duff:

Wonko



#303 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 30 March 2015 - 01:23 PM

Yup, it's what I was talking about:

 

Clipboard02.png

 

Clipboard03.png

 

Thank you very much, Steve :)



#304 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 March 2015 - 01:14 PM

Steve, I have been thinking at your idea to store the removable bit status (on/off) in the Grub4Dos MBR/PBR.
Chenall and Yaya have said nothing when you asked them. So it seems they're not so happy about it.
But I found a way for you to make a custom grubinst.exe by just commenting/uncommenting a line of code in grubinst.c:

Not implemented:

#ifdef WIN32
//#define STORE_RMB_STATUS 1
#endif


Implemented:

#ifdef WIN32
#define STORE_RMB_STATUS 1
#endif

The rest of the code checks for this STORE_RMB_STATUS (defined or not).

For now I implemented in the "code byte" of the Grub4Dos MBR. But if we find a good location in PBR, I can implement for this too.

 

Attached File  grubinst exe.7z   47.33KB   570 downloads

 

Attached File  grubinst.c.7z   11.86KB   451 downloads

Here is a Grub4Dos script showing how you can check the value from the "code byte":
 

!BAT

clear
dd if=(hd0) of=(md)0x19000+1 > nul
set G4DVER=0.4.5c > nul
cat --hex --number=1 --locate="Missing MBR-help" (md)0x19000+1 | set TXTPOS=
if "%TXTPOS%"=="" && set G4DVER=0.4.6a && cat --hex --number=1 --locate="Missing helper." (md)0x19000+1 | set TXTPOS=
if "%TXTPOS%"=="" goto nogrub
echo Grub4Dos %G4DVER% MBR found
if "%G4DVER%"=="0.4.6a" goto 046a
#0.4.5c
cat --hex --length=5 (md)0x19000+1 | set HDR=
if "%HDR:~10,8%"=="33 C0 EB" goto enhver
#normal version
cat --hex --skip=0x2 --length=1 (md)0x19000+1 | set CTRLB=
set /a CTRLBN=0x%CTRLB:~10,2% > nul
set /a ISON=%CTRLBN% & 16 > nul
if not "%ISON%"=="0" && echo The disk is removable && goto end
set /a ISOFF=%CTRLBN% & 32 > nul
if not "%ISOFF%"=="0" && echo The disk is fixed && goto end
echo Removable bit status not stored in Grub4Dos MBR!
goto end
:enhver
#enhanced version
cat --hex --skip=0x4 --length=1 (md)0x19000+1 | set CTRLB=
set /a CTRLBN=0x%CTRLB:~10,2% > nul
set /a ISON=%CTRLBN% & 16 > nul
if not "%ISON%"=="0" && echo The disk is removable && goto end
set /a ISOFF=%CTRLBN% & 32 > nul
if not "%ISOFF%"=="0" && echo The disk is fixed && goto end
echo Removable bit status not stored in Grub4Dos MBR!
goto end
:046a
cat --hex --skip=0x5A --length=1 (md)0x19000+1 | set CTRLB=
set /a CTRLBN=0x%CTRLB:~10,2% > nul
set /a ISON=%CTRLBN% & 16 > nul
if not "%ISON%"=="0" && echo The disk is removable && goto end
set /a ISOFF=%CTRLBN% & 32 > nul
if not "%ISOFF%"=="0" && echo The disk is fixed && goto end
echo Removable bit status not stored in Grub4Dos MBR!
goto end
:nogrub
echo Grub4Dos MBR not found! && pause --wait=10
:end



#305 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 04:08 PM

Thanks for that.

It would be better if you could just auto-detect whether the drive is Removable or not in grubinst (or GUI?) and update the bit accordingly.

Maybe you could also check for the Hitachi/cfadisk/microdriver installed too?

 

0 = unknown (cfadisk type driver installed)

16 = RMB=1

32 = RMB=0

 

There could be a listbox in the GUI so that if a driver was install = (unknown) the user could change it to either Removable or Fixed manually.

 

In VB6 I use this to get the RMB bit...

With SCSIPass.Spt
    .Length = Len(SCSIPass.Spt) + 3
    .PathId = 0
    .TargetId = 1
    .Lun = 0
    .CdbLength = SCSI_PASS_THROUGH_CDBLENGTH.CDB6GENERIC_LENGTH
    .SenseInfoLength = 24
    .DataIn = SCSI_PASS_THROUGH_DATAIN.SCSI_IOCTL_DATA_IN
    .DataTransferLength = 192
    .TimeOutValue = 2
    .DataBufferOffset = Len(SCSIPass.Spt) + 35
    .SenseInfoOffset = Len(SCSIPass.Spt) + 3
    .Cdb(0) = SCSI_PASS_THROUGH_OPERATION.SCSIOP_INQUIRY 
    .Cdb(1) = &H8
    .Cdb(2) = &H0
    .Cdb(4) = .DataTransferLength
  End With
    
  TmpLen = 0
  retval = DeviceIoControl(GHandle, IOCTL_SCSI_PASS_THROUGH, SCSIPass, Len(SCSIPass), SCSIPass, Len(SCSIPass), TmpLen, ByVal 0&)
  If TmpLen > 0 Then
    With SCSIPass
    t = Trim(GetSTRbyBuff(.DataBuf, 8, 15, True) & " " & GetSTRbyBuff(.DataBuf, 16, 31, True))
    DRV_MODEL = t
    DRV_FIRMWARE = GetSTRbyBuff(.DataBuf, 32, 35, True)
    If (.DataBuf(1) And &H80) = 128 Then t = "REMOVABLE MEDIA" Else t = "FIXED MEDIA"
    D_MEDIATYPE = t
    End With
  End If
  Call CloseHandle(GHandle)


#306 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 March 2015 - 04:47 PM

 

Thanks for that.

It would be better if you could just auto-detect whether the drive is Removable or not in grubinst (or GUI?) and update the bit accordingly.

 

 

Have you checked "grubinst --help" to see the latest switch I added? :D


  • steve6375 likes this

#307 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 05:35 PM

I just looked at the code - it already does it automagically  :1st:

Does it work for linux and Windows?

I could use the new version in RMPrepUSB and Make_E2B script.

I will check it out and report back...

thanks!



#308 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 March 2015 - 06:20 PM

Just in Windows for now.



#309 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 06:30 PM

I used the GUI and added  --rmb-status=auto   it seems to work for USB HDD and USB Removable drives :-) :1st:

 

A few points, if I may... :dubbio:

  1. Could it output the type of drive found to the console so we can use the Test button and see what it finds - this would be useful if anyone has the filter driver installed as they could see that it always reports a fixed disk.
  2. Why does the GUI report both my NTFS flash drive and Removable drive and two internal drives as 'File system  obsolete version'?
  3. Can the next version of the GUI have a box added and can auto be selected by default? (choice of auto,removable, fixed, unknown)?
  4. Why not make the default case for grubinst (i.e. rmb-status is  not specified on command line) = auto?
  5. Add a --rmb-status=none  to set it to 'unknown' for those odd people who want to hide the RMB status.


#310 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 March 2015 - 07:03 PM

1. Ok, I'll try to implement.
2. If the GUI doesn't find the latest 0.4.5c/0.4.6a MBR/PBR versions, it calls them "obsolete".
But, if you're sure you have the latest version, please send me that MBR/PBR so I can check.
3. I don't know, the idea was to modify grubinst in such way so you could compile a RMB version. I will release the official version without the RMB (//#define STORE_RMB_STATUS 1); you will uncomment it (#define STORE_RMB_STATUS 1) and recompile the sources in Mingw (as you described in tutorial).
This way you and the RMPrepUSB/Easy2Boot users will be happy for using that version in RMPrepUSB and Make_E2B script but also Chenall and Yaya will be happy too for keeping the code byte entries free in the official version.
Btw, I removed the "silent boot" code byte entry for some time too. Without the Chenall/Yaya support was useless anyway...
I just kept the usual option.
4. See 3.
5. Why would they wanna hide it?



#311 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 07:10 PM

2. I mean just the disk filesystem

 

Didn't they say to go ahead and create a fork?

I don't see what harm two extra bits can have?

If they do continue to develop grubinst then they will use your sources and so the bits will already be reserved. Otherwise they would be creating a non-compatible fork.

Why not make --rmb-status=auto the default? They did actually not object did they?

 

having two binaries (one with the feature and one without) will create confusion.

Hopefully your new version will be the new 'standard' version soon :good:

Attached Thumbnails

  • CaptureObsolete.JPG


#312 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 07:27 PM

re. #5   for instance, under a VM a Removable-type USB flash will actually be working as a fixed-disk - maybe someone wants to configure the grub4dos table so that it reads as (unknown) or maybe they don't want either bit set or maybe the user knows he has a filter driver installed but doesn't know what type of disk they have and so they want to set it as unknown. It is just an option to cover all bases and be able to set any of the 3 states really.

 

P.S. 0.4.6a has a silent flag now

0x2073 BYTE  0=silent, 2=normal

why did you remove it?


Edited by steve6375, 31 March 2015 - 07:29 PM.


#313 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 March 2015 - 07:46 PM

2. That's not suppose to be there. Do you have the latest version of the GUI and the language files?
Is it always displayed? Is the only choice? If you move "grubinst_gui.eng" in another folder and restart the GUI, is it still displayed?

 

Clipboard02.png

3. For a while I will develop them as separate versions. But if the RMB version will be liked more then I'll switch to it.

5. That's a little weird, the user knows half, he doesn't investigate so he would know all but instead sets to undefined/unknown.
Even so, the on/off manual switches should be enough for most of these rare situations.
In a VM where the disk is always "fixed", they could set "off".

Yes, 0.4.6a has a silent patch, but there is no link between the silent boot switch from MBR and the patch from grldr. In other words, grldr doesn't know how to check the silent boot option from the MBR code byte.



#314 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 08:08 PM

Doesn't the code load grldr?

Can't it patch the memory location after loading it?

I will check about the filesystem issue (may be a win8.1 x64 issue?)



#315 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 31 March 2015 - 08:25 PM

Doesn't the code load grldr?

Can't it patch the memory location after loading it?

 

In normal programming is easy to do this but not in assembler in a boot record.

Also you have to be careful to not brake the other functions + to still fit into 8/9 KB.

For this an asm expert is needed. I'm not :(



#316 steve6375

steve6375

    Platinum Member

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

Posted 31 March 2015 - 08:32 PM

I'll take a look when I get time, patching should be easy, checking it is the correct version to patch might be a bit more tricky!



#317 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 01 April 2015 - 04:43 AM

I tested in Windows 8.1, no problems with grubinst_gui.

 

I checked and, for Regional Options >> Standard and formats >> English (United Kingdom), grubinst_gui.eng is indeed automatically loaded.

Most likely its version is different from grubinst_gui.exe's version.

 

The latest versions: Attached File  grubinst_gui exe and lngs.7z   67.57KB   613 downloads

 

Anyway I added grubinst_gui.eng only for testing, because obviously is not needed (the interface is already in english).

 

Also I have modified grubinst.exe to display the state of the removable bit when "verbose" and "--rmb-status=auto" are used.

 

Attached File  grubinst.7z   47.4KB   515 downloads

 

In the current implementation, you can get the undefined/unknown state by simply not using the"--rmb-status=" switch.

 



#318 steve6375

steve6375

    Platinum Member

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

Posted 01 April 2015 - 09:31 AM

No problem with filesystem now with those versions. Thanks.



#319 steve6375

steve6375

    Platinum Member

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

Posted 01 April 2015 - 12:35 PM

What the github URL where I can pull latest grubinst sources from so I can test mods to grldrstart.S pls?



#320 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 01 April 2015 - 01:03 PM

I haven't created a github project yet.

You can use this sources:

 

Attached File  grubinst Windows latest sources.7z   168.09KB   506 downloads



#321 steve6375

steve6375

    Platinum Member

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

Posted 01 April 2015 - 06:44 PM

hmmm - it seems the NTFS code is really tight on space! :dubbio:

Just adding in 4 or 5 instructions and it breaks it by making it too long!

I think I will have to pass on this!

Each code section will need modifying (for FAT, ext, exFAT, NTFS) and it's a real pain! :whip:

Sorry!



#322 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 03 April 2015 - 08:24 AM

Attached File  grubinst Windows binaries.7z   82.25KB   2374 downloads

 

Attached File  Grubinst Linux binaries.7z   1.04MB   680 downloads

 

Attached File  grubinst_gui languages.7z   2.24KB   779 downloads

 

Attached File  grubinst sources.7z   228.44KB   692 downloads

 

Changed a bit the way the chosen filesystem is passed to grubinst. For example, if you choose "MBR" instead of "AutoDetect" and select a partition instead of "Whole disk (MBR)", the command line switch specifying the filesystem type won't be "--file-system-type=MBR" but "--file-system-type=partition's_filesystem".
Also, in the Linux version, a rare interface bug was solved.


  • ndog37 likes this

#323 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 03 April 2015 - 09:35 AM

And a notice: 5 years ago I was diagnosed with Parkinson disease.
The medication helped me to continue my work here. But, lately, even this is not enough.
This is half of the reason a few months ago I tried to disable my account here.

My (real) name is not DavidB and I'm not from Norway. It's just a random name/country I picked up so I can made an account, like I have on many other forums.
Why I (usually) hide my real name/nationality:
1. I don't trust the internet.
2. My country (Romania) is not so well "seen" by other countries (unfairly).

Now I will log out and never come back.
I have to do it so I can have some peace in my last few years.

Good bye, everybody. And thank you.
Hope to see you all in the other life.

Cosmin


  • phoenixmet likes this

#324 steve6375

steve6375

    Platinum Member

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

Posted 13 April 2015 - 08:23 AM

I think of you every day.

Thank you for the contribution you have made to the world.

Best wishes

Steve



#325 Blackcrack

Blackcrack

    Frequent Member

  • Advanced user
  • 458 posts
  •  
    Germany

Posted 13 April 2015 - 09:06 AM

humm.. once more who be once of the best in the world where go passed ..

...no words...

i hope you time where you have now, it's once of the best..

 

and i say also thank you Cosmin !

 

thank in all honor !

 

best regards

Blacky






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users