Page 1 of 1

How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 11:02 am
by Fixitnow
I would love to learn how to do this.

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 11:17 am
by Anton
This would be generally done by first loading the header of the executable into memory. The header will indicate which parts of the executable need to be loaded, how they need to be modified, and where they are located in the file. The header also indicates the address of the entry point in the image of the file. After loading and mapping the file into memory as required, have some control flow jump to the entry point. The executable is now being executed.

Windows, Unix, and Apple executables tend to have different formats. The modern Windows format is PE. Most current versions of Apple and Unix (and clones) use ELF or a variant of a.out. There are advantages and disadvantages to each, but the general outline of the loading procedure is the same for all.

One thing to note is that you would very likely be unable to run an Apple executable on a PC. Even though you might be able to load the header and the necessary sections of the file into memory, any code would be in a format not understandable by x86 machines. This also holds for Unix executables not intended to run on Intel machines. The header will usually specify the type of processor the executable is targeted for.

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 11:22 am
by Candy
Fixitnow wrote: I would love to learn how to do this.
Option 1. Buy a PC and a Mac and use Windows, Unix and MacOS to run the programs.

Option 2. Install Windows, Unix and MacOS in emulators on your current PC and run the programs.

Option 3. Create an operating system with all hardware support you need, add binary loader (that loads certain binaries and relocates them), add PPC or X86 (or both) emulator and run.

If you're not specifically out for option 3, I'd recommend 1 or 2.

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 11:22 am
by JoeKayzA
Fixitnow wrote: I would love to learn how to do this.
What are .*NIX programs? ;)

Well, for .exe, you are looking for the so-called PE executable file format. Don't know if there is information on the FAQ, but I can remember some people on this forum which talked about it (or even use it regularly).

Linux, Solaris and some other unices use the ELF format instead. Don't know about MacOS, a google search mentioned a format called Mach-O. Maybe this is the default for MacOSX...

btw, using google is probably the best tip I can give you for the future.. ;)


cheers Joe

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 11:30 am
by Fixthestar248
*NIX files are UNIX files.

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 12:02 pm
by Colonel Kernel
Anton wrote: One thing to note is that you would very likely be unable to run an Apple executable on a PC. Even though you might be able to load the header and the necessary sections of the file into memory, any code would be in a format not understandable by x86 machines.
This will not be true for much longer:

http://www.apple.com/pr/library/2005/jun/06intel.html

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 1:13 pm
by Cjmovie
Haven't you guys ever heard of wotsit?
http://www.wotsit.org/search.asp?s=binary

;D

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 2:34 pm
by Solar
Ts, ts, ts... *shakinghishead*

None of you so far mentioned that each type of executable will expect a different set of API functions to be available at runtime...

An Apple executable, e.g. when trying to open a window, will try to call an OS function APPLE_OpenWindow(). A Windows executable will try to call WINDOWS_OpenWindow(). Where those functions reside, how exactly they are called etc. is very much system-specific. So, your loader not only would have to handle the different binary executable formats, but the OS you're running would have to provide all the applicable APIs.

Under Linux, there's Wine providing (parts of) the Windows API. Under Windows, there's Cygwin (although that requires a recompilation). I know of no such API "simulator" for MacOS.

Not to speak of how very different the applications themselves are functioning. DOS tools give help on "/?", Unix tools on "-h" or "--help". Apple GUI is rendered to Postscript IIRC, Unix tools go through toolkits to access X Window, Windows does it different yet again.

I strongly second Candy's recommendation: Go for 1) or 2), 3) won't happen.

Re:How to open and run .EXE, .*NIX, and apple programs

Posted: Sat Dec 03, 2005 2:37 pm
by Cjmovie
I assumed he wanted to know how to compile _his_ code into one of those formats and get his OS to load it. (as in, possibly, a bootloader)
Actual programs from the net in those formats, yeah, lots of problems if you want to run those, mainly the architecture difference (on MACS, PowerPC vs x86, or even x86-64 ;D) and the API difference, as solar noted.