pombreda / portable-executable-library

Automatically exported from code.google.com/p/portable-executable-library
1 stars 0 forks source link

How to remove resource section #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!
I trying to replace resource (remove and create new one with same name).
I following your example 
(https://code.google.com/p/portable-executable-library/source/browse/trunk/sampl
es/resource_editor/main.cpp)

So, i do rename of section

image.section_from_directory(pe_win::image_directory_entry_resource).set_name("o
ldres");

Then create new section 

section new_resources;
new_resources.get_raw_data().resize(1); 
new_resources.set_name(".rsrc"); 
new_resources.readable(true); 
section& attached_section = image.add_section(new_resources);

But after this my PE file become almost 2x times bigger size.

I think this is happening because my resulting PE file have two sections which 
are almost the same except one resource i working with.

So, the question is: How can i completely remove old resource "oldres", so i 
have no duplicate data inside my resulting PE.

Fix me if i'm wrong.

Thanks, Dmitry.

Original issue reported on code.google.com by sdv.br...@gmail.com on 11 Sep 2014 at 1:59