在C中合并二进制文件 [英] Merge Binary files in C

查看:103
本文介绍了在C中合并二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


以下是我的情况.
执行时a.out产生以下输出.
文件1是输出"
b.out执行时会产生以下输出.
文件2是输出"

我要做的只是一个二进制合并,在这种情况下,合并的输出应该
给出如下输出
文件1是输出"
文件2是输出"

如何在Linux或Windows上的C语言中实现此目标?

请:)

解决方案

感谢您的澄清.这没有任何意义,也是不可能的.我可以解释为什么,但这太无聊了.无论如何,没用的想法是错误的.在某种程度上,您可以反编译可执行模块并将其编译为单个可执行文件,但是由于可能发生名称冲突,因此不能保证成功,而且也不容易,并且没有任何实际意义.



我建议您阅读一般程序设计,然后学习源代码,目标文件和可执行文件,入口点,地址空间,应用程序加载和地址解析的概念.这个问题是基于围绕这些领域的一些误解.

—SA


如果要使用两个可执行文件的功能,为什么不直接从一个点运行两个可执行文件.对于像这样的简单事情,脚本是一个不错的选择...

批次 [ ^ ](适用于Windows)或 bash [二进制diff/patch实用程序


Hi,
Below is my scenario.
a.out on execution produces the below output.
"File-1 is the output"
b.out on execution produces the below output.
"File-2 is the output"

All i want to do is a binary merge and in this case the merged output should
give output as below
"File-1 is the output"
"File-2 is the output"

How can i achieve this in C on linux or windows

please :)

解决方案

Thank you for the clarification. It does not make any sense and is not possible. I can explain why, but this is too boring. Wrong useless idea anyway. In a way, you can decompile executable modules and compile it in a single executable, but it is not guaranteed to succeed due to possible name clash, and not easy, and makes no practical sense.

[EDIT]

I would suggest you read on general programming and lean about the concepts of source, object and executable files, entry points, address spaces, application loading and resolution of addresses. The question is based on some misconceptions around these areas.

—SA


If you want the functionality of two executables, why not simply run both from a single point. Scripts are a great option for something simple like this...

Batch[^] (for Windows) or bash[^] (for UNIX/Linux) are two commonly used scripting languages that enable power users to do this type of thing. Each runs pretty much natively in their environment, if you want a script that runs on either platform, then go with one of the other multi-platform scripting options (Perl, Python, etc.).


You want to merge executable files? Are you looking for software to apply binary patches?

Something like this?
Binary diff/patch utility


这篇关于在C中合并二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆