OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:31 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 12:23 am 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
I have the sample of an EXE file with code, data and a stack. I built it fully by hand and set up its stack in the program's code, also by hand.

They all (data and stack variables) are referenced relative to the position after the paragraphs of the MZ header.

I have included the file SAVEMEG.DAT to show the exact position and layout in memory of the EXE when loaded into memory. We just need to find the string "This is a command line to find the start and the end of" to find the sample command line of this program and its PSP as a result.

We can see that the EXE loader just interprets the EXE header, removes it from the image to load (normally 32 bytes long). After removing it, it generates a 256-byte PSP at the start of a segment and then loads the rest of the EXE as indicated by the size of the EXE in the MZ header as if it was a COM file but that can be more than 64K in size.

Obviously each compiler will have its own techniques to be able to use code and data among several segments, with a structure and techniques very similar to those used for being able to call and reference BIOS code and data.

But since this EXE is made fully by hand (without compilers or linkers involved), we will have to develop and maintain our own techniques to achieve the same.

We could have also created a COM file loader, then just have loaded a COM file greater than 64K. With that, we would have loaded a big COM file that supplies the vast majority of needs of a regular EXE file.

With this skeleton we can now start to learn bit by bit more practical things, like loading and executing VxD drivers all by ourselves.

However, I need to investigate and document how to implement and use relocations, which will surely be aboundantly used in VxDs.

Also, it will help to better understand LE (used by VxDs) and NE EXEs (used by Win16).

With that, along with the information about building and implementing GUIs, we could start making simple 16-bit programs that contain WinAPI functions implemented by us and now treat the WinAPI as yet another library ported natively to DOS and then to our own OSes.


Main source code:
http://archive.org/download/tmp_tests/MZ_EXE/_TMP_/MZ_EXE_SAVEMEG/src/savemeg.asm

Full source code:
http://archive.org/download/tmp_tests/MZ_EXE/_TMP_/MZ_EXE_SAVEMEG.zip

Sample memory disposition of the EXE in memory (it starts with the 256-byte PSP at physical offset 0x1920):
http://archive.org/download/tmp_tests/MZ_EXE/_TMP_/MZ_EXE_SAVEMEG/src/SAVEMEG.DAT

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Last edited by ~ on Tue Aug 30, 2016 3:00 pm, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 12:25 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
I have added you to my "foes" list. :roll:
I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now. This is not a DOS programming forum. If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here. :roll:

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 12:31 am 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
I know relatively little.

But I need to study and publish this information in a much clearer way, by examples.

After fully developing this basic level, I will try to advance a simple step towards using VxD drivers in my own OS and GUI.

This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits, and also invoke those modes and return from them, for example, to start and finish loading a custom OS.

It's temporary code, it is better referenced on the spot.

I guess that if I was to implement a full DOS system, it would receive criticism all the same by several people, but I really need to work at that level because it matches perfectly what I know and what I need to explain in the way I better can.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 12:37 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
The only OS which supports MZ executables is DOS. Windows and Linux support them through emulation, and even 64-bit Windows doesn't support them due to the absence of virtual 8086 mode.
~ wrote:
This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits

What does this even mean? An MZ executable is not an OS, and cannot be ported to 32-bit or 64-bits. PE32 and PE64 files have an MZ header, but that doesn't make them MZ executables. The MZ program just prints "This program cannot be run in DOS mode." or a similar message.
Oh, and about LE and NE executables, both are just as deprecated as DOS is. Maybe you could document on PE instead; that would be more useful for this forum/wiki.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 1:07 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
omarrx024 wrote:
~ wrote:
This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits
What does this even mean?


Probably, DOS-excluding was meant.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 1:25 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
I must say, this (creation of various DOS/Windows/Linux/whatever executables manually) has been done before and examples can be found online. It may be a good exercise for you, but I seriously doubt that the rest of the forum users are interested in this code of yours or in making DOS MZ EXEs by hand. Or in trying to resurrect and reuse bits of Windows 9x.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 1:37 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
~ wrote:
Stop using archive.org as a file sharing platform.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 2:32 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

~ wrote:
This is not a DOS-exclusive forum but that is a valid OS which can be ported to 32 and 64 bits, and also invoke those modes and return from them, for example, to start and finish loading a custom OS.


The "OS Development" sub-forum (and the entire OSdev forums in general) are specifically for people creating new operating systems. It is not for people creating applications for any existing OS (Windows, Linux, FreeDOS, MS-DOS, etc).

Also note that what people consider an OS has changed in the last several decades; and MS-DOS no longer really qualifies as an OS (if it ever did). If you compare MS-DOS to UEFI you'll find that UEFI is more like an OS than MS-DOS ever was, but nobody thinks UEFI firmware is an OS. In today's world, you'd have to downgrade DOS to "about 10% of an OS".


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 2:58 am 
Offline
Member
Member

Joined: Wed Jun 17, 2015 9:40 am
Posts: 501
Location: Athens, Greece
Hi,


omarrx024 wrote:
I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now.
I second that.

omarrx024 wrote:
If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here. :roll:
Please, don't encourage him to use the wiki. He will spam it with, well, spam.


Regards,
glauxosdever


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 3:07 am 
Offline
Member
Member
User avatar

Joined: Wed Jul 13, 2011 7:38 pm
Posts: 558
omarrx024 wrote:
I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now.

Of the list of 16 moderators on this forum, only three of them actively visit. One other one is in the IRC frequently. The rest haven't been around in years, or show up once in a blue moon to post and then disappear again.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 3:54 am 
Online
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
glauxosdever wrote:
Hi,


omarrx024 wrote:
I really think the mods should do something about your posts. I'd like a decent explanation for their quietness until now.
I second that.

omarrx024 wrote:
If you know so much on MZ, then maybe write something on the MZ Wiki entry, but not here. :roll:
Please, don't encourage him to use the wiki. He will spam it with, well, spam.


Regards,
glauxosdever

The simple answer is to put the guy on your Foes list and stop replying to his posts, rather than feeding him. That way you need never know that they exist.


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 4:53 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
I think it's not a complete answer. I did that, but I still see him in "View unread posts". I can also see his posts in the forum index and the forums themselves. Why can't Brendan or Combuster just ban him? Aren't we all sure he is not appropriate for this forum and only spreads unrelated garbage?

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 9:26 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
onlyonemac wrote:


Why are you guys so mad about him using that website???
When I type archive.org and press enter I go to a site called "way back machine"? What is going on?

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 9:52 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
octacone wrote:
Why are you guys so mad about him using that website???
When I type archive.org and press enter I go to a site called "way back machine"? What is going on?
archive.org is a project aimed at preserving digital artefacts for historical reasons, much like a traditional archive or museum preserves physical artefacts. The Wayback Machine part of the site archives (read: preserves) old versions of websites. They also archive other forms of historically-significant (or likely to be historically-significant in the future) digital media, such as e-books/digital texts, music/internet radio/podcasts and software. ~ is using the site as a cloud storage and file-sharing site, specifically to store his code in a place that he can find it easily and to link to it from this forum.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: MZ EXE Skeleton Made By hand
PostPosted: Sun Aug 28, 2016 12:12 pm 
Offline
Member
Member
User avatar

Joined: Mon Dec 28, 2015 11:11 am
Posts: 401
onlyonemac wrote:
octacone wrote:
Why are you guys so mad about him using that website???
When I type archive.org and press enter I go to a site called "way back machine"? What is going on?
archive.org is a project aimed at preserving digital artefacts for historical reasons, much like a traditional archive or museum preserves physical artefacts. The Wayback Machine part of the site archives (read: preserves) old versions of websites. They also archive other forms of historically-significant (or likely to be historically-significant in the future) digital media, such as e-books/digital texts, music/internet radio/podcasts and software. ~ is using the site as a cloud storage and file-sharing site, specifically to store his code in a place that he can find it easily and to link to it from this forum.

+1. ~ shall not be given premission to upload that or I'm going to report him in archive.org, if he adds any other random DOS executable posted on this forum.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 51 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group