EXE question

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

EXE question

Post 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. :?
"Real corn makes it special!" -The Grim Adventures of Billy and Mandy

MMM...Caffeine

Intel Inside, Idiot Outside
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Post by matthias »

Can you explain that a little bit more, don't quite understand :wink:
The source of my problems is in the source.
User avatar
jakelstr
Member
Member
Posts: 52
Joined: Wed Jul 05, 2006 9:30 am

Post 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?
"Real corn makes it special!" -The Grim Adventures of Billy and Mandy

MMM...Caffeine

Intel Inside, Idiot Outside
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post 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
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post 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.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post 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
User avatar
viral
Posts: 15
Joined: Tue Dec 14, 2004 12:00 am
Location: India
Contact:

Post 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..
Currently working on "TAJ: India's first object oriented operating system"...
http://www.viralpatel.net
http://www.geocities.com/taj_os
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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.
Post Reply