Page 1 of 1
Loading A .exe File
Posted: Sat Oct 13, 2007 4:22 pm
by JoeTheProgrammer
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
Posted: Sat Oct 13, 2007 4:39 pm
by LordMage
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.
Posted: Sat Oct 13, 2007 4:41 pm
by JoeTheProgrammer
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.
I want to load a DOS EXE.
Posted: Sat Oct 13, 2007 4:46 pm
by LordMage
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?
Posted: Sat Oct 13, 2007 4:51 pm
by JoeTheProgrammer
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?
Also I wanted to know how to load a Win32 EXE as well. The compiler I am using is gcc on Mac.
Posted: Sat Oct 13, 2007 4:59 pm
by LordMage
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.
Posted: Sat Oct 13, 2007 5:07 pm
by JoeTheProgrammer
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.
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.
Posted: Sat Oct 13, 2007 5:09 pm
by LordMage
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
Posted: Sat Oct 13, 2007 5:58 pm
by Brynet-Inc
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".
Posted: Sat Oct 13, 2007 6:28 pm
by Colonel Kernel
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.
Posted: Sat Oct 13, 2007 7:48 pm
by Dex
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.
Posted: Sat Oct 13, 2007 8:10 pm
by JoeTheProgrammer
Thanks all for all of the information.