Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a resource into a new PE file? #4

Open
GoogleCodeExporter opened this issue Mar 31, 2016 · 2 comments
Open

How to add a resource into a new PE file? #4

GoogleCodeExporter opened this issue Mar 31, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link


Hello, I'm a beginner, my English is not good.I now have a good pe generated 
files. I want to fill it to add a zip package. . I'm running on linux. I hope 
to get your help?

email  460457528@qq.com

Original issue reported on code.google.com by 460457...@qq.com on 23 Aug 2013 at 4:16

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

//Create PE image from file stream
pe_base image(pe_factory::create_pe(pe_file));

//Get Resource Manager
resource_directory root(get_resources(image));
pe_resource_manager res(root);

//Change the name of the old resource section (Not Sure if this is neccesary)
image.section_from_directory(pe_win::image_directory_entry_resource).set_name("o
ldres");

//Add the resource by providing data, a root name, resource id, language, ...
res.add_resource(<-Some Binary Data Here->, L"BIN", 205, 1033,0,0);

//Create new resource section and add it to the image
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);

//Rebuild the resources
rebuild_resources(image, root, attached_section);

//Build the new executable by providing file stream to write new PE to
rebuild_pe(image, new_pe_file);

Original comment by Damian.D...@gmail.com on 28 Nov 2013 at 10:14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant