开发者

How can I extract an array from an executable file?

I want to do the inverse of this question.

I am embedding a file into an executable as an array, and I would later like to extract the embedded file from the executable.

It seems like objcopy might be useful here but I haven't figured out the proper incantation yet.

(Edit: clarify question, I somehow removed the 开发者_运维知识库crux of it in editing originally...)


If you place the embedded file within its own section you can use objcopy to extract that section into a raw output file, I think. Look into gcc's __attribute__((section("embedded_file") )) Or if you are getting the file into the exe some other way using the linker you should be able to get it into another section another way, but I'm not familiar with doing that.


Put a recognizable pattern at the beginning of the array to help you find the data in the file.

If you're creating a Windows executable, put the data into a binary resource in the executable instead of just encoding it into an array -- you can then use normal Windows resource functions (FindResource, LoadResource, etc.) to get the data (though this is a bit trickier to get working correctly than it initially seems like it should be).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜