Grub for dos

xiaoxiao2021-03-06  38

Take a look at the differences in each of the Series of Grub for DOS before entering the topic.

Grub for dos 0.0.x series is a version without any disk emulation extension features, which is fully equivalent to GNU GRUB. Here, the GNU GRUB itself has a disk mapping function. Disk mapping is a special disk simulation. Disk mapping can only map a BIOS disk number to another BIOS disk number, that is, it can only intend to intend to simulate, and cannot simulate another disk with a file in the disk. This version is also the safest and reliable, it can be considered that gnu grub has more security, and Grub for dos 0.0.x is much secure.

The GRUB for DOS 0.1.x series has all the features of 0.0.x, in addition to this, there is a floppy disk simulation extension. However, only the IMG file on the hard disk simulate the 1.44m floppy disk, and write the floppography, which means that the prohibition software is written to the floppography of the software via the INT13 interface. This version is not known for security issues.

GRUB for DOS 0.2.x series adds a floppy disk and hard disk of any specification, which is a relatively complete version. Its and 0.1.x series is that it is no longer protected by the simulated disk image by default. If you want to get the functionality of the 0.1.x equivalent, you must add -READ-ONLY parameters for the map command. [Note: 0.1.x Series also supports - READ-ONLY parameters, but even without this parameter, the 0.1.x series will automatically protect the disk image is not written. 】

Version 0.2.x Although supports writing virtual disk images, INT13 / AH = 05H function formatting virtual disk images is not fully implemented. When the magic is formatted, Grub for dos 0.2.x does not really adopt any substantive formatting action, that is, it does not change the content of any sector in the virtual disk, but only returns "formatted" Success "(a false) message similar to Fake Write is given to the call. This is not too big. Only one thing needs to be aware: When you need to format the virtual disk in DOS / WIN98, you should not be busy with formatting commands, but to run the delete command first, put all the files under the virtual disk root directory and all directories. Both delete, become a empty disk, then down to format the command, so that the formatted virtual disk can be used normally. Otherwise, the garbagete item before formatting is still remaining, which will affect the normal use of the virtual disk.

Since version 0.2.x supports writing virtual disks, checking of virtual disk boundaries is an essential step. The program has been protected by this. When trying to read or write those sectors that exceed the virtual disk boundary, the INT13 interface returns the failure information "Sector is not found" instead of being read or written (!!) hard disk immediately following virtual disks. The sector content behind the image. [Read these offshore sectors, there is no substantial danger; however, it is written to these offshore sectors will bring disasters to the hard drive. So this protection is necessary. 】

For documentation for the Grub for DOS 0.0.x series, please see here:

DOS Using GRUB.EXE Restoration Start Fault

For the documentation of the GRUB for DOS 0.1.x series, please see here:

Use GRUB to guide flutter images - save floppy disk media

Download GRUB for DOS from here:

http://newdos.yginfo.net/grubdos.htm (English homepage, thank you us!)

FTP: //211.100.7.71/incoming/ is also: ftp: //ftp.cosoft.org.cn/incoming/

Next, this article only discusses new features of the GRUB for DOS 0.2.x series.

First, safety considerations. At the time of version 0.1.x, since only the floppy disk is simulated, the security issue is not very important. However, 0.2.x is great, it can not only write a floppy disk, but this feature is opened by default. So, if you don't pay attention, you may have trouble. There are several cases:

First, if your program (or virus) is to write to the floppy disk, your floppography may change the content, which may not be the result you want.

Second, if you simulate the hard disk, after entering Windows98, the number of the hard disk may be misplaced [such as the BIOS disk 0x81 to 0x82, etc.]. At this time, if a hard disk image is written, another real hard disk may cause another real hard disk. Here, if you add -READ-ONLY parameters, security can still get better guarantees.

Third, even if the only-read parameters are added as described above, there is still a certain security hazard. The reason is that Win98 treats our INT13 simulation procedures as a virus to treat [Find in www.google.com MBrint13 can find such information], so Win98 may deliberate some errors to destroy our INT13 operation. It has not been found so far, "After the only parameter, Win98 still destroyed disk map", but it is absolutely safe.

Fourth, in the case of the overall map, after the - READ-ONLY parameter, the simulated disk is read only under DOS, but it is not read only under Win98. This is because Win98 is implemented for "32-bit disk access" [32-bit disk access "[should be called" protective mode disk access "], it does not use BIOS, so it doesn't know that we plus - Read-ONLY Parameters, so it will write to disk. In view of this, do not use the - READ-ONLY parameter in the case of the overall map [Of course, there is no disadvantage].

5. If there is no simulation of the hard disk, that is, only a floppy disk emulation command similar to Map Destination (FD0) is used, then it should be relatively secure under DOS. However, if you want to run Win98 after simulation: First use map --read-only destination (fd0) to run, when you can confirm that Win98 can properly read the contents of the simulation floppy disk, run Map next time You can no longer add - READ-ONLY parameters when you command. If you cannot read the contents of the simulation floppy disk, you will explain the wrong position [may read the sectors on other disks], which indicates that "writing simulation floppy" will bring disaster. So it is recommended to confirm using the - READ-ONLY parameters when running Win98, guaranteeing security.

For version 0.2.x, if a problem is only caused "crash", this is not considered a security issue. The security issue is only calculated when a disk sector is destroyed.

The use of floppy dish simulation is more, so, the usage of disk emulation commands is mainly used with examples of floppy dish simulation.

1. Simulation of a disk (for example, C :) on the hard disk is A:, from C: disk boot win98:

Map - READ-ONLY (HD0, 0) 1 (FD0) CHAINLOADER (HD0, 0) 1

Rootnoverify (HD0)

Boot

The above (HD0, 0) is a C: disk under Win98. After entering Win98, you can find that now A: The contents of the disk are exactly the same. At this time, if you are free to delete files at A: disk, it will cause C: disc also delete the file, so it is possible to cause a fault (such as a crash).

In the MAP command, (HDM, N) 1 is interpreted as representing the entire (HDM, N) partition, not just the first sector representing the partition. In contrast, in other places, (HDM, N) 1 still represents the first sector of the partition.

2. Simulation of a disk (for example, C :) on the hard disk is A:, and from A: Packed Win98:

Map - READ-ONLY (HD0, 0) 1 (FD0)

Map --hook

ChainLoader (FD0) 1

Rootnoverify (fd0)

Boot

You need to activate A: disk in the local simulation of the Map --Hook command. If there is no map --hook command, then the subsequent ChainLoader (FD0) 1 command is looking for content on the floppy disk of the real floppy drive, not the content on the virtual floppy disk we want.

The last rootnoverify (fd0) tells the boot program that we start the machine from the floppy disk.

3. Transistive aim of IMG file on the hard disk as A:, from C: C: disk boot WIN98

Map - Read-Only (HD0, 0) / File.Img (FD0)

ChainLoader (HD0, 0) 1

Rootnoverify (HD0)

Boot

4. Turn the machine with a floppy disk IMG file on the hard disk is A:, and use the file DOS.IMG inside the IMG image to boot the machine:

Map - Read-Only (HD0, 0) / File.Img (FD0)

Map --hook

ChainLoader (fd0) /dos.img

Rootnoverify (fd0)

Boot

Here, File.IMG is a floppy image file on the disc, in which a file called Dos.img is included in this image file. If you don't have to use the map --hook command (this command is enabled), you cannot access the dos.img file in the subsequent GRUB command line. This example only shows the role of the map --hook command, we usually do not use the methods in this example.

In the above command, the floppy disk can be any specification, any size.

Let's take an example of hard disk simulation, but it is best not to launch Win98, but should be limited to start DOS:

Map - READ-ONLY (HD2, 6) 1 (HD0)

Map --hook

ChainLoader (HD0, 0) 1

Rootnoverify (HD0)

Boot

Here, (HD2, 6) 1 is a logical DOS partition on the third hard disk. "The MAP (HD2, 6) 1 (HD0) command will extend the DOS partition simulation to the 0x80 hard disk of the BIOS. After activating [map --hook], "CHAINLOADER (HD0, 0) 1" (HD0, 0) 1 is the virtual 0x80 hard disk partition after the simulation, not the 0x80 hard disk partition before the simulation. . [The (HD0, 0) 1 here is actually the previous (HD2, 6) 1]. You should ensure that there is DOS in this partition, otherwise the guidance will fail. If you don't start Win98, you can not need to - READ-ONLY parameters. If you try to start Win98, it usually guides fails. Because the 63 sectors before the MS-DOS logical partition, a "extension partition partition table" is stored, so it is possible to simulate a hard drive. The boot record in the Extended Partition Table is all 00 bytes. Grub for dos 0.2.x made some modifications when reading this partition table, so that this table looks like a legal hard disk home partition table. GRUB for DOS does not write to the sector because the default SafeBoot works. This is safe. In this case, the -unsafe-boot option should not be added because Win98 will be free to write to the guiding sector of the virtual disk, which will result in the misplacement of the partition table information, resulting in the consequences of the expansion partition unacceptable [content is still, Just extend the partition meter error causes irrevable. Manually modify the extension partition table can solve this problem, but it needs to be accurate].

Example of the above hard disk simulation, if it is changed to the following manner, this will fail:

Map - READ-ONLY (HD2, 6) 1 (HD0)

CHAINLOADER (HD2, 6) 1

Rootnoverify (HD0)

Boot

There is a "hidden sector" field in the DOS boot record of the partition (HD2, 6). This field must be modified. If there is no map --hook command, this field will not be modified correctly, thus will result in the guidance failure. Modifying the field of this field is in the interrupt handler of the INT13, so it is required to read the content of the sector after Map --Hook [At this time, the sector content read has been properly modified]. After mapp --hook, CHAINLOADER (HD0, 0) 1 should be used to load the simulation (HD2, 6) 1, directly using ChainLoader (HD2, 6) 1 is wrong [Direct CHAINLOADER (HD2) 6) 1 results such that the sector cannot be used to make the necessary modifications using the interrupt handler of INT13, which will result in guidance failure]. Note that INT13 acts only on disk (HD0), which does not work (HD2), because the Map-READ-ONLY (HD2, 6) 1 (HD0) command is only simulated (HD0), and There is no simulation for other disks [including (HD2)]. Therefore, the INT13 program will modify (HD0, 0) 1 but do not modify (HD2, 6) 1.

Also, the above "modification" does not occur on the disk, but occurs in memory. Therefore, the sector content on the disk will not change. That is, when the sector is read, the read sector is modified to ensure that the sector content is available; while when writing a sector, the default SafeBoot works, so Will have a written action, directly return to the message of false "written success".

It has been explained earlier, SafeBoot protects the hard disk MBR main guidance sector and the first sector of the hard disk first primary partition (usually DOS guiding sectors) - only protects these two sectors, not protecting others Sector. GRUB for DOS 0.2.0 also includes bootgrub and grldr files [they are called "grub for ntldr"]. These two files are used to launch GRUB directly from the boating menu of Windows NT / 2000 / XP / 2003. Usage is to copy Bootgrub and GRLDR to Windows NT / 2000 / XP / 2003 C: Plate root directory [C: There should be hidden NTLDR and Boot.ini files in the root directory], then modify the boot.ini file, general It is a line similar to the bottom of the Boot.ini file:

C: / bootgrub = "Start GRUB"

Restart the machine and select the corresponding menu item to enter GRUB.

Security suggestions (this is written before, and now keep it, perhaps this is a good way to pay attention to):

1. If you use GRUB for DOS, try to use version 0.0.x, don't use it.

2. If you don't have to use 0.0.x, please use the version 0.1.x as much as possible, don't use it.

3. If you don't have to use 0.1.x, try to use version 0.2.x, don't use it.

4. If you use 0.2.x versions, try not to use a disk emulation command with MAP.

5. If you use the 0.2.x version, you also use the map command, please try to run in the virtual machine first.

6. After the version 0.2.x is tested in your virtual machine, try to run the parameters such as -Read-only in the real machine.

7. Although the Map command has been added to -read-only, please do not start Windows.

8. If you want to start Windows, try not to place an IMG image used to simulate in (HD0) drive.

9. If Windows is started, even if the image of the emulation disk is not on the (HD0) drive, you have to do the worst plan: one, if the simulation image is destroyed, you don't feel unexpected; 2, if a real thing Disk is all destroyed, you don't feel unacceptable; it's three, if you, all hard drives are scrapped, you don't feel too strange.

10. The simulation technology after version 0.2.x is used to skilled computer players as the purpose of research, not used by ordinary users.

11. Players are best to communicate with each other and study the failure of others in the use process, and read the instruction document in detail to avoid unnecessary losses.

In the initial test, there are many problems, which also damaged a lot of hard drives, so it is specifically notified here and writes the above precautions.

The new features of the MAP command are some dangerous, and it is recommended to test in the virtual machine of VMware or Virtual PC. First run the map command with the - READ-ONLY or - FAKE-WRITE parameter, which is tested in a read-only state, safe. After reading a test for a while, there is no problem, and it is fully tested. When testing, DOS / WIN9X / ME is installed on a virtual disk simulated in GRUB, and do not use other operating systems. Even if all tests succeed, this simulation technology still has its own inherent danger. This is based on BIOS-based simulation, not a full range of simulations. For example, when you format a disk, you have to understand whether this disk is simulated? And the format software you use is using the BIOS? Or use the disk IO port reading and write? Use the BIOS format software, The simulation is safe. Using the formatting software of the disk IO port, when it formsats a simulated disk, in the worst case, it will actually format your true hard drive, as for this hazardous misoperation, which hard disk On, depending on what kind of MAP command set (refer to the "Technical Detail and Implementation Method" below). Further test, please report the format command of DOS, the Format of Windows Explorer, the disk scaffold command, etc., and whether the HD-COPY such as third parties is safe when formatting. Technical details and implementation methods:

Grub for dos 0.2.x will be supported to the floppy image of various specifications. Since the simulation of the hard disk is similar, it is also necessary to support the IMG of the hard disk. In addition, Grub for dos 0.2.x also opens an operation of writing a virtual disk (written to the virtual disk is a dangerous operation, because in fact we write the hard disk IMG file, in case GRUB for dos 0.2.x The simulation program has bugs, written in other sectors of the hard disk, may result in serious problems such as data damage and cannot start!).

For floppy specifications: How to resolve technical issues proactively handle three-dimensional geometric addresses, that is, the usual CHS (C-track column number; H - head number; S - sector number). For true floppy drives (and flops), there are these specifications. However, we simulate the IMG file after the simulation, but it cannot represent these specifications. For example, a 1.44M has no formatted IMG file, all of which are 00, how to determine its CHS value?

When the IMG file has been formatted by DOS, the CHS value is determined using the BPB table of the floppy disk first sector. If there is no formatting of DOS, or if its BPB table is wrong, the CHS value is determined according to the size of the IMG file. If it is a standard (or common) floppy disk IMG size, such as 1.44m, 1.2m, 2.88m, etc., use known CHS values. We support the floppy disk size can even be arbitrary (non-standard), such as 10m or 50m or 500m floppy IMG file. At this time, if there is no legitimate CHS value in the BPB table, you need to manually set the CHS value with the MAP command line parameters. If the command line does not specify a CHS value, give an error message, refuse to simulate. When the floppy BPB table and the MAP command line are specified, the specified command line is specified, and if the two are different, give a warning message.

Soft disk specification list (not supported by the sector size is not equal to 512 bytes of anti-copy encryption floppy disk):

Floppy disk capacity The number of magnetic heads or faces in each fan area per surface

-------------------------------------------------- ----------------

0160K (standard) 40 08 1

0180K (standard) 40 09 1

0200K 40 05 2

0250K 50 (Temporary) 10 (Temfer) 1

0320K 80 08 1

0320K (standard) 40 08 2

0360K (Standard) 40 09 2

0400K (priority) 40 10 2

0400K 80 05 2

0420K 42 10 2

0500K 50 (Temporary) 10 (Temfer) 2

0640K 80 08 2

0720K (standard) 80 09 2

0729K 81 09 2

0738K 82 09 2

0747k 83 09 2

0756k 84 09 2

0800K 80 10 2

0810K 81 10 2

0820K 82 10 2

0830k 83 10 2

0840K 84 10 2

0902k ** 82 11 2

0984K ** 82 12 2

1066k ** 82 13 2

1200K (Standard) 80 15 2

1215K 81 15 2

1230K 82 15 2

1245K 83 15 2

1260K 84 15 2

1360K 80 17 2

1377K 81 17 2

1394K 82 17 2

1411K 83 17 2

1428K 84 17 2

1440K (standard) 80 18 2

1458K 81 18 2

1476K 82 18 2

1494K 83 18 2

1512K 84 18 2

1558k ** 82 19 2

1600K 80 20 2

1620K 81 20 2

1640K 82 20 2

1660K 83 20 2

1680K 84 20 21680K (priority) 80 21 2

1701K 81 21 2

1722K 82 21 2

1743K 83 21 2

1764K 84 21 2

1804K ** 82 22 2

1886k ** 82 23 2

2880K (standard) 80 36 2

3198K 82 39 2

3608k ** 82 44 2

3690k ** 82 45 2

3772k ** 82 46 2

(Thanks to the Roy brother to provide a large amount of disk specification)

The hard disk is complicated than the floppy disk. The hard disk first sector is not a boot area of ​​the DOS, but the main boot record (MBR), there is no BPB table, but there is a partition table. Therefore, for the hard disk's CHS, as the following processing:

When there is no partition table or partition error, the MAP command line must be specified, otherwise the simulation is refused. When the partition table exists, any of the four partition entries can determine the value of H and S. Use the IMG file length to determine the value of C. [The CHS value of the big hard disk is also determined by this method. 】

It is also possible that someone is not willing to give the command line CHS parameters, they want GRUB FOR DOS to choose an appropriate value. The MAP command will provide an option. First determine CHS according to the above BPB or partition table, if it fails, use the following method to determine. For floppy disk, try to use parameters with 2 heads. For hard disk IMG files, if Grub for DOS is movable, 63 sectors, 256 heads are always selected.

DRIVE_MAP_SLOT structure:

Byte: from_Drive - Which BIOS disk number is mapped to another disk number or map to another IMG file?

Byte: to_drive - the mapped disk number. BIOS disk number: 0, 1, ... indicates the floppy disk, 0x80, 0x81, ... represents the hard disk.

Byte: max_head - maximum header. Value range: 0 to 255.

Byte: max_sector - the maximum sector code. Value range: 1 to 63.

4 bytes: start_sector - the start fan area number of the mapped IMG file.

4 bytes: sector_count - The total number of sectors that are mapped to the IMG file. Must be an even number.

When the value of the max_sector is 0, it means that the general disk read / write interrupt (for example INT13 / AH = 02) [Map command line parameters - Disable-Chs-mode] is prohibited. Max_sector is also useful. The highest bit is 1 indicating that the read-only operation [Map command line parameters - READ-ONLY or - FAKE-WRITE], the sector data written to the simulation floppy disk is discarded. The second high is 1 indicates that the expansion disk read and write interrupt (for example INT13 / AH = 42H) [MAP command line parameters - Disable-LBA-MODE]. Sector_count is the total number of sectors. This number must be an even number (when it is odd, one sector at the end does not participate in simulation). Therefore, the minimum bit of Sector_Count is also useful. When this bit is 1 and the max_sector is 1, it is 1 when the max_sector is 1, indicating the "command line parameters of the" Map "operation [MAP command line parameters". "Camouflage Write" and "Reading" are similar, the difference is that after "Reading", after the sector throws away, tell the caller program: "This disk is written, can not write"; and "camouflage Write "After the sector throws away, the deceived caller program says:" Successful write, please continue. "[We sometimes really need this feature]. When the start_sector is 0 and the high 31 bit of the sector_count is 0, it means that the entire disk (instead of a portion of the sector) is simulated [Sector_Count's lowest position indicates "camouflage write"], so that the simulation is highly efficient. [GNU grub original simulation is like this, the code is also very simple]. When sector_count is an odd number (i.e., -fake-write setting) and the maximum bit of Max_sector is 0 (i.e.,-Readly is not set), called SafeBoot, at this time, although the virtual disk is allowed, A first sector (boot area) of the virtual disk is not allowed. Also, if the virtual disk image is a hard disk image, it is not allowed to write to the first 16th sector of the 0th Cylindrical No. 1 (that is, the sector of the logical sector number LBA = 63, which is usually the boot of the operating system. Sectors, such as the Boot Record, such as DOS. This is for INT13 / AH = 03h. The program does not prohibit the write to INT13 / AH = 43H (extension writing feature). That is, any sector can be written with INT13 / AH = 43h. SafeBoot is turned on by default, you can use the Map command line parameter --unsafe-boot to close it. [Note: There is no - Safe-Boot option. The reason why SafeBoot is opened by default because it has happened to the Win98 destroying guidance zone. If you are not ready to start Win98, you can add the --unsafe-boot option to allow int13 / AH = 03H to write into the boot sector. Obviously, only the -unsafe-boot option is required when partitioning and formatting on the virtual disk, or if the SYS command runs DOS. 】

There are two command line parameters: Map command:

--Heads-per-cylinder = number_Heads

--sectors-per-track = Num_sectors

Num_Heads ranges from 1 to 256; Num_sectors ranges from 1 to 63. But they also allow 0, which means that the user allows the GRUB for DOS to pick a suitable value. If the Map command line does not specify -Heads-Per-cylinder, then, when GRUB FOR DOS can't detect a suitable value from the first sector of the IMG file, it will give an error. Information and refuse to simulate. Here is a point limit. Grub for DOS extends the simulation of the original GNU grub. GNU grub's original simulation is a simple simulation, which can only simulate the entire disk, and cannot use some sectors to simulate. The new simulation can simulate some sectors on disk, but this feature is implemented, using the new BIOS logical block addressing (LBA) function, that is, disk extension read and write functions. This is invalid for old BIOS. Therefore, the old BIOS cannot take the new simulation function. However, Grub for DOS is compatible with GNU Grub's simulation, so old BIOS can still use the "use of the entire disk" function using GRUB for DOS, which is the original GNU Grub, which is used in GRUB for DOS. There is no change at all.

Instant help information can be viewed with the Help Map command in the GRUB> prompt.

The usage of several other MAP command line parameters is described below.

Map --status This command displays the status of disk simulation, it is useful. In the displayed status title bar, the rightmost HK represents hook meaning, and its value is two binary number XY, so there are four types: 00, 01, 10, 11. When X is 1, it means that GRUB is now using the virtual disk. When x is 0, it means that the GRUB is now not using the virtual disk. When Y is 1, the GRUB will use the virtual disk after running the Map -rehook command. When Y is 0, the GRUB will not use the virtual disk after running the map -rehook command.

The other status values ​​displayed by the map --status command are easy to understand, they are values ​​represented by hexadecimal.

Map --hook This command is used to start using simulation directly within GRUB. Usually the grub itself is not used simulation. After this command, the effect of the simulation can be started from the GRUB command line. Cool! Turning off this function is map --unhook

Map --unhook is as explained above, shutting down the real simulation function of GRUB.

Map --rehook This command is used: When you use the map --hook command, you can use the new map command to map other disks, then you can activate all these simulations with the map --rehook command. This command is equivalent to the following two commands:

Map --unhook

Map --hook

When the disk simulation is revoked, it is not enough to use Map -unhook, and it is necessary to cancel (FD0) simulation with a command similar to MAP (FD0) (FD0). The "map --unhook" command only makes it only to use the simulation under the grub command line. When you use the boot command, it will automatically hook again. To make a map destination from_drive command completely invalid, you must use the map from_drive from_drive command to undo it [map a BIOS disk number to itself, which means to revoke it]. After the simulation of partial BIOS disk numbers, it is generally necessary to run the map --rehook command. For example, the "MAP (HD1) (HD1) command revokes the simulation of (HD1), but it works after running" Map --Rehook ". Some legacy issues:

1. Support from the ISO image file startup. (The situation is complex, there is difficulty)

2. Support from CDROM startup. (The situation is complex, there is difficulty)

3. Supports running GRUB from Win98. (High technical difficulty)

4. Automatically detect and restore the BIOS interrupt vector, so that GRUB for DOS supports any real-mode DOS. (Technical difficulty is medium)

5. Grub for DOS can also be run when the EMM386 is run (first resolving the switch to the real mode). (High technical difficulty)

6. Some conflicts of WIN98 are solved in disk simulation. (High technical difficulty)

7. Increase the function of exiting to DOS. (Technical difficulty is medium)

8. Create a tool that can generate a "file with a continuous disk sector".

Interested friends will continue to develop for Grub for DOS.

转载请注明原文地址:https://www.9cbs.com/read-63271.html

New Post(0)