flat assembler
Message board for the users of flat assembler.

Index > OS Construction > An EXE header stripper program. how does it work?

Author
Thread Post new topic Reply to topic
milind



Joined: 15 Feb 2004
Posts: 33
milind
Hello,
I got this small example of a hello world OS from the web. It has 3 files: boot.asm, stripexe.cpp and copyboot.cpp. It gives the following instructions to make a bootable floppy:

1. Compile and link the file copyboot.cpp to copyboot.exe
2. Compile and link the file stripexe.cpp to stripexe.exe
3. Assemble BOOT.ASM using TASM
tasm boot.asm
4. Link the object file thus generated boot.obj
tlink /x /3 boot.obj
5. Strip the header off the file boot.exe
stripexe boot.exe boot.bin hdr.bin
6. Copy the boot sector code into a floppy
copyboot boot.bin
7. Restart The Computer

This all seems fine, and since now if I use FASM I think I can manage without the stripexe.cpp file since fasm can generate a flat binary file directly. But in the files provided i don't understand one thing in the stripexe.cpp code. The code opens the hdr.bin file and copies the 1st 512 bytes from the boot.exe file to it. Then it proceeds to copy the remaining bytes of boot.exe to boot.bin.
I don't understand this. My question is, does TASM generate a header which is 512 bytes in length??? I have also attached the file if someone is interested in going thru its code.
Any clarifications would be really helpful. Thank You.


The Extension 'cpp' was deactivated by an board admin, therefore this Attachment is not displayed.

Post 15 Feb 2004, 17:22
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Boot sector is 512 bytes?

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 15 Feb 2004, 18:47
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
milind



Joined: 15 Feb 2004
Posts: 33
milind
yes the boot sector is 512 bytes but the thing is 512 bytes are written to hdr.bin while the file actually written to the boot sector is boot.bin
Post 15 Feb 2004, 19:29
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph
Tasm will generate whatever header you tell it too, and in your case that seems to be a standard DOS MZ executable. A much better thing to do would've been to simply make tasm spit out a .com file which could be written directly to the boot-disk instead of going through the trouble of generating a header only to remove it in the next step. I would probably just ignore all that and rewrite boot.asm directly for fasm, which won't be too hard. Just make sure you're not specifying any destination file format and that you include 'org 7C00h' to make sure your absolute addresses are calculated properly.
Post 15 Feb 2004, 21:47
View user's profile Send private message Reply with quote
milind



Joined: 15 Feb 2004
Posts: 33
milind
Thank you Ralph, well I was thinking of doing the same thing. I just need one help, how do I write my binary file to the 1st sector of the disk??
Post 16 Feb 2004, 09:43
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
There's already a fasm source for writing a bootsector in menuetOS site to allow booting Menuetos from HDD
Post 16 Feb 2004, 13:02
View user's profile Send private message Yahoo Messenger Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog
http://bitdog.home.att.net/temp/bootread.zip
with fasm source
bootread.com & bootwrite.com
for floppy drive A:

FreeBee rough draft version, but it works.
Post 18 Feb 2004, 12:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.