Re: Adding a section to a PE executable at runtime
- From: Florent Ouchet <ouchet.florent@xxxxxxxxxxx>
- Date: Mon, 26 Jun 2006 07:36:51 +0200
Nicholas Sherlock a écrit :
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?
This question is OT in this group. You should post this article in news://newsgroups.borland.com:119/borland.public.delphi.language.delphi.win32 or news://newsgroups.borland.com:119/borland.public.delphi.nativeapi.win32
However, you can find a working implementation of this functionality in the Jedi Code Library (JCL http://jcl.sf.net) in the unit JclDebug.pas. The function InsertDebugDataIntoExecutableFile creates a new section and updates the file on the disk.
Best regards,
--
Florent Ouchet
.
- References:
- Adding a section to a PE executable at runtime
- From: Nicholas Sherlock
- Adding a section to a PE executable at runtime
- Prev by Date: Re: Adding a section to a PE executable at runtime
- Next by Date: Re: Adding a section to a PE executable at runtime
- Previous by thread: Re: Adding a section to a PE executable at runtime
- Next by thread: Re: Adding a section to a PE executable at runtime
- Index(es):
Relevant Pages
|