I was wondering if there existed a way to replace the DOS part of a PE EXE, so I wouldn't have to write a potentially buggy utility to do that. I'm using VC++08EE to write the PE part, in case there's some hidden thing in there.
I'm working on my bootloader, which at this point will load and try to run the MZ exe. The problem is that the default stub does not do what I need it to in any way, shape or form, and depends on DOS (big surprise there), which my stage1 is not. I want to write a new stub that will set up the environment for, as well as parse and set up, the PE part of the EXE, so that hopefully the second stage can be run by both my stage1 and eventually an EFI setup (though I don't have a clue how I'm going to test that without any EFI emulator, unless someone can suggest one of those too).
Way to replace DOS part of an EXE?
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Way to replace DOS part of an EXE?
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Way to replace DOS part of an EXE?
The WDOSX DOS extender does that. It is quite old but very good. It replaces the DOS stub with its own. The stub contains the DPMI server, PE loader and a decompressor (as the original file gets compressed). You could have a look at its source code.
Re: Way to replace DOS part of an EXE?
When you link, use the /STUB:filename option and specify an existing MZ exe as the filename.
Re: Way to replace DOS part of an EXE?
Gigasoft, you are right of course, but the OP still needs a stub.
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Way to replace DOS part of an EXE?
I can make the stub (I wanted to do it myself anyway), I just didn't know how to get it into the PE file without doing it manually. I'll try the /STUB:blah thing, I hope it works. Does it automatically resize the header to lop off unneeded padding (since YASM's EXE output pads the header to 512 bytes)?
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?