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

Started by
7 comments, last by jocasbb3 18 years, 7 months ago
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!
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?
Are you sure the exe you made isn't in PE format? What is it's magic number?
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!!
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
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.

Niko Suni

IIRC, Windows XP is able to run .com files, Win16 EXE files and PE's.

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

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Hello!

Thanks everybody for the great help!

This topic is closed to new replies.

Advertisement