Page 1 of 1
EXE question
Posted: Wed Jul 19, 2006 2:34 pm
by jakelstr
Hi,
Would it be possible to write a program to strip the windows files from an EXE file and then write another one to place the Files from another os into the EXE file? Also, chase, jAAman, carbonbased, get rid of the inopropriate post please.
Posted: Wed Jul 19, 2006 4:02 pm
by matthias
Can you explain that a little bit more, don't quite understand
Posted: Wed Jul 19, 2006 5:26 pm
by jakelstr
I recently heard of a program called exe2com that strips an exe file down to a com one. Would it be possible to strip an exe file down to com, then, add info to the com file so that another os could use windows exe files?
Posted: Wed Jul 19, 2006 10:20 pm
by earlz
exe2com IIRC only works with MZ type exe files and not PE
MZ I think just has some extra info like stack size and preferred memory address or something like that and is NOT relocatable, but PE will have RELOCATIONS wich means you have to
1.read/interpret the header(for linker stuff)
2.change the relocations to actual memory locations(or leave it that way if you support relocations in your format)
3.interpret the header again to convert it to your header
4.copy it to your header applying sections and such
but yea i don't remeber if it was MZE or PE or both but 1 is so simple you can just attach a template header onto a com/bin file and work perfectly
btw what do you need this for? if you need it to convert your kernel to .exe then well I would need to know what compiler your using
Posted: Thu Jul 20, 2006 7:00 am
by bubach
The hard part isn't reading the binary, even if it's a PE file (windows EXE format). The hard part is to offer all the OS services that the Windows program requires.
Posted: Thu Jul 20, 2006 9:53 am
by JAAman
MZ I think just has some extra info like stack size and preferred memory address or something like that and is NOT relocatable
MZ executables
are relocatable, dos did come with a program for converting DOS 'MZ' files, into CP/M style 'com' files (called exe2bin), however (iirc) it wouldnt work unless the program was compiled specifically for it (couldnt work if they were relocatable, or it specified a stack -- both required by the specification)
Also, chase, jAAman, carbonbased, get rid of the inopropriate post please
done
Posted: Thu Jul 20, 2006 5:32 pm
by viral
Hello..
As mentioned here, MZ exes can only converted into com and so on. Now from your question I can guess that you want to convert a standard exe to a file say "xyz" that can be executed in your OS.
Now for this you have to make your APIs windows (or rather DOS) compatible.. When a DOS program to print "Hello World" is compiled.. the DOS interrupts are assembled(int 21 I guess). So when such file executes it calls int 21 without knowing in which OS it is..
So you need to change such calls to your own API calls.. You have to map them...
Hope I was on right track.. its 5 AM.. so I am half in bed..
Posted: Thu Jul 20, 2006 9:05 pm
by Dex
From my understanding MZ and PE are both relocatable, but mz default to realmode and PE to pmode with a realmode stub that prints the mesage about can run in realmode.