Jump to content
  • Advertisement
Sign in to follow this  
jocasbb3

PE (Portable Executable) and plain exe....

This topic is 4809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody, I'm studying some compiler theory and I started thinking about how to write a code generation function to create a windows executable. Until today, I was sure that windows xp/2000 could load and execute only executable files in the PE (Portable Executable) format. But... I've found a article about creating a exe file "by hand". I opened my hex editor and put some code to show a "hello" on screen. Ok, I saved as a exe file. To my surprise, when I double clicked the exe file, the "hello" word appear on screen!!! How could this be possible?? It's just a flat exe file... some machine code without the PE formatting... what's going on? Could someone please explain this? And, BTW, can someone point me a good resource about generating a exe in PE format? Thanks in advance!! Best regards!

Share this post


Link to post
Share on other sites
Advertisement
Uhh... exactly how did you display the text? You'd need to import Windows functions to do that, and that would require an import table (and, by association, PE packaging). Did you by chance use int 21, and Windows executed it like a COM file?

Share this post


Link to post
Share on other sites
Hello,

It's from this article:

http://daniel.lorch.cc/articles/8086MachineLanguage/8086MachineLanguage.html

And Catafriggm, I used the 21 INT... but I didn't get the stuff about windows
executed it like a COM file.. can you explain how? Thanks!!

Share this post


Link to post
Share on other sites
COM files, unlike EXEs (either DOS or Windows) are raw machine code. They have no packaging. PC Computing magazine (no longer exists) used to have little utility programs (COM files) you could write with a hex editor. At the time (way before I got into assembly) I wondered why the phrase 'CD 21' occurred so often. Well, that's int 21 right there :P

Share this post


Link to post
Share on other sites
XP/2K emulates the MS-DOS subsystem when you run 16-bit applications. While PE format is the native executable format for Win32 systems, it doesn't mean that it's impossible to run other types of executable programs.

Share this post


Link to post
Share on other sites
Notepad from Windows 2 runs under XP (as does Write, IIRC), and doesn't look too different to the modern XP version. [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!