Loading A .exe File
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
Loading A .exe File
Does anyone know where I can get any information on loading a .exe file into memory and executing it in c++ or c?
Thanks,
Joseph
Thanks,
Joseph
What EXE, there are more than several formats, do you mean strictly a DOS EXE, Win16 EXE, Win32 EXE, or do you simply mean any executable format file?? what are you using to compile your c++/c program? Your EXE depends on your compiler and will determine what format you are speaking of.
Getting back in the game.
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
I want to load a DOS EXE.LordMage wrote:What EXE, there are more than several formats, do you mean strictly a DOS EXE, Win16 EXE, Win32 EXE, or do you simply mean any executable format file?? what are you using to compile your c++/c program? Your EXE depends on your compiler and will determine what format you are speaking of.
Well, as far as actually loading one I have not done it before. but I do know that you first have to make sure that your kernel is going to support the calls within the program. If you are planning on having your kernel as a DOS EXE then I don't suppose that would be a problem. Now, the main thing you need to do is get past the header information and look for the start of the binary execution statements inside. this website has information of the header http://www.delorie.com/djgpp/doc/exe/
Hopefully that will help
By the By, what compiler are you using?
Hopefully that will help
By the By, what compiler are you using?
Getting back in the game.
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
Also I wanted to know how to load a Win32 EXE as well. The compiler I am using is gcc on Mac.LordMage wrote:Well, as far as actually loading one I have not done it before. but I do know that you first have to make sure that your kernel is going to support the calls within the program. If you are planning on having your kernel as a DOS EXE then I don't suppose that would be a problem. Now, the main thing you need to do is get past the header information and look for the start of the binary execution statements inside. this website has information of the header http://www.delorie.com/djgpp/doc/exe/
Hopefully that will help
By the By, what compiler are you using?
have you setup gcc for cross compiling to those formats??? Okay, a common Win32 EXE is the PE or Portable Executable. I am using this type and you can get actualy code and a good explaination of how to load them in asm at Neon's OS Development Tutorial site. here is the address http://www.mt2002.sitesled.com/OSDevIndex.html
again hope this helps.
again hope this helps.
Getting back in the game.
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
For some reason that url is not working for me. Also how do you set up cross compiling for the exe format, since I am new to programming on Mac.LordMage wrote:have you setup gcc for cross compiling to those formats??? Okay, a common Win32 EXE is the PE or Portable Executable. I am using this type and you can get actualy code and a good explaination of how to load them in asm at Neon's OS Development Tutorial site. here is the address http://www.mt2002.sitesled.com/OSDevIndex.html
again hope this helps.
you got me, I don't use gcc or Mac. I am a windows junkie. why have you chosen to load microsoft formats anyway. most Mac/Unix/Linux users load ELF which is I think the native compile format for gcc. I could be wrong though.
I think the site mite be undergoing an update or something check it out later. I found it very informative
I think the site mite be undergoing an update or something check it out later. I found it very informative
Getting back in the game.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Most modern Unix systems use ELF, Mac OSX does not..
http://en.wikipedia.org/wiki/Mach-O
http://en.wikipedia.org/wiki/Executable ... ble_Format
As for the "PE" cross-compiler, Try visiting our friend.. "Google".
http://en.wikipedia.org/wiki/Mach-O
http://en.wikipedia.org/wiki/Executable ... ble_Format
As for the "PE" cross-compiler, Try visiting our friend.. "Google".
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
There is a tutorial on the OS-Dev wiki for creating a GCC cross-compiler. The example target format in the tutorial is elf, but you could probably use whatever target you want. I've followed the tutorial successfully to create a gcc cross-compiler on Mac OS X that targets elf.
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
You can get C code for loading a MZ exe here: http://alexfru.chat.ru/epm.html#los4d
I also have code for loading a PE file, but its in asm.
I also have code for loading a PE file, but its in asm.
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm