How to open and run .EXE, .*NIX, and apple programs
How to open and run .EXE, .*NIX, and apple programs
I would love to learn how to do this.
Re:How to open and run .EXE, .*NIX, and apple programs
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.
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
Option 1. Buy a PC and a Mac and use Windows, Unix and MacOS to run the programs.Fixitnow wrote: I would love to learn how to do this.
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
What are .*NIX programs?Fixitnow wrote: I would love to learn how to do this.
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
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re:How to open and run .EXE, .*NIX, and apple programs
This will not be true for much longer: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.
http://www.apple.com/pr/library/2005/jun/06intel.html
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
Re:How to open and run .EXE, .*NIX, and apple programs
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.
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.
Every good solution is obvious once you've found it.
Re:How to open and run .EXE, .*NIX, and apple programs
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.
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.