View Full Version : bootable floppy

03-07-2002, 03:35 PM
I have a bootable floppy (io.sys, msdos.sys & command.com) that also contains an exe file.

How can I make the EXE file run straight away without the need to type in its filename?

03-07-2002, 03:41 PM
Name it Command.com

03-07-2002, 03:41 PM
or Put it in the Autoexec.bat
You know Batch?

03-07-2002, 03:42 PM
How the hell will command.com work if I rename my EXE file command.com?


03-07-2002, 04:18 PM
It wont. I thoughjt you ment getting an EXE to work , without using autoexec.bat. Just add a line in the autoexec.bat. It ya dont know what that is , I suggest you learn DOS first.

03-07-2002, 04:53 PM
By adding up your posts for today it sems to me that you are trying to make a boot floppy that formats the hdd without any user interaction, but your not that kinda guy..right?

03-08-2002, 02:46 AM
To do that you would have to do several things. First you would have to patch the boot sector to both load and then jump to the EXE. Or you could patch the bootsector code and add code to the end of it (if there is space) that would jump to another sector of the disk, load your code, and then have that code load the EXE.

To run the EXE, you first have to know how to read FAT12. You need to look in the FAT first to find out the starting cluster of the EXE. Then you read in clusters via int 13h until you reach the last cluster in file mark or EOF. EXEs are relocatable code. This means you have to read in the data header for an EXE, look at the relocation table entry and relocate the code. Relocations make sure that the variable offsets within the code actualy point to the correct area of memory. You can look up more information on the EXE file header. It would be easier to load a COM since they are straight binaries and always start at 0100h into the load segment. You would only have to switch the stack, push some values to change the DS, CS registers and then execute a FAR return which would jump to the code and thus execute your COM.
EXEs are a bit different since they can have multiple segments - as many as memory will allow. So you cannot just jump to the byte immediately following the header. As you load the code, you must relocate it. I do have code that does this, but you are talking about pure assembly language here. So, if you do not know assembly language, you are pretty much out of luck.

The bootsector is 512 bytes long and resides at sector 1 on every disk. The actual bootstrap code start immediately after the BPB and DOS header stuff. The bootstrap code is 449 bytes long and the sector ends with 55 AA or 0AA55h. This tells the BIOS that this disk is bootable - called the boot signature.

I have code that will boot the machine, although it does little else, as well as code in C that will patch the boot sector with a new bootstrap and new header info. The code will also save the bootsector to disk as a bin file for backup purposes.

Let me know if you still wish to pursue this and I'll be much more straightforward with the information.