Grubinst Gui.exe Grub4dos Grub4dos.zip

0 views
Skip to first unread message
Message has been deleted

Latrina Cobbett

unread,
Jul 11, 2024, 7:47:26 AM7/11/24
to naecheejelpe

Happy new year to everybody !

I'm trying to improve a bit "grubinst.exe" and "grubinst_gui.exe".
It's my first time I'm modifying other programmer(s)'s source code. I hope Bean, Tinybit and Chenall won't be upset

What I did so far:
grubinst_gui.exe:
1. The window is now a DS_MODALFRAME instead of a WS_POPUP, meaning it can't be resized anymore. Which it's a good thing, because resizing doesn't help the user, on the contrary.
2. In the Options groupbox I added 2 checkboxes: "Skip MBR test" and "Silent boot". The first one is adding "--skip-mbr-test" to the command line, the second is adding "--silent-boot".
3. If Device "File" is used, it is adding quotes to the path to file in the command line. This way you can use even a file name with spaces in it.
4. When the user is clicking on the first Refresh button, the Part List combobox is cleared.
5. When the user is choosing a disk in the first combobox, the Part list combobox is not just cleared; the disk will be scanned for partitions and the list will be added to that combobox.

grubinst gui.exe grub4dos grub4dos.zip


Download Zip https://vbooc.com/2yLxYs



Now I have to actually modify the grub4dos MBR in the code.
2 ways:
1. In grubinst.c I can search for the messages in the grub_mbr variable and replace each of their chars with \0.
This is easy to implement but it is not so professional and the result will not be 100% complete.
2. Modify the asm code from grldrstart.S to not display those messages when the 4th bit in 0x80 byte is 1 (or to display the messages when the 4th bit in 0x80 byte is 0).
But this is not that easy.
From what I understand the compilation is done this way (it's simplified a bit):
1. grldrstart.S + ntfsbs.S >> grldr.mbr
2. bin2h.c + grldr.mbr >> grub_mbr.h
3. grubinst.c + grub_mbr.h >> grubinst.exe
Adding extra code to grldrstart.S means that grub_mbr variable will increase size and all bytes after the extra code will be shifted. Meaning probably I have to "resynchronize" it in grubinst.c
Also, since I'm not an assembler pro, I don't know how to modify this to work for the 4th bit:

I have previously asked chenall et al. for silent switches for booting and for grldr and they were very resistant to it as they 'need' to see any messages etc. in case of errors, etc. I would prefer it if there was a 'debug key' which the user could press on bootup (e.g. L-CTRL) which would display all messages but otherwise it was silent.

Normal installation of grubdos to the MBR means that the MBR sector starts with a non-standard sequence of bytes - it seems that some BIOSes actually look at the first few bytes for a 'valid' jump instruction and thus these BIOSes won't boot to grub4dos!

Unfortunately, grub4dos uses some of the initial bytes in the MBR as flags (e.g. timeout, hotkey scancode, etc.) and so by adding the extra 'compatible' code bytes to the beginning of the MBR, it shifts these flag bytes along.

Only partially, if you add one it will always start it as an admin no matter if you set in Properties or not. But the main problem will still be there...
Unfortunately, to properly get the information about drives and/or to write the MBR you need direct access.

This error appears because grubinst_gui uses the old WinExec function instead of a newer one like CreateProcess(W).
Only CreateProcess(W) is able to start another process with the same security context as the calling proceess.
Btw, in VMUB I use CreateProcessW...
I will try to implement it also in grubinst_gui.


It will take some time to figure out how to properly modify grldrstart.S so, for the moment, I implemented the first way. Btw, it wasn't so easy as I thought...


Another issue: I'm thinking of adding a new switch "--force-standard-mbr". Or at least to try to improve the filesystem type detection in get_fstype function.
Because it's not working properly. For example on all my USB flash drives and on the mounted virtual drives grubinst is saying "Unknown image type". No matter which combination of parameters I try, can't install grub4dos.
Unfortunately, RMPrepUSB is no different...
However, if in code I force the use of a standard MBR, all is fine. Grub4dos finally boots and the drives show no error.

Meantime I have made other modifications:
- "Read only" checkbox is now "Force standard MBR";
- "Force standard MBR": in case of file system detection failure, it will use a standard MBR (I'm open to suggestions for a better name/explanation);
- "Test" button now starts grubinst with "--read-only" switch;
- on success, "grubinst.exe --read-only ..." displays "The MBR/BS can be successfully installed".
- if grubinst_gui fails to start grubinst.exe it will show an error code.

If you could actually explain to me (I am a bit tough ) what is the connection between filesystem and choice of MBR code , and you could define WHICH code is to be intended as "Standard", I may be able to help.

I will take a look at the code. Just post it here.
But right now I'm thinking at a way to make grldr read the MBR byte where the options are stored (including --silent-boot) and not show those unnecessary messages on screen. The problem is I have to make it work in any situation: current MBR style + new grldr, new MBR style + current grldr, your current MBR style + new grldr and so on.
Plus I have to take into account the differences between grub4dos versions too...
Because of these I have chosen to modify grub_mbr in grubinst instead of modifying grldrstart.S (for the time being).

You will need a DOS bootable device copy the file C:\Grub4dos\GRUB.EXE to it. Boot from the device and wait for the DOS prompt, then type GRUB.EXE [ENTER] to load grub4dos. Alternatively grub4dos can be automatically loaded by adding an entry in CONFIG.SYS. To add an option to the Windows 98 (SE) boot disk menu, edit config.sys (in a text editor such as notepad) and add the following entries (for changes to original config.sys see here - changes are in red text) -

To load via Syslinux you will first need to install Syslinux to a bootable device. Copy C:\Grub4dos\GRUB.EXE to the drive containing your Syslinux files and add an entry to the Syslinux configuration file syslinux.cfg. e.g.

This method can be used to boot via the Windows NT/2K/XP boot loader ntldr, even when Windows is not installed - the boot device will however need to have a Windows NT/2000/XP partition boot sector (boot sector must call NT Loader ntldr). There are several utilities for installing the boot sector including -

Windows Vista's boot configuration file BCD (Boot Configuration Data) is a database similar in format to a registry hive and cannot be directly edited with a text editor. To add an entry for Grub4dos use the command line tool bcdedit.exe. To install grub4dos copy the file C:\Grub4dos\grldr.mbr to the Vista boot partition (usually the active partition on the first hard disk - the drive will contain the BCD store and bootmgr (Vista's boot manager)). To manually create an entry using Windows Vista -

To install grub4dos to MBR via Windows XP/2000 - download grubinst/grubutil package from here (or here). Grubinst.exe is a command line tool however a Graphic User Interface (GUI) is included in the download. Check the disk number allocated to the device you intend to install the grub4dos MBR to - use Windows Disk Management console (type C:\Windows\System32\diskmgmt.msc [ENTER] at a command prompt or in a RUN box). Installing to the wrong disk could result in Windows not booting so be careful. To install to MBR of disk:0 use command C:\Grub4dos\grubinst.exe (hd0); to install to MBR of disk:1 use command C:\Grub4dos\grubinst.exe (hd1); etc.

Using the Grubinst package, it is also possible to install Grub4dos code to the partition boot sector. Use command syntax grubinst.exe -p=n [device] or grubinst.exe --install-partition=n [device] (where n = partition number, starting from 0 for first partition. e.g. grubinst.exe -p=0 (hd0). Alternatively, use command grubinst.exe (hd0,0). grldr must be copied to the partition on which the bootsector was installed, and the partition must be active.

To install grub4dos to MBR via DOS or Windows 9x copy C:\Grub4dos\BOOTLACE.COM to the root of a DOS bootable drive/disk. Now reboot your PC and boot into DOS. To install Grub4dos MBR to the first hard disk (usually the first hard disk set to boot within the BIOS settings) use command -

To avoid installing Grub4dos to the wrong disk use a third party tool such as MBRWizD.exe (available here) to check the disk order. Copy MBRWizD.exe to the root of the DOS bootable device and type MBRWizD.exe /List - you should be able to identify the correct disk from the attributes outputted by the command (to install to disk 0 - use command BOOTLACE.COM 0x80; to install to disk 1 - use command BOOTLACE.COM 0x81; etc.). You will also need to copy grldr and menu.lst to the root of a (supported) local drive/disk.

Using the Grubinst package, it is possible to install Grub4dos code to the partition boot sector. Although this feature is documented in bootlace.com, attempting to install to the bootsector (using the command bootlace.com --install-partition=0 0x80) results in the following -

Use instead the DOS version of grubinst tool with command syntax grbins16.exe -p=n [device] or grbins16.exe --install-partition=n [device] (where n = partition number, starting from 0 for first partition. e.g. grbins16.exe -p=0 (hd0).

If the active partition contains a Windows NT/2000/XP/2003 bootsector (boot sector loads "NTLDR") an alternative method of installing Grub4dos to the partition boot sector is possible. Hex edit the bootsector and replace the text string NTLDR with GRLDR. A batch file for replacing the text string is available here.

7fc3f7cf58
Reply all
Reply to author
Forward
0 new messages