Jump to content
Tuts 4 You

Saving and writing sections


CrazyRider

Recommended Posts

Posted

Hi,

I have the name, base address and size of a section which i have to save to disk. I have to do this with C/C++ and not PE tools or something like that.

Well I guess that's not a big problem, just save each byte from base address to (base address + size) to a file right?

Then I have to attach this section to a binary with c++, but i am not sure how to do this. First I have to write the section at some address in the binary, but what do i have to edit in the PE header? Is there a way to add a section and use it directly, while the program is in memory? Primarily I'm talking about code sections here.

Posted

If you've got enough space to add another section header simply do so and let the pointer to raw data point to your new attached section (align the values to their proper alignments which are found in PE header). But beware of relocating the section if you'd like to execute the code the new section contains (you might want to search the forums in that case as this has been discussed recently).

Posted (edited)

thanks, I'll try this

Edited by CrazyRider

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...