Adding a section to a PE executable at runtime
- From: Nicholas Sherlock <N.sherlock@xxxxxxxxx>
- Date: Sun, 25 Jun 2006 23:51:17 +1200
Hey all,
I want to add a new 'section' of code to a PE executable. I'll redirect the entry point of the .exe to the new section so that I can run code before the application starts running (No, I'm not writing a virus :)). I've written a little tool which should be able to do this: It adds an entry into the section table, writes out the new section (Padded out to and aligned on the FileAlignment size), and updates ImageSize (ie. RoundUpToSectionAlignment( Sections[lastsection].VirtualAddress+Sections[lastsection].VirtualSize) ). But Windows chokes on the .exe, giving "My program.exe is not a valid Win32 application".
The modified .exe looks kosher in PEBrowse professional. How can I figure out why Windows is rejecting my .exe?
Cheers,
Nicholas Sherlock
--
http://www.sherlocksoftware.org
.
- Follow-Ups:
- Re: Adding a section to a PE executable at runtime
- From: Eric Grange
- Re: Adding a section to a PE executable at runtime
- From: Florent Ouchet
- Re: Adding a section to a PE executable at runtime
- From: Nicholas Sherlock
- Re: Adding a section to a PE executable at runtime
- Prev by Date: Re: MicrosoftMM Better than FastMM ???
- Next by Date: Re: Adding a section to a PE executable at runtime
- Previous by thread: Fastcode CompareText B&V
- Next by thread: Re: Adding a section to a PE executable at runtime
- Index(es):
Relevant Pages
|