Page 1 of 1

MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 12:23 am
by ~
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/M ... avemeg.asm

Full source code:
http://archive.org/download/tmp_tests/M ... AVEMEG.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/M ... AVEMEG.DAT

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 12:25 am
by BrightLight
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:

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 12:31 am
by ~
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 12:37 am
by BrightLight
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 1:07 am
by alexfru
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 1:25 am
by alexfru
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 1:37 am
by onlyonemac
Stop using archive.org as a file sharing platform.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 2:32 am
by Brendan
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

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 2:58 am
by glauxosdever
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

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 3:07 am
by Kazinsal
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 3:54 am
by iansjack
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 4:53 am
by Roman
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?

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 9:26 am
by Octacone
onlyonemac wrote:
Stop using archive.org as a file sharing platform.
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?

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 9:52 am
by onlyonemac
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.

Re: MZ EXE Skeleton Made By hand

Posted: Sun Aug 28, 2016 12:12 pm
by Ycep
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.